]> git.ipfire.org Git - thirdparty/iproute2.git/log
thirdparty/iproute2.git
7 months agoMerge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next
Stephen Hemminger [Mon, 2 Dec 2024 00:29:17 +0000 (16:29 -0800)] 
Merge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next

8 months agodevlink: fix memory leak in ifname_map_rtnl_init()
Minhong He [Mon, 25 Nov 2024 03:24:54 +0000 (11:24 +0800)] 
devlink: fix memory leak in ifname_map_rtnl_init()

When the return value of rtnl_talk() is greater than
or equal to 0, 'answer' will be allocated.
The 'answer' should be free after using,
otherwise it will cause memory leak.

Signed-off-by: Minhong He <heminhong@kylinos.cn>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 months agoip: fix memory leak in do_show()
Minhong He [Mon, 25 Nov 2024 06:08:48 +0000 (14:08 +0800)] 
ip: fix memory leak in do_show()

Free the 'answer' obtained from 'rtnl_talk()'.

Fixes: 6887a0656dad ("ip: netconf: fix overzealous error checking")
Signed-off-by: Minhong He <heminhong@kylinos.cn>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 months agoadd .editorconfig file for basic formatting
Vincent Mailhol [Sat, 16 Nov 2024 03:05:43 +0000 (12:05 +0900)] 
add .editorconfig file for basic formatting

EditorConfig is a specification to define the most basic code formatting
stuff, and it is supported by many editors and IDEs, either directly or via
plugins, including VSCode/VSCodium, Vim, emacs and more.

It allows to define formatting style related to indentation, charset, end
of lines and trailing whitespaces. It also allows to apply different
formats for different files based on wildcards, so for example it is
possible to apply different configurations to *.{c,h}, *.json or *.yaml.

In linux related projects, defining a .editorconfig might help people that
work on different projects with different indentation styles, so they
cannot define a global style. Now they will directly see the correct
indentation on every fresh clone of the project.

Add the .editorconfig file at the root of the iproute2 project with a broad
generic configuration for all file types. Then add exceptions for the file
types which follow different conventions.

See https://editorconfig.org

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agov6.12.0 v6.12.0
Stephen Hemminger [Tue, 19 Nov 2024 16:57:22 +0000 (08:57 -0800)] 
v6.12.0

8 months agotc: Add support for Hold/Release mechanism in TSN as per IEEE 802.1Q-2018
Choong Yong Liang [Tue, 12 Nov 2024 04:00:29 +0000 (12:00 +0800)] 
tc: Add support for Hold/Release mechanism in TSN as per IEEE 802.1Q-2018

This commit enhances the q_taprio module by adding support for the
Hold/Release mechanism in Time-Sensitive Networking (TSN), as specified
in the IEEE 802.1Q-2018 standard.

Changes include:
- Addition of `TC_TAPRIO_CMD_SET_AND_HOLD` and `TC_TAPRIO_CMD_SET_AND_RELEASE`
cases in the `entry_cmd_to_str` function to return "H" and "R" respectively.
- Addition of corresponding string comparisons in the `str_to_entry_cmd`
function to map "H" and "R" to `TC_TAPRIO_CMD_SET_AND_HOLD` and
`TC_TAPRIO_CMD_SET_AND_RELEASE`.

The Hold/Release feature works as follows:
- Set-And-Hold-MAC (H): This command sets the gates and holds the current
configuration, preventing any further changes until a release command is
issued.
- Set-And-Release-MAC (R): This command releases the hold, allowing
subsequent gate configuration changes to take effect.

These changes ensure that the q_taprio module can correctly interpret and
handle the Hold/Release commands, aligning with the IEEE 802.1Q-2018 standard
for enhanced TSN configuration.

Signed-off-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoMerge branch 'can-xl-prep' into next
David Ahern [Mon, 18 Nov 2024 16:51:49 +0000 (16:51 +0000)] 
Merge branch 'can-xl-prep' into next

Vincent Mailhol  says:

====================

An RFC was sent last weekend to kick-off the discussion of the
introduction of CAN XL: [1] for the kernel side and [2] for the
iproute2 interface. While the series received some positive feedback,
it is far from completion. Some work is still needed to:

  - adjust the nesting of the IFLA_CAN_XL_DATA_BITTIMING_CONST in the
    netlink interface

  - add the CAN XL PWM configuration

and this TODO list may grow if more feedback is received.

Regardless of this, the RFC started with a set of trivial patches to
do some clean-up and some renaming in preparation of the introduction
of CAN XL.

This series just contains those preparation patches which were cherry
picked from the RFC.

The goal is to have those merged first to remove some overhead from
the netlink CAN XL main series before tacking care of the other
comments.

[1] [RFC] can: netlink: add CAN XL
Link: https://lore.kernel.org/linux-can/20241110155902.72807-16-mailhol.vincent@wanadoo.fr/
[2] [RFC] iplink_can: add CAN XL
Link: https://lore.kernel.org/linux-can/20241110160406.73584-10-mailhol.vincent@wanadoo.fr/
====================

Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: rename dbt into fd_dbt in can_parse_opt()
Vincent Mailhol [Tue, 12 Nov 2024 17:27:56 +0000 (02:27 +0900)] 
iplink_can: rename dbt into fd_dbt in can_parse_opt()

The CAN XL support will introduce another dbt variable. Rename the
current dbt variable into fd_dbt to avoid future confusion. When
introduced, the CAN XL variable will be named xl_dbt.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: add struct can_tdc
Vincent Mailhol [Tue, 12 Nov 2024 17:27:55 +0000 (02:27 +0900)] 
iplink_can: add struct can_tdc

Add the struct can_tdc to group the tdcv, tdco and tdvf variables
together. The structure is borrowed from linux/can/bittiming.h [1].

This refactor is a preparation for the introduction of CAN XL.

[1] https://elixir.bootlin.com/linux/v6.11/source/include/linux/can/bittiming.h#L78

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: use invarg() instead of fprintf()
Vincent Mailhol [Tue, 12 Nov 2024 17:27:54 +0000 (02:27 +0900)] 
iplink_can: use invarg() instead of fprintf()

invarg() is specifically designed to print error messages when an
invalid argument is provided. Replace the generic fprintf() by
invarg() in can_parse_opt().

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: remove newline at the end of invarg()'s messages
Vincent Mailhol [Tue, 12 Nov 2024 17:27:53 +0000 (02:27 +0900)] 
iplink_can: remove newline at the end of invarg()'s messages

invarg() already prints a new line by default. Adding an explicit "\n"
at the end of the message results in two lines being printed. Remove
all newlines at the end of the invarg() messages.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: reduce the visibility of tdc in can_parse_opt()
Vincent Mailhol [Tue, 12 Nov 2024 17:27:52 +0000 (02:27 +0900)] 
iplink_can: reduce the visibility of tdc in can_parse_opt()

tdc is only used in a single if block. Move its declaration to the top
of the compound statement where it is used.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoiplink_can: remove unused FILE *f parameter in three functions
Vincent Mailhol [Tue, 12 Nov 2024 17:27:51 +0000 (02:27 +0900)] 
iplink_can: remove unused FILE *f parameter in three functions

FILE *f, the first parameter of below functions:

 * can_print_tdc_opt()
 * can_print_tdc_const_opt()
 * void can_print_ctrlmode_ext()

is unused. Remove it.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agolib: names: check calloc return value in db_names_alloc
Denis Kirjanov [Wed, 13 Nov 2024 10:53:49 +0000 (13:53 +0300)] 
lib: names: check calloc return value in db_names_alloc

db_names_load() may crash since it touches the
hash member. Fix it by checking the return value

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 months agobridge: add ip/iplink_bridge files to MAINTAINERS
Nikolay Aleksandrov [Thu, 31 Oct 2024 08:51:43 +0000 (10:51 +0200)] 
bridge: add ip/iplink_bridge files to MAINTAINERS

Add F line for the ip/iplink_bridge* files to bridge's MAINTAINERS
entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 months agolib: utils: close file handle on error
Denis Kirjanov [Thu, 31 Oct 2024 12:14:11 +0000 (15:14 +0300)] 
lib: utils: close file handle on error

reap_prop() doesn't close the file descriptor
on some errors, fix it.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
8 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Sat, 16 Nov 2024 04:45:51 +0000 (04:45 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agoMerge branch 'rdma-monitor' into next
David Ahern [Sat, 16 Nov 2024 04:45:03 +0000 (04:45 +0000)] 
Merge branch 'rdma-monitor' into next

Chiara Meiohas  says:

====================

This series adds support to a new command to monitor IB events
and expands the rdma-sys command to indicate whether this new
functionality is supported.
We've also included a fix for a typo in rdma-link man page.

Command usage and examples are in the commits and man pages.

These patches are complimentary to the kernel patches:
https://lore.kernel.org/linux-rdma/20240821051017.7730-1-michaelgur@nvidia.com/
https://lore.kernel.org/linux-rdma/093c978ef2766fd3ab4ff8798eeb68f2f11582f6.1730367038.git.leon@kernel.org/

====================

Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agordma: Add IB device and net device rename events
Chiara Meiohas [Tue, 12 Nov 2024 09:58:02 +0000 (11:58 +0200)] 
rdma: Add IB device and net device rename events

rdma monitor displays the IB device name and the netdevice
name when displaying event info. Since users can modiy these
names, we track and notify on renaming events.

$ rdma monitor
$ rmmod mlx5_ib
[UNREGISTER]    dev 1  rocep8s0f1
[UNREGISTER]    dev 0  rocep8s0f0

$ modprobe mlx5_ib
[REGISTER]      dev 2  mlx5_0
[NETDEV_ATTACH] dev 2  mlx5_0 port 1 netdev 4 eth2
[REGISTER]      dev 3  mlx5_1
[NETDEV_ATTACH] dev 3  mlx5_1 port 1 netdev 5 eth3
[RENAME]        dev 2  rocep8s0f0
[RENAME]        dev 3  rocep8s0f1

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev
[UNREGISTER]    dev 2  rocep8s0f0
[REGISTER]      dev 4  mlx5_0
[NETDEV_ATTACH] dev 4  mlx5_0 port 30 netdev 4 eth2
[RENAME]        dev 4  rdmap8s0f0

$ echo 4 > /sys/class/net/eth2/device/sriov_numvfs
[NETDEV_ATTACH] dev 4  rdmap8s0f0 port 2 netdev 7 eth4
[NETDEV_ATTACH] dev 4  rdmap8s0f0 port 3 netdev 8 eth5
[NETDEV_ATTACH] dev 4  rdmap8s0f0 port 4 netdev 9 eth6
[NETDEV_ATTACH] dev 4  rdmap8s0f0 port 5 netdev 10 eth7
[REGISTER]      dev 5  mlx5_0
[NETDEV_ATTACH] dev 5  mlx5_0 port 1 netdev 11 eth8
[REGISTER]      dev 6  mlx5_1
[NETDEV_ATTACH] dev 6  mlx5_1 port 1 netdev 12 eth9
[RENAME]        dev 5  rocep8s0f0v0
[RENAME]        dev 6  rocep8s0f0v1
[REGISTER]      dev 7  mlx5_0
[NETDEV_ATTACH] dev 7  mlx5_0 port 1 netdev 13 eth10
[RENAME]        dev 7  rocep8s0f0v2
[REGISTER]      dev 8  mlx5_0
[NETDEV_ATTACH] dev 8  mlx5_0 port 1 netdev 14 eth11
[RENAME]        dev 8  rocep8s0f0v3

$ ip link set eth2 name myeth2
[NETDEV_RENAME]  netdev 4 myeth2

$ ip link set eth1 name myeth1

** no events received, because eth1 is not attached to
   an IB device **

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agordma: update uapi headers
Chiara Meiohas [Tue, 12 Nov 2024 09:58:01 +0000 (11:58 +0200)] 
rdma: update uapi headers

Update rdma_netlink.h file upto kernel commit 7566752e4d7d
("RDMA/nldev: Add IB device and net device rename events")

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agordma: Fix typo in rdma-link man page
Chiara Meiohas [Tue, 12 Nov 2024 09:58:00 +0000 (11:58 +0200)] 
rdma: Fix typo in rdma-link man page

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agordma: Expose whether RDMA monitoring is supported
Chiara Meiohas [Tue, 12 Nov 2024 09:57:59 +0000 (11:57 +0200)] 
rdma: Expose whether RDMA monitoring is supported

Extend the "rdma sys" command to display whether RDMA
monitoring is supported.

Example output for kernel where monitoring is supported:
$ rdma sys show
netns shared privileged-qkey off monitor on copy-on-fork on

Example output for kernel where monitoring is not supported:
$ rdma sys show
netns shared privileged-qkey off monitor off copy-on-fork on

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agordma: Add support for rdma monitor
Chiara Meiohas [Tue, 12 Nov 2024 09:57:58 +0000 (11:57 +0200)] 
rdma: Add support for rdma monitor

Introduce a new command for RDMA event monitoring.
This patch adds a new attribute "event_type" which describes
the event recieved. Add a new NETLINK_RDMA multicast group
and processes listening to this multicast group receive RDMA
events.

The event types supported are IB device registration/unregistration
and net device attachment/detachment.

Example output of rdma monitor and the commands which trigger
the events:

$ rdma monitor
$ rmmod mlx5_ib
[UNREGISTER]    dev 3 rocep8s0f1
[UNREGISTER]    dev 2 rocep8s0f0

$modprobe mlx5_ib
[REGISTER]      dev 4 mlx5_0
[NETDEV_ATTACH] dev 4 mlx5_0 port 1 netdev 4 eth2
[REGISTER]      dev 5 mlx5_1
[NETDEV_ATTACH] dev 5 mlx5_1 port 1 netdev 5 eth3

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev
[UNREGISTER]    dev 4 rocep8s0f0
[REGISTER]      dev 6 mlx5_0
[NETDEV_ATTACH] dev 6 mlx5_0 port 30 netdev 4 eth2

$ echo 4 > /sys/class/net/eth2/device/sriov_numvfs
[NETDEV_ATTACH] dev 6 rdmap8s0f0 port 2 netdev 7 eth4
[NETDEV_ATTACH] dev 6 rdmap8s0f0 port 3 netdev 8 eth5
[NETDEV_ATTACH] dev 6 rdmap8s0f0 port 4 netdev 9 eth6
[NETDEV_ATTACH] dev 6 rdmap8s0f0 port 5 netdev 10 eth7
[REGISTER]      dev 7 mlx5_0
[NETDEV_ATTACH] dev 7 mlx5_0 port 1 netdev 11 eth8
[REGISTER]      dev 8 mlx5_0
[NETDEV_ATTACH] dev 8 mlx5_0 port 1 netdev 12 eth9
[REGISTER]      dev 9 mlx5_0
[NETDEV_ATTACH] dev 9 mlx5_0 port 1 netdev 13 eth10
[REGISTER]      dev 10 mlx5_0
[NETDEV_ATTACH] dev 10 mlx5_0 port 1 netdev 14 eth11

$ echo 0 > /sys/class/net/eth2/device/sriov_numvfs
[UNREGISTER]    dev 7 rocep8s0f0v0
[UNREGISTER]    dev 8 rocep8s0f0v1
[UNREGISTER]    dev 9 rocep8s0f0v2
[UNREGISTER]    dev 10 rocep8s0f0v3
[NETDEV_DETACH] dev 6 rdmap8s0f0 port 2
[NETDEV_DETACH] dev 6 rdmap8s0f0 port 3
[NETDEV_DETACH] dev 6 rdmap8s0f0 port 4
[NETDEV_DETACH] dev 6 rdmap8s0f0 port 5

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
8 months agobridge: add ip/iplink_bridge files to MAINTAINERS
Nikolay Aleksandrov [Thu, 31 Oct 2024 08:51:43 +0000 (10:51 +0200)] 
bridge: add ip/iplink_bridge files to MAINTAINERS

Add F line for the ip/iplink_bridge* files to bridge's MAINTAINERS
entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
8 months agolib: utils: close file handle on error
Denis Kirjanov [Thu, 31 Oct 2024 12:14:11 +0000 (15:14 +0300)] 
lib: utils: close file handle on error

reap_prop() doesn't close the file descriptor
on some errors, fix it.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
9 months agouapi: update to bpf.h
Stephen Hemminger [Wed, 30 Oct 2024 04:33:41 +0000 (21:33 -0700)] 
uapi: update to bpf.h

Stay insync with upstream

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agovdpa: Add support for setting the MAC address in vDPA tool.
Cindy Lu [Tue, 29 Oct 2024 08:40:07 +0000 (16:40 +0800)] 
vdpa: Add support for setting the MAC address in vDPA tool.

Add a new function in vDPA tool to support set MAC address.
Currently, the kernel only supports setting the MAC address.

Update the man page to include usage for setting the MAC address.

The usage is: vdpa dev set name vdpa_name mac **:**:**:**:**

here is example:
root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "82:4d:e9:5d:d7:e6",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}

