* [PATCH iproute2-next 0/2] ipmaddr: read link-layer multicast addresses via netlink
@ 2026-11-08 1:29 Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 1/2] uapi: update if_addr.h Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 2/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
0 siblings, 2 replies; 3+ messages in thread
From: Yuyang Huang @ 2026-11-08 1:29 UTC (permalink / raw)
To: Yuyang Huang; +Cc: David Ahern, netdev
"ip maddr show" gets the IPv4 and IPv6 multicast addresses from
RTM_GETMULTICAST dumps, but it still parses /proc/net/dev_mcast for the
link-layer addresses. The kernel now also supports RTM_GETMULTICAST
dumps with ifa_family AF_PACKET, which report the device multicast list
with every column of /proc/net/dev_mcast. Patch 2 uses this dump. The
output does not change. Older kernels reject the AF_PACKET dump with
EOPNOTSUPP, and "ip maddr" then reads /proc/net/dev_mcast as before.
Patch 1 adds IFA_F_GLOBAL to include/uapi/linux/if_addr.h. It is only
there so that the series builds, and it should not be merged: the uapi
headers are synced into iproute2-next regularly, and the next sync
brings in IFA_F_GLOBAL.
The kernel side is the net-next series "rtnetlink: dump link-layer
multicast addresses":
https://patch.msgid.link/20261012011707.3378-1-sigefriedhyy@gmail.com
Testing:
- net-next kernel in vng: "ip maddr show" output is byte-identical to
the current code for plain, -0/-4/-6, -o, -j, dev and -n <netns>, and
/proc/net/dev_mcast is not read. This includes a multi-part dump with
2000 entries on one device.
- 7.1 kernel without AF_PACKET support: falls back to
/proc/net/dev_mcast, with the same output.
Yuyang Huang (2):
uapi: update if_addr.h
ipmaddr: read link-layer multicast addresses via netlink
include/uapi/linux/if_addr.h | 1 +
ip/ipmaddr.c | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
--
2.56.0.455.g6c5a503b38-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH iproute2-next 1/2] uapi: update if_addr.h
2026-11-08 1:29 [PATCH iproute2-next 0/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
@ 2026-11-08 1:29 ` Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 2/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
1 sibling, 0 replies; 3+ messages in thread
From: Yuyang Huang @ 2026-11-08 1:29 UTC (permalink / raw)
To: Yuyang Huang; +Cc: David Ahern, netdev
Add IFA_F_GLOBAL, added in net-next by the series "rtnetlink: dump
link-layer multicast addresses". The next patch uses it.
Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
---
include/uapi/linux/if_addr.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h
index 5a28b958..aa30ef50 100644
--- a/include/uapi/linux/if_addr.h
+++ b/include/uapi/linux/if_addr.h
@@ -57,6 +57,7 @@ enum {
#define IFA_F_NOPREFIXROUTE 0x200
#define IFA_F_MCAUTOJOIN 0x400
#define IFA_F_STABLE_PRIVACY 0x800
+#define IFA_F_GLOBAL 0x1000
struct ifa_cacheinfo {
__u32 ifa_prefered;
--
2.56.0.455.g6c5a503b38-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH iproute2-next 2/2] ipmaddr: read link-layer multicast addresses via netlink
2026-11-08 1:29 [PATCH iproute2-next 0/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 1/2] uapi: update if_addr.h Yuyang Huang
@ 2026-11-08 1:29 ` Yuyang Huang
1 sibling, 0 replies; 3+ messages in thread
From: Yuyang Huang @ 2026-11-08 1:29 UTC (permalink / raw)
To: Yuyang Huang; +Cc: David Ahern, netdev
"ip maddr show" gets the IPv4 and IPv6 entries from RTM_GETMULTICAST
dumps but still parses /proc/net/dev_mcast for the link-layer ones.
The kernel now also dumps the device multicast list (dev->mc) for
RTM_GETMULTICAST requests with ifa_family AF_PACKET, so use it for
those too.
The dump carries every column of /proc/net/dev_mcast: IFA_MULTICAST is
the address, IFA_MC_USERS the reference count and IFA_F_GLOBAL in
IFA_FLAGS the "static" column, set for entries added explicitly, e.g.
by "ip maddr add". The output does not change.
Older kernels reject the AF_PACKET dump with EOPNOTSUPP, in which case
/proc/net/dev_mcast is parsed as before.
Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
---
ip/ipmaddr.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
index 95b703d2..2df520a3 100644
--- a/ip/ipmaddr.c
+++ b/ip/ipmaddr.c
@@ -261,6 +261,10 @@ static int accept_maddr(struct nlmsghdr *n, void *arg)
ma->addr.bitlen = ma->addr.bytelen << 3;
memcpy(ma->addr.data, RTA_DATA(tb[IFA_MULTICAST]), ma->addr.bytelen);
ma->users = rta_getattr_u32(tb[IFA_MC_USERS]);
+ /* IFA_F_GLOBAL is the "static" column of /proc/net/dev_mcast */
+ if (ifm->ifa_family == AF_PACKET && tb[IFA_FLAGS] &&
+ (rta_getattr_u32(tb[IFA_FLAGS]) & IFA_F_GLOBAL))
+ ma->features = "static";
maddr_ins(&ctx->list, ma);
return 0;
@@ -388,8 +392,10 @@ static int multiaddr_list(int argc, char **argv)
}
}
- if (!filter.family || filter.family == AF_PACKET)
- read_dev_mcast(&list);
+ if (!filter.family || filter.family == AF_PACKET) {
+ if (read_maddr_netlink(AF_PACKET, &list) < 0)
+ read_dev_mcast(&list);
+ }
if (!filter.family || filter.family == AF_INET) {
if (read_maddr_netlink(AF_INET, &list) < 0)
read_igmp(&list);
--
2.56.0.455.g6c5a503b38-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-08 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-08 1:29 [PATCH iproute2-next 0/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 1/2] uapi: update if_addr.h Yuyang Huang
2026-11-08 1:29 ` [PATCH iproute2-next 2/2] ipmaddr: read link-layer multicast addresses via netlink Yuyang Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox