mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: ipv4: report multicast group user count
RTM_GETMULTICAST has been part of the rtnetlink ABI for a long time and already reports IPv4 multicast group membership through IFA_MULTICAST and IFA_CACHEINFO. It does not report how many consumers hold each membership, so userspace still has to parse /proc/net/igmp to get the Users column. Add IFA_MC_USERS as a u32 attribute carrying ip_mc_list::users in RTM_GETMULTICAST replies and entry-lifecycle notifications. This gives iproute2 enough information to migrate the IPv4 part of "ip maddr show" from procfs parsing to rtnetlink. Signed-off-by: Yuyang Huang <sigefriedhyy@gmail.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260630110207.37841-2-sigefriedhyy@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
2ed8d5c724
commit
7cb8198761
|
|
@ -123,6 +123,9 @@ attribute-sets:
|
||||||
-
|
-
|
||||||
name: proto
|
name: proto
|
||||||
type: u8
|
type: u8
|
||||||
|
-
|
||||||
|
name: mc-users
|
||||||
|
type: u32
|
||||||
|
|
||||||
|
|
||||||
operations:
|
operations:
|
||||||
|
|
@ -176,6 +179,7 @@ operations:
|
||||||
value: 58
|
value: 58
|
||||||
attributes: &mcaddr-attrs
|
attributes: &mcaddr-attrs
|
||||||
- multicast
|
- multicast
|
||||||
|
- mc-users
|
||||||
- cacheinfo
|
- cacheinfo
|
||||||
dump:
|
dump:
|
||||||
request:
|
request:
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ enum {
|
||||||
IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
|
IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
|
||||||
IFA_TARGET_NETNSID,
|
IFA_TARGET_NETNSID,
|
||||||
IFA_PROTO, /* u8, address protocol */
|
IFA_PROTO, /* u8, address protocol */
|
||||||
|
IFA_MC_USERS, /* u32, multicast group users */
|
||||||
__IFA_MAX,
|
__IFA_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1473,6 +1473,7 @@ int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
|
||||||
ci.ifa_valid = INFINITY_LIFE_TIME;
|
ci.ifa_valid = INFINITY_LIFE_TIME;
|
||||||
|
|
||||||
if (nla_put_in_addr(skb, IFA_MULTICAST, im->multiaddr) < 0 ||
|
if (nla_put_in_addr(skb, IFA_MULTICAST, im->multiaddr) < 0 ||
|
||||||
|
nla_put_u32(skb, IFA_MC_USERS, READ_ONCE(im->users)) < 0 ||
|
||||||
nla_put(skb, IFA_CACHEINFO, sizeof(ci), &ci) < 0) {
|
nla_put(skb, IFA_CACHEINFO, sizeof(ci), &ci) < 0) {
|
||||||
nlmsg_cancel(skb, nlh);
|
nlmsg_cancel(skb, nlh);
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
|
|
@ -1494,6 +1495,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
|
||||||
|
|
||||||
skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg)) +
|
skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg)) +
|
||||||
nla_total_size(sizeof(__be32)) +
|
nla_total_size(sizeof(__be32)) +
|
||||||
|
nla_total_size(sizeof(u32)) +
|
||||||
nla_total_size(sizeof(struct ifa_cacheinfo)),
|
nla_total_size(sizeof(struct ifa_cacheinfo)),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user