Commit Graph

177 Commits

Author SHA1 Message Date
tc
f1333cd79a support netkit
netkit device is merged to Linux upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=22360fad5889cbefe1eca695b0cc0273ab280b56

this PR add support to manage a netkit device in Golang

authored-by: tangchen <tangchen.1@bytedance.com>
2023-11-27 10:22:01 -08:00
adrianc
95ab6696a5 fix: check for ext ACK TLVs
checking for Extended ACK in nlmsghdr flags
should be done with bitwise AND op instead of OR op

Signed-off-by: adrianc <adrianc@nvidia.com>
2023-11-12 12:14:56 -08:00
adrianc
aa4f20db57 fix: check nlmsghdr flags for interrupt
fail if NLM_F_DUMP_INTR flag is set

Signed-off-by: adrianc <adrianc@nvidia.com>
2023-11-12 12:06:03 -08:00
Tobias Klauser
7b4e1dec46 nl: avoid trailing NULL byte in error messages
Use unix.ByteSliceToString to convert the NULL-terminated
NLMSGERR_ATTR_MSG error message.
2023-10-24 09:29:12 -07:00
Dave Setzke
229a10237c Add ReceiveBufferSize and force option to *Subscribe
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.
2023-09-21 19:50:55 -07:00
Marcelo Guerrero
63484bbf69 Add support to manage the vlan protocol on a vf
This allows users to get and set the vlan protocol on a vf
Signed-off-by: Marcelo Guerrero <marguerr@redhat.com>
2023-09-05 08:20:06 -07:00
Robin Jarry
19c6398aa9 link: allow isolating bridge ports
This is the equivalent of:

	bridge link set dev <foo> isolated on|off

Add more bridge port netlink attributes Imported from
include/uapi/linux/if_link.h in Linux v6.3.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
2023-07-16 12:21:30 +02:00
Tobias Klauser
77712cff87 Use IFLA_G{S,R}O_IPV4_MAX_SIZE constants from golang.org/x/sys/unix
Commit 2b008399a4 ("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 <tklauser@distanz.ch>
2023-06-21 15:13:34 -07:00
Daniel Borkmann
2b008399a4 link: add LinkSetGSOIPv4MaxSize and LinkSetGROIPv4MaxSize
Add two new methods to allow setting GSO and GRO max size attributes only.
They make it much easier to enable IPv4 BIG TCP [0].

The equivalent iproute2 commands are:

$ ip link set $link gso_ipv4_max_size $maxSize
$ ip link set $link gro_ipv4_max_size $maxSize

Also add tests for them. We already do support the IPv6 counterpart via
543bb1cade ("link: add LinkSetGSOMaxSize and LinkSetGROMaxSize").

  [0] https://lore.kernel.org/netdev/cover.1674921359.git.lucien.xin@gmail.com/

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2023-06-14 23:26:06 -07: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
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
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
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
chengzhycn
8baf7b0c69 add support for skbedit mask 2022-10-26 18:47:10 -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
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
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
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
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
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
Steven Falken
dd687eb2f2 feat: add proc events support 2022-01-15 12:48:04 -06:00
Patryk Strusiewicz-Surmacki
b10eb8fe5c Support for devlink info command 2021-11-01 11:35:09 -05:00
张祖建
b8aac10bba fix staticcheck issues 2021-09-21 09:10:48 -05: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
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
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
bersoare
079db23e21 lwtunnel: add support for encap type bpf
add bpf program types

add unit tests

don't use strings to determine type

fix camel case
2021-07-03 11:44:22 +02:00
Parav Pandit
22c099edb4 Add devlink port add delete APIs
Add APIs to add and delete a devlink port of specified flavour for a
given devlink device.

Extended test to accept devlink device and sf number parameters from the
test command line.

Signed-off-by: Parav Pandit <parav@nvidia.com>
2021-05-08 09:00:34 -07:00
Parav Pandit
83b6143251 Extend devlink port for function attributes
Extend devlink port for optional port function attributes.

Signed-off-by: Parav Pandit <parav@nvidia.com>
2021-05-08 09:00:34 -07:00
arthurchiao
9de6d08565 Allow to set/get netlink socket timeout for default handle
Ref: #613

Signed-off-by: arthurchiao <arthurchiao@hotmail.com>
2021-02-17 20:27:53 -08:00
Julian Kornberger
6ffafa9fc1 Improve attribute parsing
This improves dealing with invalid input data.
2020-12-30 21:45:07 -08:00
Moshe Litvin
77e4d032a0 Allow building on non-linux machine 2020-12-28 10:31:32 -08:00
Stephen Hassard
d185ffdb62 Add Geneve link support
Heavily based on the existing Gretap support
2020-11-21 23:35:49 -08:00
Parav Pandit
ff8f17bc19 Add devlink command to query devlink port list
Add devlink command to get list of devlink ports and their common
attributes.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2020-11-21 23:31:39 -08:00
lmbsog0
c7261bd9e0 add support for CAN 2020-11-20 12:42:29 -08:00
root
e30b76407c VF stats struct and deserialization method added. VfStats now reported in the VfInfo struct
Co-authored-by: PatrickKutch <patrick.kutch@gmail.com>
2020-10-19 15:29:26 -04:00
Ivan Milchev
abd6d09710 added support for SFQ qdiscs 2020-10-19 15:28:26 -04:00
Julian Kornberger
1e3d26b1b3 Add support for ipset 2020-09-24 21:36:22 -04:00
Julian Kornberger
b4a20b8556 Add Uint32Attribute 2020-09-24 21:36:22 -04:00
tanbangcheng
06362a6c16 Add DestPort to TunnelKeyAction
Fix parsing of TCA_TUNNEL_KEY_ENC_IPV6_SRC & TCA_TUNNEL_KEY_ENC_IPV6_DST
2020-09-24 21:30:07 -04:00
Tobias Klauser
bfba8e4149 Correct value of SizeofXfrmUsersaFlush
struct xfrm_usersa_flush contains a single u8, thus sizeof(struct
xfrm_usersa_flush) == 1 as can be verified by running the following
code through go tool cgo -godefs:

    package xfrm_test

    // #include <linux/xfrm.h>
    import "C"

    const SizeofXfrmUsersaFlush = C.sizeof_struct_xfrm_usersa_flush

which results in

    // Code generated by cmd/cgo -godefs; DO NOT EDIT.
    // cgo -godefs foo.go

    package xfrm_test

    const SizeofXfrmUsersaFlush = 0x1

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-02-10 14:25:39 -08:00
chendotjs
a2e8781202 rule: add support for dport/sport 2020-02-10 06:52:06 -08:00
Jianlin Lv
5e92c072cd check payload of the NLMSG_DONE nlmsg
check the payload of the NLMSG_DONE type netlink
message for possible error

Signed-off-by: Jianlin Lv <Jianlin.Lv@arm.com>
2020-02-09 10:25:19 -08:00