netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
@ 2019-08-13 13:52 Hangbin Liu
  2019-08-20  0:32 ` David Miller
  2019-08-20  2:19 ` [PATCHv2 " Hangbin Liu
  0 siblings, 2 replies; 7+ messages in thread
From: Hangbin Liu @ 2019-08-13 13:52 UTC (permalink / raw)
  To: netdev
  Cc: Madhu Challa, David Ahern, David S . Miller, Jianlin Shi, Hangbin Liu

The ip address autojoin is not working for IPv6 as ipv6_add_addr()
will return -EADDRNOTAVAIL when adding a multicast address.

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 93a714d6b53d ("multicast: Extend ip address command to enable multicast group join/leave on")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/addrconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index dc73888c7859..ced995f3fec4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1045,7 +1045,8 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
 	int err = 0;
 
 	if (addr_type == IPV6_ADDR_ANY ||
-	    addr_type & IPV6_ADDR_MULTICAST ||
+	    (addr_type & IPV6_ADDR_MULTICAST &&
+	     !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) ||
 	    (!(idev->dev->flags & IFF_LOOPBACK) &&
 	     !netif_is_l3_master(idev->dev) &&
 	     addr_type & IPV6_ADDR_LOOPBACK))
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-13 13:52 [PATCH net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set Hangbin Liu
@ 2019-08-20  0:32 ` David Miller
  2019-08-20  2:19 ` [PATCHv2 " Hangbin Liu
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2019-08-20  0:32 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, challa, dsahern, jishi

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Tue, 13 Aug 2019 21:52:32 +0800

> The ip address autojoin is not working for IPv6 as ipv6_add_addr()
> will return -EADDRNOTAVAIL when adding a multicast address.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 93a714d6b53d ("multicast: Extend ip address command to enable multicast group join/leave on")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

I don't understand how all of this works and why ipv6_add_addr(), which
seems designed explicitly to exclude multicast addresses, should accept
them and what all of the possible fallout might be from such a change.

Your commit message is way too terse and makes it impossible to evaluate
your change.  Really, a change of this nature should have a couple paragraphs
of text explaining the existing situation, what is wrong with it, how you
are fixing it, and why you are fixing it that way.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv2 net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-13 13:52 [PATCH net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set Hangbin Liu
  2019-08-20  0:32 ` David Miller
@ 2019-08-20  2:19 ` Hangbin Liu
  2019-08-20  2:33   ` David Ahern
  2019-08-22  3:40   ` David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Hangbin Liu @ 2019-08-20  2:19 UTC (permalink / raw)
  To: netdev
  Cc: Madhu Challa, David Ahern, David S . Miller, Jianlin Shi, Hangbin Liu

In commit 93a714d6b53d ("multicast: Extend ip address command to enable
multicast group join/leave on") we added a new flag IFA_F_MCAUTOJOIN
to make user able to add multicast address on ethernet interface.

This works for IPv4, but not for IPv6. See the inet6_addr_add code.

static int inet6_addr_add()
{
	...
	if (cfg->ifa_flags & IFA_F_MCAUTOJOIN) {
		ipv6_mc_config(net->ipv6.mc_autojoin_sk, true...)
	}

	ifp = ipv6_add_addr(idev, cfg, true, extack); <- always fail with maddr
	if (!IS_ERR(ifp)) {
		...
	} else if (cfg->ifa_flags & IFA_F_MCAUTOJOIN) {
		ipv6_mc_config(net->ipv6.mc_autojoin_sk, false...)
	}
}

But in ipv6_add_addr() it will check the address type and reject multicast
address directly. So this feature is never worked for IPv6.

We should not remove the multicast address check totally in ipv6_add_addr(),
but could accept multicast address only when IFA_F_MCAUTOJOIN flag supplied.

v2: update commit description

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 93a714d6b53d ("multicast: Extend ip address command to enable multicast group join/leave on")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/addrconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index dc73888c7859..ced995f3fec4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1045,7 +1045,8 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
 	int err = 0;
 
 	if (addr_type == IPV6_ADDR_ANY ||
-	    addr_type & IPV6_ADDR_MULTICAST ||
+	    (addr_type & IPV6_ADDR_MULTICAST &&
+	     !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) ||
 	    (!(idev->dev->flags & IFF_LOOPBACK) &&
 	     !netif_is_l3_master(idev->dev) &&
 	     addr_type & IPV6_ADDR_LOOPBACK))
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-20  2:19 ` [PATCHv2 " Hangbin Liu
@ 2019-08-20  2:33   ` David Ahern
  2019-08-22  8:20     ` Hangbin Liu
  2019-08-22  3:40   ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: David Ahern @ 2019-08-20  2:33 UTC (permalink / raw)
  To: Hangbin Liu, netdev; +Cc: Madhu Challa, David S . Miller, Jianlin Shi

On 8/19/19 10:19 PM, Hangbin Liu wrote:
> But in ipv6_add_addr() it will check the address type and reject multicast
> address directly. So this feature is never worked for IPv6.

If true, that is really disappointing.

We need to get a functional test script started for various address cases.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-20  2:19 ` [PATCHv2 " Hangbin Liu
  2019-08-20  2:33   ` David Ahern
@ 2019-08-22  3:40   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2019-08-22  3:40 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, challa, dsahern, jishi

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Tue, 20 Aug 2019 10:19:47 +0800

> In commit 93a714d6b53d ("multicast: Extend ip address command to enable
> multicast group join/leave on") we added a new flag IFA_F_MCAUTOJOIN
> to make user able to add multicast address on ethernet interface.
> 
> This works for IPv4, but not for IPv6. See the inet6_addr_add code.
> 
> static int inet6_addr_add()
> {
> 	...
> 	if (cfg->ifa_flags & IFA_F_MCAUTOJOIN) {
> 		ipv6_mc_config(net->ipv6.mc_autojoin_sk, true...)
> 	}
> 
> 	ifp = ipv6_add_addr(idev, cfg, true, extack); <- always fail with maddr
> 	if (!IS_ERR(ifp)) {
> 		...
> 	} else if (cfg->ifa_flags & IFA_F_MCAUTOJOIN) {
> 		ipv6_mc_config(net->ipv6.mc_autojoin_sk, false...)
> 	}
> }
> 
> But in ipv6_add_addr() it will check the address type and reject multicast
> address directly. So this feature is never worked for IPv6.
> 
> We should not remove the multicast address check totally in ipv6_add_addr(),
> but could accept multicast address only when IFA_F_MCAUTOJOIN flag supplied.
> 
> v2: update commit description
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 93a714d6b53d ("multicast: Extend ip address command to enable multicast group join/leave on")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-20  2:33   ` David Ahern
@ 2019-08-22  8:20     ` Hangbin Liu
  2019-08-23 12:41       ` David Ahern
  0 siblings, 1 reply; 7+ messages in thread
From: Hangbin Liu @ 2019-08-22  8:20 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, Madhu Challa, David S . Miller, Jianlin Shi

On Mon, Aug 19, 2019 at 10:33:58PM -0400, David Ahern wrote:
> On 8/19/19 10:19 PM, Hangbin Liu wrote:
> > But in ipv6_add_addr() it will check the address type and reject multicast
> > address directly. So this feature is never worked for IPv6.
> 
> If true, that is really disappointing.
> 
> We need to get a functional test script started for various address cases.

Do you mean an `ip addr add` testing for all kinds of address types?

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set
  2019-08-22  8:20     ` Hangbin Liu
@ 2019-08-23 12:41       ` David Ahern
  0 siblings, 0 replies; 7+ messages in thread
From: David Ahern @ 2019-08-23 12:41 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, Madhu Challa, David S . Miller, Jianlin Shi

On 8/22/19 4:20 AM, Hangbin Liu wrote:
> On Mon, Aug 19, 2019 at 10:33:58PM -0400, David Ahern wrote:
>> On 8/19/19 10:19 PM, Hangbin Liu wrote:
>>> But in ipv6_add_addr() it will check the address type and reject multicast
>>> address directly. So this feature is never worked for IPv6.
>>
>> If true, that is really disappointing.
>>
>> We need to get a functional test script started for various address cases.
> 
> Do you mean an `ip addr add` testing for all kinds of address types?
> 
yes.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-23 12:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 13:52 [PATCH net] ipv6/addrconf: allow adding multicast addr if IFA_F_MCAUTOJOIN is set Hangbin Liu
2019-08-20  0:32 ` David Miller
2019-08-20  2:19 ` [PATCHv2 " Hangbin Liu
2019-08-20  2:33   ` David Ahern
2019-08-22  8:20     ` Hangbin Liu
2019-08-23 12:41       ` David Ahern
2019-08-22  3:40   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).