Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

multicast: do not restore deleted record source filter mode to new one

There are two scenarios that we will restore deleted records. The first is
when device down and up(or unmap/remap). In this scenario the new filter
mode is same with previous one. Because we get it from in_dev->mc_list and
we do not touch it during device down and up.

The other scenario is when a new socket join a group which was just delete
and not finish sending status reports. In this scenario, we should use the
current filter mode instead of restore old one. Here are 4 cases in total.

old_socket new_socket before_fix after_fix
IN(A) IN(A) ALLOW(A) ALLOW(A)
IN(A) EX( ) TO_IN( ) TO_EX( )
EX( ) IN(A) TO_EX( ) ALLOW(A)
EX( ) EX( ) TO_EX( ) TO_EX( )

Fixes: 24803f38a5c0b (igmp: do not remove igmp souce list info when set link down)
Fixes: 1666d49e1d416 (mld: do not remove mld souce list info when set link down)
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Hangbin Liu and committed by
David S. Miller
08d3ffcc 3d82475a

+2 -4
+1 -2
net/ipv4/igmp.c
··· 1200 1200 spin_lock_bh(&im->lock); 1201 1201 if (pmc) { 1202 1202 im->interface = pmc->interface; 1203 - im->sfmode = pmc->sfmode; 1204 - if (pmc->sfmode == MCAST_INCLUDE) { 1203 + if (im->sfmode == MCAST_INCLUDE) { 1205 1204 im->tomb = pmc->tomb; 1206 1205 im->sources = pmc->sources; 1207 1206 for (psf = im->sources; psf; psf = psf->sf_next)
+1 -2
net/ipv6/mcast.c
··· 790 790 spin_lock_bh(&im->mca_lock); 791 791 if (pmc) { 792 792 im->idev = pmc->idev; 793 - im->mca_sfmode = pmc->mca_sfmode; 794 - if (pmc->mca_sfmode == MCAST_INCLUDE) { 793 + if (im->mca_sfmode == MCAST_INCLUDE) { 795 794 im->mca_tomb = pmc->mca_tomb; 796 795 im->mca_sources = pmc->mca_sources; 797 796 for (psf = im->mca_sources; psf; psf = psf->sf_next)