Skip to content

Commit

Permalink
Fix FlowBased support for Geneve
Browse files Browse the repository at this point in the history
The IFLA_GENEVE_COLLECT_METADATA netlink attribute shouldn't have any a
payload. For Geneve devices also other attributes can be set next to
FlowBased, however the VNI needs to be 0.

This commit also adds a test for creating a Geneve device in FlowBased
mode.

Signed-off-by: Robin Gögge <[email protected]>
  • Loading branch information
rgo3 authored and aboch committed Aug 7, 2023
1 parent dbf1bd0 commit 6afddb3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions link_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,9 +2778,8 @@ func addGeneveAttrs(geneve *Geneve, linkInfo *nl.RtAttr) {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)

if geneve.FlowBased {
// In flow based mode, no other attributes need to be configured
linkInfo.AddRtAttr(nl.IFLA_GENEVE_COLLECT_METADATA, boolAttr(geneve.FlowBased))
return
geneve.ID = 0
data.AddRtAttr(nl.IFLA_GENEVE_COLLECT_METADATA, []byte{})
}

if ip := geneve.Remote; ip != nil {
Expand Down Expand Up @@ -2822,6 +2821,8 @@ func parseGeneveData(link Link, data []syscall.NetlinkRouteAttr) {
geneve.Ttl = uint8(datum.Value[0])
case nl.IFLA_GENEVE_TOS:
geneve.Tos = uint8(datum.Value[0])
case nl.IFLA_GENEVE_COLLECT_METADATA:
geneve.FlowBased = true
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ func compareGeneve(t *testing.T, expected, actual *Geneve) {
t.Fatalf("Geneve.Remote is not equal: %s!=%s", actual.Remote, expected.Remote)
}

if actual.FlowBased != expected.FlowBased {
t.Fatal("Geneve.FlowBased doesn't match")
}

// TODO: we should implement the rest of the geneve methods
}

Expand Down Expand Up @@ -661,6 +665,16 @@ func TestLinkAddDelGeneve(t *testing.T) {
Remote: net.ParseIP("2001:db8:ef33::2")})
}

func TestLinkAddDelGeneveFlowBased(t *testing.T) {
tearDown := setUpNetlinkTest(t)
defer tearDown()

testLinkAddDel(t, &Geneve{
LinkAttrs: LinkAttrs{Name: "foo"},
Dport: 1234,
FlowBased: true})
}

func TestGeneveCompareToIP(t *testing.T) {
ns, tearDown := setUpNamedNetlinkTest(t)
defer tearDown()
Expand Down

0 comments on commit 6afddb3

Please sign in to comment.