mirror of
https://github.com/vishvananda/netlink
synced 2024-12-29 02:02:21 +00:00
Add support for IFLA_GSO_*
IFLA_GSO_MAX_SIZE - maximum GSO segment size IFLA_GSO_MAX_SEGS - maximum number of GSO segments Signed-off-by: Andrei Vagin <avagin@google.com>
This commit is contained in:
parent
aa950f24b9
commit
adb577d4a4
2
link.go
2
link.go
@ -41,6 +41,8 @@ type LinkAttrs struct {
|
||||
NetNsID int
|
||||
NumTxQueues int
|
||||
NumRxQueues int
|
||||
GSOMaxSize uint32
|
||||
GSOMaxSegs uint32
|
||||
Vfs []VfInfo // virtual functions available on link
|
||||
}
|
||||
|
||||
|
@ -1118,6 +1118,16 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
||||
req.AddData(rxqueues)
|
||||
}
|
||||
|
||||
if base.GSOMaxSegs > 0 {
|
||||
gsoAttr := nl.NewRtAttr(unix.IFLA_GSO_MAX_SEGS, nl.Uint32Attr(base.GSOMaxSegs))
|
||||
req.AddData(gsoAttr)
|
||||
}
|
||||
|
||||
if base.GSOMaxSize > 0 {
|
||||
gsoAttr := nl.NewRtAttr(unix.IFLA_GSO_MAX_SIZE, nl.Uint32Attr(base.GSOMaxSize))
|
||||
req.AddData(gsoAttr)
|
||||
}
|
||||
|
||||
if base.Namespace != nil {
|
||||
var attr *nl.RtAttr
|
||||
switch ns := base.Namespace.(type) {
|
||||
@ -1537,6 +1547,10 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
|
||||
base.OperState = LinkOperState(uint8(attr.Value[0]))
|
||||
case unix.IFLA_LINK_NETNSID:
|
||||
base.NetNsID = int(native.Uint32(attr.Value[0:4]))
|
||||
case unix.IFLA_GSO_MAX_SIZE:
|
||||
base.GSOMaxSize = native.Uint32(attr.Value[0:4])
|
||||
case unix.IFLA_GSO_MAX_SEGS:
|
||||
base.GSOMaxSegs = native.Uint32(attr.Value[0:4])
|
||||
case unix.IFLA_VFINFO_LIST:
|
||||
data, err := nl.ParseRouteAttr(attr.Value)
|
||||
if err != nil {
|
||||
|
30
link_test.go
30
link_test.go
@ -694,6 +694,36 @@ func TestLinkAddVethWithZeroTxQLen(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkAddDelDummyWithGSO(t *testing.T) {
|
||||
const (
|
||||
gsoMaxSegs = 16
|
||||
gsoMaxSize = 1 << 14
|
||||
)
|
||||
minKernelRequired(t, 4, 16)
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
||||
dummy := &Dummy{LinkAttrs: LinkAttrs{Name: "foo", GSOMaxSize: gsoMaxSize, GSOMaxSegs: gsoMaxSegs}}
|
||||
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.GSOMaxSize != gsoMaxSize {
|
||||
t.Fatalf("GSOMaxSize is %d, should be %d", dummy.GSOMaxSize, gsoMaxSize)
|
||||
}
|
||||
if dummy.GSOMaxSegs != gsoMaxSegs {
|
||||
t.Fatalf("GSOMaxSeg is %d, should be %d", dummy.GSOMaxSegs, gsoMaxSegs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkAddDummyWithTxQLen(t *testing.T) {
|
||||
tearDown := setUpNetlinkTest(t)
|
||||
defer tearDown()
|
||||
|
Loading…
Reference in New Issue
Block a user