mirror of
https://github.com/vishvananda/netlink
synced 2025-01-14 11:01:16 +00:00
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:
parent
866f5f32e3
commit
c94808a88b
1
link.go
1
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
|
||||
|
@ -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 {
|
||||
|
26
link_test.go
26
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()
|
||||
|
@ -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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user