]> git.ipfire.org Git - thirdparty/iproute2.git/log
thirdparty/iproute2.git
16 months agoUpdate kernel headers
David Ahern [Fri, 15 Mar 2024 15:02:15 +0000 (15:02 +0000)] 
Update kernel headers

Update kernel headers to commit:
    237bb5f7f7f5 ("cxgb4: unnecessary check for 0 in the free_sge_txq_uld() function")

Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoiproute2: move generic_proc_open into lib
Denis Kirjanov [Mon, 4 Mar 2024 14:13:40 +0000 (09:13 -0500)] 
iproute2: move generic_proc_open into lib

the function has the same definition in ifstat and ss

v2: fix the typo in the chagelog
v3: rebase on master

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoifstat: support 64 interface stats
Stephen Hemminger [Thu, 29 Feb 2024 04:37:28 +0000 (20:37 -0800)] 
ifstat: support 64 interface stats

The 32 bit statistics are problematic since 32 bit value can
easily wraparound at high speed. Use 64 bit stats if available.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agonstat: convert sprintf to snprintf
Denis Kirjanov [Wed, 28 Feb 2024 13:58:58 +0000 (08:58 -0500)] 
nstat: convert sprintf to snprintf

Use snprintf to print only valid data.
That's the similar change done for ifstat.

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agonstat: use stack space for history file name
Denis Kirjanov [Wed, 28 Feb 2024 13:58:57 +0000 (08:58 -0500)] 
nstat: use stack space for history file name

as the name doesn't require a lot of storage put
it on the stack. Moreover the memory allocated via
malloc wasn't returned.

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agonstat: constify name argument in generic_proc_open
Denis Kirjanov [Wed, 28 Feb 2024 13:58:56 +0000 (08:58 -0500)] 
nstat: constify name argument in generic_proc_open

the argument passed to the function
is always a constant value

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoman8: ioam: add doc for monitor command
Justin Iurman [Thu, 22 Feb 2024 15:45:39 +0000 (16:45 +0100)] 
man8: ioam: add doc for monitor command

Add a sentence in the doc to describe what the new "monitor" command
does.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoip: ioam6: add monitor command
Justin Iurman [Thu, 22 Feb 2024 15:45:38 +0000 (16:45 +0100)] 
ip: ioam6: add monitor command

Add the "ip ioam monitor" command to be able to read all IOAM data
received. This is based on a netlink multicast group.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoUpdate kernel headers
David Ahern [Sun, 3 Mar 2024 22:24:26 +0000 (22:24 +0000)] 
Update kernel headers

Update kernel headers to commit
    4b2765ae410a ("Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next")

Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Tue, 27 Feb 2024 04:09:35 +0000 (04:09 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoMerge branch 'ss-socket-local-storage' into next
David Ahern [Tue, 27 Feb 2024 04:08:34 +0000 (04:08 +0000)] 
Merge branch 'ss-socket-local-storage' into next

Quentin Deslandes  says:

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

BPF allows programs to store socket-specific data using
BPF_MAP_TYPE_SK_STORAGE maps. The data is attached to the socket itself,
and Martin added INET_DIAG_REQ_SK_BPF_STORAGES, so it can be fetched
using the INET_DIAG mechanism.

Currently, ss doesn't request the socket-local data, this patch aims to
fix this.

The first patch requests the socket-local data for the requested map ID
(--bpf-map-id=) or all the maps (--bpf-maps). It then prints the map_id
in COL_EXT.

Patch #2 uses libbpf and BTF to pretty print the map's content, like
`bpftool map dump` would do.

Patch #3 updates ss' man page to explain new options.

While I think it makes sense for ss to provide the socket-local storage
content for the sockets, it's difficult to conciliate the column-based
output of ss and having readable socket-local data. Hence, the
socket-local data is printed in a readable fashion over multiple lines
under its socket statistics, independently of the column-based approach.

Here is an example of ss' output with --bpf-maps:
[...]
ESTAB                  340116             0 [...]
    map_id: 114 [
        (struct my_sk_storage){
            .field_hh = (char)3,
            (union){
                .a = (int)17,
                .b = (int)17,
            },
        }
    ]

Changed this series to an RFC as the merging window for net-next is
closed.

Changes from v8:
* Remove usage of libbpf_bpf_map_type_str() which requires libbpf-1.0+
  and provide very little added value (David).
* Use ENABLE_BPF_SKSTORAGE_SUPPORT to gate the BPF socket-local storage
  support, instead of HAVE_LIBBPF. iproute2 depends on libbpf-0.1, but
  this change needs libbpf-0.5+. If the requirements are not met, ss can
  still be compiled and used without BPF socket-local storage support, but
  a warning will be printed at compile time.
Changes from v7:
* Fix comment format and checkpatch warnings (Stephen, David).
* Replaced Co-authored-by with Co-developed-by + Signed-off-by for
  Martin's contribution on patch #1 to follow checkpatch requirements,
  with Martin's approval.
Changes from v6:
* Remove column dedicated to BPF socket-local storage (COL_SKSTOR),
  use COL_EXT instead (Matthieu).
Changes from v5:
* Add support for --oneline when printing socket-local data.
* Use \t to indent instead of "  " to be consistent with other columns.
* Removed Martin's ack on patch #2 due to amount of lines changed.
Changes from v4:
* Fix return code for 2 calls.
* Fix issue when inet_show_netlink() retries a request.
* BPF dump object is created in bpf_map_opts_load_info().
Changes from v3:
* Minor refactoring to reduce number of HAVE_LIBBF usage.
* Update ss' man page.
* btf_dump structure created to print the socket-local data is cached
  in bpf_map_opts. Creation of the btf_dump structure is performed if
  needed, before printing the data.
* If a map can't be pretty-printed, print its ID and a message instead
  of skipping it.
* If show_all=true, send an empty message to the kernel to retrieve all
  the maps (as Martin suggested).
Changes from v2:
* bpf_map_opts_is_enabled is not inline anymore.
* Add more #ifdef HAVE_LIBBPF to prevent compilation error if
  libbpf support is disabled.
* Fix erroneous usage of args instead of _args in vout().
* Add missing btf__free() and close(fd).
Changes from v1:
* Remove the first patch from the series (fix) and submit it separately.
* Remove double allocation of struct rtattr.
* Close BPF map FDs on exit.
* If bpf_map_get_fd_by_id() fails with ENOENT, print an error message
  and continue to the next map ID.
* Fix typo in new command line option documentation.
* Only use bpf_map_info.btf_value_type_id and ignore
  bpf_map_info.btf_vmlinux_value_type_id (unused for socket-local storage).
* Use btf_dump__dump_type_data() instead of manually using BTF to
  pretty-print socket-local storage data. This change alone divides the size
  of the patch series by 2.

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

Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoss: update man page to document --bpf-maps and --bpf-map-id=
Quentin Deslandes [Wed, 21 Feb 2024 15:16:21 +0000 (16:16 +0100)] 
ss: update man page to document --bpf-maps and --bpf-map-id=

Document new --bpf-maps and --bpf-map-id= options.

Signed-off-by: Quentin Deslandes <qde@naccy.de>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoss: pretty-print BPF socket-local storage
Quentin Deslandes [Wed, 21 Feb 2024 15:16:20 +0000 (16:16 +0100)] 
ss: pretty-print BPF socket-local storage

ss is able to print the map ID(s) for which a given socket has BPF
socket-local storage defined (using --bpf-maps or --bpf-map-id=). However,
the actual content of the map remains hidden.

This change aims to pretty-print the socket-local storage content following
the socket details, similar to what `bpftool map dump` would do. The exact
output format is inspired by drgn, while the BTF data processing is similar
to bpftool's.

ss will use libbpf's btf_dump__dump_type_data() to ease pretty-printing
of binary data. This requires out_bpf_sk_storage_print_fn() as a print
callback function used by btf_dump__dump_type_data(). vout() is also
introduced, which is similar to out() but accepts a va_list as
parameter.

ss' output remains unchanged unless --bpf-maps or --bpf-map-id= is used,
in which case each socket containing BPF local storage will be followed by
the content of the storage before the next socket's info is displayed.

Signed-off-by: Quentin Deslandes <qde@naccy.de>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoss: add support for BPF socket-local storage
Quentin Deslandes [Wed, 21 Feb 2024 15:16:19 +0000 (16:16 +0100)] 
ss: add support for BPF socket-local storage

While sock_diag is able to return BPF socket-local storage in response
to INET_DIAG_REQ_SK_BPF_STORAGES requests, ss doesn't request it.

This change introduces the --bpf-maps and --bpf-map-id= options to request
BPF socket-local storage for all SK_STORAGE maps, or only specific ones.

The bigger part of this change will check the requested map IDs and
ensure they are valid. The column COL_EXT is used to print the
socket-local data into.

When --bpf-maps is used, ss will send an empty
INET_DIAG_REQ_SK_BPF_STORAGES request, in return the kernel will send
all the BPF socket-local storage entries for a given socket. The BTF
data for each map is loaded on demand, as ss can't predict which map ID
are used.

When --bpf-map-id=ID is used, a file descriptor to the requested maps is
open to 1) ensure the map doesn't disappear before the data is printed,
and 2) ensure the map type is BPF_MAP_TYPE_SK_STORAGE. The BTF data for
each requested map is loaded before the request is sent to the kernel.

Co-developed-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Quentin Deslandes <qde@naccy.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoman: ip-link.8: add a note for gso_ipv4_max_size
Xin Long [Mon, 19 Feb 2024 19:16:04 +0000 (14:16 -0500)] 
man: ip-link.8: add a note for gso_ipv4_max_size

As Paolo noticed, a skb->len check against gso_max_size was added in:

  https://lore.kernel.org/netdev/20231219125331.4127498-1-edumazet@google.com/

gso_max_size needs to be set to a value greater than or equal to
gso_ipv4_max_size to make BIG TCP IPv4 work properly.

To not break the current setup, this patch just adds a note into its
man doc for this.

Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
17 months agoip: Update command usage in man page
Yedaya Katsman [Fri, 16 Feb 2024 14:49:39 +0000 (16:49 +0200)] 
ip: Update command usage in man page

The usage in the man page was out of date with the usage help, fix it.
Also sort the commands alphabetically, the same as the command usage.

Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: Support json option in tc-cgroup, tc-flow and tc-route
Takanori Hirano [Tue, 13 Feb 2024 10:01:04 +0000 (10:01 +0000)] 
tc: Support json option in tc-cgroup, tc-flow and tc-route

Fix json corruption when using the "-json" option in some cases

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: Change of json format in tc-fw
Takanori Hirano [Sun, 11 Feb 2024 01:38:48 +0000 (01:38 +0000)] 
tc: Change of json format in tc-fw

In the case of a process such as mapping a json to a structure,
it can be difficult if the keys have the same name but different types.
Since handle is used in hex string, change it to fw.

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agoifstat: convert sprintf to snprintf
Denis Kirjanov [Wed, 14 Feb 2024 12:56:59 +0000 (07:56 -0500)] 
ifstat: convert sprintf to snprintf

Use snprintf to print only valid data

v2: adjust formatting
v3: fix the issue with a buffer length

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agonetlink: display information from missing type extack
Stephen Hemminger [Sat, 10 Feb 2024 17:32:31 +0000 (09:32 -0800)] 
netlink: display information from missing type extack

The kernel will now send missing type information in error response.
Print it if present.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoMerge remote-tracking branch 'main/main' into next
David Ahern [Sun, 18 Feb 2024 17:41:39 +0000 (17:41 +0000)] 
Merge remote-tracking branch 'main/main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
17 months agoiproute2: fix type incompatibility in ifstat.c
Stephen Gallagher [Tue, 6 Feb 2024 16:52:34 +0000 (11:52 -0500)] 
iproute2: fix type incompatibility in ifstat.c

Throughout ifstat.c, ifstat_ent.val is accessed as a long long unsigned
type, however it is defined as __u64. This works by coincidence on many
systems, however on ppc64le, __u64 is a long unsigned.

This patch makes the type definition consistent with all of the places
where it is accessed.

Fixes: 5a52102b7c8f ("ifstat: Add extended statistics to ifstat")
Reviewed-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: u32: check return value from snprintf
Stephen Hemminger [Sun, 11 Feb 2024 00:47:25 +0000 (16:47 -0800)] 
tc: u32: check return value from snprintf

Add assertion to check for case of snprintf failing (bad format?)
or buffer getting full.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: drop no longer used prototype from tc_util.h
Stephen Hemminger [Sat, 10 Feb 2024 00:48:29 +0000 (16:48 -0800)] 
tc: drop no longer used prototype from tc_util.h

Part of the ipt removal missed this.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: print unknown action on stderr
Stephen Hemminger [Fri, 9 Feb 2024 20:57:21 +0000 (12:57 -0800)] 
tc: print unknown action on stderr

This is an error, and should not go to stdout.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: bpf: fix extra newline in JSON output
Stephen Hemminger [Fri, 9 Feb 2024 20:56:43 +0000 (12:56 -0800)] 
tc: bpf: fix extra newline in JSON output

Don't print newline at end of bpf if in JSON mode.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: Support json option in tc-fw.
Takanori Hirano [Fri, 9 Feb 2024 14:22:50 +0000 (14:22 +0000)] 
tc: Support json option in tc-fw.

Fix json corruption when using the "-json" option in cases where tc-fw is set.

Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
17 months agotc: u32: errors should be printed on stderr
Stephen Hemminger [Fri, 9 Feb 2024 16:47:06 +0000 (08:47 -0800)] 
tc: u32: errors should be printed on stderr

Don't corrupt stdout with error messages, matters if JSON is used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agodocs, man: fix some typos
Andrea Claudi [Fri, 9 Feb 2024 15:25:46 +0000 (16:25 +0100)] 
docs, man: fix some typos

Fix some typos and spelling errors in iproute2 documentation.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agotreewide: fix typos in various comments
Andrea Claudi [Fri, 9 Feb 2024 15:25:45 +0000 (16:25 +0100)] 
treewide: fix typos in various comments

Fix various typos and spelling errors in some iproute2 comments.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoip: detect rtnl_listen errors while monitoring netns
Stephen Hemminger [Thu, 8 Feb 2024 17:25:08 +0000 (09:25 -0800)] 
ip: detect rtnl_listen errors while monitoring netns

If rtnl_listen detects error (such as netlink socket EOF),
then exit with status 2 like other iproute2 monitor commands.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoip: detect errors in netconf monitor mode
Stephen Hemminger [Thu, 8 Feb 2024 17:23:07 +0000 (09:23 -0800)] 
ip: detect errors in netconf monitor mode

If rtnl_listen() returns error while looking for netconf events,
then exit with status of 2 as other iproute2 monitor actions do.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoctrl: Fix fd leak in ctrl_listen()
Maks Mishin [Tue, 6 Feb 2024 23:54:16 +0000 (02:54 +0300)] 
ctrl: Fix fd leak in ctrl_listen()

Use the same pattern for handling rtnl_listen() errors that
is used across other iproute2 commands. All other commands
exit with status of 2 if rtnl_listen fails.

Reported-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoctrl: Fix fd leak in ctrl_list()
Maks Mishin [Tue, 6 Feb 2024 23:54:03 +0000 (02:54 +0300)] 
ctrl: Fix fd leak in ctrl_list()

if ctrl_list is called with get operation and wrong number
of parameters, it would forget to close the local netlink
handle.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoip/bond: add coupled_control support
Aahil Awatramani [Thu, 25 Jan 2024 23:11:47 +0000 (23:11 +0000)] 
ip/bond: add coupled_control support

coupled_control specifies whether the LACP state machine's MUX in the
802.3ad mode should have separate Collecting and Distributing states per
IEEE 802.1AX-2008 5.4.15 for coupled and independent control state.

By default this setting is on and does not separate the Collecting and
Distributing states, maintaining the bond in coupled control. If set off,
will toggle independent control state machine which will seperate
Collecting and Distributing states.

Signed-off-by: Aahil Awatramani <aahila@google.com>
v2:
  Dropped uapi header change
  Use of print_on_off and parse_on_off
Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agoUpdate kernel headers
David Ahern [Wed, 7 Feb 2024 16:25:36 +0000 (16:25 +0000)] 
Update kernel headers

