[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250523032518.251497-1-yuyanghuang@google.com>
Date: Fri, 23 May 2025 12:25:18 +0900
From: Yuyang Huang <yuyanghuang@...gle.com>
To: Yuyang Huang <yuyanghuang@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
Luca Boccassi <bluca@...ian.org>, "Maciej Żenczykowski" <maze@...gle.com>, Lorenzo Colitti <lorenzo@...gle.com>,
Adel Belhouane <bugs.a.b@...e.fr>
Subject: [PATCH iproute2] iproute2: bugfix - restore ip monitor backward compatibility.
The current ip monitor implementation fails on older kernels that lack
newer RTNLGRP_* definitions. As ip monitor is expected to maintain
backward compatibility, this commit updates the code to check if errno
is not EINVAL when rtnl_add_nl_group() fails. This change restores ip
monitor's backward compatibility with older kernel versions.
Cc: David Ahern <dsahern@...nel.org>
Cc: Luca Boccassi <bluca@...ian.org>
Cc: Maciej Żenczykowski <maze@...gle.com>
Cc: Lorenzo Colitti <lorenzo@...gle.com>
Reported-by: Adel Belhouane <bugs.a.b@...e.fr>
Closes: https://lore.kernel.org/netdev/CADXeF1GgJ_1tee3hc7gca2Z21Lyi3mzxq52sSfMg3mFQd2rGWQ@mail.gmail.com/T/#t
Signed-off-by: Yuyang Huang <yuyanghuang@...gle.com>
---
ip/ipmonitor.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index b890b4d0..1f4e860f 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -5,6 +5,7 @@
* Authors: Alexey Kuznetsov, <kuznet@....inr.ac.ru>
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -328,38 +329,46 @@ int do_ipmonitor(int argc, char **argv)
if (lmask & IPMON_LNEXTHOP &&
rtnl_add_nl_group(&rth, RTNLGRP_NEXTHOP) < 0) {
- fprintf(stderr, "Failed to add nexthop group to list\n");
- exit(1);
+ if (errno != EINVAL) {
+ fprintf(stderr, "Failed to add nexthop group to list\n");
+ exit(1);
+ }
}
if (lmask & IPMON_LSTATS &&
rtnl_add_nl_group(&rth, RTNLGRP_STATS) < 0 &&
nmask & IPMON_LSTATS) {
- fprintf(stderr, "Failed to add stats group to list\n");
- exit(1);
+ if (errno != EINVAL) {
+ fprintf(stderr, "Failed to add stats group to list\n");
+ exit(1);
+ }
}
if (lmask & IPMON_LMADDR) {
if ((!preferred_family || preferred_family == AF_INET) &&
rtnl_add_nl_group(&rth, RTNLGRP_IPV4_MCADDR) < 0) {
- fprintf(stderr,
- "Failed to add ipv4 mcaddr group to list\n");
- exit(1);
+ if (errno != EINVAL) {
+ fprintf(stderr, "Failed to add ipv4 mcaddr group to list\n");
+ exit(1);
+ }
}
if ((!preferred_family || preferred_family == AF_INET6) &&
rtnl_add_nl_group(&rth, RTNLGRP_IPV6_MCADDR) < 0) {
- fprintf(stderr,
- "Failed to add ipv6 mcaddr group to list\n");
- exit(1);
+ if (errno != EINVAL) {
+ fprintf(stderr,
+ "Failed to add ipv6 mcaddr group to list\n");
+ exit(1);
+ }
}
}
if (lmask & IPMON_LACADDR) {
if ((!preferred_family || preferred_family == AF_INET6) &&
rtnl_add_nl_group(&rth, RTNLGRP_IPV6_ACADDR) < 0) {
- fprintf(stderr,
- "Failed to add ipv6 acaddr group to list\n");
- exit(1);
+ if (errno != EINVAL) {
+ fprintf(stderr, "Failed to add ipv6 acaddr group to list\n");
+ exit(1);
+ }
}
}
--
2.49.0.1204.g71687c7c1d-goog
Powered by blists - more mailing lists