* [PATCH iproute2-next 1/2] lib/ll_map: Update name when changed
@ 2025-07-31 21:59 William A. Kennington III
2025-07-31 21:59 ` [PATCH iproute2-next 2/2] ip-monitor: Always monitor links William A. Kennington III
0 siblings, 1 reply; 2+ messages in thread
From: William A. Kennington III @ 2025-07-31 21:59 UTC (permalink / raw)
To: netdev; +Cc: William A. Kennington III
On systems with a predictable naming scheme, our interfaces always first
come up with the incremental kernel name prior to being renamed. If we
have multiple links that come up at different times, they will usually
use overlapping names when first seen. The predictable name is then set
shorlty after. When using ip-monitor, all routes will then end up
printing with this same first name (usually best seen with eth0). In
these instances the routes cannot have their interfaces distinguished,
as they are printed with a stale name.
Consider the following example while running `ip-monitor`
```
$ sudo ip link add dummy1 type dummy
$ sudo ip link set dummy1 name dummy2
$ sudo ip link set dummy2 addr 00:00:00:00:00:02
$ sudo ip link add dummy1 type dummy
$ sudo ip link set dummy1 addr 00:00:00:00:00:01
$ sudo ip link set dummy2 up
$ sudo ip link set dummy1 up
```
We currently see the following, notice the address and route lines
```
20: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 82:49:17:d4:21:88 brd ff:ff:ff:ff:ff:ff
20: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 86:61:a6:69:1d:7b brd ff:ff:ff:ff:ff:ff
20: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 86:61:a6:69:1d:7b brd ff:ff:ff:ff:ff:ff
20: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 00:00:00:00:00:02 brd ff:ff:ff:ff:ff:ff
21: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether d6:f6:da:e5:d7:7c brd ff:ff:ff:ff:ff:ff
21: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 86:61:a6:69:1d:7b brd ff:ff:ff:ff:ff:ff
21: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
link/ether 00:00:00:00:00:01 brd ff:ff:ff:ff:ff:ff
20: dummy2: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 00:00:00:00:00:02 brd ff:ff:ff:ff:ff:ff
multicast ff00::/8 dev dummy1 table local proto kernel metric 256 pref medium
fe80::/64 dev dummy1 proto kernel metric 256 pref medium
20: dummy1 inet6 fe80::200:ff:fe00:2/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
local fe80::200:ff:fe00:2 dev dummy1 table local proto kernel metric 0 pref medium
21: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether 00:00:00:00:00:01 brd ff:ff:ff:ff:ff:ff
multicast ff00::/8 dev dummy1 table local proto kernel metric 256 pref medium
fe80::/64 dev dummy1 proto kernel metric 256 pref medium
21: dummy1 inet6 fe80::200:ff:fe00:1/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
local fe80::200:ff:fe00:1 dev dummy1 table local proto kernel metric 0 pref medium
```
Signed-off-by: William A. Kennington III <william@wkennington.com>
---
lib/ll_map.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 8970c20f..431946f5 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -118,9 +118,8 @@ static void ll_entry_update(struct ll_cache *im, struct ifinfomsg *ifi,
{
unsigned int h;
+ strcpy(im->name, ifname);
im->flags = ifi->ifi_flags;
- if (!strcmp(im->name, ifname))
- return;
hlist_del(&im->name_hash);
h = namehash(ifname) & (IDXMAP_SIZE - 1);
hlist_add_head(&im->name_hash, &name_head[h]);
--
2.50.1.565.gc32cd1483b-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH iproute2-next 2/2] ip-monitor: Always monitor links
2025-07-31 21:59 [PATCH iproute2-next 1/2] lib/ll_map: Update name when changed William A. Kennington III
@ 2025-07-31 21:59 ` William A. Kennington III
0 siblings, 0 replies; 2+ messages in thread
From: William A. Kennington III @ 2025-07-31 21:59 UTC (permalink / raw)
To: netdev; +Cc: William A. Kennington III
We need to watch link changes even if we don't actively print them.
Otherwise, route changes will not print the correct link name.
Signed-off-by: William A. Kennington III <william@wkennington.com>
---
ip/ipmonitor.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index 1f4e860f..14aba1f1 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -25,6 +25,7 @@ static int prefix_banner;
int listen_all_nsid;
struct rtnl_ctrl_data *ctrl_data;
int do_monitor;
+int print_link;
static void usage(void)
{
@@ -100,7 +101,8 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
case RTM_NEWLINK:
case RTM_DELLINK:
ll_remember_index(n, NULL);
- print_linkinfo(n, arg);
+ if (print_link)
+ print_linkinfo(n, arg);
return 0;
case RTM_NEWADDR:
@@ -263,8 +265,10 @@ int do_ipmonitor(int argc, char **argv)
if (!lmask)
lmask = IPMON_L_ALL;
+ /* Always monitor links for renaming */
+ groups |= nl_mgrp(RTNLGRP_LINK);
if (lmask & IPMON_LLINK)
- groups |= nl_mgrp(RTNLGRP_LINK);
+ print_link = true;
if (lmask & IPMON_LADDR) {
if (!preferred_family || preferred_family == AF_INET)
groups |= nl_mgrp(RTNLGRP_IPV4_IFADDR);
--
2.50.1.565.gc32cd1483b-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-31 21:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 21:59 [PATCH iproute2-next 1/2] lib/ll_map: Update name when changed William A. Kennington III
2025-07-31 21:59 ` [PATCH iproute2-next 2/2] ip-monitor: Always monitor links William A. Kennington III
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.