Update kernel headers to commit:
    1e8f1477aba5 ("Merge branch 'net-phy-c22-c45-enumeration'")

Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agoip: Add missing -echo option to usage
Yedaya Katsman [Mon, 5 Feb 2024 19:29:23 +0000 (21:29 +0200)] 
ip: Add missing -echo option to usage

In commit b264b4c6568c ("ip: add NLM_F_ECHO support") the "-echo" option
was added, but not to the options in the usage. Add it.

Note there doesn't seem to be any praticular order for the options here,
so it's placed kind of randomly.

Fixes: b264b4c6568c ("ip: add NLM_F_ECHO support")
Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoip: Add missing stats command to usage
Yedaya Katsman [Sat, 3 Feb 2024 20:03:05 +0000 (22:03 +0200)] 
ip: Add missing stats command to usage

The stats command was added in 54d82b0699a0 ("ip: Add a new family of
commands, "stats""), but wasn't included in the subcommand list in the
help usage.
Add it in the right position alphabetically.

Fixes: 54d82b0699a0 ("ip: Add a new family of commands, "stats"")
Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Reviewed-by: Petr Machata <me@pmachata.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoip: remove non-existent amt subcommand from usage
Yedaya Katsman [Sat, 27 Jan 2024 16:45:08 +0000 (18:45 +0200)] 
ip: remove non-existent amt subcommand from usage

Commit 6e15d27aae94 ("ip: add AMT support") added "amt" to the list
of "first level" commands list, which isn't correct, as it isn't present
in the cmds list. remove it from the usage help.

Fixes: 6e15d27aae94 ("ip: add AMT support")
Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoifstat: make load_info() more verbose on error
Denis Kirjanov [Fri, 26 Jan 2024 10:08:55 +0000 (05:08 -0500)] 
ifstat: make load_info() more verbose on error

convert frprintf calls to perror() so the caller
can see the reason of an error

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agoMerge branch 'echo-tc-filter-actions' into next
David Ahern [Tue, 30 Jan 2024 15:49:23 +0000 (15:49 +0000)] 
Merge branch 'echo-tc-filter-actions' into next

Victor Nogueira  says:

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

Continuing on what Hangbin Liu started [1], this patch set adds support for
the NLM_F_ECHO flag for tc actions and filters. For qdiscs it will require
some kernel surgery, and we'll send it soon after this surgery is merged.

When user space configures the kernel with netlink messages, it can set
NLM_F_ECHO flag to request the kernel to send the applied configuration
back to the caller. This allows user space to receive back configuration
information that is populated by the kernel. Often because there are
parameters that can only be set by the kernel which become visible with the
echo, or because user space lets the kernel choose a default value.

To illustrate a use case where the kernel will give us a default value,
the example below shows the user not specifying the action index:

    tc -echo actions add action mirred egress mirror dev lo

    total acts 0
    Added action
          action order 1: mirred (Egress Mirror to device lo) pipe
          index 1 ref 1 bind 0
          not_in_hw

Note that the echoed response indicates that the kernel gave us a value
of index 1

[1] https://lore.kernel.org/netdev/20220916033428.400131-2-liuhangbin@gmail.com/

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

Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agotc: Add NLM_F_ECHO support for filters
Victor Nogueira [Wed, 24 Jan 2024 15:34:56 +0000 (12:34 -0300)] 
tc: Add NLM_F_ECHO support for filters

If the user specifies this flag for a filter command the kernel will
return the command's result back to user space.
For example:

  tc -echo filter add dev lo parent ffff: protocol ip matchall action ok

  added filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0

As illustrated above, the kernel will give us a pref of 491252

The same can be done for other filter commands (replace, delete, and
change). For example:

  tc -echo filter del dev lo parent ffff: pref 49152 protocol ip matchall

  deleted filter dev lo parent ffff: protocol ip pref 49152 matchall chain 0

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agotc: add NLM_F_ECHO support for actions
Victor Nogueira [Wed, 24 Jan 2024 15:34:55 +0000 (12:34 -0300)] 
tc: add NLM_F_ECHO support for actions

This patch adds the -echo flag to tc command line and support for it in
tc actions. If the user specifies this flag for an action command, the
kernel will return the command's result back to user space.
For example:

  tc -echo actions add action mirred egress mirror dev lo

  total acts 0
  Added action
        action order 1: mirred (Egress Mirror to device lo) pipe
        index 10 ref 1 bind 0
        not_in_hw

As illustrated above, the kernel will give us an index of 10

The same can be done for other action commands (replace, change, and
delete). For example:

  tc -echo actions delete action mirred index 10

  total acts 0
  Deleted action
        action order 1: mirred (Egress Mirror to device lo) pipe
        index 10 ref 0 bind 0
        not_in_hw

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agobpf: fix warning from basename()
Stephen Hemminger [Sat, 27 Jan 2024 21:58:14 +0000 (13:58 -0800)] 
bpf: fix warning from basename()

The function basename() expects a mutable character string,
which now causes a warning:

bpf_legacy.c: In function â€˜bpf_load_common’:
bpf_legacy.c:975:38: warning: passing argument 1 of â€˜__xpg_basename’ discards â€˜const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  975 |                          basename(cfg->object), cfg->mode == EBPF_PINNED ?
      |                                   ~~~^~~~~~~~
In file included from bpf_legacy.c:21:
/usr/include/libgen.h:34:36: note: expected â€˜char *’ but argument is of type â€˜const char *’
   34 | extern char *__xpg_basename (char *__path) __THROW;

Fixes: f20ff2f19552 ("bpf: keep parsed program mode in struct bpf_cfg_in")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agospelling fixes
Stephen Hemminger [Fri, 26 Jan 2024 00:49:10 +0000 (16:49 -0800)] 
spelling fixes

Use codespell and ispell to fix some spelling errors
in comments and README's.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agom_mirred: Allow mirred to block
Victor Nogueira [Tue, 23 Jan 2024 21:38:11 +0000 (18:38 -0300)] 
m_mirred: Allow mirred to block

So far the mirred action has dealt with syntax that handles
mirror/redirection for netdev. A matching packet is redirected or mirrored
to a target netdev.

In this patch we enable mirred to mirror to a tc block as well.
IOW, the new syntax looks as follows:
... mirred <ingress | egress> <mirror | redirect> [index INDEX] < <blockid BLOCKID> | <dev <devname>> >

Examples of mirroring or redirecting to a tc block:
$ tc filter add block 22 protocol ip pref 25 \
  flower dst_ip 192.168.0.0/16 action mirred egress mirror blockid 22

$ tc filter add block 22 protocol ip pref 25 \
  flower dst_ip 10.10.10.10/32 action mirred egress redirect blockid 22

Co-developed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Co-developed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agobpf: include libgen.h for basename
Pedro Tammela [Mon, 22 Jan 2024 21:05:46 +0000 (18:05 -0300)] 
bpf: include libgen.h for basename

In musl basename() is only available via libgen.h

Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agocolor: handle case where fmt is NULL
Stephen Hemminger [Tue, 23 Jan 2024 04:26:08 +0000 (20:26 -0800)] 
color: handle case where fmt is NULL

There are cases where NULL is passed as format string when
nothing is to be printed. This is commonly done in the print_bool
function when a flag is false. Glibc seems to handle this case nicely
but for musl it will cause a segmentation fault

Since nothing needs to be printed, in this case; just check
for NULL and return.

Reported-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 months agouapi: update virtio_config.h
Stephen Hemminger [Mon, 22 Jan 2024 18:11:00 +0000 (10:11 -0800)] 
uapi: update virtio_config.h

Updated from to 6.8.0-rc1.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
18 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>
18 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>
18 months agoss: add option to suppress queue columns
Christian Göttsche [Mon, 8 Jan 2024 11:10:20 +0000 (12:10 +0100)] 
ss: add option to suppress queue columns

Add a new option `-Q/--no-queues` to ss(8) to suppress the two standard
columns Send-Q and Recv-Q.  This helps to keep the output steady for
monitoring purposes (like listening sockets).

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
18 months agoMerge branch 'main' into next
David Ahern [Mon, 22 Jan 2024 03:44:13 +0000 (03:44 +0000)] 
Merge branch 'main' into next

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

19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 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>