link: add TSOMaxSize and TSOMaxSegs to link attributes

This is a read-only netlink attribute which has been added in 5.19
kernel. This is useful to query in order to probe if a given driver
supports IPv6 BIG TCP.

  [0] https://lore.kernel.org/netdev/20220513183408.686447-2-eric.dumazet@gmail.com/

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
Daniel Borkmann 2023-06-16 09:29:55 +00:00 committed by Alessandro Boch
parent 2b008399a4
commit a8a91c0504
3 changed files with 26 additions and 0 deletions

View File

@ -45,6 +45,8 @@ type LinkAttrs struct {
NetNsID int
NumTxQueues int
NumRxQueues int
TSOMaxSegs uint32
TSOMaxSize uint32
GSOMaxSegs uint32
GSOMaxSize uint32
GROMaxSize uint32

View File

@ -2070,6 +2070,10 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
base.PhysSwitchID = int(native.Uint32(attr.Value[0:4]))
case unix.IFLA_LINK_NETNSID:
base.NetNsID = int(native.Uint32(attr.Value[0:4]))
case unix.IFLA_TSO_MAX_SEGS:
base.TSOMaxSegs = native.Uint32(attr.Value[0:4])
case unix.IFLA_TSO_MAX_SIZE:
base.TSOMaxSize = native.Uint32(attr.Value[0:4])
case unix.IFLA_GSO_MAX_SEGS:
base.GSOMaxSegs = native.Uint32(attr.Value[0:4])
case unix.IFLA_GSO_MAX_SIZE:

View File

@ -2148,6 +2148,26 @@ func TestLinkSetGROMaxSize(t *testing.T) {
}
}
func TestLinkGetTSOMax(t *testing.T) {
minKernelRequired(t, 5, 19)
tearDown := setUpNetlinkTest(t)
defer tearDown()
iface := &Veth{LinkAttrs: LinkAttrs{Name: "foo", TxQLen: testTxQLen, MTU: 1500}, PeerName: "bar"}
if err := LinkAdd(iface); err != nil {
t.Fatal(err)
}
link, err := LinkByName("foo")
if err != nil {
t.Fatal(err)
}
if link.Attrs().TSOMaxSize != 524280 || link.Attrs().TSOMaxSegs != 65535 {
t.Fatalf("TSO max size and segments could not be retrieved")
}
}
func TestLinkSetGSOIPv4MaxSize(t *testing.T) {
minKernelRequired(t, 6, 3)
tearDown := setUpNetlinkTest(t)