All of lore.kernel.org
 help / color / mirror / Atom feed
From: "William A. Kennington III" <william@wkennington.com>
To: netdev@vger.kernel.org
Cc: "William A. Kennington III" <william@wkennington.com>
Subject: [PATCH iproute2-next 1/2] lib/ll_map: Update name when changed
Date: Thu, 31 Jul 2025 14:59:19 -0700	[thread overview]
Message-ID: <20250731215920.3675217-1-william@wkennington.com> (raw)

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


             reply	other threads:[~2025-07-31 21:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 21:59 William A. Kennington III [this message]
2025-07-31 21:59 ` [PATCH iproute2-next 2/2] ip-monitor: Always monitor links William A. Kennington III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250731215920.3675217-1-william@wkennington.com \
    --to=william@wkennington.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.