Commit Graph

624 Commits

Author SHA1 Message Date
Yutaro Hayakawa
ef1d7077fb Support XFRMA_REPLAY_VAL attribute
Add support of XFRMA_REPLAY_VAL which can be used with various XFRM
state-related messages.
2022-06-04 09:35:41 -07:00
Yutaro Hayakawa
1f7c9af2fa Support XFRM extra-flag attribute
Add support of XFRMA_SA_EXTRA_FLAGS attribute of XFRM State interface.
The attribute is a 32bit flag and currently two flags
(XFRM_SA_XFLAG_DONT_ENCAP_DSCP and XFRM_SA_XFLAG_OSEQ_MAY_WRAP) are
defined. Two boolean flags added to XfrmState struct are correspoinding
to those flags. Naming of the flags are taken from iproute2's options
(extra-flag dont-encap-dscp | oseq-may-wrap).
2022-06-03 09:40:00 -07:00
Nikolay Aleksandrov
c94808a88b 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>
2022-06-02 16:02:03 -07:00
Tobias Klauser
866f5f32e3 Fix TestLinkAddDelXfrmiNoId
Adding an xfrmi link with if_id 0 results in EINVAL being returned, see
[1]. Adjust TestLinkAddDelXfrmiNoId accordingly to expect an error.

[1] 8efd0d9c31/net/xfrm/xfrm_interface.c (L645-L648)

Fixes: f7fd7af437 ("Only set IFLA_XFRM_IF_ID if not 0")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2022-05-31 09:13:25 -07:00
Hasan Mahmood
5e915e0149 Don't make setsockopt call if option is false 2022-04-04 10:29:18 -05:00
Nicholas Hollett
5cb84e47ad filter: Add support for the csum action in u32
This patch adds support for the U32 action that can force a csum
recalculation in different layers of a packet.
2022-03-29 10:02:56 -07:00
open-cmi
6bb6f8abbc fix: build failed on macos when use RT_FILTER_TABLE 2022-03-29 11:19:33 -05:00
conjones
8f52b0b093 Add SetStrictCheck() method to NetlinkHandle
Allows the ability to set NETLINK_GET_STRICT_CHK socket option on netlink handles.

This can be used to avoid missing routes due to a kernel bug[1]. The
choice to make this a toggle is because not all operations use the
correctly formatted message and so some will fail. The scope of
determining which calls use the wrong message format is an unknown
amount of work at this time so we give the consumer of the library a
toggle they can use when needed.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=885b8b4dbba5ca6114db0fcd0737fe2512650745
2022-03-29 11:15:07 -05:00
conjones
657c30750a Use Addrmsg when listing addrs, and RtMsg when listing routes 2022-03-29 11:15:07 -05:00
Dan Williams
083e92e21e addr: add receive timeout option for AddrSubscribe
Otherwise addrSubscribeAt()'s goroutine will block in s.Receive()
and potentially call callbacks long after the done channel has
been closed by the caller.

Signed-off-by: Dan Williams <dcbw@redhat.com>
2022-03-18 10:22:40 -05:00
Gui774ume
b112db377d parse program tag from the entire buffer 2022-03-16 12:37:41 -07:00
yzp0n
facc790515 Annotate Execute() errors using netlink error message.
This patch makes two changes:
- setsockopt NETLINK_EXT_ACK, if EnableErrorMessageReporting is
  configured. (defaults to false for compatibility with existing code)
- NetlinkRequest.Execute is modified to parse the nlmsgerr attributes
  if they are present on the response message.
  - After this patch, when the request results in NLMSG_ERROR and the
    response contains a netlink error message (NLMSGERR_ATTR_MSG),
    NetlinkRequest.Execute will return an error with the message that
    wraps syscall.Errno.
2022-03-09 09:22:25 -08:00
Tobias Klauser
f7fd7af437 Only set IFLA_XFRM_IF_ID if not 0
A value of 0 for IFLA_XFRM_IF_ID is not valid and will be rejected by
the kernel by returning EINVAL, see [1]. Thus, only set the
IFLA_XFRM_IF_ID attribute in case Xfrmi.Ifid != 0.

[1] 8efd0d9c31/net/xfrm/xfrm_interface.c (L645-L648)
2022-02-24 05:54:17 -08:00
Shengjing Zhu
59bb5b4d56 Fix test on 32bit arch
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2022-02-22 10:18:32 -08:00
Tao Li
f24382625b add proto field to Iptun 2022-02-17 12:20:32 -06:00
Aditi Ghag
0639e7e787 Fix darwin target compilation
dd687eb broke compilation on mac OS (darwin target). Rename the
linux specific files accordingly.

