]> xenbits.xensource.com Git - arm/linux.git/commit
net: Allow IP_MULTICAST_IF to set index to L3 slave
authorDavid Ahern <dsa@cumulusnetworks.com>
Thu, 29 Dec 2016 23:39:37 +0000 (15:39 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Nov 2017 08:39:11 +0000 (08:39 +0000)
commit5c68a428aaafcbab570df428910caeb364efe7d2
treeb30d4c297817e4c6154438b779e66b5484b44e76
parentd3d5e69b5e45370db9dcbc3bdde3787debcbc5bf
net: Allow IP_MULTICAST_IF to set index to L3 slave

[ Upstream commit 7bb387c5ab12aeac3d5eea28686489ff46b53ca9 ]

IP_MULTICAST_IF fails if sk_bound_dev_if is already set and the new index
does not match it. e.g.,

    ntpd[15381]: setsockopt IP_MULTICAST_IF 192.168.1.23 fails: Invalid argument

Relax the check in setsockopt to allow setting mc_index to an L3 slave if
sk_bound_dev_if points to an L3 master.

Make a similar change for IPv6. In this case change the device lookup to
take the rcu_read_lock avoiding a refcnt. The rcu lock is also needed for
the lookup of a potential L3 master device.

This really only silences a setsockopt failure since uses of mc_index are
secondary to sk_bound_dev_if if it is set. In both cases, if either index
is an L3 slave or master, lookups are directed to the same FIB table so
relaxing the check at setsockopt time causes no harm.

Patch is based on a suggested change by Darwin for a problem noted in
their code base.

Suggested-by: Darwin Dingel <darwin.dingel@alliedtelesis.co.nz>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/ip_sockglue.c
net/ipv6/ipv6_sockglue.c