aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/igmp.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7af3146939dc..5088f90835ae 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1687,24 +1687,25 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
1687{ 1687{
1688 struct inet_sock *inet = inet_sk(sk); 1688 struct inet_sock *inet = inet_sk(sk);
1689 struct ip_mc_socklist *iml, **imlp; 1689 struct ip_mc_socklist *iml, **imlp;
1690 struct in_device *in_dev;
1691 u32 group = imr->imr_multiaddr.s_addr;
1692 u32 ifindex;
1690 1693
1691 rtnl_lock(); 1694 rtnl_lock();
1695 in_dev = ip_mc_find_dev(imr);
1696 if (!in_dev) {
1697 rtnl_unlock();
1698 return -ENODEV;
1699 }
1700 ifindex = imr->imr_ifindex;
1692 for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) { 1701 for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) {
1693 if (iml->multi.imr_multiaddr.s_addr==imr->imr_multiaddr.s_addr && 1702 if (iml->multi.imr_multiaddr.s_addr == group &&
1694 iml->multi.imr_address.s_addr==imr->imr_address.s_addr && 1703 iml->multi.imr_ifindex == ifindex) {
1695 (!imr->imr_ifindex || iml->multi.imr_ifindex==imr->imr_ifindex)) { 1704 (void) ip_mc_leave_src(sk, iml, in_dev);
1696 struct in_device *in_dev;
1697
1698 in_dev = inetdev_by_index(iml->multi.imr_ifindex);
1699 if (in_dev)
1700 (void) ip_mc_leave_src(sk, iml, in_dev);
1701 1705
1702 *imlp = iml->next; 1706 *imlp = iml->next;
1703 1707
1704 if (in_dev) { 1708 ip_mc_dec_group(in_dev, group);
1705 ip_mc_dec_group(in_dev, imr->imr_multiaddr.s_addr);
1706 in_dev_put(in_dev);
1707 }
1708 rtnl_unlock(); 1709 rtnl_unlock();
1709 sock_kfree_s(sk, iml, sizeof(*iml)); 1710 sock_kfree_s(sk, iml, sizeof(*iml));
1710 return 0; 1711 return 0;