๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Wenbo Sun Thu, 12 Nov 2026 08:23
[PATCH net-next v2] ipv4: igmp: report IFA_TARGET_NETNSID in multicast address dumps
#14958
Author: Wenbo Sun
Date: Thu, 12 Nov 2026 08:23
66 lines
11217 bytes
Commit eb4e17a1d915 ("netlink: support dumping IPv4 multicast addresses")
extended RTM_GETMULTICAST to dump IPv4 multicast addresses by reusing
inet_valid_dump_ifaddr_req(), which already accepts IFA_TARGET_NETNSID
and switches to the target network namespace. However,
inet_fill_ifmcaddr() does not include IFA_TARGET_NETNSID in the dump
replies yet.

In contrast, IPv4 unicast dumps (inet_fill_ifaddr()), IPv6 multicast
dumps (inet6_fill_ifmcaddr()), and AF_PACKET multicast dumps
(dev_mc_fill_addr()) all report IFA_TARGET_NETNSID when a netns id is
specified. Adding the same behavior to IPv4 multicast dumps aligns
reporting across address families and helps userspace consistently
identify target-netns replies.

Emit IFA_TARGET_NETNSID in inet_fill_ifmcaddr() when args->netnsid >= 0,
and initialize fillargs.netnsid = -1 in inet_ifmcaddr_notify() so that
multicast join/leave notifications do not include IFA_TARGET_NETNSID or
exceed their preallocated skb size.

This alignment was identified with the assistance of an LLM-based code
review tool, confirmed in a User-Mode Linux (UML) environment where AF_INET
RTM_GETMULTICAST dumps with IFA_TARGET_NETNSID omitted the attribute while
AF_INET6 included it, and verified in UML that AF_INET multicast dumps
now report IFA_TARGET_NETNSID, regular dumps without netnsid continue to
work, and multicast join/leave notifications succeed without warning.

Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
Changes in v2:
- Target net-next as an enhancement/alignment change and drop the Fixes
  tag, per Hangbin Liu's review.
- Soften and clarify the commit message to reflect feature alignment with
  inet_fill_ifaddr(), inet6_fill_ifmcaddr(), and dev_mc_fill_addr().
- Link to v1: https://lore.kernel.org/r/20261111082222.327963-1-sunwenbo@cmss.chinamobile.com

 net/ipv4/igmp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 144fca158adc..831d003677ba 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1517,6 +1517,12 @@ int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
 	ifm->ifa_scope = RT_SCOPE_UNIVERSE;
 	ifm->ifa_index = dev->ifindex;
 
+	if (args->netnsid >= 0 &&
+	    nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
+		nlmsg_cancel(skb, nlh);
+		return -EMSGSIZE;
+	}
+
 	ci.cstamp = (READ_ONCE(im->mca_cstamp) - INITIAL_JIFFIES) * 100UL / HZ;
 	ci.tstamp = ci.cstamp;
 	ci.ifa_prefered = INFINITY_LIFE_TIME;
@@ -1538,6 +1544,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
 {
 	struct inet_fill_args fillargs = {
 		.event = event,
+		.netnsid = -1,
 	};
 	struct net *net = dev_net(dev);
 	struct sk_buff *skb;
-- 
2.33.0
Re: [PATCH net-next v2] ipv4: igmp: report IFA_TARGET_NETNSID in multicast address dumps
#15637
Author: Hangbin Liu
Date: Fri, 13 Nov 2026 07:06
70 lines
11411 bytes
On Thu, Nov 12, 2026 at 04:23:52PM +0800, Wenbo Sun wrote:
> Commit eb4e17a1d915 ("netlink: support dumping IPv4 multicast addresses")
> extended RTM_GETMULTICAST to dump IPv4 multicast addresses by reusing
> inet_valid_dump_ifaddr_req(), which already accepts IFA_TARGET_NETNSID
> and switches to the target network namespace. However,
> inet_fill_ifmcaddr() does not include IFA_TARGET_NETNSID in the dump
> replies yet.
> 
> In contrast, IPv4 unicast dumps (inet_fill_ifaddr()), IPv6 multicast
> dumps (inet6_fill_ifmcaddr()), and AF_PACKET multicast dumps
> (dev_mc_fill_addr()) all report IFA_TARGET_NETNSID when a netns id is
> specified. Adding the same behavior to IPv4 multicast dumps aligns
> reporting across address families and helps userspace consistently
> identify target-netns replies.
> 
> Emit IFA_TARGET_NETNSID in inet_fill_ifmcaddr() when args->netnsid >= 0,
> and initialize fillargs.netnsid = -1 in inet_ifmcaddr_notify() so that
> multicast join/leave notifications do not include IFA_TARGET_NETNSID or
> exceed their preallocated skb size.
> 
> This alignment was identified with the assistance of an LLM-based code
> review tool, confirmed in a User-Mode Linux (UML) environment where AF_INET
> RTM_GETMULTICAST dumps with IFA_TARGET_NETNSID omitted the attribute while
> AF_INET6 included it, and verified in UML that AF_INET multicast dumps
> now report IFA_TARGET_NETNSID, regular dumps without netnsid continue to
> work, and multicast join/leave notifications succeed without warning.
> 
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
> ---
> Changes in v2:
> - Target net-next as an enhancement/alignment change and drop the Fixes
>   tag, per Hangbin Liu's review.
> - Soften and clarify the commit message to reflect feature alignment with
>   inet_fill_ifaddr(), inet6_fill_ifmcaddr(), and dev_mc_fill_addr().
> - Link to v1: https://lore.kernel.org/r/20261111082222.327963-1-sunwenbo@cmss.chinamobile.com
> 
>  net/ipv4/igmp.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 144fca158adc..831d003677ba 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -1517,6 +1517,12 @@ int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
>  	ifm->ifa_scope = RT_SCOPE_UNIVERSE;
>  	ifm->ifa_index = dev->ifindex;
>  
> +	if (args->netnsid >= 0 &&
> +	    nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
> +		nlmsg_cancel(skb, nlh);
> +		return -EMSGSIZE;
> +	}
> +
>  	ci.cstamp = (READ_ONCE(im->mca_cstamp) - INITIAL_JIFFIES) * 100UL / HZ;
>  	ci.tstamp = ci.cstamp;
>  	ci.ifa_prefered = INFINITY_LIFE_TIME;
> @@ -1538,6 +1544,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
>  {
>  	struct inet_fill_args fillargs = {
>  		.event = event,
> +		.netnsid = -1,
>  	};
>  	struct net *net = dev_net(dev);
>  	struct sk_buff *skb;
> -- 
> 2.33.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Re: [PATCH net-next v2] ipv4: igmp: report IFA_TARGET_NETNSID in multicast address dumps
#15960
Author: Nicolas Dichtel
Date: Fri, 13 Nov 2026 15:01
31 lines
12942 bytes
Le 12/11/2026 ร  09:23, Wenbo Sun a รฉcritย :
> Commit eb4e17a1d915 ("netlink: support dumping IPv4 multicast addresses")
> extended RTM_GETMULTICAST to dump IPv4 multicast addresses by reusing
> inet_valid_dump_ifaddr_req(), which already accepts IFA_TARGET_NETNSID
> and switches to the target network namespace. However,
> inet_fill_ifmcaddr() does not include IFA_TARGET_NETNSID in the dump
> replies yet.
> 
> In contrast, IPv4 unicast dumps (inet_fill_ifaddr()), IPv6 multicast
> dumps (inet6_fill_ifmcaddr()), and AF_PACKET multicast dumps
> (dev_mc_fill_addr()) all report IFA_TARGET_NETNSID when a netns id is
> specified. Adding the same behavior to IPv4 multicast dumps aligns
> reporting across address families and helps userspace consistently
> identify target-netns replies.
> 
> Emit IFA_TARGET_NETNSID in inet_fill_ifmcaddr() when args->netnsid >= 0,
> and initialize fillargs.netnsid = -1 in inet_ifmcaddr_notify() so that
> multicast join/leave notifications do not include IFA_TARGET_NETNSID or
> exceed their preallocated skb size.
> 
> This alignment was identified with the assistance of an LLM-based code
> review tool, confirmed in a User-Mode Linux (UML) environment where AF_INET
> RTM_GETMULTICAST dumps with IFA_TARGET_NETNSID omitted the attribute while
> AF_INET6 included it, and verified in UML that AF_INET multicast dumps
> now report IFA_TARGET_NETNSID, regular dumps without netnsid continue to
> work, and multicast join/leave notifications succeed without warning.
> 
> Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>

Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Re: [PATCH net-next v2] ipv4: igmp: report IFA_TARGET_NETNSID in multicast address dumps
#17835
Author: patchwork-bot+netdevbpf
Date: Tue, 17 Nov 2026 12:10
24 lines
9020 bytes
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu, 12 Nov 2026 16:23:52 +0800 you wrote:
> Commit eb4e17a1d915 ("netlink: support dumping IPv4 multicast addresses")
> extended RTM_GETMULTICAST to dump IPv4 multicast addresses by reusing
> inet_valid_dump_ifaddr_req(), which already accepts IFA_TARGET_NETNSID
> and switches to the target network namespace. However,
> inet_fill_ifmcaddr() does not include IFA_TARGET_NETNSID in the dump
> replies yet.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] ipv4: igmp: report IFA_TARGET_NETNSID in multicast address dumps
    https://git.kernel.org/netdev/net-next/c/400bd920a724

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads