Commit 8752be62 authored by Hangbin Liu's avatar Hangbin Liu Committed by Ben Hutchings

mld: do not remove mld souce list info when set link down

commit 1666d49e upstream.

This is an IPv6 version of commit 24803f38 ("igmp: do not remove igmp
souce list..."). In mld_del_delrec(), we will restore back all source filter
info instead of flush them.

Move mld_clear_delrec() from ipv6_mc_down() to ipv6_mc_destroy_dev() since
we should not remove source list info when set link down. Remove
igmp6_group_dropped() in ipv6_mc_destroy_dev() since we have called it in
ipv6_mc_down().

Also clear all source info after igmp6_group_dropped() instead of in it
because ipv6_mc_down() will call igmp6_group_dropped().
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent b38c6e0b
...@@ -93,7 +93,7 @@ static void mld_gq_timer_expire(unsigned long data); ...@@ -93,7 +93,7 @@ static void mld_gq_timer_expire(unsigned long data);
static void mld_ifc_timer_expire(unsigned long data); static void mld_ifc_timer_expire(unsigned long data);
static void mld_ifc_event(struct inet6_dev *idev); static void mld_ifc_event(struct inet6_dev *idev);
static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc); static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *addr); static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
static void mld_clear_delrec(struct inet6_dev *idev); static void mld_clear_delrec(struct inet6_dev *idev);
static bool mld_in_v1_mode(const struct inet6_dev *idev); static bool mld_in_v1_mode(const struct inet6_dev *idev);
static int sf_setstate(struct ifmcaddr6 *pmc); static int sf_setstate(struct ifmcaddr6 *pmc);
...@@ -727,9 +727,9 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc) ...@@ -727,9 +727,9 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
dev_mc_del(dev, buf); dev_mc_del(dev, buf);
} }
if (mc->mca_flags & MAF_NOREPORT)
goto done;
spin_unlock_bh(&mc->mca_lock); spin_unlock_bh(&mc->mca_lock);
if (mc->mca_flags & MAF_NOREPORT)
return;
if (!mc->idev->dead) if (!mc->idev->dead)
igmp6_leave_group(mc); igmp6_leave_group(mc);
...@@ -737,8 +737,6 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc) ...@@ -737,8 +737,6 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
spin_lock_bh(&mc->mca_lock); spin_lock_bh(&mc->mca_lock);
if (del_timer(&mc->mca_timer)) if (del_timer(&mc->mca_timer))
atomic_dec(&mc->mca_refcnt); atomic_dec(&mc->mca_refcnt);
done:
ip6_mc_clear_src(mc);
spin_unlock_bh(&mc->mca_lock); spin_unlock_bh(&mc->mca_lock);
} }
...@@ -783,10 +781,11 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im) ...@@ -783,10 +781,11 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
spin_unlock_bh(&idev->mc_lock); spin_unlock_bh(&idev->mc_lock);
} }
static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *pmca) static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
{ {
struct ifmcaddr6 *pmc, *pmc_prev; struct ifmcaddr6 *pmc, *pmc_prev;
struct ip6_sf_list *psf, *psf_next; struct ip6_sf_list *psf;
struct in6_addr *pmca = &im->mca_addr;
spin_lock_bh(&idev->mc_lock); spin_lock_bh(&idev->mc_lock);
pmc_prev = NULL; pmc_prev = NULL;
...@@ -803,14 +802,20 @@ static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *pmca) ...@@ -803,14 +802,20 @@ static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *pmca)
} }
spin_unlock_bh(&idev->mc_lock); spin_unlock_bh(&idev->mc_lock);
spin_lock_bh(&im->mca_lock);
if (pmc) { if (pmc) {
for (psf=pmc->mca_tomb; psf; psf=psf_next) { im->idev = pmc->idev;
psf_next = psf->sf_next; im->mca_crcount = idev->mc_qrv;
kfree(psf); im->mca_sfmode = pmc->mca_sfmode;
if (pmc->mca_sfmode == MCAST_INCLUDE) {
im->mca_tomb = pmc->mca_tomb;
im->mca_sources = pmc->mca_sources;
for (psf = im->mca_sources; psf; psf = psf->sf_next)
psf->sf_crcount = im->mca_crcount;
} }
in6_dev_put(pmc->idev); in6_dev_put(pmc->idev);
kfree(pmc);
} }
spin_unlock_bh(&im->mca_lock);
} }
static void mld_clear_delrec(struct inet6_dev *idev) static void mld_clear_delrec(struct inet6_dev *idev)
...@@ -915,7 +920,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr) ...@@ -915,7 +920,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
idev->mc_list = mc; idev->mc_list = mc;
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
mld_del_delrec(idev, &mc->mca_addr); mld_del_delrec(idev, mc);
igmp6_group_added(mc); igmp6_group_added(mc);
ma_put(mc); ma_put(mc);
return 0; return 0;
...@@ -938,6 +943,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr) ...@@ -938,6 +943,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
igmp6_group_dropped(ma); igmp6_group_dropped(ma);
ip6_mc_clear_src(ma);
ma_put(ma); ma_put(ma);
return 0; return 0;
...@@ -2479,15 +2485,17 @@ void ipv6_mc_down(struct inet6_dev *idev) ...@@ -2479,15 +2485,17 @@ void ipv6_mc_down(struct inet6_dev *idev)
/* Withdraw multicast list */ /* Withdraw multicast list */
read_lock_bh(&idev->lock); read_lock_bh(&idev->lock);
mld_ifc_stop_timer(idev);
mld_gq_stop_timer(idev);
mld_dad_stop_timer(idev);
for (i = idev->mc_list; i; i=i->next) for (i = idev->mc_list; i; i=i->next)
igmp6_group_dropped(i); igmp6_group_dropped(i);
read_unlock_bh(&idev->lock);
mld_clear_delrec(idev); /* Should stop timer after group drop. or we will
* start timer again in mld_ifc_event()
*/
mld_ifc_stop_timer(idev);
mld_gq_stop_timer(idev);
mld_dad_stop_timer(idev);
read_unlock_bh(&idev->lock);
} }
...@@ -2500,8 +2508,10 @@ void ipv6_mc_up(struct inet6_dev *idev) ...@@ -2500,8 +2508,10 @@ void ipv6_mc_up(struct inet6_dev *idev)
/* Install multicast list, except for all-nodes (already installed) */ /* Install multicast list, except for all-nodes (already installed) */
read_lock_bh(&idev->lock); read_lock_bh(&idev->lock);
for (i = idev->mc_list; i; i=i->next) for (i = idev->mc_list; i; i = i->next) {
mld_del_delrec(idev, i);
igmp6_group_added(i); igmp6_group_added(i);
}
read_unlock_bh(&idev->lock); read_unlock_bh(&idev->lock);
} }
...@@ -2540,6 +2550,7 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev) ...@@ -2540,6 +2550,7 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
/* Deactivate timers */ /* Deactivate timers */
ipv6_mc_down(idev); ipv6_mc_down(idev);
mld_clear_delrec(idev);
/* Delete all-nodes address. */ /* Delete all-nodes address. */
/* We cannot call ipv6_dev_mc_dec() directly, our caller in /* We cannot call ipv6_dev_mc_dec() directly, our caller in
...@@ -2554,11 +2565,9 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev) ...@@ -2554,11 +2565,9 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
write_lock_bh(&idev->lock); write_lock_bh(&idev->lock);
while ((i = idev->mc_list) != NULL) { while ((i = idev->mc_list) != NULL) {
idev->mc_list = i->next; idev->mc_list = i->next;
write_unlock_bh(&idev->lock);
igmp6_group_dropped(i); write_unlock_bh(&idev->lock);
ma_put(i); ma_put(i);
write_lock_bh(&idev->lock); write_lock_bh(&idev->lock);
} }
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment