Fix FlowBased support for Geneve

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 <r.goegge@isovalent.com>
This commit is contained in:
Robin Gögge 2023-07-22 19:51:51 +02:00 committed by Alessandro Boch
parent dbf1bd04f9
commit 6afddb37c1
2 changed files with 18 additions and 3 deletions

View File

@ -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 {
@ -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
}
}
}

View File

@ -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
}
@ -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()