root@L1# vdpa dev set name vdpa0 mac 00:11:22:33:44:55

root@L1# vdpa -jp dev config show vdpa0
{
    "config": {
        "vdpa0": {
            "mac": "00:11:22:33:44:55",
            "link ": "up",
            "link_announce ": false,
            "mtu": 1500
        }
    }
}

Signed-off-by: Cindy Lu <lulu@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Fri, 25 Oct 2024 16:53:41 +0000 (16:53 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agoip: Add "down" filter for "ip addr/link show"
Yedaya Katsman [Sun, 13 Oct 2024 18:53:08 +0000 (21:53 +0300)] 
ip: Add "down" filter for "ip addr/link show"

Currently there is an "up" option, which allows showing only devices
that are up and running. Add a corresponding "down" option.

Also change the usage and man pages accordingly.

Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agouapi: update of bpf.h
Stephen Hemminger [Mon, 21 Oct 2024 17:22:11 +0000 (10:22 -0700)] 
uapi: update of bpf.h

Update from 6.12-rc4

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agoiplink: Fix link-netns id and link ifindex
Xiao Liang [Fri, 11 Oct 2024 08:01:09 +0000 (16:01 +0800)] 
iplink: Fix link-netns id and link ifindex

When link-netns or link-netnsid is supplied, lookup link in that netns.
And if both netns and link-netns are given, IFLA_LINK_NETNSID should be
the nsid of link-netns from the view of target netns, not from current
one.

For example, when handling:

    # ip -n ns1 link add netns ns2 link-netns ns3 link eth1 eth1.100 type vlan id 100

should lookup eth1 in ns3 and IFLA_LINK_NETNSID is the id of ns3 from
ns2.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agoip: Move of set_netnsid_from_name() to namespace.c
Xiao Liang [Fri, 11 Oct 2024 08:01:08 +0000 (16:01 +0800)] 
ip: Move of set_netnsid_from_name() to namespace.c

Move set_netnsid_from_name() outside for reuse, like what's done for
netns_id_from_name().

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agordma: Fix help information of 'rdma resource'
wenglianfa [Wed, 16 Oct 2024 09:35:26 +0000 (17:35 +0800)] 
rdma: Fix help information of 'rdma resource'

'rdma resource show cq' supports object 'dev' but not 'link', and
doesn't support device name with port.

Fixes: b0b8e32cbf6e ("rdma: Add CQ resource tracking information")
Signed-off-by: wenglianfa <wenglianfa@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agort_names: read `rt_addrprotos.d` directory
David Lamparter [Fri, 4 Oct 2024 09:16:38 +0000 (11:16 +0200)] 
rt_names: read `rt_addrprotos.d` directory

`rt_addrprotos` doesn't currently use the `.d` directory thing - add it.

My magic 8-ball predicts we might be grabbing a value or two for use in
FRRouting at some point in the future.  Let's make it so we can ship
those in a separate file when it's time.

Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agoip: netconf: fix overzealous error checking
Jakub Kicinski [Wed, 9 Oct 2024 18:21:54 +0000 (11:21 -0700)] 
ip: netconf: fix overzealous error checking

The rtnetlink.sh kernel test started reporting errors after
iproute2 update. The error checking introduced by commit
under fixes is incorrect. rtnl_listen() always returns
an error, because the only way to break the loop is to
return an error from the handler, it seems.

Switch this code to using normal rtnl_talk(), instead of
the rtnl_listen() abuse. As far as I can tell the use of
rtnl_listen() was to make get and dump use common handling
but that's no longer the case, anyway.

Before:
  $ ip -6 netconf show dev lo
  inet6 lo forwarding off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off
  $ echo $?
  2

After:
  $ ./ip/ip -6 netconf show dev lo
inet6 lo forwarding off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off
  $ echo $?
  0

Fixes: 00e8a64dac3b ("ip: detect errors in netconf monitor mode")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agoiprule: Add DSCP support
Ido Schimmel [Wed, 9 Oct 2024 06:20:54 +0000 (09:20 +0300)] 
iprule: Add DSCP support

Add support for 'dscp' selector in ip-rule.

Rules can be added with a numeric DSCP value:

 # ip rule add dscp 1 table 100
 # ip rule add dscp 0x02 table 200

Or using symbolic names from /usr/share/iproute2/rt_dsfield or
/etc/iproute2/rt_dsfield:

 # ip rule add dscp AF42 table 300

Dump output:

 $ ip rule show
 0:      from all lookup local
 32763:  from all lookup 300 dscp AF42
 32764:  from all lookup 200 dscp 2
 32765:  from all lookup 100 dscp 1
 32766:  from all lookup main
 32767:  from all lookup default

Dump can be filtered by DSCP value:

 $ ip rule show dscp 1
 32765:  from all lookup 100 dscp 1

Or by a symbolic name:

 $ ip rule show dscp AF42
 32763:  from all lookup 300 dscp AF42

When the numeric option is specified, symbolic names will be translated
to numeric values:

 $ ip -N rule show
 0:      from all lookup 255
 32763:  from all lookup 300 dscp 36
 32764:  from all lookup 200 dscp 2
 32765:  from all lookup 100 dscp 1
 32766:  from all lookup 254
 32767:  from all lookup 253

The same applies to the JSON output in order to be consistent with
existing fields such as "tos" and "table":

 $ ip -j -p rule show dscp AF42
 [ {
         "priority": 32763,
         "src": "all",
         "table": "300",
         "dscp": "AF42"
     } ]

 $ ip -j -p -N rule show dscp AF42
 [ {
         "priority": 32763,
         "src": "all",
         "table": "300",
         "dscp": "36"
     } ]

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agoman: Add ip-rule(8) as generation target
Ido Schimmel [Wed, 9 Oct 2024 06:20:53 +0000 (09:20 +0300)] 
man: Add ip-rule(8) as generation target

In a similar fashion to other man pages, add ip-rule(8) as generation
target so that we could use variable substitutions there in a subsequent
patch.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agoip/ipmroute: use preferred_family to get prefix
Hangbin Liu [Wed, 9 Oct 2024 09:53:09 +0000 (09:53 +0000)] 
ip/ipmroute: use preferred_family to get prefix

The mroute family is reset to RTNL_FAMILY_IPMR or RTNL_FAMILY_IP6MR when
retrieving the multicast routing cache. However, the get_prefix() and
subsequently __get_addr_1() cannot identify these families. Using
preferred_family to obtain the prefix can resolve this issue.

Fixes: 98ce99273f24 ("mroute: fix up family handling")
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agonetem: swap transposed calloc args
Stephen Hemminger [Mon, 7 Oct 2024 16:37:24 +0000 (09:37 -0700)] 
netem: swap transposed calloc args

Gcc with -Wextra complains about transposed args to calloc
in netem.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agobridge: catch invalid stp state
Stephen Hemminger [Mon, 7 Oct 2024 16:33:48 +0000 (09:33 -0700)] 
bridge: catch invalid stp state

The stp state parsing was putting result in an __u8 which
would mean that check for invalid string was never happening.

Caught by enabling -Wextra:
    CC       mst.o
mst.c: In function â€˜mst_set’:
mst.c:217:27: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  217 |                 if (state == -1) {

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
9 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Sat, 5 Oct 2024 23:06:06 +0000 (23:06 +0000)] 
Merge remote-tracking branch 'main/main' into next

Fixed conflicts in lib/utils.c

Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agolib: utils: move over `print_num` from ip/
David Lamparter [Fri, 4 Oct 2024 09:30:14 +0000 (11:30 +0200)] 
lib: utils: move over `print_num` from ip/

`print_num()` was born in `ip/ipaddress.c` but considering it has
nothing to do with IP addresses it should really live in `lib/utils.c`.

(I've had reason to call it from bridge/* on some random hackery.)

Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: David Ahern <dsahern@kernel.org>
9 months agouapi: update headers
Stephen Hemminger [Sat, 5 Oct 2024 16:05:28 +0000 (09:05 -0700)] 
uapi: update headers

Current headers from 6.12-rc1

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoiplink: fix fd leak when playing with netns
Nicolas Dichtel [Wed, 18 Sep 2024 16:49:41 +0000 (18:49 +0200)] 
iplink: fix fd leak when playing with netns

The command 'ip link set foo netns mynetns' opens a file descriptor to fill
the netlink attribute IFLA_NET_NS_FD. This file descriptor is never closed.
When batch mode is used, the number of file descriptor may grow greatly and
reach the maximum file descriptor number that can be opened.

This fd can be closed only after the netlink answer. Moreover, a second
fd could be opened because some (struct link_util)->parse_opt() handlers
call iplink_parse().

Let's add a helper to manage these fds:
 - open_fds_add() stores a fd, up to 5 (arbitrary choice, it seems enough);
 - open_fds_close() closes all stored fds.

Fixes: 0dc34c7713bb ("iproute2: Add processless network namespace support")
Reported-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoarpd: use designated initializers for msghdr structure
Dario Binacchi [Sat, 28 Sep 2024 09:03:11 +0000 (11:03 +0200)] 
arpd: use designated initializers for msghdr structure

This patch fixes the following error:

arpd.c:442:17: error: initialization of 'int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
  442 |                 NULL,   0,

raised by Buildroot autobuilder [1].

In the case in question, the analysis of socket.h [2] containing the
msghdr structure shows that it has been modified with the addition of
padding fields, which cause the compilation error. The use of designated
initializers allows the issue to be fixed.

struct msghdr {
void *msg_name;
socklen_t msg_namelen;
struct iovec *msg_iov;
int __pad1;
int msg_iovlen;
int __pad1;
void *msg_control;
int __pad2;
socklen_t msg_controllen;
int __pad2;
int msg_flags;
};

[1] http://autobuild.buildroot.org/results/e4cdfa38ae9578992f1c0ff5c4edae3cc0836e3c/
[2] iproute2/host/mips64-buildroot-linux-musl/sysroot/usr/include/sys/socket.h

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agobridge: mst: fix a further musl build issue
Dario Binacchi [Sun, 22 Sep 2024 14:50:11 +0000 (16:50 +0200)] 
bridge: mst: fix a further musl build issue

This patch fixes the following build errors:

In file included from mst.c:11:
../include/json_print.h:80:30: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   80 | _PRINT_FUNC(tv, const struct timeval *)
      |                              ^~~~~~~
../include/json_print.h:50:37: note: in definition of macro '_PRINT_FUNC'
   50 |                                     type value);                        \
      |                                     ^~~~
../include/json_print.h:80:30: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   80 | _PRINT_FUNC(tv, const struct timeval *)
      |                              ^~~~~~~
../include/json_print.h:55:45: note: in definition of macro '_PRINT_FUNC'
   55 |                                             type value)                 \
      |                                             ^~~~
