link: add INNER_PROTO_INHERIT support for Geneve

This commit is contained in:
konradh 2023-03-09 19:03:10 +01:00 committed by Alessandro Boch
parent 70def89fcb
commit 9453b0562a
4 changed files with 25 additions and 11 deletions

21
link.go
View File

@ -1022,16 +1022,17 @@ func (v *VrfSlave) SlaveType() string {
// https://github.com/torvalds/linux/blob/47ec5303d73ea344e84f46660fff693c57641386/drivers/net/geneve.c#L1209-L1223
type Geneve struct {
LinkAttrs
ID uint32 // vni
Remote net.IP
Ttl uint8
Tos uint8
Dport uint16
UdpCsum uint8
UdpZeroCsum6Tx uint8
UdpZeroCsum6Rx uint8
Link uint32
FlowBased bool
ID uint32 // vni
Remote net.IP
Ttl uint8
Tos uint8
Dport uint16
UdpCsum uint8
UdpZeroCsum6Tx uint8
UdpZeroCsum6Rx uint8
Link uint32
FlowBased bool
InnerProtoInherit bool
}
func (geneve *Geneve) Attrs() *LinkAttrs {

View File

@ -2997,6 +2997,10 @@ func linkFlags(rawFlags uint32) net.Flags {
func addGeneveAttrs(geneve *Geneve, linkInfo *nl.RtAttr) {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
if geneve.InnerProtoInherit {
data.AddRtAttr(nl.IFLA_GENEVE_INNER_PROTO_INHERIT, []byte{})
}
if geneve.FlowBased {
geneve.ID = 0
data.AddRtAttr(nl.IFLA_GENEVE_COLLECT_METADATA, []byte{})
@ -3043,6 +3047,8 @@ func parseGeneveData(link Link, data []syscall.NetlinkRouteAttr) {
geneve.Tos = uint8(datum.Value[0])
case nl.IFLA_GENEVE_COLLECT_METADATA:
geneve.FlowBased = true
case nl.IFLA_GENEVE_INNER_PROTO_INHERIT:
geneve.InnerProtoInherit = true
}
}
}

View File

@ -389,6 +389,10 @@ func compareGeneve(t *testing.T, expected, actual *Geneve) {
t.Fatal("Geneve.FlowBased doesn't match")
}
if actual.InnerProtoInherit != expected.InnerProtoInherit {
t.Fatal("Geneve.InnerProtoInherit doesn't match")
}
// TODO: we should implement the rest of the geneve methods
}

View File

@ -227,7 +227,10 @@ const (
IFLA_GENEVE_UDP_ZERO_CSUM6_TX
IFLA_GENEVE_UDP_ZERO_CSUM6_RX
IFLA_GENEVE_LABEL
IFLA_GENEVE_MAX = IFLA_GENEVE_LABEL
IFLA_GENEVE_TTL_INHERIT
IFLA_GENEVE_DF
IFLA_GENEVE_INNER_PROTO_INHERIT
IFLA_GENEVE_MAX = IFLA_GENEVE_INNER_PROTO_INHERIT
)
const (