Fixes: dd687eb
2022-01-25 13:50:16 -06:00
Tom Payne
ab4cd23987 add build on macOS test
netlink is Linux-only, but adding this test ensures that netlink builds
without error on macOS, which helps catch missing build tags.
2022-01-25 13:50:16 -06:00
Artem Glazychev
d6b03fdeb8 Fix review comment
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
2022-01-18 11:05:37 -06:00
Zihong Zheng
5a3e901175 rule: add support for ipproto
This is similar to https://github.com/vishvananda/netlink/pull/511,
but this time for the ipproto option:
```
ip rule add ipproto xxx table main
```
2022-01-18 11:05:37 -06:00
Tobias Klauser
796d4ea903 Only set XFRMA_IF_ID if not 0
A value of 0 for XFRMA_IF_ID is not valid and will be rejected as of
Linux kernel commit torvalds/linux@68ac0f3810 ("xfrm: state and policy
should fail if XFRMA_IF_ID 0"), which will return EINVAL when setting
XFRMA_IF_ID = 0. Thus, only set the XFRMA_IF_ID attribute in case
XfrmState.Ifid or XfrmPolicy.Ifid are != 0.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2022-01-17 14:58:32 -08:00
Steven Falken
dd687eb2f2 feat: add proc events support 2022-01-15 12:48:04 -06:00
conjones
76d8bfe0aa Adds ip6tunnel encap types, encap flags, and flags 2022-01-12 19:00:49 -06:00
Vishvananda Abrams
359304793a fix badge 2022-01-12 16:57:20 -06:00
Vishvananda Abrams
47ee01798a skip flaky test in ci 2022-01-12 16:52:50 -06:00
Vishvananda Abrams
523ee65ce3 fix the tests to run again 2022-01-12 16:05:20 -06:00
Vishvananda Abrams
e5fd1f8193 replace travis with github action 2022-01-12 13:45:29 -06:00
Wu Zongyong
9ada19101f filter: add support for police action
This patch adds support for tc police action. And codes of fw filter
have been refactored with the police action for reducing redundant
codes.

Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
2021-11-29 08:39:51 -08:00
Tobias Urdin
650dca95af Export LinkModify function
When the LinkModify was merged in [1] a function
that exports it outside of pkgHandle was never
added like is available for LinkAdd, LinkDel etc.

Update testing to use exported LinkModify that
itself calls the pkgHandle.LinkModify function.

[1] https://github.com/vishvananda/netlink/pull/541
2021-11-18 08:18:26 -08:00
Patryk Strusiewicz-Surmacki
b10eb8fe5c Support for devlink info command 2021-11-01 11:35:09 -05:00
Daniel Borkmann
74e723f230 Fix inserting a nil neigh.HardwareAddr into the neighboring subsystem
The condition to demand a lladdress for neigh.Flags != NTF_PROXY is just
buggy, since there are various other flags such as NTF_USE, NTF_EXT_MANAGED,
etc where this is not required. Besides, the kernel handles this internally
anyway if it demands a NDA_LLADDR attribute. Simply get rid of the NTF_PROXY
flag/condition since it's wrong.

Fixes: d710fbade4 ("Add proxy support to the neighbor functions (#149)")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2021-11-01 11:31:57 -05:00
Daniel Borkmann
b08d99c0d0 Add support for NDA_FLAGS_EXT neighboring attribute
This allows to set NTF_EXT_MANAGED neighbor flag for managed neighbor
entries as per kernel commit 7482e3841d52 ("net, neigh: Add NTF_MANAGED
flag for managed neighbor entries"). The flag then indicates to the
kernel that the neighbor entry should be periodically probed for keeping
the entry in NUD_REACHABLE state iff possible.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2021-11-01 11:31:57 -05:00
Joris Bonnefoy
fc5a223eaf Set NetNsId to -1 when attr is not specified 2021-11-01 11:26:46 -05:00
montag451
187053b978 Use SyscallConn() instead of Fd() to persist TUN/TAP interface
os.File.Fd() puts back the file descriptor in blocking mode which is
pretty annoying as SetDeadline will stop working
2021-09-24 15:29:09 -05:00
Vishvananda Abrams
d5e9ae8469 link travis to builds, not image 2021-09-21 09:39:15 -05:00
yuwenchao
f055e5464f Add linux route get oif option.
This option is equivalent to "ip route get ... dev ...", which is useful when the route is multipath.

Signed-off-by: yuwenchao <yuwenchao@qiyi.com>
2021-09-21 09:12:08 -05:00
Rinat Baygildin
533d417a1a Extend route unspecified operations 2021-09-21 09:11:18 -05:00
张祖建
b8aac10bba fix staticcheck issues 2021-09-21 09:10:48 -05:00
张祖建
6757be61c4 Add trailing null char to string in devlink request 2021-09-21 09:09:38 -05:00
Quentin McGaw
30ec08bc3d Rule.String() method returns .Dst
- Return `to <all | ipNetString>` in string
- Return `all` for `from` if `rule.Src == nil`
- Return `all` for `to` if `rule.Dst == nil`

Add unit test
2021-09-20 13:10:42 -07:00
Tobias Urdin
65349edba8 Add support for RTA_FLOW
This adds support for the RTA_FLOW routing msg
attribute and adds the Realm field to the Route
object.
2021-09-20 10:45:34 -07:00
Zack Liu
fc21756312 Make IPSet actually support hash set types 2021-09-18 10:50:26 -07:00
Wei Fu
c33185cb84 rdma: support rdma link add/del functionality
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-09-18 10:31:51 -07:00
TheDiveO
626202eca8 Provide handle Close() and deprecate Delete() 2021-09-18 09:03:48 -07:00
Milan Lenco
871f8a156e Add test for conntrack entry raw data parsing
Signed-off-by: Milan Lenco <milan@zededa.com>
2021-09-17 19:01:08 -07:00
GopiKrishna Kodali
607db9998a Fix netlink to skip reading TLVs that we are not interested.
Signed-off-by: GopiKrishna Kodali <gkodali@zededa.com>
2021-09-17 19:01:08 -07:00
Naiming Shen
fbf10179ff add timestamp/timeout to netlink/conntrack
Signed-off-by: Naiming Shen <naiming@zededa.com>
2021-09-17 19:01:08 -07:00
tanbangcheng
5f76ae2b4d Add basic flower support
Signed-off-by: tanbangcheng <tanbangcheng@bytedance.com>
2021-09-17 18:42:15 -07:00
bersoare
7992ad9959 add support for bareudp link type 2021-09-17 10:14:18 -07:00
Vishvananda Abrams
2c39f34919 one more fix 2021-09-16 11:13:39 -05:00
Vishvananda Abrams
bb30b20672 fix the travis badge 2021-09-16 11:09:50 -05:00