../include/json_print.h: In function 'print_tv':
../include/json_print.h:58:48: error: passing argument 5 of 'print_color_tv' from incompatible pointer type [-Wincompatible-pointer-types]
   58 |                                                value);                  \
      |                                                ^~~~~
      |                                                |
      |                                                const struct timeval *
../include/json_print.h:80:1: note: in expansion of macro '_PRINT_FUNC'
   80 | _PRINT_FUNC(tv, const struct timeval *)
      | ^~~~~~~~~~~
../include/json_print.h:50:42: note: expected 'const struct timeval *' but argument is of type 'const struct timeval *'
   50 |                                     type value);                        \
      |                                          ^
../include/json_print.h:80:1: note: in expansion of macro '_PRINT_FUNC'
   80 | _PRINT_FUNC(tv, const struct timeval *)

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agobridge: mst: fix a musl build issue
Dario Binacchi [Sun, 22 Sep 2024 14:50:10 +0000 (16:50 +0200)] 
bridge: mst: fix a musl build issue

This patch fixes a compilation error raised by the bump to version 6.11.0
in Buildroot using musl as the C library for the cross-compilation
toolchain.

After setting the CFLGAS

ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
IPROUTE2_CFLAGS += -D__UAPI_DEF_IN6_ADDR=0 -D__UAPI_DEF_SOCKADDR_IN6=0 \
-D__UAPI_DEF_IPV6_MREQ=0
endif

