link: add support for IFLA_GRO_MAX_SIZE

Add support for the new IFLA_GRO_MAX_SIZE attribute which is needed to
enable BIG TCP[1] properly. Define the attribute in the local link
attributes (nl/link_linux.go) because it isn't yet present in Go's
x/sys/unix package. Also add a test for it.

[1] https://patchwork.kernel.org/project/netdevbpf/cover/20220513183408.686447-1-eric.dumazet@gmail.com/

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
This commit is contained in:
Nikolay Aleksandrov 2022-06-02 13:55:32 +03:00 committed by Alessandro Boch
parent 866f5f32e3
commit c94808a88b
4 changed files with 39 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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