This commit added support to allow the operation of ip6tnl encapsulation.
It is equivalent to the iproute2 command, e.g., ip route add 192.168.99.0/24 encap ip6 dst 2001:db8:: dev ip6-tunnel
The limitation include that the options field defined in encap nl route attribute is not implenmented yet.
Testcase is included.
When there are a large number of existing results for the link, neighbor, and
address subscribe functions with ListExisting are likely to fail with ENOBUFS.
This takes the AddrSubscribeOptions ReceiveBufferSize, already applied
to LinkSubscribeOptions, and applies it to NeighSubscribeOptions and
RouteSubscribeOptions. The ReceiveTimeout option was also added to each.
Added a SetReceiveBufferSize to the nl_linux socket API.
The existing addr_linux subscribe function was modified so instead of setting
the ReceiveBufferSize on the netlink pkghandle, it is set on the socket
associated with the subscription. The new implementations also only change the
receive buffer size on the socket.
Lastly, a new ReceiveBufferForceSize option was applied to all four of the
modified Subscribe functions.
Support `ip route get fibmatch` equivalent with RouteGetWithOptions by
adding FIBMatch flag to RouteGetOptions.
Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
RouteListFiltered constructs an RtMsg with default options and lists
routes. Only routes matching these default options are returned from the
kernel when STRICT_CHECK enabled. The kernel will return all routes only
when an option is set to the zero value. This patch sets the zero value
by default, overwriting when specified by the consumer.
The package level var native (holding the native endianness) is
initialized at package load time. Thus there is no need to re-initalize
it in functions using it, e.g. (*Handle).filterModify, parseU32Data,
parseFwData, parseBpfData and parseMatchAllData.
This fixes a data race between these functions and any read access of
var native, e.g. in LinkDeserialize as reported in issue #633.
Also don't re-declare local variables shadowing the global package-level
var.
Fixes#633
Signed-off-by: Tobias Klauser <tobias@cilium.io>
Commit ec93726159 ("Adds strings translation methods") broke non-Linux
builds by relying on unix constants that are only declared on the linux
platform in the upstream x/sys/unix package.
Other platforms report undefined variables, such as the following:
$ GOOS=darwin go build .
# github.com/vishvananda/netlink
./route.go:17:7: undefined: SCOPE_UNIVERSE
./route.go:19:7: undefined: SCOPE_SITE
./route.go:21:7: undefined: SCOPE_LINK
./route.go:23:7: undefined: SCOPE_HOST
./route.go:25:7: undefined: SCOPE_NOWHERE
./route.go:55:7: undefined: unix.RTPROT_BABEL
./route.go:57:7: undefined: unix.RTPROT_BGP
./route.go:59:7: undefined: unix.RTPROT_BIRD
./route.go:61:7: undefined: unix.RTPROT_BOOT
./route.go:63:7: undefined: unix.RTPROT_DHCP
./route.go:63:7: too many errors
Move the platform-specific implementations to platform-specific files
and add stubs to satisfy other platforms.
Fixes: ec93726159 ("Adds strings translation methods")
Signed-off-by: Joe Stringer <joe@cilium.io>
There are lots of route metrics to be added, such as rto_min,
quick_ack and so on, and these metrics are useful for users to
tune network performance, so we add all these metrics.
Signed-off-by: bianze <bianze1993@gmail.com>
iproute2's own netlink library asserts that the sockaddr sender pid
has to be the one of the kernel [0]. It also doesn't bail out on pid
mismatch but only skips the message instead. We've seen cases where
the latter had a pid 0; in such case we should skip to the next nl
message instead of hard bail out.
[0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/libnetlink.c
rtnl_dump_filter_l(), __rtnl_talk_iov()
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
For link, address, route, add a `WithOptions` variant to the
`*Subscribe()` function to specify a namespace and an error
callback. Those options can be extended in the future without adding
more functions. For example, it could be possible to subscribe only
for a given family by adding a `Family` member to the appropriate
struct.
As a minor change, the private function is always suffixed by `At`,
since it was the case for route and raw netlink functions (but not for
address and link).