to fix the following errors:

In file included from ../../../host/mips64-buildroot-linux-musl/sysroot/usr/include/arpa/inet.h:9,
                 from ../include/libnetlink.h:14,
                 from mst.c:10:
../../../host/mips64-buildroot-linux-musl/sysroot/usr/include/netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
   23 | struct in6_addr {
      |        ^~~~~~~~
In file included from ../include/uapi/linux/if_bridge.h:19,
                 from mst.c:7:
../include/uapi/linux/in6.h:33:8: note: originally defined here
   33 | struct in6_addr {
      |        ^~~~~~~~
../../../host/mips64-buildroot-linux-musl/sysroot/usr/include/netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
   34 | struct sockaddr_in6 {
      |        ^~~~~~~~~~~~
../include/uapi/linux/in6.h:50:8: note: originally defined here
   50 | struct sockaddr_in6 {
      |        ^~~~~~~~~~~~
../../../host/mips64-buildroot-linux-musl/sysroot/usr/include/netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
   42 | struct ipv6_mreq {
      |        ^~~~~~~~~
../include/uapi/linux/in6.h:60:8: note: originally defined here
   60 | struct ipv6_mreq {

I got this further errors

../include/uapi/linux/in6.h:72:25: error: field 'flr_dst' has incomplete type
   72 |         struct in6_addr flr_dst;
      |                         ^~~~~~~
../include/uapi/linux/if_bridge.h:711:41: error: field 'ip6' has incomplete type
  711 |                         struct in6_addr ip6;
      |                                         ^~~

fixed by including the netinet/in.h header.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoMerge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next
Stephen Hemminger [Wed, 18 Sep 2024 15:45:43 +0000 (08:45 -0700)] 
Merge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next

10 months agov6.11.0 v6.11.0
Stephen Hemminger [Sun, 15 Sep 2024 19:42:26 +0000 (12:42 -0700)] 
v6.11.0

10 months agoman: replace use of term whitelist
Stephen Hemminger [Thu, 12 Sep 2024 17:20:17 +0000 (10:20 -0700)] 
man: replace use of term whitelist

Avoid use of term whitelist because it propgates white == good
assumptions. Not really neede on the man page.
See: https://inclusivenaming.org/word-lists/tier-1/whitelist/

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoman: replace use of word segregate
Stephen Hemminger [Thu, 12 Sep 2024 17:17:58 +0000 (10:17 -0700)] 
man: replace use of word segregate

The term segregate carries a lot of racist baggage in the US.
It is on the Inclusive Naming word list.
See: https://inclusivenaming.org/word-lists/tier-3/segregate/

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoreplace use of term 'Sanity check'
Stephen Hemminger [Thu, 12 Sep 2024 17:12:21 +0000 (10:12 -0700)] 
replace use of term 'Sanity check'

The term "sanity check" is on the Tier2 word list (should replace).
See https://inclusivenaming.org/word-lists/tier-2/sanity-check/

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
10 months agoman8: ip-route: update documentation
Justin Iurman [Thu, 29 Aug 2024 09:15:24 +0000 (11:15 +0200)] 
man8: ip-route: update documentation

Include "tunsrc" in the man page.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Signed-off-by: David Ahern <dsahern@kernel.org>
10 months agoip: lwtunnel: tunsrc support
Justin Iurman [Thu, 29 Aug 2024 09:15:23 +0000 (11:15 +0200)] 
ip: lwtunnel: tunsrc support

Add support for setting/getting the new "tunsrc" feature.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Signed-off-by: David Ahern <dsahern@kernel.org>
10 months agoUpdate kernel headers
David Ahern [Mon, 9 Sep 2024 15:15:51 +0000 (15:15 +0000)] 
Update kernel headers

Update kernel headers to commit:
    bfba7bc8b7c2 ("Merge branch 'unmask-dscp-part-four'")

Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Mon, 19 Aug 2024 01:07:16 +0000 (01:07 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoip: nexthop: Support 16-bit nexthop weights
Petr Machata [Fri, 16 Aug 2024 17:38:12 +0000 (19:38 +0200)] 
ip: nexthop: Support 16-bit nexthop weights

Two interlinked changes related to the nexthop group management have been
recently merged in kernel commit e96f6fd30eec ("Merge branch
'net-nexthop-increase-weight-to-u16'").

- One of the reserved bytes in struct nexthop_grp was redefined to carry
  high-order bits of the nexthop weight, thus allowing 16-bit nexthop
  weights.

- NHA_OP_FLAGS started getting dumped on nexthop group dump to carry a
  flag, NHA_OP_FLAG_RESP_GRP_RESVD_0, that indicates that reserved fields
  in struct nexthop_grp are zeroed before dumping.

If NHA_OP_FLAG_RESP_GRP_RESVD_0 is given, it is safe to interpret the newly
named nexthop_grp.weight_high as high-order bits of nexthop weight.

Extend ipnexthop to support configuring nexthop weights of up to 65536, and
when dumping, to interpret nexthop_grp.weight_high if safe.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoUpdate kernel headers
David Ahern [Mon, 19 Aug 2024 01:04:45 +0000 (01:04 +0000)] 
Update kernel headers

Update kernel headers to commit:
    a99ef548bba0 ("bnx2x: Set ivi->vlan field as an integer")

Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoss: fix libbpf version check for ENABLE_BPF_SKSTORAGE_SUPPORT
Stefan Mätje [Sun, 11 Aug 2024 22:31:35 +0000 (00:31 +0200)] 
ss: fix libbpf version check for ENABLE_BPF_SKSTORAGE_SUPPORT

This patch fixes a problem with the libbpf version comparison to decide
if ENABLE_BPF_SKSTORAGE_SUPPORT could be enabled.

- The code enabled by ENABLE_BPF_SKSTORAGE_SUPPORT uses the function
  btf_dump__new with an API that was introduced in libbpf 0.6.0. So
  check now against libbpf version to be >= 0.6.x instead of 0.5.x.

- This code still depends on the necessity to have LIBBPF_MAJOR_VERSION
  and LIBBPF_MINOR_VERSION defined, even if libbpf_version.h is not
  present in the library development package. This was ensured with
  the previous patch for the configure script.

Fixes: e3ecf048 ("ss: pretty-print BPF socket-local storage")
Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoconfigure: provide surrogates for possibly missing libbpf_version.h
Stefan Mätje [Sun, 11 Aug 2024 22:31:34 +0000 (00:31 +0200)] 
configure: provide surrogates for possibly missing libbpf_version.h

Old libbpf library versions (< 0.7.x) may not have the libbpf_version.h
header packaged. This header would provide LIBBPF_MAJOR_VERSION and
LIBBPF_MINOR_VERSION which are then missing to control conditional
compilation in some source files.

Provide surrogates for these defines via CFLAGS that are derived from
the LIBBPF_VERSION determined with $(${PKG_CONFIG} libbpf --modversion).

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agotc-cake: reformat
Lương Việt Hoàng [Mon, 12 Aug 2024 04:41:38 +0000 (11:41 +0700)] 
tc-cake: reformat

Reformat tc-cake to use man format (nroff) instead of pre-formatting.

Signed-off-by: Lương Việt Hoàng <tcm4095@gmail.com>
Acked-by: Toke Høiland-Jørgensen <toke@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agotc-cake: document 'ingress'
Lương Việt Hoàng [Mon, 12 Aug 2024 04:41:37 +0000 (11:41 +0700)] 
tc-cake: document 'ingress'

Linux kernel commit 7298de9cd7255a783ba ("sch_cake: Add ingress mode") added
an ingress mode for CAKE, which can be enabled with the 'ingress' parameter.
Document the changes in CAKE's behavior when ingress mode is enabled.

Signed-off-by: Lương Việt Hoàng <tcm4095@gmail.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman/tc-codel: cleanup man page
Stephen Hemminger [Sun, 11 Aug 2024 16:53:29 +0000 (09:53 -0700)] 
man/tc-codel: cleanup man page

Instead of pre-formatted bullet list, use the man macros.
Make sure same sentence format is used in all options.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman/ip-xfrm: fix dangling quote
Stephen Hemminger [Sun, 11 Aug 2024 16:43:45 +0000 (09:43 -0700)] 
man/ip-xfrm: fix dangling quote

The man page had a dangling quote character in the usage text
which can confuse auto-color/format code like Emacs and Vim.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoip/netkit: print peer policy
Nikolay Aleksandrov [Tue, 6 Aug 2024 10:55:48 +0000 (13:55 +0300)] 
ip/netkit: print peer policy

Print also the peer policy, example:
$ ip -d l sh dev netkit0
...
 netkit mode l2 type primary policy blackhole peer policy forward
...

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agobridge: Remove duplicated textification macros
Tobias Waldekranz [Tue, 2 Jul 2024 12:08:03 +0000 (14:08 +0200)] 
bridge: Remove duplicated textification macros

include/utils.h already provides textify(), which is functionally
equivalent to __stringify().

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agotc: f_flower: add support for matching on tunnel metadata
Davide Caratti [Tue, 16 Jul 2024 08:57:20 +0000 (10:57 +0200)] 
tc: f_flower: add support for matching on tunnel metadata

extend TC flower for matching on tunnel metadata.

Changes since v2:
 - split uAPI changes and TC code in separate patches, as per David's request [2]

Changes since v1:
 - fix incostintent naming in explain() and in tc-flower.8 (Asbjørn)

Changes since RFC:
 - update uAPI bits to Asbjørn's most recent code [1]
 - add 'tun' prefix to all flag names (Asbjørn)
 - allow parsing 'enc_flags' multiple times, without clearing the match
   mask every time, like happens for 'ip_flags' (Asbjørn)
 - don't use "matches()" for parsing argv[]  (Stephen)
 - (hopefully) improve usage() printout (Asbjørn)
 - update man page

[1] https://lore.kernel.org/netdev/20240709163825.1210046-1-ast@fiberby.net/
[2] https://lore.kernel.org/netdev/cc73004c-9aa8-9cd3-b46e-443c0727c34d@kernel.org/

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Sun, 4 Aug 2024 15:18:51 +0000 (15:18 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
11 months agoip: mptcp: 'id 0' is only for 'del'
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:36 +0000 (12:10 +0200)] 
ip: mptcp: 'id 0' is only for 'del'

Adding an endpoint with 'id 0' is not allowed. In this case, the kernel
will ignore this 'id 0' and set another one.

Similarly, because there are no endpoints with this 'id 0', changing an
attribute for such endpoint will not be possible.

To avoid some confusions, it sounds better to clearly report an error
that the ID cannot be 0 in these cases.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: clarify the 'ID' parameter
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:35 +0000 (12:10 +0200)] 
man: mptcp: clarify the 'ID' parameter

Explain the range (u8), and the special case for ID 0.

The endpoints here are for all the connections, while the ID 0 is a
special case per connection, depending on the source address used by the
initial subflow. This ID 0 can then not be used for the global
endpoints.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: 'fullmesh' has to be used with 'subflow'
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:34 +0000 (12:10 +0200)] 
man: mptcp: 'fullmesh' has to be used with 'subflow'

'fullmesh' affects the subflow creation, it has to be used with the
'subflow' flag. That's what is enforced on the kernel side.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: 'backup' flag also affects outgoing data
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:33 +0000 (12:10 +0200)] 
man: mptcp: 'backup' flag also affects outgoing data

That's the behaviour with the default packet scheduler.

In some early design, the default scheduler was supposed to take into
account only the received backup flags, but it ended up not being the
case, and setting the flag would also affect outgoing data.

Suggested-by: Mat Martineau <martineau@kernel.org>
Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: 'port' has to be used with 'signal'
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:32 +0000 (12:10 +0200)] 
man: mptcp: 'port' has to be used with 'signal'

That's what is enforced by the kernel: the 'port' is used to create a
new listening socket on that port, not to create a new subflow from/to
that port. It then requires the 'signal' flag.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: clarify 'signal' and 'subflow' flags
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:31 +0000 (12:10 +0200)] 
man: mptcp: clarify 'signal' and 'subflow' flags

According to some bug reports on the MPTCP project, these options might
be a bit confusing for some.

Mentioning that the 'signal' flag is typically for a server, and the
'subflow' one is typically for a client should help the user knowing in
which context which flag should be picked.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
11 months agoman: mptcp: document 'dev IFNAME'
Matthieu Baerts (NGI0) [Sat, 27 Jul 2024 10:10:30 +0000 (12:10 +0200)] 
man: mptcp: document 'dev IFNAME'

It was missing, while it is a very important option.

Indeed, without it, the kernel might not pick the right interface to
send packets for additional subflows. Mention that in the man page.

Acked-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agouapi: update to 6.11-rc1
Stephen Hemminger [Mon, 29 Jul 2024 16:37:31 +0000 (09:37 -0700)] 
uapi: update to 6.11-rc1

Update from 6.11-rc1

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agoman: update ip-address man page
Stephen Hemminger [Thu, 25 Jul 2024 18:24:45 +0000 (11:24 -0700)] 
man: update ip-address man page

The ip address man page had some small things that needed update:
  - ip address delete without address returns not supported
  - always use full words for commands in man pages
       (ie "delete" not "del")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agoss: fix expired time format of timer
xixiliguo [Sat, 20 Jul 2024 15:23:27 +0000 (23:23 +0800)] 
ss: fix expired time format of timer

When expired time of time-wait timer is less than or equal to 9 seconds,
as shown below, result that below 1 sec is incorrect.
Expect output should be show 9 seconds and 373 millisecond, but 9.373ms
mean only 9 millisecond and 373 microseconds

Before:
TIME-WAIT 0      0     ...    timer:(timewait,12sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,11sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,10sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,9.373ms,0)
TIME-WAIT 0      0     ...    timer:(timewait,8.679ms,0)
TIME-WAIT 0      0     ...    timer:(timewait,1.574ms,0)
TIME-WAIT 0      0     ...    timer:(timewait,954ms,0)
TIME-WAIT 0      0     ...    timer:(timewait,303ms,0)

After:
TIME-WAIT 0      0     ...    timer:(timewait,13sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,12sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,10sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,9.501sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,8.990sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,7.865sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,1.098sec,0)
TIME-WAIT 0      0     ...    timer:(timewait,476ms,0)

Signed-off-by: xixiliguo <xixiliguo@foxmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agoip: do not print stray prefixes in monitor mode
Beniamino Galvani [Sat, 13 Jul 2024 14:56:41 +0000 (16:56 +0200)] 
ip: do not print stray prefixes in monitor mode

When running "ip monitor", accept_msg() first prints the prefix and
then calls the object-specific print function, which also does the
filtering. Therefore, it is possible that the prefix is printed even
for events that get ignored later. For example:

  ip link add dummy1 type dummy
  ip link set dummy1 up
  ip -ts monitor all dev dummy1 &
  ip link add dummy2 type dummy
  ip addr add dev dummy1 192.0.2.1/24

generates:

  [2024-07-12T22:11:26.338342] [LINK][2024-07-12T22:11:26.339846] [ADDR]314: dummy1    inet 192.0.2.1/24 scope global dummy1
       valid_lft forever preferred_lft forever

Fix this by printing the prefix only after the filtering. Now the
output for the commands above is:

 [2024-07-12T22:11:26.339846] [ADDR]314: dummy1    inet 192.0.2.1/24 scope global dummy1
       valid_lft forever preferred_lft forever

See also commit 7e0a889b5494 ("bridge: Do not print stray prefixes in
monitor mode") which fixed the same problem in the bridge tool.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agof_flower: Remove always zero checks
Maks Mishin [Sun, 7 Jul 2024 17:27:41 +0000 (20:27 +0300)] 
f_flower: Remove always zero checks

Expression 'ttl & ~(255 >> 0)' is always zero, because right operand
has 8 trailing zero bits, which is greater or equal than the size
of the left operand == 8 bits.

Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agoMerge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next
Stephen Hemminger [Wed, 17 Jul 2024 16:07:26 +0000 (09:07 -0700)] 
Merge ssh://gitolite.kernel.org/pub/scm/network/iproute2/iproute2-next

12 months agov6.10.0 v6.10.0
Stephen Hemminger [Wed, 17 Jul 2024 02:38:17 +0000 (19:38 -0700)] 
v6.10.0

12 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Mon, 8 Jul 2024 22:36:13 +0000 (22:36 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agoman: devlink-resource: add missing words in the example
Przemek Kitszel [Wed, 3 Jul 2024 13:15:19 +0000 (15:15 +0200)] 
man: devlink-resource: add missing words in the example

Add missing "size" and "path" words in the example, as the current example
is incorrect and will be rejected by the command.

The keywords were missing from very inception of devlink-resource man page

Fixes: 58b48c5d75e2 ("devlink: Update man pages and add resource man")
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 months agobridge: mst: Add get/set support for MST states
Tobias Waldekranz [Mon, 24 Jun 2024 13:00:35 +0000 (15:00 +0200)] 
bridge: mst: Add get/set support for MST states

Allow a port's spanning tree state to be modified on a per-MSTI basis,
and support dumping the current MST states for every port and MSTI.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agobridge: vlan: Add support for setting a VLANs MSTI
Tobias Waldekranz [Mon, 24 Jun 2024 13:00:34 +0000 (15:00 +0200)] 
bridge: vlan: Add support for setting a VLANs MSTI

Allow the user to associate one or more VLANs with a multiple spanning
tree instance (MSTI), when MST is enabled on the bridge.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agoip: bridge: add support for mst_enabled
Tobias Waldekranz [Mon, 24 Jun 2024 13:00:33 +0000 (15:00 +0200)] 
ip: bridge: add support for mst_enabled

When enabled, the bridge's legacy per-VLAN STP facility is replaced
with the Multiple Spanning Tree Protocol (MSTP) compatible version.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agodevlink: print missing params even if an unknown one is present
Przemek Kitszel [Wed, 3 Jul 2024 13:15:20 +0000 (15:15 +0200)] 
devlink: print missing params even if an unknown one is present

Print all of the missing parameters, also in the presence of unknown ones.

Take for example a correct command:
    $ devlink resource set pci/0000:01:00.0 path /kvd/linear size 98304
And remove the "size" keyword:
    $ devlink resource set pci/0000:01:00.0 path /kvd/linear 98304
That yields output:
    Resource size expected.
    Unknown option "98304"

Prior to the patch only the last line of output was present. And if user
would forgot also the "path" keyword, there will be additional line:
    Resource path expected.
in the stderr.

Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agordma: Supports to add/delete a device with type SMI
Mark Zhang [Thu, 4 Jul 2024 06:29:01 +0000 (09:29 +0300)] 
rdma: Supports to add/delete a device with type SMI

This patch adds a new device attribute "type", as well as supports to
add and delete a rdma device with a specific type. This new device
provides a subset of functionalists defined in IBTA spec.

Currently only type "SMI" is supported: A SMI device provides SMI (QP0)
interface; This device and it's parent associates with the same HCA port
and shares the physical link, so when the parent doesn't support SMI,
It allows the subnet manager to configure the link.

This patch also supports to print device type and parent if any.

Examples:
$ rdma dev add smi1 type SMI parent ibp8s0f1
$ rdma dev show smi1
2: smi1: node_type ca fw 20.38.1002 node_guid 9803:9b03:009f:d5ef sys_image_guid 9803:9b03:009f:d5ee type smi parent ibp8s0f1
$ rdma dev del smi1

Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Acked-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agordma: update uapi header
Mark Zhang [Thu, 4 Jul 2024 06:29:00 +0000 (09:29 +0300)] 
rdma: update uapi header

Update rdma_netlink.h file upto kernel commit 294424839b5e
("RDMA/nldev: Add support to dump device type and parent device if exists")

Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Acked-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
12 months agoroute: filter by interface on multipath routes
Stephen Hemminger [Fri, 5 Jul 2024 00:26:41 +0000 (17:26 -0700)] 
route: filter by interface on multipath routes

The ip route command would silently hide multipath routes when filter
by interface. The problem was it was not looking for interface when
filter multipath routes.

Example:
ip link add name dummy1 up type dummy
ip link add name dummy2 up type dummy
ip address add 192.0.2.1/28 dev dummy1
ip address add 192.0.2.17/28 dev dummy2
ip route add 198.51.100.0/24 \
nexthop via 192.0.2.2 dev dummy1 \
nexthop via 192.0.2.18 dev dummy2

Before:
ip route show dev dummy1
192.0.2.0/28 proto kernel scope link src 192.0.2.1

After:
ip route show dev dummy1
192.0.2.0/28 proto kernel scope link src 192.0.2.1
198.51.100.0/24
nexthop via 192.0.2.2 dev dummy1 weight 1
nexthop via 192.0.2.18 dev dummy2 weight 1

Reported-by: "Muggeridge, Matt" <matt.muggeridge2@hpe.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
13 months agoss: fix format string warnings
Stephen Hemminger [Thu, 27 Jun 2024 16:59:18 +0000 (09:59 -0700)] 
ss: fix format string warnings

Clang complains that format string is not a string literal
unless the functions are annotated.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
13 months agodevlink: Fix setting max_io_eqs as the sole attribute
Parav Pandit [Thu, 6 Jun 2024 04:38:08 +0000 (07:38 +0300)] 
devlink: Fix setting max_io_eqs as the sole attribute

dl_opts_put() function missed to consider IO eqs option flag.
Due to this, when max_io_eqs setting is applied only when it
is combined with other attributes such as roce/hw_addr.
When max_io_eqs is the only attribute set, it missed to
apply the attribute.

Fix it by adding the missing flag.

Fixes: e8add23c59b7 ("devlink: Support setting max_io_eqs")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
13 months agodevlink: trivial: fix err format on max_io_eqs
William Tu [Mon, 10 Jun 2024 19:24:51 +0000 (22:24 +0300)] 
devlink: trivial: fix err format on max_io_eqs

Add missing ']'.

Signed-off-by: William Tu <witu@nvidia.com>
Fixes: e8add23c59b7 ("devlink: Support setting max_io_eqs")
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
13 months agoxfrm: document new SA direction option
Christian Hopps [Thu, 23 May 2024 15:17:07 +0000 (11:17 -0400)] 
xfrm: document new SA direction option

Signed-off-by: Christian Hopps <chopps@labn.net>
Signed-off-by: David Ahern <dsahern@kernel.org>
13 months agoxfrm: add SA direction attribute
Christian Hopps [Thu, 23 May 2024 15:17:06 +0000 (11:17 -0400)] 
xfrm: add SA direction attribute

Add support for new SA direction netlink attribute.

Co-developed-by: Antony Antony <antony.antony@secunet.com>
Co-developed-by: Christian Hopps <chopps@labn.net>
Signed-off-by: Christian Hopps <chopps@labn.net>
Signed-off-by: David Ahern <dsahern@kernel.org>
14 months agoss: use COLUMNS from the environment, if TIOCGWINSZ fails
Dragan Simic [Tue, 21 May 2024 10:04:52 +0000 (12:04 +0200)] 
ss: use COLUMNS from the environment, if TIOCGWINSZ fails

Use the COLUMNS environment variable [1] when determining the screen width,
if using TIOCGWINSZ isn't possible or if it fails.  This allows better use
of the available horizontal screen space in certain scenarios, and makes
the produced outputs more readable, as described further below.

All major shells can maintain the COLUMNS variable according to the current
screen size, [2][3][4] but this shell variable isn't actually an environment
variable, i.e. it doesn't get exported to the shell subprocesses by default.
For example, no COLUMNS environment variable reaches ss(8) when it's executed
as part of a shell pipeline or inside a shell script.

Though, users can opt to export the COLUMNS variable by hand, or they can
rely on some other utilities to do that for them.  A good example of such
utilities is watch(1) that exports COLUMNS as an environment variable to
the processes it executes. [5]  Using ss(8) together with watch(1) is rather
useful, and honoring the exported COLUMNS variable makes the outputs produced
by ss(8) in this scenario more readable.

The behavior of shells, which don't export the COLUMNS variable by default,
makes this change safe in the sense of not affecting the usual shell pipeline
workflows or various shell scripts that use ss(8).

[1] https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/basedefs/V1_chap08.html
[2] https://man.archlinux.org/man/bash.1.en#COLUMNS
[3] https://man.archlinux.org/man/tcsh.1.en#Terminal_management_(+)
[4] https://man.archlinux.org/man/zshall.1.en#Configuration
[5] https://gitlab.com/procps-ng/procps/-/blob/master/NEWS?ref_type=heads#L623

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
14 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Fri, 24 May 2024 20:36:16 +0000 (14:36 -0600)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
14 months agoFix usage of poll.h header
Ismael Luceno [Sat, 18 May 2024 22:39:44 +0000 (00:39 +0200)] 
Fix usage of poll.h header

Change the legacy <sys/poll.h> to <poll.h> (POSIX.1-2001).

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
14 months agouapi: update to pre 6.10-rc1 headers
Stephen Hemminger [Mon, 20 May 2024 15:45:51 +0000 (08:45 -0700)] 
uapi: update to pre 6.10-rc1 headers

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>