From: Yuyang Huang <yuyanghuang@google.com>
To: Yuyang Huang <yuyanghuang@google.com>
Cc: David Ahern <dsahern@kernel.org>, netdev@vger.kernel.org
Subject: [PATCH iproute2-next 2/2] ipmaddr: read link-layer multicast addresses via netlink
Date: Sun, 8 Nov 2026 10:29:49 +0900 [thread overview]
Message-ID: <20261108012949.3943642-3-yuyanghuang@google.com> (raw)
In-Reply-To: <20261108012949.3943642-1-yuyanghuang@google.com>
"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
prev parent reply other threads:[~2026-11-08 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20261108012949.3943642-3-yuyanghuang@google.com \
--to=yuyanghuang@google.com \
--cc=dsahern@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox