diff options
| author | Felix Fietkau | 2025-10-20 17:43:27 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-10-20 17:46:54 +0000 |
| commit | b6d371f307705b32e1ef5c63d7bf6440c8859789 (patch) | |
| tree | 3a1ea17d9a14cbb02c7b74a8a23ed3ad3c7e0344 | |
| parent | df2f5c9a30f8faadf8dee962cc17d315e967d70a (diff) | |
| download | netifd-b6d371f307705b32e1ef5c63d7bf6440c8859789.tar.gz | |
system-linux: handle RTM_DELLINK events for device state tracking
Add RTM_DELLINK handling to properly track device lifecycle. When a
device is deleted, update its state with flags=0 to mark it as not
present. This improves synchronization compared to only relying on
the hotplug handler.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | system-linux.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/system-linux.c b/system-linux.c index 6582535..ceeabe3 100644 --- a/system-linux.c +++ b/system-linux.c @@ -732,8 +732,9 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) struct ifinfomsg *ifi = NLMSG_DATA(nh); struct nlattr *nla[__IFLA_MAX]; struct device *dev; + unsigned int flags; - if (nh->nlmsg_type != RTM_NEWLINK) + if (nh->nlmsg_type != RTM_NEWLINK && nh->nlmsg_type != RTM_DELLINK) return 0; nlmsg_parse(nh, sizeof(struct ifinfomsg), nla, __IFLA_MAX - 1, NULL); @@ -744,7 +745,8 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) if (!dev) return 0; - system_device_update_state(dev, ifi->ifi_flags); + flags = (nh->nlmsg_type == RTM_DELLINK) ? 0 : ifi->ifi_flags; + system_device_update_state(dev, flags); return 0; } |