mirror of
https://github.com/vishvananda/netlink
synced 2025-04-01 22:58:37 +00:00
link: Add FlowBased
support to Gretun
GRE L3 devices support "FlowBased" ("collect_md"/"external") mode. Add support for this configuration and relevant test. Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
This commit is contained in:
parent
d0aef2fdcd
commit
7e7feb220f
1
link.go
1
link.go
@ -1166,6 +1166,7 @@ type Gretun struct {
|
||||
EncapFlags uint16
|
||||
EncapSport uint16
|
||||
EncapDport uint16
|
||||
FlowBased bool
|
||||
}
|
||||
|
||||
func (gretun *Gretun) Attrs() *LinkAttrs {
|
||||
|
@ -2797,6 +2797,12 @@ func parseGretapData(link Link, data []syscall.NetlinkRouteAttr) {
|
||||
func addGretunAttrs(gre *Gretun, linkInfo *nl.RtAttr) {
|
||||
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
|
||||
|
||||
if gre.FlowBased {
|
||||
// In flow based mode, no other attributes need to be configured
|
||||
data.AddRtAttr(nl.IFLA_GRE_COLLECT_METADATA, []byte{})
|
||||
return
|
||||
}
|
||||
|
||||
if ip := gre.Local; ip != nil {
|
||||
if ip.To4() != nil {
|
||||
ip = ip.To4()
|
||||
@ -2867,6 +2873,8 @@ func parseGretunData(link Link, data []syscall.NetlinkRouteAttr) {
|
||||
gre.EncapSport = ntohs(datum.Value[0:2])
|
||||
case nl.IFLA_GRE_ENCAP_DPORT:
|
||||
gre.EncapDport = ntohs(datum.Value[0:2])
|
||||
case nl.IFLA_GRE_COLLECT_METADATA:
|
||||
gre.FlowBased = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
link_test.go
14
link_test.go
@ -455,6 +455,9 @@ func compareGretun(t *testing.T, expected, actual *Gretun) {
|
||||
if actual.EncapDport != expected.EncapDport {
|
||||
t.Fatal("Gretun.EncapDport doesn't match")
|
||||
}
|
||||
if actual.FlowBased != expected.FlowBased {
|
||||
t.Fatal("Gretun.FlowBased doesn't match")
|
||||
}
|
||||
}
|
||||
|
||||
func compareVxlan(t *testing.T, expected, actual *Vxlan) {
|
||||
@ -742,6 +745,17 @@ func TestLinkAddDelGretunPointToMultiPoint(t *testing.T) {
|
||||
OKey: 7890})
|
||||
}
|
||||
|
||||
func TestLinkAddDelGretunFlowBased(t *testing.T) {
|
||||
minKernelRequired(t, 4, 3)
|
||||
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
testLinkAddDel(t, &Gretun{
|
||||
LinkAttrs: LinkAttrs{Name: "foo"},
|
||||
FlowBased: true})
|
||||
}
|
||||
|
||||
func TestLinkAddDelGretapFlowBased(t *testing.T) {
|
||||
minKernelRequired(t, 4, 3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user