backport upstream patches

This commit is contained in:
tmacbb 2024-01-12 16:07:21 +08:00
parent 42504a744e
commit 4ab95ce26b
10 changed files with 502 additions and 1 deletions

View File

@ -0,0 +1,58 @@
From 3a463c152a9a5503f9c37362b63acd6f72ecba6c Mon Sep 17 00:00:00 2001
From: Mathieu Schroeter <mathieu@schroetersa.ch>
Date: Tue, 8 Aug 2023 23:42:55 +0200
Subject: [PATCH] Add get_long utility and adapt get_integer accordingly
Conflict:contaxt adapt in include/utiles.h due to ebe23249ce1eeedb3610890e4c0c0f52fb8341fe
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=3a463c152a9a5503f9c37362b63acd6f72ecba6c
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
include/utils.h | 1 +
lib/utils.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/utils.h b/include/utils.h
index 3159dbab1..cf11174d9 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -142,6 +142,7 @@ int get_addr_rta(inet_prefix *dst, const struct rtattr *rta, int family);
int read_prop(const char *dev, char *prop, long *value);
int get_hex(char c);
+int get_long(long *val, const char *arg, int base);
int get_integer(int *val, const char *arg, int base);
int get_unsigned(unsigned *val, const char *arg, int base);
int get_time_rtt(unsigned *val, const char *arg, int *raw);
diff --git a/lib/utils.c b/lib/utils.c
index b1f273054..68f443038 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -108,7 +108,7 @@ static int get_hex(char c)
return -1;
}
-int get_integer(int *val, const char *arg, int base)
+int get_long(long *val, const char *arg, int base)
{
long res;
char *ptr;
@@ -133,6 +133,17 @@ int get_integer(int *val, const char *arg, int base)
if ((res == LONG_MAX || res == LONG_MIN) && errno == ERANGE)
return -1;
+ if (val)
+ *val = res;
+ return 0;
+}
+
+int get_integer(int *val, const char *arg, int base)
+{
+ long res;
+
+ res = get_long(NULL, arg, base);
+
/* Outside range of int */
if (res < INT_MIN || res > INT_MAX)
return -1;

View File

@ -0,0 +1,45 @@
From db7fb3f1965751444c3b743ba0253061fd7e3b44 Mon Sep 17 00:00:00 2001
From: Mathieu Schroeter <mathieu@schroetersa.ch>
Date: Tue, 8 Aug 2023 23:42:56 +0200
Subject: [PATCH] Add utility to convert an unsigned int to string
Conflict:contaxt adapt in include/utiles.h due to ebe23249ce1eeedb3610890e4c0c0f52fb8341fe
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=db7fb3f1965751444c3b743ba0253061fd7e3b44
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
include/utils.h | 1 +
lib/utils.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/include/utils.h b/include/utils.h
index cf11174d9..f26ed822f 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -309,6 +309,7 @@ unsigned int print_name_and_link(const char *fmt,
int makeargs(char *line, char *argv[], int maxargs);
char *int_to_str(int val, char *buf);
+char *uint_to_str(unsigned int val, char *buf);
int get_guid(__u64 *guid, const char *arg);
int get_real_family(int rtm_type, int rtm_family);
diff --git a/lib/utils.c b/lib/utils.c
index 68f443038..efa01668d 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1409,6 +1409,12 @@ char *int_to_str(int val, char *buf)
return buf;
}
+char *uint_to_str(unsigned int val, char *buf)
+{
+ sprintf(buf, "%u", val);
+ return buf;
+}
+
int get_guid(__u64 *guid, const char *arg)
{
unsigned long tmp;

View File

@ -0,0 +1,121 @@
From 61695c493ec14a63740bbb81e0564f753bd054dd Mon Sep 17 00:00:00 2001
From: Ido Schimmel <idosch@nvidia.com>
Date: Tue, 11 Jul 2023 09:59:03 +0300
Subject: f_flower: Treat port 0 as valid
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=61695c493ec14a63740bbb81e0564f753bd054dd
It is not currently possible to add a filter matching on port 0 despite
it being a valid port number. This is caused by cited commit which
treats a value of 0 as an indication that the port was not specified.
Instead of inferring that a port range was specified by checking that both
the minimum and the maximum ports are non-zero, simply add a boolean
argument to parse_range() and set it after parsing a port range.
Before:
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp src_port 0 action pass
Illegal "src_port"
# tc filter add dev swp1 ingress pref 2 proto ip flower ip_proto udp dst_port 0 action pass
Illegal "dst_port"
# tc filter add dev swp1 ingress pref 3 proto ip flower ip_proto udp src_port 0-100 action pass
Illegal "src_port"
# tc filter add dev swp1 ingress pref 4 proto ip flower ip_proto udp dst_port 0-100 action pass
Illegal "dst_port"
After:
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp src_port 0 action pass
# tc filter add dev swp1 ingress pref 2 proto ip flower ip_proto udp dst_port 0 action pass
# tc filter add dev swp1 ingress pref 3 proto ip flower ip_proto udp src_port 0-100 action pass
# tc filter add dev swp1 ingress pref 4 proto ip flower ip_proto udp dst_port 0-100 action pass
# tc filter show dev swp1 ingress | grep _port
src_port 0
dst_port 0
src_port 0-100
dst_port 0-100
Fixes: 767b6fd620dd ("tc: flower: fix port value truncation")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/f_flower.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tc/f_flower.c b/tc/f_flower.c
index c71394f75..737df199a 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -735,7 +735,7 @@ static int flower_port_range_attr_type(__u8 ip_proto, enum flower_endpoint type,
}
/* parse range args in format 10-20 */
-static int parse_range(char *str, __be16 *min, __be16 *max)
+static int parse_range(char *str, __be16 *min, __be16 *max, bool *p_is_range)
{
char *sep;
@@ -748,6 +748,8 @@ static int parse_range(char *str, __be16 *min, __be16 *max)
if (get_be16(max, sep + 1, 10))
return -1;
+
+ *p_is_range = true;
} else {
if (get_be16(min, str, 10))
return -1;
@@ -759,19 +761,20 @@ static int flower_parse_port(char *str, __u8 ip_proto,
enum flower_endpoint endpoint,
struct nlmsghdr *n)
{
+ bool is_range = false;
char *slash = NULL;
__be16 min = 0;
__be16 max = 0;
int ret;
- ret = parse_range(str, &min, &max);
+ ret = parse_range(str, &min, &max, &is_range);
if (ret) {
slash = strchr(str, '/');
if (!slash)
return -1;
}
- if (min && max) {
+ if (is_range) {
__be16 min_port_type, max_port_type;
if (ntohs(max) <= ntohs(min)) {
@@ -784,7 +787,7 @@ static int flower_parse_port(char *str, __u8 ip_proto,
addattr16(n, MAX_MSG, min_port_type, min);
addattr16(n, MAX_MSG, max_port_type, max);
- } else if (slash || (min && !max)) {
+ } else {
int type;
type = flower_port_attr_type(ip_proto, endpoint);
@@ -802,8 +805,6 @@ static int flower_parse_port(char *str, __u8 ip_proto,
return -1;
return flower_parse_u16(str, type, mask_type, n, true);
}
- } else {
- return -1;
}
return 0;
}
--
cgit

View File

@ -0,0 +1,48 @@
From 84ffffeb0a2ff69e36bd972d57699f9e3bb29a48 Mon Sep 17 00:00:00 2001
From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 31 Jul 2023 09:19:20 -0700
Subject: ip: error out if iplink does not consume all options
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=84ffffeb0a2ff69e36bd972d57699f9e3bb29a48
dummy does not define .parse_opt, which make ip ignore all
trailing arguments, for example:
# ip link add type dummy a b c d e f name cheese
will work just fine (and won't call the device "cheese").
Error out in this case with a clear error message:
# ip link add type dummy a b c d e f name cheese
Garbage instead of arguments "a ...". Try "ip link help".
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/iplink.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index 6c5d13d53..9a548dd35 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1112,13 +1112,12 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
argc -= ret;
argv += ret;
- if (lu && argc) {
+ if (lu && lu->parse_opt && argc) {
struct rtattr *data;
data = addattr_nest(&req.n, sizeof(req), iflatype);
- if (lu->parse_opt &&
- lu->parse_opt(lu, argc, argv, &req.n))
+ if (lu->parse_opt(lu, argc, argv, &req.n))
return -1;
addattr_nest_end(&req.n, data);
--
cgit

View File

@ -0,0 +1,34 @@
From 3181d4e14964d7845ca9730ec6b4d7b72f3712c5 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Fri, 1 Sep 2023 16:02:26 +0800
Subject: iplink_bridge: fix incorrect root id dump
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=3181d4e14964d7845ca9730ec6b4d7b72f3712c5
Fix the typo when dump root_id.
Fixes: 70dfb0b8836d ("iplink: bridge: export bridge_id and designated_root")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/iplink_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 7e4e62c81..462075295 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -499,7 +499,7 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_BR_ROOT_ID]) {
char root_id[32];
- br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_BRIDGE_ID]), root_id,
+ br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_ROOT_ID]), root_id,
sizeof(root_id));
print_string(PRINT_ANY,
"root_id",
--
cgit

View File

@ -0,0 +1,37 @@
From 92e9915c36b7d4820f004fa74e0d93be99b8272a Mon Sep 17 00:00:00 2001
From: Phil Sutter <phil@nwl.cc>
Date: Tue, 22 Aug 2023 14:19:16 +0200
Subject: ss: Fix socket type check in packet_show_line()
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=92e9915c36b7d4820f004fa74e0d93be99b8272a
The field is accessed before being assigned a meaningful value,
effectively disabling the checks.
Fixes: 4a0053b606a34 ("ss: Unify packet stats output from netlink and proc")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
misc/ss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index c71b08f98..653b1512c 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -4535,9 +4535,9 @@ static int packet_show_line(char *buf, const struct filter *f, int fam)
&type, &prot, &iface, &state,
&rq, &uid, &ino);
- if (stat.type == SOCK_RAW && !(f->dbs&(1<<PACKET_R_DB)))
+ if (type == SOCK_RAW && !(f->dbs & (1<<PACKET_R_DB)))
return 0;
- if (stat.type == SOCK_DGRAM && !(f->dbs&(1<<PACKET_DG_DB)))
+ if (type == SOCK_DGRAM && !(f->dbs & (1<<PACKET_DG_DB)))
return 0;
stat.type = type;
--
cgit

View File

@ -0,0 +1,68 @@
From 012cb5152d05122299384c9159ea82d059c80873 Mon Sep 17 00:00:00 2001
From: Mathieu Schroeter <mathieu@schroetersa.ch>
Date: Tue, 8 Aug 2023 23:42:57 +0200
Subject: ss: change aafilter port from int to long (inode support)
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=012cb5152d05122299384c9159ea82d059c80873
The aafilter struct considers the port as (usually) 32 bit signed
integer. In case of a unix socket, the port is used with an inode
number which is an unsigned int. In this case, the 'ss' command
fails because it assumes that the value does not look like a port
(<0).
Here an example of command call where the inode is passed and
is larger than a signed integer:
ss -H -A unix_stream src :2259952798
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
misc/ss.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index e9d813596..baa835149 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1733,7 +1733,7 @@ static void inet_addr_print(const inet_prefix *a, int port,
struct aafilter {
inet_prefix addr;
- int port;
+ long port;
unsigned int iface;
__u32 mark;
__u32 mask;
@@ -2256,7 +2256,7 @@ void *parse_hostcond(char *addr, bool is_port)
port = find_port(addr, is_port);
if (port) {
if (*port && strcmp(port, "*")) {
- if (get_integer(&a.port, port, 0)) {
+ if (get_long(&a.port, port, 0)) {
if ((a.port = xll_name_to_index(port)) <= 0)
return NULL;
}
@@ -2279,7 +2279,7 @@ void *parse_hostcond(char *addr, bool is_port)
port = find_port(addr, is_port);
if (port) {
if (*port && strcmp(port, "*")) {
- if (get_integer(&a.port, port, 0)) {
+ if (get_long(&a.port, port, 0)) {
if (strcmp(port, "kernel") == 0)
a.port = 0;
else
@@ -2335,7 +2335,7 @@ void *parse_hostcond(char *addr, bool is_port)
*port++ = 0;
if (*port && *port != '*') {
- if (get_integer(&a.port, port, 0)) {
+ if (get_long(&a.port, port, 0)) {
struct servent *se1 = NULL;
struct servent *se2 = NULL;
--
cgit

View File

@ -0,0 +1,33 @@
From e12d0c929cf5f4266f745063696dd291cb6f06a4 Mon Sep 17 00:00:00 2001
From: Mathieu Schroeter <mathieu@schroetersa.ch>
Date: Tue, 8 Aug 2023 23:42:58 +0200
Subject: ss: print unix socket "ports" as unsigned int (inode)
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e12d0c929cf5f4266f745063696dd291cb6f06a4
Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
misc/ss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index baa835149..13b2523f4 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -4073,9 +4073,9 @@ static void unix_stats_print(struct sockstat *s, struct filter *f)
sock_state_print(s);
sock_addr_print(s->name ?: "*", " ",
- int_to_str(s->lport, port_name), NULL);
+ uint_to_str(s->lport, port_name), NULL);
sock_addr_print(s->peer_name ?: "*", " ",
- int_to_str(s->rport, port_name), NULL);
+ uint_to_str(s->rport, port_name), NULL);
proc_ctx_print(s);
}
--
cgit

View File

@ -0,0 +1,33 @@
From 877f8149d2ed94b6ab412fabaab9fe8d15193db7 Mon Sep 17 00:00:00 2001
From: Pedro Tammela <pctammela@mojatatu.com>
Date: Sat, 19 Aug 2023 17:54:48 -0300
Subject: [PATCH] utils: fix get_integer() logic
Conflict:NA
Reference:https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=877f8149d2ed94b6ab412fabaab9fe8d15193db7
After 3a463c15, get_integer() doesn't return the converted value and
always writes 0 in 'val' in case of success.
Fix the logic so it writes the converted value in 'val'.
Fixes: 3a463c15 ("Add get_long utility and adapt get_integer accordingly"
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
lib/utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/utils.c b/lib/utils.c
index efa01668d..99ba7a233 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -142,7 +142,8 @@ int get_integer(int *val, const char *arg, int base)
{
long res;
- res = get_long(NULL, arg, base);
+ if (get_long(&res, arg, base) < 0)
+ return -1;
/* Outside range of int */
if (res < INT_MIN || res > INT_MAX)

View File

@ -2,7 +2,7 @@
Name: iproute
Version: 5.15.0
Epoch: 1
Release: 17
Release: 18
Summary: Linux network configuration utilities
License: GPLv2+ and Public Domain
URL: https://kernel.org/pub/linux/utils/net/iproute2/
@ -49,6 +49,16 @@ Patch6033: backport-tc-ct-Fix-invalid-pointer-dereference.patch
Patch6034: backport-libnetlink-Fix-memory-leak-in-__rtnl_talk_iov.patch
Patch6035: backport-xfrm-prepare-state-offload-logic-to-set-mode.patch
Patch6036: backport-Add-get_long-utility-and-adapt-get_integer-accordingly.patch
Patch6037: backport-Add-utility-to-convert-an-unsigned-int-to-string.patch
Patch6038: backport-f_flower-Treat-port-0-as-valid.patch
Patch6039: backport-ip-error-out-if-iplink-does-not-consume-all-options.patch
Patch6040: backport-iplink_bridge-fix-incorrect-root-id-dump.patch
Patch6041: backport-ss-change-aafilter-port-from-int-to-long-inode-support.patch
Patch6042: backport-ss-Fix-socket-type-check-in-packet_show_line.patch
Patch6043: backport-ss-print-unix-socket-ports-as-unsigned-int-inode.patch
Patch6044: backport-utils-fix-get_integer-logic.patch
Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch
Patch9001: bugfix-iproute2-cancel-some-test-cases.patch
Patch9002: feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch
@ -128,6 +138,20 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%{_mandir}/*
%changelog
* Fri Jan 12 2024 liubo <liubo335@huawei.com> - 1:5.15.0-18
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:f_flower: Treat port 0 as valid
ip: error out if iplink does not consume all options
iplink_bridge: fix incorrect root id dump
ss: change aafilter port from int to long (inode support)
ss: Fix socket type check in packet_show_line()
ss: print unix socket "ports" as unsigned int (inode)
Add utility to convert an unsigned int to string
Add get_long utility and adapt get_integer accordingly
utils: fix get_integer() logic
* Mon Nov 27 2023 liubo <liubo335@huawei.com> - 1:5.15.0-17
- Type:bugfix
- ID:NA