6723 Commits

Author SHA1 Message Date
Stephen Hemminger
fa740c21b4 tc: make filter_util args const
The callbacks in filter_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
8576afbb89 tc: make qdisc_util arg const
The callbacks in qdisc_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-12 15:11:43 -07:00
Stephen Hemminger
ade05d59c3 Merge branch 'main' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next 2024-03-11 16:39:39 -07:00
Stephen Hemminger
88f0b157e9 tc/action: remove trailing whitespace
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-11 10:32:05 -07:00
Stephen Hemminger
0891990b0a rt_names: whitespace cleanup
Fix indentation.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-11 09:18:44 -07:00
Stephen Hemminger
e5fd785830 v6.8.0 2024-03-11 08:53:55 -07:00
Denis Kirjanov
a9fce55334 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>
2024-03-06 16:23:10 +00:00
Stephen Hemminger
2558ab97c0 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>
2024-03-06 16:20:49 +00:00
Lars Ellenberg
857a328934 ss: fix output of MD5 signature keys configured on TCP sockets
da9cc6ab introduced printing of MD5 signature keys when found.
But when changing printf() to out() calls with 90351722,
the implicit printf call in print_escape_buf() was overlooked.
That results in a funny output in the first line:
"<all-your-tcp-signature-keys-concatenated>State"
and ambiguity as to which of those bytes belong to which socket.

Add a static void out_escape_buf() immediately before we use it.

da9cc6ab (ss: print MD5 signature keys configured on TCP sockets, 2017-10-06)
90351722 (ss: Replace printf() calls for "main" output by calls to helper, 2017-12-12)

Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-04 08:25:34 -08:00
Takanori Hirano
b8daf861a4 tc: Fix json output for f_u32
Signed-off-by: Takanori Hirano <me@hrntknr.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-04 08:20:46 -08:00
Denis Kirjanov
67685422bf ifstat: handle unlink return value
Print an error message if we can't remove the history file

v2: exit if unlink failed
v3: restore the changelog

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-03-03 17:12:11 -08:00
Denis Kirjanov
b69e1e0445 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>
2024-03-03 22:32:50 +00:00
Denis Kirjanov
2f8b36e146 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>
2024-03-03 22:32:46 +00:00
Denis Kirjanov
4ce906c3d5 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>
2024-03-03 22:32:39 +00:00
Justin Iurman
94107bba24 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>
2024-03-03 22:29:19 +00:00
Justin Iurman
ae5c6f9b03 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>
2024-03-03 22:29:19 +00:00
David Ahern
691b688900 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>
2024-03-03 22:24:26 +00:00
Stephen Hemminger
68eef949c2 uapi: update in6.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-29 16:09:24 -08:00
David Ahern
4306b28650 Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-02-27 04:09:35 +00:00
David Ahern
7c05edd3ec 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>
2024-02-27 04:08:34 +00:00
Quentin Deslandes
50763d5331 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>
2024-02-27 04:06:28 +00:00
Quentin Deslandes
e3ecf04857 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>
2024-02-27 04:06:11 +00:00
Yedaya Katsman
2bae5a315a ip: Add missing command exaplantions in man page
There are a few commands missing from the ip command syntax list, add
them. They are also missing from the see also section, add them there as
well.
Note there isn't a ip-ila man page, so I didn't link to it.

Also fix a few punctuation mistakes.

Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-26 16:33:24 -08:00
Denis Kirjanov
533fb3c4be iptuntap: use TUNDEV macro
the code already has a path to the tan/tap device

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-26 12:25:27 -08:00
Quentin Deslandes
8740ca9dcd 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>
2024-02-26 16:05:47 +00:00
Xin Long
1d7f908103 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>
2024-02-19 11:41:45 -08:00
Yedaya Katsman
ecac96e37d 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>
2024-02-19 10:09:29 -08:00
Takanori Hirano
4b6e97b5f3 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>
2024-02-19 10:08:56 -08:00
Takanori Hirano
bc5468c5eb 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>
2024-02-19 10:08:49 -08:00
Denis Kirjanov
d2f1c3c9a8 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>
2024-02-18 17:44:36 +00:00
Stephen Hemminger
7e646c80d7 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>
2024-02-18 17:41:56 +00:00
David Ahern
f900302f32 Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2024-02-18 17:41:39 +00:00
Stephen Gallagher
d9b886d745 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: 5a52102b7c ("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>
2024-02-14 19:06:36 -08:00
Stephen Hemminger
d06f6a3d17 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>
2024-02-10 16:47:25 -08:00
Stephen Hemminger
e91dfaaaea 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>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
b958d3c25d tc: print unknown action on stderr
This is an error, and should not go to stdout.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
46031294e3 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>
2024-02-10 09:48:55 -08:00
Takanori Hirano
49a8b895ad 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>
2024-02-10 09:48:55 -08:00
Stephen Hemminger
e449400508 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>
2024-02-10 09:48:49 -08:00
Andrea Claudi
3c4712b95d 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>
2024-02-09 08:45:10 -08:00
Andrea Claudi
9cf6493cab 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>
2024-02-09 08:45:10 -08:00
Stephen Hemminger
8f340a0751 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>
2024-02-08 09:25:08 -08:00
Stephen Hemminger
00e8a64dac 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>
2024-02-08 09:23:07 -08:00
Maks Mishin
f4dc6a784f 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>
2024-02-08 09:21:39 -08:00
Maks Mishin
35c0215739 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>
2024-02-08 09:12:42 -08:00
Aahil Awatramani
e8dcb1214a 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>
2024-02-07 16:26:36 +00:00
David Ahern
cb47f27143 Update kernel headers
Update kernel headers to commit:
    1e8f1477aba5 ("Merge branch 'net-phy-c22-c45-enumeration'")

Signed-off-by: David Ahern <dsahern@kernel.org>
2024-02-07 16:25:36 +00:00
Yedaya Katsman
e333097527 ip: Add missing -echo option to usage
In commit b264b4c656 ("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: b264b4c656 ("ip: add NLM_F_ECHO support")
Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2024-02-05 14:12:11 -08:00
Yedaya Katsman
32bb7f8f99 ip: Add missing stats command to usage
The stats command was added in 54d82b0699 ("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: 54d82b0699 ("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>
2024-02-05 08:53:36 -08:00
Yedaya Katsman
327741c6e8 ip: remove non-existent amt subcommand from usage
Commit 6e15d27aae ("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: 6e15d27aae ("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>
2024-01-31 16:03:56 -08:00