From 77712cff873955325726807a2d1c55ad97200ad0 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 19 Jun 2023 16:59:18 +0200 Subject: [PATCH] Use IFLA_G{S,R}O_IPV4_MAX_SIZE constants from golang.org/x/sys/unix Commit 2b008399a406 ("link: add LinkSetGSOIPv4MaxSize and LinkSetGROIPv4MaxSize") introduced the use of these constants, but they were added only recently to the golang.org/x/sys/unix package. Update its version in go.mod and use the pre-defined constants instead of duplicating them. Signed-off-by: Tobias Klauser --- go.mod | 2 +- go.sum | 4 ++-- link_linux.go | 12 ++++++------ nl/link_linux.go | 5 ----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index e7fa06d..01abea3 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,5 @@ go 1.12 require ( github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae - golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 + golang.org/x/sys v0.9.1-0.20230616193735-e0c3b6e6ae3b ) diff --git a/go.sum b/go.sum index eb43c9e..53ef073 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 h1:9vYwv7OjYaky/tlAeD7C4oC9EsPTlaFl1H2jS++V+ME= -golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.1-0.20230616193735-e0c3b6e6ae3b h1:5elkVbSN5WHw2BspeECIoFRcbpHNAZJEU8jlgEQl3p0= +golang.org/x/sys v0.9.1-0.20230616193735-e0c3b6e6ae3b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/link_linux.go b/link_linux.go index 36a1f37..2c2612c 100644 --- a/link_linux.go +++ b/link_linux.go @@ -1030,7 +1030,7 @@ func (h *Handle) LinkSetGSOIPv4MaxSize(link Link, maxSize int) error { b := make([]byte, 4) native.PutUint32(b, uint32(maxSize)) - data := nl.NewRtAttr(nl.IFLA_GSO_IPV4_MAX_SIZE, b) + data := nl.NewRtAttr(unix.IFLA_GSO_IPV4_MAX_SIZE, b) req.AddData(data) _, err := req.Execute(unix.NETLINK_ROUTE, 0) @@ -1057,7 +1057,7 @@ func (h *Handle) LinkSetGROIPv4MaxSize(link Link, maxSize int) error { b := make([]byte, 4) native.PutUint32(b, uint32(maxSize)) - data := nl.NewRtAttr(nl.IFLA_GRO_IPV4_MAX_SIZE, b) + data := nl.NewRtAttr(unix.IFLA_GRO_IPV4_MAX_SIZE, b) req.AddData(data) _, err := req.Execute(unix.NETLINK_ROUTE, 0) @@ -1525,12 +1525,12 @@ func (h *Handle) linkModify(link Link, flags int) error { } if base.GSOIPv4MaxSize > 0 { - gsoAttr := nl.NewRtAttr(nl.IFLA_GSO_IPV4_MAX_SIZE, nl.Uint32Attr(base.GSOIPv4MaxSize)) + gsoAttr := nl.NewRtAttr(unix.IFLA_GSO_IPV4_MAX_SIZE, nl.Uint32Attr(base.GSOIPv4MaxSize)) req.AddData(gsoAttr) } if base.GROIPv4MaxSize > 0 { - groAttr := nl.NewRtAttr(nl.IFLA_GRO_IPV4_MAX_SIZE, nl.Uint32Attr(base.GROIPv4MaxSize)) + groAttr := nl.NewRtAttr(unix.IFLA_GRO_IPV4_MAX_SIZE, nl.Uint32Attr(base.GROIPv4MaxSize)) req.AddData(groAttr) } @@ -2080,9 +2080,9 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) { base.GSOMaxSize = native.Uint32(attr.Value[0:4]) case unix.IFLA_GRO_MAX_SIZE: base.GROMaxSize = native.Uint32(attr.Value[0:4]) - case nl.IFLA_GSO_IPV4_MAX_SIZE: + case unix.IFLA_GSO_IPV4_MAX_SIZE: base.GSOIPv4MaxSize = native.Uint32(attr.Value[0:4]) - case nl.IFLA_GRO_IPV4_MAX_SIZE: + case unix.IFLA_GRO_IPV4_MAX_SIZE: base.GROIPv4MaxSize = native.Uint32(attr.Value[0:4]) case unix.IFLA_VFINFO_LIST: data, err := nl.ParseRouteAttr(attr.Value) diff --git a/nl/link_linux.go b/nl/link_linux.go index 2f9778c..e10edbc 100644 --- a/nl/link_linux.go +++ b/nl/link_linux.go @@ -20,11 +20,6 @@ const ( IFLA_INFO_MAX = IFLA_INFO_SLAVE_DATA ) -const ( - IFLA_GSO_IPV4_MAX_SIZE = 63 - IFLA_GRO_IPV4_MAX_SIZE = 64 -) - const ( IFLA_VLAN_UNSPEC = iota IFLA_VLAN_ID