"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 --- 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.1.839.g22a8290db9-goog