diff --git a/link.go b/link.go index 33c8723..e8915a5 100644 --- a/link.go +++ b/link.go @@ -47,6 +47,7 @@ type LinkAttrs struct { NumRxQueues int GSOMaxSize uint32 GSOMaxSegs uint32 + GROMaxSize uint32 Vfs []VfInfo // virtual functions available on link Group uint32 Slave LinkSlave diff --git a/link_linux.go b/link_linux.go index 276947a..e6c3279 100644 --- a/link_linux.go +++ b/link_linux.go @@ -1401,6 +1401,11 @@ func (h *Handle) linkModify(link Link, flags int) error { req.AddData(gsoAttr) } + if base.GROMaxSize > 0 { + groAttr := nl.NewRtAttr(nl.IFLA_GRO_MAX_SIZE, nl.Uint32Attr(base.GROMaxSize)) + req.AddData(groAttr) + } + if base.Group > 0 { groupAttr := nl.NewRtAttr(unix.IFLA_GROUP, nl.Uint32Attr(base.Group)) req.AddData(groupAttr) @@ -1941,6 +1946,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) { base.GSOMaxSize = native.Uint32(attr.Value[0:4]) case unix.IFLA_GSO_MAX_SEGS: base.GSOMaxSegs = native.Uint32(attr.Value[0:4]) + case nl.IFLA_GRO_MAX_SIZE: + base.GROMaxSize = native.Uint32(attr.Value[0:4]) case unix.IFLA_VFINFO_LIST: data, err := nl.ParseRouteAttr(attr.Value) if err != nil { diff --git a/link_test.go b/link_test.go index ea0032d..db86e7e 100644 --- a/link_test.go +++ b/link_test.go @@ -985,6 +985,32 @@ func TestLinkAddDelDummyWithGSO(t *testing.T) { } } +func TestLinkAddDelDummyWithGRO(t *testing.T) { + const ( + groMaxSize = 1 << 14 + ) + minKernelRequired(t, 5, 19) + tearDown := setUpNetlinkTest(t) + defer tearDown() + + dummy := &Dummy{LinkAttrs: LinkAttrs{Name: "foo", GROMaxSize: groMaxSize}} + if err := LinkAdd(dummy); err != nil { + t.Fatal(err) + } + link, err := LinkByName("foo") + if err != nil { + t.Fatal(err) + } + dummy, ok := link.(*Dummy) + if !ok { + t.Fatalf("unexpected link type: %T", link) + } + + if dummy.GROMaxSize != groMaxSize { + t.Fatalf("GROMaxSize is %d, should be %d", dummy.GROMaxSize, groMaxSize) + } +} + func TestLinkAddDummyWithTxQLen(t *testing.T) { tearDown := setUpNetlinkTest(t) defer tearDown() diff --git a/nl/link_linux.go b/nl/link_linux.go index e10edbc..edf1c80 100644 --- a/nl/link_linux.go +++ b/nl/link_linux.go @@ -718,3 +718,8 @@ const ( IFLA_BAREUDP_MULTIPROTO_MODE IFLA_BAREUDP_MAX = IFLA_BAREUDP_MULTIPROTO_MODE ) + +const ( + IFLA_UNSPEC = iota + IFLA_GRO_MAX_SIZE = 0x3a +)