Commit Graph

651 Commits

Author SHA1 Message Date
Ivan Kolodyazhny
70ca0345ee Support dst_port and src_port attributes in flower filter 2023-02-06 10:37:46 -08:00
Ivan Kolodyazhny
130828cd57 Add Flower ip_proto attribute support 2023-02-06 10:37:46 -08:00
Ivan Kolodyazhny
05506ada9f Implement filter goto action support 2023-01-30 09:12:08 -08:00
Ivan Kolodyazhny
378a404a26 Implement chains support
This patch implements both tc and filter chains.

We also need to align tc filter delition implementation
with iprote2 to delete filters withichain by passing
additional bits during filter deletion call.
2022-12-14 10:59:49 -08:00
Ivan Kolodyazhny
e20cb98f77 Support skip_hw/skip_sw flags
This feature could not be tested with virtual interfaces that's why
unit-tests aren't added into this change.
2022-12-14 08:41:50 -08:00
Ivan Kolodyazhny
7f2b136d34 qdisc ingress_block support 2022-12-13 09:41:45 -08:00
Evgeniy Zakharochkin
e0988fd129 Fix adding ipset entry comment 2022-12-12 09:07:43 -08:00
Hu Jun
d3c0a2caa5 - fixes vishvananda/netlink#815
- changes: 1. set userTmpl.Family to correct family 2. add Selector to XfrmState which is corresponding to XfrmUsersaInfo.Sel

- update *XfrmAddress.ToIPNet method to support 0.0.0.0/0 and ::/0 correctly
- update xfrmStateFromXfrmUsersaInfo to get XfrmState.Selector
- extend TestXfrmStateAddGetDel for v6ov4 and v4ov6 cases
2022-11-07 14:26:36 -08:00
Steffen Vogel
d3b7a6fadd Add firewall mark option to RouteGetOptions
This option allows performing FIB lookups for a particular
firewall mark. It is equivalent to iproute2's 'ip route get mark'
option.
2022-11-07 10:26:17 -08:00
Surya Seetharaman
8e1ce9665a Add labelFilter for conntrack
This PR adds support for filtering flows
based on conntrack labels. It adds two
filters `ConntrackMatchLabels` &&
`ConntackUnmatchLabels` through which user can
provide a list of labels as type "bytes" which
will then be compared to flow.Labels to see if
any matches were found.

ConntrackMatchLabels: Every label passed should
be contained in flow.Labels for a match to be true
ConntrackUmmatchLabels: Every label passed should
not be contained in the flow.Labels for a match to
be true

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
2022-11-03 10:05:53 -07:00
Noah
eab52eee5a Add XfrmPolicyGet to unspecified operations 2022-11-03 09:19:10 -07:00
Dave Setzke
b4d07e8343 Use ndmsg payload for neighbor subscribe requests 2022-11-03 09:05:21 -07:00
chengzhycn
d3b8a16e9b add actions support for fwfilter
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-27 09:19:20 -07:00
chengzhycn
8baf7b0c69 add support for skbedit mask 2022-10-26 18:47:10 -07:00
chengzhycn
337a587de1 fix RouteList can't list routes properly when unspecifying link
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-26 10:42:34 -07:00
Damien Tournoud
8715fe718d ipset: Expose MaxElements to IpsetCreate 2022-09-15 11:54:47 -07:00
Damien Tournoud
d44b87fd4d ipset: Add support for IPv6 2022-08-12 20:31:58 +02:00
Tobias Klauser
afa2eb2a66 Use IFLA_* consts defined in golang.org/x/sys/unix
Use the constants provided in the golang.org/x/sys/unix package instead
of locally defining them, as done in commit c94808a88b ("link: add
support for IFLA_GRO_MAX_SIZE").

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2022-08-07 20:12:18 +02:00
Manjiri Gadagkar
6e2993d135 RouteGetWithOptions: Add UID option 2022-08-02 12:21:20 +02:00
Eyal Birger
7e7feb220f link: Add FlowBased support to Gretun
GRE L3 devices support "FlowBased" ("collect_md"/"external") mode.
Add support for this configuration and relevant test.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2022-08-02 12:16:27 +02:00
Eyal Birger
d0aef2fdcd link: fix FlowBased support in Gretap
IFLA_GRE_COLLECT_METADATA is a "flag" netlink attribute. As such it should
not be sent with a data payload.

Fix gretap link to send this flag correctly and re-enable tests.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2022-08-02 12:15:32 +02:00
Manjiri Gadagkar
20de99527f rule: add support for uidrange
Rename rule.UID as rule.UIDRange
2022-07-28 08:58:17 -07:00
conjones
7b913bc23e routes: Uses empty RtMsg and routeHandle in RouteListFiltered
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.
2022-07-12 21:14:29 +02:00
Javier Garcia
c591ada0fb fix. nl.DeserializeRtNexthop return.
Return a full created nl.RtNexthop ptr to avoid the
"converted pointer straddles multiple allocations".

UT by fasaxc.

Co-authored-by: fasaxc
Signed-off-by: Javier Garcia <javier.martin.garcia@ibm.com>
2022-06-30 09:52:24 -07:00
Damien Tournoud
836d892b17 Add IpsetSwap() 2022-06-21 10:43:08 -07:00
Anton Protopopov
1a118fe229 Add horizon attributes to fq
Add two attributes to fq: Horizon and HorizonDrop (which correspond to the
TCA_FQ_HORIZON and TCA_FQ_HORIZON_DROP attributes). The HorizonDrop attribute
specifies which policy to apply: drop (1, kernel default), cap delivery time to
horizon (0), and the Horizon attribute specifies the number of useconds before
applying the policy.

Add a new test TestFqHorizon to test the changes and as an example of usage.

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
2022-06-08 12:58:07 -07:00
Nikolay Aleksandrov
543bb1cade link: add LinkSetGSOMaxSize and LinkSetGROMaxSize
Add two new methods to allow setting GSO and GRO max size attributes only.
They make it much easier to enable BIG TCP[1].
The equivalent iproute2 commands are:
$ ip link set $link gso_max_size $maxSize
$ ip link set $link gro_max_size $maxSize

Also add tests for them.

[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-07 09:11:27 -07:00
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