Re: [PATCH 1/1] ipv6: Add sockopt IPV6_MULTICAST_ALL analogue to IP_MULTICAST_ALL

From: Andre Naujoks
Date: Mon Sep 10 2018 - 05:30:28 EST


On 9/10/18 11:07 AM, Maciej Åenczykowski wrote:
> Any reason not to use the same bit that is used by ipv4?
> (as in add the setsockopt/getsockopt but just toggle the v4 bit)
>

I wanted to keep the current behavior for an ipv6 socket as is. I think
user space api/behavioral changes are frowned upon!?

Currently the bit is settable for an ipv6 socket and changes the
handling for ipv4 multicasts for that socket. If I had just added the
socket option and set the v4 bit, you would get maybe unexpected
behavior from that, if you used it for ipv4 multicasts.

Another approach I tried, was to just honor the v4 bit in v6 context,
like this:

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 4ae54aaca373..af1659327d46 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -636,7 +636,7 @@ bool inet6_mc_check(struct sock *sk, const struct
in6_addr *mc_addr,
}
if (!mc) {
rcu_read_unlock();
- return true;
+ return inet_sk(sk)->mc_all;
}
read_lock(&mc->sflock);
psl = mc->sflist;


But that has the same problem of changing current behavior in a possibly
unexpected way.

Regards
Andre