]> git.ipfire.org Git - thirdparty/iproute2.git/log
thirdparty/iproute2.git
4 months agoman: fix duplicate words in l2tp, sfb and tipc
Stephen Hemminger [Mon, 22 Jan 2024 18:01:20 +0000 (10:01 -0800)] 
man: fix duplicate words in l2tp, sfb and tipc

Doing simple regex found a couple more duplicates.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoman: correct double word in htb
Simon Egli [Mon, 22 Jan 2024 15:39:32 +0000 (16:39 +0100)] 
man: correct double word in htb

There was a word too much in the documentation of tc-htb

Signed-off-by: Simon Egli <simon@egli.online>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agotc: better clockid handling
Stephen Hemminger [Sun, 21 Jan 2024 17:19:19 +0000 (09:19 -0800)] 
tc: better clockid handling

All clockid values not available on some older glibc versions.
Also, add some comments.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agotc: unify clockid handling
Stephen Hemminger [Fri, 19 Jan 2024 16:38:58 +0000 (08:38 -0800)] 
tc: unify clockid handling

There are three places in tc which all have same code for
handling clockid (copy/paste). Move it into tc_util.c.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agouapi: remove tc_ipt.h
Stephen Hemminger [Thu, 18 Jan 2024 16:13:21 +0000 (08:13 -0800)] 
uapi: remove tc_ipt.h

Removed upstream.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agodoc: remove out dated actions-general
Stephen Hemminger [Thu, 11 Jan 2024 18:38:36 +0000 (10:38 -0800)] 
doc: remove out dated actions-general

This file is rather free form, out dated, and redundant.
Everything here should be covered on man pages.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agodoc: remove ifb README
Stephen Hemminger [Thu, 11 Jan 2024 17:39:23 +0000 (09:39 -0800)] 
doc: remove ifb README

Most of this document goes back to when IFB was first integrated
and covers the motivation. Only of historical interest.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoman/tc-gact: move generic action documentation to man page
Stephen Hemminger [Thu, 11 Jan 2024 18:37:33 +0000 (10:37 -0800)] 
man/tc-gact: move generic action documentation to man page

Convert from free form doc to man page.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoman: get rid of doc/actions/mirred-usage
Stephen Hemminger [Thu, 11 Jan 2024 17:36:47 +0000 (09:36 -0800)] 
man: get rid of doc/actions/mirred-usage

The only bit of information not already on the man page
is some of the limitations.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoss: show extra info when '--processes' is not used
Matthieu Baerts (NGI0) [Sat, 13 Jan 2024 17:10:21 +0000 (18:10 +0100)] 
ss: show extra info when '--processes' is not used

A recent modification broke "extra" options for all protocols showing
info about the processes when '-p' / '--processes' option was not used
as well. In other words, all the additional bits displayed at the end or
at the next line were no longer printed if the user didn't ask to show
info about processes as well.

The reason is that, the "current_field" pointer never switched to the
"Ext" column. If the user didn't ask to display the processes, nothing
happened when trying to print extra bits using the "out()" function,
because the current field was still pointing to the "Process" one, now
marked as disabled.

Before the commit mentioned below, it was not an issue not to switch to
the "Ext" or "Process" columns because they were never marked as
"disabled".

Here is a quick list of options that were no longer displayed if '-p' /
'--processes' was not set:

- AF_INET(6):
  -o, --options
  -e, --extended
  --tos
  --cgroup
  --inet-sockopt
  -m, --memory
  -i, --info

- AF_PACKET:
  -e, --extended

- AF_XDP:
  -e, --extended

- AF_UNIX:
  -m, --memory
  -e, --extended

- TIPC:
  --tipcinfo

That was just by quickly reading the code, I probably missed some. But
this shows that the impact can be quite important for all scripts using
'ss' to monitor connections or to report info.

Fixes: 1607bf53 ("ss: prevent "Process" column from being printed unless requested")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoReapply "ss: prevent "Process" column from being printed unless requested"
Stephen Hemminger [Wed, 17 Jan 2024 17:17:42 +0000 (09:17 -0800)] 
Reapply "ss: prevent "Process" column from being printed unless requested"

This reverts commit f22c49730c3691c25a1147081363eb35aa9d1048.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agouapi: update headers from 6.8-rc1
Stephen Hemminger [Mon, 15 Jan 2024 17:39:36 +0000 (09:39 -0800)] 
uapi: update headers from 6.8-rc1

Removal of no longer used TC structs.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoRevert "ss: prevent "Process" column from being printed unless requested"
Stephen Hemminger [Sat, 13 Jan 2024 16:51:55 +0000 (08:51 -0800)] 
Revert "ss: prevent "Process" column from being printed unless requested"

This reverts commit 1607bf531fd2f984438d227ea97312df80e7cf56.

This commit is being reverted because it breaks output of tcp info.
The order of the columns enum is order sensistive.

Bug: https://bugzilla.kernel.org/show_bug.cgi?id=218372
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoman: drop references to ifconfig
Stephen Hemminger [Thu, 11 Jan 2024 17:47:25 +0000 (09:47 -0800)] 
man: drop references to ifconfig

The documentation does not need to have any references to the
legacy command ifconfig.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agogenl: ctrl.c: spelling fix in error message
Andrea Claudi [Tue, 9 Jan 2024 15:33:54 +0000 (16:33 +0100)] 
genl: ctrl.c: spelling fix in error message

Canot --> Cannot

Fixes: 65018ae43b14 ("This patch adds a generic netlink controller...")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoiplink_xstats: spelling fix in error message
Andrea Claudi [Tue, 9 Jan 2024 15:33:53 +0000 (16:33 +0100)] 
iplink_xstats: spelling fix in error message

Cannont --> Cannot

Fixes: 2b99748a60bf ("add missing iplink_xstats.c")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Mon, 8 Jan 2024 19:25:43 +0000 (19:25 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
4 months agov6.7.0 v6.7.0
Stephen Hemminger [Mon, 8 Jan 2024 17:38:23 +0000 (09:38 -0800)] 
v6.7.0

4 months agolnstat: Fix deref of null in print_json() function
Maks Mishin [Sat, 6 Jan 2024 19:04:23 +0000 (22:04 +0300)] 
lnstat: Fix deref of null in print_json() function

Now pointer `jw` is being checked for NULL before using
in function `jsonw_start_object`.
Added exit from function when `jw==NULL`.

Found by RASU JSC

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
4 months agordma: Fix the error of accessing string variable outside the lifecycle
wenglianfa [Fri, 29 Dec 2023 06:52:41 +0000 (14:52 +0800)] 
rdma: Fix the error of accessing string variable outside the lifecycle

All these SPRINT_BUF(b) definitions are inside the 'if' block, but
accessed outside the 'if' block through the pointers 'comm'. This
leads to empty 'comm' attribute when querying resource information.
So move the definitions to the beginning of the functions to extend
their life cycle.

Before:
$ rdma res show srq
dev hns_0 srqn 0 type BASIC lqpn 18 pdn 5 pid 7775 comm

After:
$ rdma res show srq
dev hns_0 srqn 0 type BASIC lqpn 18 pdn 5 pid 7775 comm ib_send_bw

Fixes: 1808f002dfdd ("lib/fs: fix memory leak in get_task_name()")
Signed-off-by: wenglianfa <wenglianfa@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Acked-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoremove support for iptables action
Stephen Hemminger [Tue, 26 Dec 2023 18:25:09 +0000 (10:25 -0800)] 
remove support for iptables action

There is an open upstream kernel patch to remove ipt action from
kernel. This is corresponding iproute2 change.

 - Remove support fot ipt and xt in tc.
 - Remove no longer used header files.
 - Update man pages.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
5 months agordma: do not mix newline and json object
Stephen Hemminger [Tue, 2 Jan 2024 23:53:04 +0000 (15:53 -0800)] 
rdma: do not mix newline and json object

Mixing the semantics of ending lines with the json object
leads to several bugs where json object is closed twice, etc.
Replace by breaking the meaning of newline() function into
two parts.

Now, lots of functions were taking the rdma data structure as
argument but never using it.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: add oneline flag
Stephen Hemminger [Tue, 2 Jan 2024 17:30:15 +0000 (09:30 -0800)] 
rdma: add oneline flag

Add oneline output format like other commands.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: make supress_errors a bit
Stephen Hemminger [Tue, 2 Jan 2024 17:22:35 +0000 (09:22 -0800)] 
rdma: make supress_errors a bit

Like other command line flags supress_errors can be a bit.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: make pretty behave like other commands
Stephen Hemminger [Tue, 2 Jan 2024 17:20:41 +0000 (09:20 -0800)] 
rdma: make pretty behave like other commands

For tc, ip, etc the -pretty flag only has meaning if json
is used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: use standard flag for json
Stephen Hemminger [Tue, 2 Jan 2024 17:16:38 +0000 (09:16 -0800)] 
rdma: use standard flag for json

The other iproute2 utils use variable json as flag.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: shorten print_ lines
Stephen Hemminger [Tue, 2 Jan 2024 16:44:18 +0000 (08:44 -0800)] 
rdma: shorten print_ lines

With the shorter form of print_ function some of the lines can
now be shortened. Max line length in iproute2 should be 100 characters
or less.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoip: merge duplicate if clauses
Stephen Hemminger [Thu, 4 Jan 2024 00:30:26 +0000 (16:30 -0800)] 
ip: merge duplicate if clauses

The code that handles brief option had two exactly matching
if (filter == AF_PACKET) clauses; merge them

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoconfigure: avoid un-recommended command substitution form
Eli Schwartz [Fri, 29 Dec 2023 06:00:09 +0000 (01:00 -0500)] 
configure: avoid un-recommended command substitution form

The use of backticks to surround commands instead of "$(cmd)" is a
legacy of the oldest pre-POSIX shells. It is confusing, unreliable, and
hard to read. Its use is not recommended in new programs.

Link: http://mywiki.wooledge.org/BashFAQ/082
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agordma: use print_XXX instead of COLOR_NONE
Stephen Hemminger [Mon, 1 Jan 2024 18:46:30 +0000 (10:46 -0800)] 
rdma: use print_XXX instead of COLOR_NONE

The rdma utility should be using same code pattern as rest of
iproute2. When printing, color should only be requested when
desired; if no color wanted, use the simpler print_XXX instead.

Fixes: b0a688a542cd ("rdma: Rewrite custom JSON and prints logic to use common API")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: mdb: Add flush support
Ido Schimmel [Tue, 26 Dec 2023 15:30:13 +0000 (17:30 +0200)] 
bridge: mdb: Add flush support

Implement MDB flush functionality, allowing user space to flush MDB
entries from the kernel according to provided parameters.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
5 months agoUpdate kernel headers
David Ahern [Sat, 30 Dec 2023 21:25:22 +0000 (14:25 -0700)] 
Update kernel headers

Update kernel headers to commit:
    92de776d2090 ("Merge tag 'mlx5-updates-2023-12-20' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux")

Signed-off-by: David Ahern <dsahern@kernel.org>
5 months agoip-link: use shorter URL to kernel docs
Stephen Hemminger [Fri, 22 Dec 2023 18:21:51 +0000 (10:21 -0800)] 
ip-link: use shorter URL to kernel docs

Use shorter URL (docs.kernel.org) so that manual entry does not
have too long a line. The debian troff checker would fail when
doing make check.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: Provide rta_type()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:32 +0000 (09:07 -0500)] 
bridge: Provide rta_type()

Factor out the repeated code pattern
rta_type = attr->rta_type & NLA_TYPE_MASK
into a helper which is similar to the existing kernel function nla_type().

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: Deduplicate print_range()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:29 +0000 (09:07 -0500)] 
bridge: Deduplicate print_range()

The two implementations are now identical so keep only one instance and
move it to json_print.c where there are already a few other specialized
printing functions.

The string that's formatted in the "end" buffer is only needed when
outputting a range so move the snprintf() call within the condition.

The second argument's purpose is better conveyed by calling it "end" rather
than "id" so rename it.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Indent statistics with 2 spaces
Benjamin Poirier [Mon, 11 Dec 2023 14:07:28 +0000 (09:07 -0500)] 
bridge: vni: Indent statistics with 2 spaces

`bridge -s vlan` indents statistics with 2 spaces compared to the vlan id
column while `bridge -s vni` indents them with 1 space. Change `bridge vni`
to match the behavior of `bridge vlan` since that second command predates
`bridge vni`.

Before:
$ bridge -s vni
dev               vni                group/remote
vxlan1            4001
                   RX: bytes 0 pkts 0 drops 0 errors 0
                   TX: bytes 0 pkts 0 drops 0 errors 0
                  4002               10.0.0.1
                   RX: bytes 0 pkts 0 drops 0 errors 0
                   TX: bytes 0 pkts 0 drops 0 errors 0
vxlan2            100
                   RX: bytes 0 pkts 0 drops 0 errors 0
                   TX: bytes 0 pkts 0 drops 0 errors 0

After:
$ bridge -s vni
dev               vni                group/remote
vxlan1            4001
                    RX: bytes 0 pkts 0 drops 0 errors 0
                    TX: bytes 0 pkts 0 drops 0 errors 0
                  4002               10.0.0.1
                    RX: bytes 0 pkts 0 drops 0 errors 0
                    TX: bytes 0 pkts 0 drops 0 errors 0
vxlan2            100
                    RX: bytes 0 pkts 0 drops 0 errors 0
                    TX: bytes 0 pkts 0 drops 0 errors 0

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Align output columns
Benjamin Poirier [Mon, 11 Dec 2023 14:07:27 +0000 (09:07 -0500)] 
bridge: vni: Align output columns

Use fixed column widths to improve readability.

These changes are similar to commit e0c457b1a5a2 ("bridge: Align output
columns").

Before:
$ bridge vni
dev               vni              group/remote
vxlan1             4001
                   4002           10.0.0.1
                   5000-5010
                   16777214-16777215        10.0.0.2
vxlan2             100

After:
$ bridge vni
dev               vni                group/remote
vxlan1            4001
                  4002               10.0.0.1
                  5000-5010
                  16777214-16777215  10.0.0.2
vxlan2            100

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Remove unused argument in open_vni_port()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:26 +0000 (09:07 -0500)] 
bridge: vni: Remove unused argument in open_vni_port()

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Replace open-coded instance of print_nl()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:25 +0000 (09:07 -0500)] 
bridge: vni: Replace open-coded instance of print_nl()

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Remove stray newlines after each interface
Benjamin Poirier [Mon, 11 Dec 2023 14:07:24 +0000 (09:07 -0500)] 
bridge: vni: Remove stray newlines after each interface

Currently, `bridge vni` outputs an empty line after each interface. This is
not consistent with the output style of other iproute2 commands, in
particular `bridge vlan`. Therefore, remove the empty lines.

If there are scripts that parse the normal text output of `bridge vni`,
those scripts might be broken by the removal of the empty lines. This is a
secondary concern because those scripts should consume the JSON output
instead.

Before:
$ bridge vni
dev               vni              group/remote
vxlan1             4001
                   5000-5010

vxlan2             100

$

After:
$ ./bridge/bridge vni
dev               vni              group/remote
vxlan1             4001
                   5000-5010
vxlan2             100
$

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Reverse the logic in print_vnifilter_rtm()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:23 +0000 (09:07 -0500)] 
bridge: vni: Reverse the logic in print_vnifilter_rtm()

print_vnifilter_rtm() is structured similarly to print_vlan_tunnel_info()
except that in the former, the open_vni_port() call is guarded by a "if
(first)" check whereas in the latter, the open_vlan_port() call is guarded
by a "if (!opened)" check.

Reverse the logic in one of the functions to have the same structure in
both. Since the calls being guarded are "open_...()", "close_...()", use
the "opened" logic structure.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Guard close_vni_port() call
Benjamin Poirier [Mon, 11 Dec 2023 14:07:22 +0000 (09:07 -0500)] 
bridge: vni: Guard close_vni_port() call

Currently, the call to open_vni_port() within print_vnifilter_rtm() is
written in a way that is safe if there is a RTM_{NEW,DEL,GET}TUNNEL message
without any VXLAN_VNIFILTER_ENTRY attribute. However the close_vni_port()
call is written in a way that assumes there is always at least one
VXLAN_VNIFILTER_ENTRY attribute within every RTM_*TUNNEL message. At this
time, this assumption is correct. However, the code should be consistent in
its assumptions. Choose the safe approach and fix the asymmetry between the
open_vni_port() and close_vni_port() calls by guarding the latter call with
a check.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Move open_json_object() within print_vni()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:21 +0000 (09:07 -0500)] 
bridge: vni: Move open_json_object() within print_vni()

print_vni() is used to output one vni or vni range which, in json output
mode, looks like
      {
        "vni": 100
      }

Currently, the closing bracket is handled within the function but the
opening bracket is handled by open_json_object() before calling the
function. For consistency, move the call to open_json_object() within
print_vni().

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Remove print_vnifilter_rtm_filter()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:20 +0000 (09:07 -0500)] 
bridge: vni: Remove print_vnifilter_rtm_filter()

print_vnifilter_rtm_filter() adds an unnecessary level of indirection so
remove it to simplify the code.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vlan: Remove paranoid check
Benjamin Poirier [Mon, 11 Dec 2023 14:07:19 +0000 (09:07 -0500)] 
bridge: vlan: Remove paranoid check

To make the code lighter, remove the check on the actual print_range()
output width. In the odd case that an out-of-range, wide vlan id is
printed, printf() will treat the negative field width as positive and the
output will simply be further misaligned.

Suggested-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vlan: Use printf() to avoid temporary buffer
Benjamin Poirier [Mon, 11 Dec 2023 14:07:18 +0000 (09:07 -0500)] 
bridge: vlan: Use printf() to avoid temporary buffer

Currently, print_vlan_tunnel_info() is first outputting a formatted string
to a temporary buffer in order to use print_string() which can handle json
or normal text mode. Since this specific string is only output in normal
text mode, by calling printf() directly, we can avoid the need to first
output to a temporary string buffer.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Fix vni filter help strings
Benjamin Poirier [Mon, 11 Dec 2023 14:07:17 +0000 (09:07 -0500)] 
bridge: vni: Fix vni filter help strings

Add the missing 'vni' subcommand to the top level `bridge help`.
For `bridge vni { add | del } ...`, 'dev' is a mandatory argument.
For `bridge vni show`, 'dev' is an optional argument.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Report duplicate vni argument using duparg()
Benjamin Poirier [Mon, 11 Dec 2023 14:07:16 +0000 (09:07 -0500)] 
bridge: vni: Report duplicate vni argument using duparg()

When there is a duplicate 'vni' option, report the error using duparg()
instead of the generic invarg().

Before:
$ bridge vni add vni 100 vni 101 dev vxlan2
Error: argument "101" is wrong: duplicate vni

After:
$ ./bridge/bridge vni add vni 100 vni 101 dev vxlan2
Error: duplicate "vni": "101" is the second value.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Fix duplicate group and remote error messages
Benjamin Poirier [Mon, 11 Dec 2023 14:07:15 +0000 (09:07 -0500)] 
bridge: vni: Fix duplicate group and remote error messages

Consider the following command with a duplicated "remote" argument:
$ bridge vni add vni 150 remote 10.0.0.1 remote 10.0.0.2 dev vxlan2
Error: argument "remote" is wrong: duplicate group

The error message is misleading because there is no "group" argument. Both
of the "group" and "remote" options specify a destination address and are
mutually exclusive so change the variable name and error messages
accordingly.

The result is:
$ ./bridge/bridge vni add vni 150 remote 10.0.0.1 remote 10.0.0.2 dev vxlan2
Error: duplicate "destination": "10.0.0.2" is the second value.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Remove dead code in group argument parsing
Benjamin Poirier [Mon, 11 Dec 2023 14:07:14 +0000 (09:07 -0500)] 
bridge: vni: Remove dead code in group argument parsing

is_addrtype_inet_not_multi(&daddr) may read an uninitialized "daddr". Even
if that is fixed, the error message that follows cannot be reached because
the situation would be caught by the previous test (group_present).
Therefore, remove this test on daddr.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agobridge: vni: Accept 'del' command
Benjamin Poirier [Mon, 11 Dec 2023 14:07:13 +0000 (09:07 -0500)] 
bridge: vni: Accept 'del' command

`bridge vni help` shows "bridge vni { add | del } ..." but currently
`bridge vni del ...` errors out unexpectedly:
# bridge vni del
Command "del" is unknown, try "bridge vni help".

Recognize 'del' as a synonym of the original 'delete' command.

Fixes: 45cd32f9f7d5 ("bridge: vxlan device vnifilter support")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoconfigure: drop test for ATM
Stephen Hemminger [Fri, 22 Dec 2023 17:26:59 +0000 (09:26 -0800)] 
configure: drop test for ATM

The ATM qdisc was removed by:
commit 8a20feb6388f ("tc: drop support for ATM qdisc")
but configure check was not removed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoman: Fix malformatted database file locations
Phil Sutter [Fri, 15 Dec 2023 22:19:23 +0000 (23:19 +0100)] 
man: Fix malformatted database file locations

The .BR macro does not put spaces in between its arguments. Also it will
apply to all arguments.

Fixes: 0a0a8f12fa1b ("Read configuration files from /etc and /usr")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoman: ip-route.8: Fix typo in rt_protos location spec
Phil Sutter [Fri, 15 Dec 2023 22:19:22 +0000 (23:19 +0100)] 
man: ip-route.8: Fix typo in rt_protos location spec

RTPROTO description erroneously specified /etc/iproute2/rt_protos twice.

Fixes: 0a0a8f12fa1b ("Read configuration files from /etc and /usr")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
5 months agoss: Add support for dumping TCP bound-inactive sockets.
Guillaume Nault [Tue, 19 Dec 2023 13:18:13 +0000 (14:18 +0100)] 
ss: Add support for dumping TCP bound-inactive sockets.

Make ss aware of the new "bound-inactive" pseudo-state for TCP (see
Linux commit 91051f003948 ("tcp: Dump bound-only sockets in inet_diag.")).
These are TCP sockets that have been bound, but are neither listening nor
connecting.

With this patch, these sockets can now be dumped with:

  * the existing -a (--all) option, to dump all sockets, including
    bound-inactive ones,

  * the new -B (--bound-inactive) option, to dump them exclusively,

  * the new "bound-inactive" state, to be used in a STATE-FILTER.

Note that the SS_BOUND_INACTIVE state is a pseudo-state used for queries
only. The kernel returns them as SS_CLOSE.

The SS_NEW_SYN_RECV pseudo-state is added in this patch only because we
have to set its entry in the sstate_namel array (in scan_state()). Care
is taken not to make it visible by users.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agomnl_utils: sanitize incoming netlink payload size in callbacks
Jiri Pirko [Thu, 7 Dec 2023 12:53:51 +0000 (13:53 +0100)] 
mnl_utils: sanitize incoming netlink payload size in callbacks

Don't trust the kernel to send payload of certain size. Sanitize that by
checking the payload length in mnlu_cb_stop() and mnlu_cb_error() and
only access the payload if it is of required size.

Note that for mnlu_cb_stop(), this is happening already for example
with devlink resource. Kernel sends NLMSG_DONE with zero size payload.

Fixes: 049c58539f5d ("devlink: mnlg: Add support for extended ack")
Fixes: c934da8aaacb ("devlink: mnlg: Catch returned error value of dumpit commands")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agouapi: update stddef.h
Stephen Hemminger [Fri, 8 Dec 2023 17:27:59 +0000 (09:27 -0800)] 
uapi: update stddef.h

Change from upstream 6.7-rc4

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoss: prevent "Process" column from being printed unless requested
Quentin Deslandes [Wed, 6 Dec 2023 11:14:44 +0000 (12:14 +0100)] 
ss: prevent "Process" column from being printed unless requested

Commit 5883c6eba517 ("ss: show header for --processes/-p") added
"Process" to the list of columns printed by ss. However, the "Process"
header is now printed even if --processes/-p is not used.

This change aims to fix this by moving the COL_PROC column ID to the same
index as the corresponding column structure in the columns array, and
enabling it if --processes/-p is used.

Fixes: 5883c6eba517 ("ss: show header for --processes/-p")
Signed-off-by: Quentin Deslandes <qde@naccy.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoss: mptcp: print out subflows_total counter
Geliang Tang [Thu, 30 Nov 2023 11:40:36 +0000 (19:40 +0800)] 
ss: mptcp: print out subflows_total counter

A new counter mptcpi_subflows_total has been added in mptcpi_flags
to count the total amount of subflows from mptcp_info including the
initial one into kernel in this commit:

  6ebf6f90ab4a ("mptcp: add mptcpi_subflows_total counter")

This patch prints out this counter into mptcp_stats output.

Acked-by: Matthieu Baerts <matttbe@kernel.org>
Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoUpdate kernel headers
David Ahern [Wed, 6 Dec 2023 17:08:17 +0000 (17:08 +0000)] 
Update kernel headers

Update kernel headers to commit:
    074ac38d5b95 ("octeontx2-af: cn10k: Increase outstanding LMTST transactions")

Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoconfigure: Add _GNU_SOURCE to strlcpy configure test
Sam James [Sat, 2 Dec 2023 02:47:04 +0000 (02:47 +0000)] 
configure: Add _GNU_SOURCE to strlcpy configure test

>=glibc-2.38 adds strlcpy but it's guarded under a feature-test macro. Just
add _GNU_SOURCE to the configure test because we already pass _GNU_SOURCE unconditionally
in the Makefiles when building iproute2.

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoip: require RTM_NEWLINK
Stephen Hemminger [Sun, 3 Dec 2023 18:29:14 +0000 (10:29 -0800)] 
ip: require RTM_NEWLINK

The kernel support for creating network devices was added back
in 2007 and iproute2 has been carrying backward compatability
support since then. After 16 years, it is enough time to
drop the code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoMerge branch 'tcp-usec-fq' into next
David Ahern [Wed, 6 Dec 2023 16:52:47 +0000 (16:52 +0000)] 
Merge branch 'tcp-usec-fq' into next

Eric Dumazet  says:

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

Add iproute2 patches to support recent TCP usec timestamps,
and FQ changes landed in linux-6.7

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

Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agotc: fq: reports stats added in linux-6.7
Eric Dumazet [Mon, 4 Dec 2023 09:19:11 +0000 (09:19 +0000)] 
tc: fq: reports stats added in linux-6.7

Report new fields added in linux-6.7:

- fastpath        : Number of packets that have used the fast path.
- band[012]_pkts  : Number of packets currently queued per band.
- band[012]_drops : Counters of dropped packets, per band
                    (only printed if not zero)

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agotc: fq: add TCA_FQ_WEIGHTS handling
Eric Dumazet [Mon, 4 Dec 2023 09:19:10 +0000 (09:19 +0000)] 
tc: fq: add TCA_FQ_WEIGHTS handling

Linux-6.7 FQ got WRR scheduling.

TCA_FQ_WEIGHTS attribute can report/change per-band weights.

tc qdisc show dev eth1
...
qdisc fq ... weights 589824 196608 65536 quantum 8364b ...

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agotc: fq: add TCA_FQ_PRIOMAP handling
Eric Dumazet [Mon, 4 Dec 2023 09:19:09 +0000 (09:19 +0000)] 
tc: fq: add TCA_FQ_PRIOMAP handling

linux-6.7 FQ packet scheduler gets 3-bands, and the ability
to report or program the associated priomap.

$ tc qdisc show dev eth0
...
qdisc fq ... bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

$ tc qdisc change dev eth0 ... qdisc fq ... bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoss: add report of TCPI_OPT_USEC_TS
Eric Dumazet [Mon, 4 Dec 2023 09:19:08 +0000 (09:19 +0000)] 
ss: add report of TCPI_OPT_USEC_TS

linux-6.7 supports usec resolution in TCP TS values.
ss -ie can show if a flow is using this new resolution.

$ ss -tie
 ...
State Recv-Q Send-Q           Local Address:Port           Peer Address:Port Process
ESTAB 0      12869632 [2002:a05:6608:295::]:37054 [2002:a05:6608:297::]:35721
 ts usec_ts sack bbr2s wscale:12,12 ...

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoip route: add support for TCP usec TS
Eric Dumazet [Mon, 4 Dec 2023 09:19:07 +0000 (09:19 +0000)] 
ip route: add support for TCP usec TS

linux-6.7 got support for TCP usec resolution timestamps,
using one bit in the features mask : RTAX_FEATURE_TCP_USEC_TS.

ip route add 10/8 ... features tcp_usec_ts

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoip: require RTM_NEWLINK
Stephen Hemminger [Sun, 3 Dec 2023 18:27:19 +0000 (10:27 -0800)] 
ip: require RTM_NEWLINK

The kernel support for creating network devices was added back
in 2007 and iproute2 has been carrying backward compatability
support since then. After 16 years, it is enough time to
drop the code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoiplink: spelling fix in error message
Stephen Hemminger [Wed, 29 Nov 2023 04:47:49 +0000 (20:47 -0800)] 
iplink: spelling fix in error message

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoiproute2: prevent memory leak on error return
heminhong [Tue, 14 Nov 2023 08:13:07 +0000 (16:13 +0800)] 
iproute2: prevent memory leak on error return

When rtnl_statsdump_req_filter() or rtnl_dump_filter() failed to process,
just return will cause memory leak.

Signed-off-by: heminhong <heminhong@kylinos.cn>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoMerge branch 'main' into next
David Ahern [Wed, 22 Nov 2023 19:38:34 +0000 (19:38 +0000)] 
Merge branch 'main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoMerge branch 'parsing-cleanup' into next
David Ahern [Wed, 22 Nov 2023 19:34:01 +0000 (19:34 +0000)] 
Merge branch 'parsing-cleanup' into next

Petr Machata  says:

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

Library functions parse_one_of() and parse_on_off() were added about three
years ago to unify all the disparate reimplementations of the same basic
idea. It used the matches() function to determine whether a string under
consideration corresponds to one of the keywords. This reflected many,
though not all cases of on/off parsing at the time.

This decision has some odd consequences. In particular, "o" can be used as
a shorthand for "off", which is not obvious, because "o" is the prefix of
both. By sheer luck, the end result actually makes some sense: "on" means
on, anything else either means off or errors out. Similar issues are in
principle also possible for parse_one_of() uses, though currently this does
not come up.

Ideally parse_on_off() would accept the strings "on" and "off" and no
others.

Patch #1 is a cleanup. Patch #2 is shaping the code for the next patches.

Patch #3 converts parse_on_off() to strcmp(). See the commit message for
the rationale of why the change should be considered acceptable.

We'd ideally do parse_one_of() likewise. But the strings this function
parses tend to be longer, which means more opportunities for typos and more
of a reason to abbreviate things.

So instead, patch #4 adds a function parse_one_of_deprecated() for ip
macsec to use in one place, where these typos are to be expected, and
converts that site to the new function.

Then patch #5 changes the behavior of parse_one_of() to accept prefixes
like it has so far, but to warn that they are deprecated:

    # dcb ets set dev swp1 tc-tsa 0:s
    WARNING: 's' matches 'strict' by prefix.
    Matching by prefix is deprecated in this context, please use the full string.

The idea is that several releases down the line, we might consider
switching over to strcmp(), as presumably enough advance warning will have
been given.

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

Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolib: utils: Have parse_one_of() warn about prefix matches
Petr Machata [Wed, 22 Nov 2023 15:23:32 +0000 (16:23 +0100)] 
lib: utils: Have parse_one_of() warn about prefix matches

The function parse_one_of() currently uses matches() for string comparison
under the hood. Extending matches()-based parsers is tricky, because newly
added matches might change the way strings are parsed, if the newly-added
string shares a prefix with a string that is matched later in the code.

Therefore in this patch, add a twist to parse_one_of() that partial prefix
matches yield a warning. This will not disturb standard output or the
overall behavior, but will make it obvious that the usage is discouraged
and prompt users to update their scripts and habits.

An example of output:

    # dcb ets set dev swp1 tc-tsa 0:s
    WARNING: 's' matches 'strict' by prefix.
    Matching by prefix is deprecated in this context, please use the full string.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolib: utils: Introduce parse_one_of_deprecated()
Petr Machata [Wed, 22 Nov 2023 15:23:31 +0000 (16:23 +0100)] 
lib: utils: Introduce parse_one_of_deprecated()

The function parse_one_of() currently uses matches() for string comparison
under the hood. Extending matches()-based parsers is tricky, because newly
added matches might change the way strings are parsed, if the newly-added
string shares a prefix with a string that is matched later in the code.

In this patch, introduce a new function, parse_one_of_deprecated(). This
will be currently synonymous with parse_one_of(), however the latter will
change behavior in the next patch.

Use the new function for parsing of the macsec "validate" option. The
reason is that the valid strings for that option are "disabled", "check"
and "strict". It is not hard to see how "disabled" could be misspelled as
"disable", and be baked in some script in this form.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolib: utils: Convert parse_on_off() to strcmp()
Petr Machata [Wed, 22 Nov 2023 15:23:30 +0000 (16:23 +0100)] 
lib: utils: Convert parse_on_off() to strcmp()

The function parse_on_off() currently uses matches() for string comparison
under the hood. This has some odd consequences. In particular, "o" can be
used as a shorthand for "off", which is not obvious, because "o" is the
prefix of both. In this patch, change parsing to strcmp(). This is a
breaking change. The following paragraphs give arguments for why it should
be considered acceptable.

First and foremost: on/off are very short strings that it makes practically
no sense to shorten. Since "o" is the universal prefix, the only
unambiguous shortening is "of" for "off". It is doubtful that anyone would
intentionally decide to save typing of the second "f" when they already
typed the first. It also seems unlikely that the typo of "of" for "off"
would not be caught immediately, as missing a third of the word length
would likely be noticed. In other words, it seems improbable that the
abbreviated variants are used, intentionally or by mistake.

Commit 9262ccc3ed32 ("bridge: link: Port over to parse_on_off()") and
commit 3e0d2a73ba06 ("ip: iplink_bridge_slave: Port over to
parse_on_off()") converted several sites from open-coding strcmp()-based
on/off parsing to parse_on_off(), which is itself based on matches(). This
made the list of permissible strings more generic, but the behavior was
exact match to begin with, and this patch restores it.

Commit 5f685d064b03 ("ip: iplink: Convert to use parse_on_off()") has
changed from matches()-based parsing, which however had branches in the
other order, and "o" would parse to mean on. This indicates that at least
in this context, people were not using the shorthand of "o" or the commit
would have broken their use case. This supports the thesis that the
abbreviations are not really used for on/off parsing.

For completeness, commit 82604d28525a ("lib: Add parse_one_of(),
parse_on_off()") introduced parse_on_off(), converting several users in the
ip link macsec code in the process. Those users have always used matches(),
and had branches in the same order as the newly-introduced parse_on_off().

A survey of selftests and documentation of Linux kernel (by way of git
grep), has not discovered any cases of the involved options getting
arguments other than the exact strings on and off.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolib: utils: Generalize parse_one_of()
Petr Machata [Wed, 22 Nov 2023 15:23:29 +0000 (16:23 +0100)] 
lib: utils: Generalize parse_one_of()

The following patch will change the way parse_one_of() and parse_on_off()
parse the strings they are given. To prepare for this change, extract from
parse_one_of() the functional core, which express in terms of a
configurable matcher, a pointer to a function that does the string
comparison. Then rewrite parse_one_of() and parse_on_off() as wrappers that
just pass matches() as the matcher, thereby maintaining the same behavior
as they currently have.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolib: utils: Switch matches() to returning int again
Petr Machata [Wed, 22 Nov 2023 15:23:28 +0000 (16:23 +0100)] 
lib: utils: Switch matches() to returning int again

Since commit 1f420318bda3 ("utils: don't match empty strings as prefixes")
the function has pretended to return a boolean. But every user expects it
to return zero on success and a non-zero value on failure, like strcmp().
Even the function itself actually returns "true" to mean "no match". This
only makes sense if one considers a boolean to be a one-bit unsigned
integer with no inherent meaning, which I do not think is reasonable.

Switch the prototype back to int, and return 1 instead of true.

Cc: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoip, link: Add support for netkit
Daniel Borkmann [Mon, 20 Nov 2023 23:33:41 +0000 (00:33 +0100)] 
ip, link: Add support for netkit

Add base support for creating/dumping netkit devices.

Minimal example usage:

  # ip link add type netkit
  # ip -d a
  [...]
  7: nk0@nk1: <BROADCAST,MULTICAST,NOARP,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    netkit mode l3 type peer policy forward numtxqueues 1 numrxqueues 1 [...]
  8: nk1@nk0: <BROADCAST,MULTICAST,NOARP,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    netkit mode l3 type primary policy forward numtxqueues 1 numrxqueues 1 [...]

Example usage with netns (for BPF examples, see BPF selftests linked below):

  # ip netns add blue
  # ip link add nk0 type netkit peer nk1 netns blue
  # ip link set up nk0
  # ip addr add 10.0.0.1/24 dev nk0
  # ip -n blue link set up nk1
  # ip -n blue addr add 10.0.0.2/24 dev nk1
  # ping -c1 10.0.0.2
  PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
  64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.021 ms

Example usage with L2 mode and peer blackholing when no BPF is attached:

  # ip link add foo type netkit mode l2 forward peer blackhole bar
  # ip -d a
  [...]
  13: bar@foo: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
     link/ether 5e:5b:81:17:02:27 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
     netkit mode l2 type peer policy blackhole numtxqueues 1 numrxqueues 1 [...]
  14: foo@bar: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN group default qlen 1000
     link/ether de:01:a5:88:9e:99 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
     netkit mode l2 type primary policy forward numtxqueues 1 numrxqueues 1 [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://git.kernel.org/torvalds/c/35dfaad7188c
Link: https://git.kernel.org/torvalds/c/05c31b4ab205
Link: https://git.kernel.org/torvalds/c/ace15f91e569
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoman: allow up to 100 character lines
Stephen Hemminger [Sun, 19 Nov 2023 16:56:43 +0000 (08:56 -0800)] 
man: allow up to 100 character lines

There are some long URL's that cause warnings from the
man page checker. Go ahead and allow these even though Debian
lintian may still complain.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoman: fix man page errors
Stephen Hemminger [Fri, 17 Nov 2023 17:22:19 +0000 (09:22 -0800)] 
man: fix man page errors

Debian is now more picky about man pages.
Need to tell man command that tbl is being used on a man page now.
Also, font macros need to have proper font.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoip: move get_failed blocks
Stephen Hemminger [Fri, 17 Nov 2023 17:16:14 +0000 (09:16 -0800)] 
ip: move get_failed blocks

Rather than doing goto back into the middle of an earlier
if() statement. Move the error returns to the end of the functions
to follow kernel coding practice.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoiproute2: prevent memory leak
heminhong [Thu, 16 Nov 2023 03:13:08 +0000 (11:13 +0800)] 
iproute2: prevent memory leak

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

Fixes: a066cc6623e1 ("gre/gre6: Unify local/remote endpoint address parsing")
Signed-off-by: heminhong <heminhong@kylinos.cn>
Reviewed-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoMakefile: use /usr/share/iproute2 for config files
Andrea Claudi [Wed, 15 Nov 2023 17:25:35 +0000 (18:25 +0100)] 
Makefile: use /usr/share/iproute2 for config files

According to FHS:

"/usr/lib includes object files and libraries. On some systems, it may
also include internal binaries that are not intended to be executed
directly by users or shell scripts."

A better directory to store config files is /usr/share:

"The /usr/share hierarchy is for all read-only architecture independent
data files.

This hierarchy is intended to be shareable among all architecture
platforms of a given OS; thus, for example, a site with i386, Alpha, and
PPC platforms might maintain a single /usr/share directory that is
centrally-mounted."

Accordingly, move configuration files to $(DATADIR)/iproute2.

Fixes: 946753a4459b ("Makefile: ensure CONF_USR_DIR honours the libdir config")
Reported-by: Luca Boccassi <luca.boccassi@gmail.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agouapi: update headers from 6.7-rc1
Stephen Hemminger [Mon, 13 Nov 2023 16:38:58 +0000 (08:38 -0800)] 
uapi: update headers from 6.7-rc1

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoMerge branch 'devlink-instances' into next
David Ahern [Sat, 11 Nov 2023 17:33:34 +0000 (17:33 +0000)] 
Merge branch 'devlink-instances' into next

Jiri Pirko  says:

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

Print out recently added attributes that expose relationships between
devlink instances. This patchset extends the outputs by
"nested_devlink" attributes.

Examples:
$ devlink dev
pci/0000:08:00.0:
  nested_devlink:
    auxiliary/mlx5_core.eth.0
auxiliary/mlx5_core.eth.0
pci/0000:08:00.1:
  nested_devlink:
    auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.1

$ devlink dev -j -p
{
    "dev": {
        "pci/0000:08:00.0": {
            "nested_devlink": {
                "auxiliary/mlx5_core.eth.0": {}
            }
        },
        "auxiliary/mlx5_core.eth.0": {},
        "pci/0000:08:00.1": {
            "nested_devlink": {
                "auxiliary/mlx5_core.eth.1": {}
            }
        },
        "auxiliary/mlx5_core.eth.1": {}
    }
}

$ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 106
pci/0000:08:00.0/32768: type eth netdev eth2 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state inactive opstate detached roce enable
$ devlink port function set pci/0000:08:00.0/32768 state active
$ devlink port show pci/0000:08:00.0/32768
pci/0000:08:00.0/32768: type eth netdev eth2 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state active opstate attached roce enable
      nested_devlink:
        auxiliary/mlx5_core.sf.2
$ devlink port show pci/0000:08:00.0/32768 -j -p
{
    "port": {
        "pci/0000:08:00.0/32768": {
            "type": "eth",
            "netdev": "eth2",
            "flavour": "pcisf",
            "controller": 0,
            "pfnum": 0,
            "sfnum": 106,
            "splittable": false,
            "function": {
                "hw_addr": "00:00:00:00:00:00",
                "state": "active",
                "opstate": "attached",
                "roce": "enable",
                "nested_devlink": {
                    "auxiliary/mlx5_core.sf.2": {}
                }
            }
        }
    }
}

$ devlink dev reload auxiliary/mlx5_core.sf.2 netns ns1
$ devlink port show pci/0000:08:00.0/32768
pci/0000:08:00.0/32768: type eth netdev eth2 flavour pcisf controller 0 pfnum 0 sfnum 106 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state active opstate attached roce enable
      nested_devlink:
        auxiliary/mlx5_core.sf.2: netns ns1
$ devlink port show pci/0000:08:00.0/32768 -j -p
{
    "port": {
        "pci/0000:08:00.0/32768": {
            "type": "eth",
            "netdev": "eth2",
            "flavour": "pcisf",
            "controller": 0,
            "pfnum": 0,
            "sfnum": 106,
            "splittable": false,
            "function": {
                "hw_addr": "00:00:00:00:00:00",
                "state": "active",
                "opstate": "attached",
                "roce": "enable",
                "nested_devlink": {
                    "auxiliary/mlx5_core.sf.2": {
                        "netns": "ns1"
                    }
                }
            }
        }
    }
}

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

Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: print nested devlink handle for devlink dev
Jiri Pirko [Tue, 7 Nov 2023 08:06:07 +0000 (09:06 +0100)] 
devlink: print nested devlink handle for devlink dev

Devlink dev may contain one or more nested devlink instances.
Print them using previously introduced pr_out_nested_handle_obj()
helper.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: print nested handle for port function
Jiri Pirko [Tue, 7 Nov 2023 08:06:06 +0000 (09:06 +0100)] 
devlink: print nested handle for port function

If port function contains nested handle attribute, print it.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: introduce support for netns id for nested handle
Jiri Pirko [Tue, 7 Nov 2023 08:06:05 +0000 (09:06 +0100)] 
devlink: introduce support for netns id for nested handle

Nested handle may contain DEVLINK_ATTR_NETNS_ID attribute that indicates
the network namespace where the nested devlink instance resides. Process
this converting to netns name if possible and print to user.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: extend pr_out_nested_handle() to print object
Jiri Pirko [Tue, 7 Nov 2023 08:06:04 +0000 (09:06 +0100)] 
devlink: extend pr_out_nested_handle() to print object

For existing pr_out_nested_handle() user (line card), the output stays
the same. For the new users, introduce __pr_out_nested_handle()
to allow to print devlink instance as object allowing to carry
attributes in it (like netns).

Note that as __pr_out_handle_start() and pr_out_handle_end() are newly
used, the function is moved below the definitions.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: do conditional new line print in pr_out_port_handle_end()
Jiri Pirko [Tue, 7 Nov 2023 08:06:03 +0000 (09:06 +0100)] 
devlink: do conditional new line print in pr_out_port_handle_end()

Instead of printing out new line unconditionally, use __pr_out_newline()
to print it only when needed avoiding double prints.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agodevlink: use snprintf instead of sprintf
Jiri Pirko [Tue, 7 Nov 2023 08:06:02 +0000 (09:06 +0100)] 
devlink: use snprintf instead of sprintf

Use snprintf instead of sprintf to ensure only valid memory is printed
to and the output string is properly terminated.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agoip/ipnetns: move internals of get_netnsid_from_name() into namespace.c
Jiri Pirko [Tue, 7 Nov 2023 08:06:01 +0000 (09:06 +0100)] 
ip/ipnetns: move internals of get_netnsid_from_name() into namespace.c

In order to be able to reuse get_netnsid_from_name() function outside of
ip code, move the internals to lib/namespace.c to a new function called
netns_id_from_name().

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
6 months agolibnetlink: validate nlmsg header length first
Max Kunzelmann [Tue, 7 Nov 2023 01:20:55 +0000 (01:20 +0000)] 
libnetlink: validate nlmsg header length first

Validate the nlmsg header length before accessing the nlmsg payload
length.

Fixes: 892a25e286fb ("libnetlink: break up dump function")
Signed-off-by: Max Kunzelmann <maxdev@posteo.de>
Reviewed-by: Benny Baumann <BenBE@geshi.org>
Reviewed-by: Robert Geislinger <github@crpykng.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
6 months agoRevert "Makefile: ensure CONF_USR_DIR honours the libdir config"
Luca Boccassi [Mon, 6 Nov 2023 00:14:10 +0000 (00:14 +0000)] 
Revert "Makefile: ensure CONF_USR_DIR honours the libdir config"

LIBDIR in Debian and derivatives is not /usr/lib/, it's
/usr/lib/<architecture triplet>/, which is different, and it's the
wrong location where to install architecture-independent default
configuration files, which should always go to /usr/lib/ instead.
Installing these files to the per-architecture directory is not
the right thing, hence revert the change.

This reverts commit 946753a4459bd035132a27bb2eb87529c1979b90.

Signed-off-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
7 months agoMerge branch 'main' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next
Stephen Hemminger [Mon, 6 Nov 2023 20:40:38 +0000 (12:40 -0800)] 
Merge branch 'main' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next

7 months agobridge: mdb: Add get support
Ido Schimmel [Wed, 1 Nov 2023 07:45:10 +0000 (09:45 +0200)] 
bridge: mdb: Add get support

Implement MDB get functionality, allowing user space to query a single
MDB entry from the kernel instead of dumping all the entries. Example
usage:

 # bridge mdb add dev br0 port swp1 grp 239.1.1.1 vid 10
 # bridge mdb add dev br0 port swp2 grp 239.1.1.1 vid 10
 # bridge mdb add dev br0 port swp2 grp 239.1.1.5 vid 10
 # bridge mdb get dev br0 grp 239.1.1.1 vid 10
 dev br0 port swp1 grp 239.1.1.1 temp vid 10
 dev br0 port swp2 grp 239.1.1.1 temp vid 10
 # bridge -j -p mdb get dev br0 grp 239.1.1.1 vid 10
 [ {
         "index": 10,
         "dev": "br0",
         "port": "swp1",
         "grp": "239.1.1.1",
         "state": "temp",
         "flags": [ ],
         "vid": 10
     },{
         "index": 10,
         "dev": "br0",
         "port": "swp2",
         "grp": "239.1.1.1",
         "state": "temp",
         "flags": [ ],
         "vid": 10
     } ]
 # bridge mdb get dev br0 grp 239.1.1.1 vid 20
 Error: bridge: MDB entry not found.
 # bridge mdb get dev br0 grp 239.1.1.2 vid 10
 Error: bridge: MDB entry not found.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
7 months agoUpdate kernel headers
David Ahern [Mon, 6 Nov 2023 17:08:23 +0000 (10:08 -0700)] 
Update kernel headers

Update kernel headers to commit:
    ff269e2cd5ad ("Merge tag 'net-next-6.7-followup' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next")

Import mptcp_pm.h due to a new dependency.

Signed-off-by: David Ahern <dsahern@kernel.org>
7 months agov6.6.0 v6.6.0
Stephen Hemminger [Sat, 4 Nov 2023 16:22:25 +0000 (09:22 -0700)] 
v6.6.0

7 months agovv6.6.0
Stephen Hemminger [Sat, 4 Nov 2023 01:04:49 +0000 (18:04 -0700)] 
vv6.6.0