Commit Graph

1206 Commits

Author SHA1 Message Date
Petr Machata
2b8766663d 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>
2023-11-22 19:32:09 +00:00
Petr Machata
60254925cc lib: utils: Switch matches() to returning int again
Since commit 1f420318bd ("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>
2023-11-22 19:31:55 +00:00
Jiri Pirko
2ded9c18a3 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>
2023-11-11 17:31:29 +00:00
Jiri Pirko
a59b83f73d 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>
2023-11-11 17:30:59 +00:00
David Ahern
34d5458cfb 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>
2023-11-06 10:08:23 -07:00
Shung-Hsi Yu
892a33ac1b bpf: increase verifier verbosity when in verbose mode
The BPF verifier allows setting a higher verbosity level, which is
helpful when it comes to debugging verifier issue, specially when used
on BPF program that loads successfully (but should not have passed the
verifier in the first place). Increase the BPF verifier log level when
in verbose mode to help with such cases.

Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-10-27 16:56:55 +00:00
David Ahern
0aa1a1c08e Update kernel headers
Update kernel headers to commit
    dcf02bac377e ("Merge branch 'net-stmmac-improve-tx-timer-logic'")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-10-19 15:34:46 +00:00
Stephen Hemminger
6474515c8a uapi: update from 6.6-rc5
Update to if_packet.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-12 19:33:46 -07:00
Stephen Hemminger
2a12e61a4a uapi: update headers from 6.6-rc4
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-10-02 14:29:10 -07:00
Stephen Hemminger
61b3433abb uapi: headers update from 6.6-rc2
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-09-15 10:26:11 -07:00
Jiri Pirko
20b299a3ec mnl_utils: introduce a helper to check if dump policy exists for command
Benefit from GET_POLICY command of ctrl netlink and introduce a helper
that dumps policies and finds out, if there is a separate policy
specified for dump op of specified command.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-09-11 09:16:45 -06:00
David Ahern
3258a969e9 Merge remote-tracking branch 'main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-09-11 09:14:18 -06:00
Stephen Hemminger
040325f543 v6.5.0 2023-09-06 09:26:52 -07:00
David Ahern
8ab5ae19da Update kernel headers
Update kernel headers to commit:
    6c9cfb853063 ("net: ethernet: mtk_wed: minor change in wed_{tx,rx}info_show")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-28 20:51:44 -06:00
Andrea Claudi
0d0eeaa6cb ip vrf: make ipvrf_exec SELinux-aware
When using ip vrf and SELinux is enabled, make sure to set the exec file
context before calling cmd_exec.

This ensures that the command is executed with the right context,
falling back to the ifconfig_t context when needed.

Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-24 17:34:40 -07:00
Andrea Claudi
e246ebc3b7 lib: add SELinux include and stub functions
ss provides some selinux stub functions, useful when iproute2 is
compiled without selinux support.

Move them to lib/ so we can use them in other iproute2 tools.

Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-24 17:34:31 -07:00
David Ahern
ce67bbcccb Merge remote-tracking branch 'main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-20 10:42:35 -06:00
Mathieu Schroeter
db7fb3f196 Add utility to convert an unsigned int to string
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-13 10:24:32 -06:00
Mathieu Schroeter
3a463c152a Add get_long utility and adapt get_integer accordingly
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-13 10:24:27 -06:00
Stephen Hemminger
6e43b962bf uapi: update headers
Based off ov 6.5-rc5

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-08-09 13:21:20 -07:00
David Ahern
80e10ccff0 Merge remote-tracking branch 'main/main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-02 09:28:53 -06:00
David Ahern
3fb794da9f Update kernel headers
Update kernel headers to commit:
    34093c9fa05d ("net: Remove duplicated include in mac.c")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-08-02 09:27:51 -06:00
Gioele Barabucci
0a0a8f12fa Read configuration files from /etc and /usr
Add support for the so called "stateless" configuration pattern (read
from /etc, fall back to /usr), giving system administrators a way to
define local configuration without changing any distro-provided files.

In practice this means that each configuration file FOO is loaded
from /usr/lib/iproute2/FOO unless /etc/iproute2/FOO exists.

Signed-off-by: Gioele Barabucci <gioele@svario.it>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-07-26 09:06:03 -07:00
Stephen Hemminger
912f5de4aa Add missing SPDX headers
All headers and source in iproute2 should be using SPDX license info.
Add a couple that were missed, and take off boilerplate.

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-07-22 09:30:36 -07:00
Stephen Hemminger
ac9650fe5c include: dual license the bpf helper includes
The files bpf_api.h and bpf_elf.h are useful for TC BPF programs
to use. And there is no requirement that those be GPL only;
we intend to allow BSD licensed BPF helpers as well.

This makes the file license same as libbpf.

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-07-22 09:30:14 -07:00
Stephen Hemminger
a28ffdcf45 uapi: update headers to 6.5-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-07-10 10:00:07 -07:00
Stephen Hemminger
5e72cc73eb Merge git://git.kernel.org/pub/scm/network/iproute2/iproute2-next 2023-06-28 08:20:57 -07:00
Stephen Hemminger
43388c729d v6.4.0 2023-06-26 09:12:23 -07:00
David Ahern
3c37c2d662 Update kernel headers
Update kernel headers to commit:
    cc7554954848 ("net: micrel: Change to receive timestamp in the frame for lan8841")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-06-21 09:13:05 -07:00
Stephen Hemminger
b3f0748348 uapi: update to bpf.h
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-06-09 09:23:58 -07:00
David Ahern
a120abc7f6 Update kernel headers
Update kernel headers to commit:
    ae91f7e436f8 ("net/pppoe: fix a typo for the PPPOE_HASH_BITS_1 definition")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-06-06 08:30:49 -06:00
Stephen Hemminger
957a3b16f0 libnetlink: drop unused rtnl_talk_iov
Function was defined but not used in current iproute2 code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-06-02 09:33:34 -07:00
Stephen Hemminger
ebe23249ce utils: make local cmdline functions static
No need to expose these parts of command line parsing.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-06-02 09:33:34 -07:00
Stephen Hemminger
709063e836 ipaddress: accept symbolic names
The function rtnl_addproto_a2n() was defined but never used.
Use it to allow for symbolic names, and fix the function signatures
so protocol value is consistently __u8.

Fixes: bdb8d8549e ("ip: Support IP address protocol")
Cc: petrm@nvidia.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-06-02 08:51:53 -07:00
Stephen Hemminger
64b9f34280 uapi: update headers to 6.4-rc4
Minor addition to in.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-05-30 14:56:06 -07:00
Stephen Hemminger
1215e9d386 vxlan: make option printing more consistent
Add new helper function print_bool_opt() which prints
with no prefix and use it for vxlan options.

If the option matches the expected default value,
it is not printed if in non JSON mode unless the details
setting is repeated.

Use a table for the vxlan options. This will change
the order of the printing of options.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-05-30 12:32:22 -07:00
Stephen Hemminger
eb64e26835 uapi: add capability.h
All kernel header files should come from local copy of sanitized
headers, rather than relying on what Linux distribution ships.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-05-09 14:22:20 -07:00
Stephen Hemminger
30d98d1455 uapi: update kernel headers 6.4-rc1
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-05-08 13:41:31 -07:00
Stephen Hemminger
6f9bd171ff Merge git://git.kernel.org/pub/scm/network/iproute2/iproute2-next 2023-04-29 12:10:38 -07:00
Stephen Hemminger
1be3fcf0ab v6.3.0 2023-04-27 08:55:24 -07:00
Vladimir Oltean
1865a60871 utils: add max() definition
There is already a min() definition, add this below it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-04-24 19:42:21 -06:00
David Ahern
47928f8851 Update kernel headers
Update kernel headers to commit:
    fbc1449d385d ("Merge tag 'mlx5-updates-2023-04-20' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-04-22 10:03:31 -06:00
David Ahern
5dbb44707c Update kernel headers
Update kernel headers to commit:
    e28531143b25 ("net: ethernet: mtk_eth_soc: mtk_ppe: prefer newly added l2 flows")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-04-07 09:34:12 -06:00
Petr Machata
bdb8d8549e ip: Support IP address protocol
IPv4 and IPv6 addresses can be assigned a protocol value that indicates the
provenance of the IP address. The attribute is modeled after ip route
protocols, and essentially allows the administrator or userspace stack to
tag addresses in some way that makes sense to the actor in question.
Support for this feature was merged with commit 47f0bd503210 ("net: Add new
protocol attribute to IP addresses"), for kernel 5.18.

In this patch, add support for setting the protocol attribute at IP address
addition, replacement, and listing requests.

An example session with the feature in action:

	# ip address add dev d 192.0.2.1/28 proto 0xab
	# ip address show dev d
	26: d: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
	    link/ether 06:29:74:fd:1f:eb brd ff:ff:ff:ff:ff:ff
	    inet 192.0.2.1/28 scope global proto 0xab d
	       valid_lft forever preferred_lft forever

	# ip address replace dev d 192.0.2.1/28 proto 0x11
	# ip address show dev d
	26: d: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
	    link/ether 06:29:74:fd:1f:eb brd ff:ff:ff:ff:ff:ff
	    inet 192.0.2.1/28 scope global proto 0x11 d
	       valid_lft forever preferred_lft forever

A JSON dump. The protocol value is always provided as a string, even in
numeric mode, to provide a consistent interface.

	# ip -j address show dev d | jq
	[
	  {
	    "ifindex": 26,
	    "ifname": "d",
	    "flags": [
	      "BROADCAST",
	      "NOARP"
	    ],
	    "mtu": 1500,
	    "qdisc": "noop",
	    "operstate": "DOWN",
	    "group": "default",
	    "txqlen": 1000,
	    "link_type": "ether",
	    "address": "06:29:74:fd:1f:eb",
	    "broadcast": "ff:ff:ff:ff:ff:ff",
	    "addr_info": [
	      {
	        "family": "inet",
	        "local": "192.0.2.1",
	        "prefixlen": 28,
	        "scope": "global",
	        "protocol": "0x11",
	        "label": "d",
	        "valid_life_time": 4294967295,
	        "preferred_life_time": 4294967295
	      }
	    ]
	  }
	]

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-03-30 09:53:13 -06:00
David Ahern
88786cd1a9 Update kernel headers
Update kernel headers to commit:
    da617cd8d906 ("smsc911x: remove superfluous variable init")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-03-30 09:43:49 -06:00
David Ahern
d0d5eeff79 Update kernel headers
Update kernel headers to commit:
    fcb3a4653bc5 ("net/sched: act_api: use the correct TCA_ACT attributes in dump")

Signed-off-by: David Ahern <dsahern@kernel.org>
2023-03-23 09:45:31 -06:00
Stephen Hemminger
7b20400960 uapi: update headers from 6.3-rc2
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-03-18 19:16:31 -07:00
Stephen Hemminger
8f7c836f7a uapi: update license of fou.h
Upstream 6.2-rc2

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-03-12 19:47:48 -07:00
Stephen Hemminger
57c4038a0f uapi: update bpf.h from upstream
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-02-22 07:33:35 -08:00
David Ahern
a969883ddc Merge branch 'main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
2023-02-22 08:22:19 -07:00