• Home
  • Raw
  • Download

Lines Matching refs:pmc

170 static int sf_setstate(struct ip_mc_list *pmc);
171 static void sf_markstate(struct ip_mc_list *pmc);
173 static void ip_mc_clear_src(struct ip_mc_list *pmc);
185 #define for_each_pmc_rcu(in_dev, pmc) \ argument
186 for (pmc = rcu_dereference(in_dev->mc_list); \
187 pmc != NULL; \
188 pmc = rcu_dereference(pmc->next_rcu))
190 #define for_each_pmc_rtnl(in_dev, pmc) \ argument
191 for (pmc = rtnl_dereference(in_dev->mc_list); \
192 pmc != NULL; \
193 pmc = rtnl_dereference(pmc->next_rcu))
264 static int is_in(struct ip_mc_list *pmc, struct ip_sf_list *psf, int type, in is_in() argument
272 if (!(pmc->gsquery && !psf->sf_gsresp)) { in is_in()
273 if (pmc->sfmode == MCAST_INCLUDE) in is_in()
280 return pmc->sfcount[MCAST_EXCLUDE] == in is_in()
291 if (pmc->sfcount[MCAST_EXCLUDE] == 0 || in is_in()
294 return pmc->sfcount[MCAST_EXCLUDE] == in is_in()
299 return (pmc->sfmode == MCAST_INCLUDE) ^ sdeleted; in is_in()
301 if (pmc->sfmode == MCAST_INCLUDE) in is_in()
309 igmp_scount(struct ip_mc_list *pmc, int type, int gdeleted, int sdeleted) in igmp_scount() argument
314 for (psf = pmc->sources; psf; psf = psf->sf_next) { in igmp_scount()
315 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) in igmp_scount()
417 static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel) in grec_size() argument
419 return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc, type, gdel, sdel); in grec_size()
422 static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc, in add_grhead() argument
425 struct net_device *dev = pmc->interface->dev; in add_grhead()
438 pgr->grec_mca = pmc->multiaddr; in add_grhead()
447 static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, in add_grec() argument
450 struct net_device *dev = pmc->interface->dev; in add_grec()
457 if (pmc->multiaddr == IGMP_ALL_HOSTS) in add_grec()
471 psf_list = sdeleted ? &pmc->tomb : &pmc->sources; in add_grec()
481 AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) { in add_grec()
494 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) { in add_grec()
516 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
544 if (pmc->crcount || isquery) { in add_grec()
550 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
557 pmc->gsquery = 0; /* clear query state on report */ in add_grec()
561 static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc) in igmpv3_send_report() argument
566 if (!pmc) { in igmpv3_send_report()
568 for_each_pmc_rcu(in_dev, pmc) { in igmpv3_send_report()
569 if (pmc->multiaddr == IGMP_ALL_HOSTS) in igmpv3_send_report()
571 spin_lock_bh(&pmc->lock); in igmpv3_send_report()
572 if (pmc->sfcount[MCAST_EXCLUDE]) in igmpv3_send_report()
576 skb = add_grec(skb, pmc, type, 0, 0); in igmpv3_send_report()
577 spin_unlock_bh(&pmc->lock); in igmpv3_send_report()
581 spin_lock_bh(&pmc->lock); in igmpv3_send_report()
582 if (pmc->sfcount[MCAST_EXCLUDE]) in igmpv3_send_report()
586 skb = add_grec(skb, pmc, type, 0, 0); in igmpv3_send_report()
587 spin_unlock_bh(&pmc->lock); in igmpv3_send_report()
617 struct ip_mc_list *pmc, *pmc_prev, *pmc_next; in igmpv3_send_cr() local
626 for (pmc = in_dev->mc_tomb; pmc; pmc = pmc_next) { in igmpv3_send_cr()
627 pmc_next = pmc->next; in igmpv3_send_cr()
628 if (pmc->sfmode == MCAST_INCLUDE) { in igmpv3_send_cr()
631 skb = add_grec(skb, pmc, type, 1, 0); in igmpv3_send_cr()
632 skb = add_grec(skb, pmc, dtype, 1, 1); in igmpv3_send_cr()
634 if (pmc->crcount) { in igmpv3_send_cr()
635 if (pmc->sfmode == MCAST_EXCLUDE) { in igmpv3_send_cr()
637 skb = add_grec(skb, pmc, type, 1, 0); in igmpv3_send_cr()
639 pmc->crcount--; in igmpv3_send_cr()
640 if (pmc->crcount == 0) { in igmpv3_send_cr()
641 igmpv3_clear_zeros(&pmc->tomb); in igmpv3_send_cr()
642 igmpv3_clear_zeros(&pmc->sources); in igmpv3_send_cr()
645 if (pmc->crcount == 0 && !pmc->tomb && !pmc->sources) { in igmpv3_send_cr()
650 in_dev_put(pmc->interface); in igmpv3_send_cr()
651 kfree(pmc); in igmpv3_send_cr()
653 pmc_prev = pmc; in igmpv3_send_cr()
658 for_each_pmc_rcu(in_dev, pmc) { in igmpv3_send_cr()
659 spin_lock_bh(&pmc->lock); in igmpv3_send_cr()
660 if (pmc->sfcount[MCAST_EXCLUDE]) { in igmpv3_send_cr()
667 skb = add_grec(skb, pmc, type, 0, 0); in igmpv3_send_cr()
668 skb = add_grec(skb, pmc, dtype, 0, 1); /* deleted sources */ in igmpv3_send_cr()
671 if (pmc->crcount) { in igmpv3_send_cr()
672 if (pmc->sfmode == MCAST_EXCLUDE) in igmpv3_send_cr()
676 skb = add_grec(skb, pmc, type, 0, 0); in igmpv3_send_cr()
677 pmc->crcount--; in igmpv3_send_cr()
679 spin_unlock_bh(&pmc->lock); in igmpv3_send_cr()
688 static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, in igmp_send_report() argument
697 __be32 group = pmc ? pmc->multiaddr : 0; in igmp_send_report()
703 return igmpv3_send_report(in_dev, pmc); in igmp_send_report()
813 static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs) in igmp_xmarksources() argument
819 for (psf = pmc->sources; psf; psf = psf->sf_next) { in igmp_xmarksources()
825 pmc->sfcount[MCAST_EXCLUDE] != in igmp_xmarksources()
834 pmc->gsquery = 0; in igmp_xmarksources()
840 static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs) in igmp_marksources() argument
845 if (pmc->sfmode == MCAST_EXCLUDE) in igmp_marksources()
846 return igmp_xmarksources(pmc, nsrcs, srcs); in igmp_marksources()
850 for (psf = pmc->sources; psf; psf = psf->sf_next) { in igmp_marksources()
861 pmc->gsquery = 0; in igmp_marksources()
864 pmc->gsquery = 1; in igmp_marksources()
1096 struct ip_mc_list *pmc; in igmpv3_add_delrec() local
1104 pmc = kzalloc(sizeof(*pmc), GFP_KERNEL); in igmpv3_add_delrec()
1105 if (!pmc) in igmpv3_add_delrec()
1107 spin_lock_init(&pmc->lock); in igmpv3_add_delrec()
1109 pmc->interface = im->interface; in igmpv3_add_delrec()
1111 pmc->multiaddr = im->multiaddr; in igmpv3_add_delrec()
1112 pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; in igmpv3_add_delrec()
1113 pmc->sfmode = im->sfmode; in igmpv3_add_delrec()
1114 if (pmc->sfmode == MCAST_INCLUDE) { in igmpv3_add_delrec()
1117 pmc->tomb = im->tomb; in igmpv3_add_delrec()
1118 pmc->sources = im->sources; in igmpv3_add_delrec()
1120 for (psf = pmc->sources; psf; psf = psf->sf_next) in igmpv3_add_delrec()
1121 psf->sf_crcount = pmc->crcount; in igmpv3_add_delrec()
1126 pmc->next = in_dev->mc_tomb; in igmpv3_add_delrec()
1127 in_dev->mc_tomb = pmc; in igmpv3_add_delrec()
1133 struct ip_mc_list *pmc, *pmc_prev; in igmpv3_del_delrec() local
1138 for (pmc = in_dev->mc_tomb; pmc; pmc = pmc->next) { in igmpv3_del_delrec()
1139 if (pmc->multiaddr == multiaddr) in igmpv3_del_delrec()
1141 pmc_prev = pmc; in igmpv3_del_delrec()
1143 if (pmc) { in igmpv3_del_delrec()
1145 pmc_prev->next = pmc->next; in igmpv3_del_delrec()
1147 in_dev->mc_tomb = pmc->next; in igmpv3_del_delrec()
1150 if (pmc) { in igmpv3_del_delrec()
1151 for (psf = pmc->tomb; psf; psf = psf_next) { in igmpv3_del_delrec()
1155 in_dev_put(pmc->interface); in igmpv3_del_delrec()
1156 kfree(pmc); in igmpv3_del_delrec()
1162 struct ip_mc_list *pmc, *nextpmc; in igmpv3_clear_delrec() local
1165 pmc = in_dev->mc_tomb; in igmpv3_clear_delrec()
1169 for (; pmc; pmc = nextpmc) { in igmpv3_clear_delrec()
1170 nextpmc = pmc->next; in igmpv3_clear_delrec()
1171 ip_mc_clear_src(pmc); in igmpv3_clear_delrec()
1172 in_dev_put(pmc->interface); in igmpv3_clear_delrec()
1173 kfree(pmc); in igmpv3_clear_delrec()
1177 for_each_pmc_rcu(in_dev, pmc) { in igmpv3_clear_delrec()
1180 spin_lock_bh(&pmc->lock); in igmpv3_clear_delrec()
1181 psf = pmc->tomb; in igmpv3_clear_delrec()
1182 pmc->tomb = NULL; in igmpv3_clear_delrec()
1183 spin_unlock_bh(&pmc->lock); in igmpv3_clear_delrec()
1433 struct ip_mc_list *pmc; in ip_mc_unmap() local
1437 for_each_pmc_rtnl(in_dev, pmc) in ip_mc_unmap()
1438 igmp_group_dropped(pmc); in ip_mc_unmap()
1443 struct ip_mc_list *pmc; in ip_mc_remap() local
1447 for_each_pmc_rtnl(in_dev, pmc) in ip_mc_remap()
1448 igmp_group_added(pmc); in ip_mc_remap()
1455 struct ip_mc_list *pmc; in ip_mc_down() local
1459 for_each_pmc_rtnl(in_dev, pmc) in ip_mc_down()
1460 igmp_group_dropped(pmc); in ip_mc_down()
1494 struct ip_mc_list *pmc; in ip_mc_up() local
1503 for_each_pmc_rtnl(in_dev, pmc) in ip_mc_up()
1504 igmp_group_added(pmc); in ip_mc_up()
1571 static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, in ip_mc_del1_src() argument
1578 for (psf = pmc->sources; psf; psf = psf->sf_next) { in ip_mc_del1_src()
1589 ip_rt_multicast_event(pmc->interface); in ip_mc_del1_src()
1593 struct in_device *in_dev = pmc->interface; in ip_mc_del1_src()
1600 pmc->sources = psf->sf_next; in ip_mc_del1_src()
1605 psf->sf_next = pmc->tomb; in ip_mc_del1_src()
1606 pmc->tomb = psf; in ip_mc_del1_src()
1622 struct ip_mc_list *pmc; in ip_mc_del_src() local
1629 for_each_pmc_rcu(in_dev, pmc) { in ip_mc_del_src()
1630 if (*pmca == pmc->multiaddr) in ip_mc_del_src()
1633 if (!pmc) { in ip_mc_del_src()
1638 spin_lock_bh(&pmc->lock); in ip_mc_del_src()
1641 sf_markstate(pmc); in ip_mc_del_src()
1645 if (!pmc->sfcount[sfmode]) in ip_mc_del_src()
1647 pmc->sfcount[sfmode]--; in ip_mc_del_src()
1651 int rv = ip_mc_del1_src(pmc, sfmode, &psfsrc[i]); in ip_mc_del_src()
1657 if (pmc->sfmode == MCAST_EXCLUDE && in ip_mc_del_src()
1658 pmc->sfcount[MCAST_EXCLUDE] == 0 && in ip_mc_del_src()
1659 pmc->sfcount[MCAST_INCLUDE]) { in ip_mc_del_src()
1665 pmc->sfmode = MCAST_INCLUDE; in ip_mc_del_src()
1667 pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; in ip_mc_del_src()
1668 in_dev->mr_ifc_count = pmc->crcount; in ip_mc_del_src()
1669 for (psf = pmc->sources; psf; psf = psf->sf_next) in ip_mc_del_src()
1671 igmp_ifc_event(pmc->interface); in ip_mc_del_src()
1672 } else if (sf_setstate(pmc) || changerec) { in ip_mc_del_src()
1673 igmp_ifc_event(pmc->interface); in ip_mc_del_src()
1677 spin_unlock_bh(&pmc->lock); in ip_mc_del_src()
1684 static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode, in ip_mc_add1_src() argument
1690 for (psf = pmc->sources; psf; psf = psf->sf_next) { in ip_mc_add1_src()
1703 pmc->sources = psf; in ip_mc_add1_src()
1707 ip_rt_multicast_event(pmc->interface); in ip_mc_add1_src()
1713 static void sf_markstate(struct ip_mc_list *pmc) in sf_markstate() argument
1716 int mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; in sf_markstate()
1718 for (psf = pmc->sources; psf; psf = psf->sf_next) in sf_markstate()
1719 if (pmc->sfcount[MCAST_EXCLUDE]) { in sf_markstate()
1727 static int sf_setstate(struct ip_mc_list *pmc) in sf_setstate() argument
1730 int mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; in sf_setstate()
1731 int qrv = pmc->interface->mr_qrv; in sf_setstate()
1735 for (psf = pmc->sources; psf; psf = psf->sf_next) { in sf_setstate()
1736 if (pmc->sfcount[MCAST_EXCLUDE]) { in sf_setstate()
1745 for (dpsf = pmc->tomb; dpsf; dpsf = dpsf->sf_next) { in sf_setstate()
1754 pmc->tomb = dpsf->sf_next; in sf_setstate()
1767 for (dpsf = pmc->tomb; dpsf; dpsf = dpsf->sf_next) in sf_setstate()
1776 dpsf->sf_next = pmc->tomb; in sf_setstate()
1777 pmc->tomb = dpsf; in sf_setstate()
1793 struct ip_mc_list *pmc; in ip_mc_add_src() local
1800 for_each_pmc_rcu(in_dev, pmc) { in ip_mc_add_src()
1801 if (*pmca == pmc->multiaddr) in ip_mc_add_src()
1804 if (!pmc) { in ip_mc_add_src()
1809 spin_lock_bh(&pmc->lock); in ip_mc_add_src()
1813 sf_markstate(pmc); in ip_mc_add_src()
1815 isexclude = pmc->sfmode == MCAST_EXCLUDE; in ip_mc_add_src()
1817 pmc->sfcount[sfmode]++; in ip_mc_add_src()
1820 err = ip_mc_add1_src(pmc, sfmode, &psfsrc[i]); in ip_mc_add_src()
1828 pmc->sfcount[sfmode]--; in ip_mc_add_src()
1830 (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[j]); in ip_mc_add_src()
1831 } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) { in ip_mc_add_src()
1834 in_dev = pmc->interface; in ip_mc_add_src()
1838 if (pmc->sfcount[MCAST_EXCLUDE]) in ip_mc_add_src()
1839 pmc->sfmode = MCAST_EXCLUDE; in ip_mc_add_src()
1840 else if (pmc->sfcount[MCAST_INCLUDE]) in ip_mc_add_src()
1841 pmc->sfmode = MCAST_INCLUDE; in ip_mc_add_src()
1845 pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; in ip_mc_add_src()
1846 in_dev->mr_ifc_count = pmc->crcount; in ip_mc_add_src()
1847 for (psf = pmc->sources; psf; psf = psf->sf_next) in ip_mc_add_src()
1850 } else if (sf_setstate(pmc)) { in ip_mc_add_src()
1854 spin_unlock_bh(&pmc->lock); in ip_mc_add_src()
1858 static void ip_mc_clear_src(struct ip_mc_list *pmc) in ip_mc_clear_src() argument
1862 spin_lock_bh(&pmc->lock); in ip_mc_clear_src()
1863 tomb = pmc->tomb; in ip_mc_clear_src()
1864 pmc->tomb = NULL; in ip_mc_clear_src()
1865 sources = pmc->sources; in ip_mc_clear_src()
1866 pmc->sources = NULL; in ip_mc_clear_src()
1867 pmc->sfmode = MCAST_EXCLUDE; in ip_mc_clear_src()
1868 pmc->sfcount[MCAST_INCLUDE] = 0; in ip_mc_clear_src()
1869 pmc->sfcount[MCAST_EXCLUDE] = 1; in ip_mc_clear_src()
1870 spin_unlock_bh(&pmc->lock); in ip_mc_clear_src()
2015 struct ip_mc_socklist *pmc; in ip_mc_source() local
2039 for_each_pmc_rtnl(inet, pmc) { in ip_mc_source()
2040 if ((pmc->multi.imr_multiaddr.s_addr == in ip_mc_source()
2042 (pmc->multi.imr_ifindex == imr.imr_ifindex)) in ip_mc_source()
2045 if (!pmc) { /* must have a prior join */ in ip_mc_source()
2050 if (pmc->sflist) { in ip_mc_source()
2051 if (pmc->sfmode != omode) { in ip_mc_source()
2055 } else if (pmc->sfmode != omode) { in ip_mc_source()
2058 ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0, in ip_mc_source()
2060 pmc->sfmode = omode; in ip_mc_source()
2063 psl = rtnl_dereference(pmc->sflist); in ip_mc_source()
2119 rcu_assign_pointer(pmc->sflist, newpsl); in ip_mc_source()
2151 struct ip_mc_socklist *pmc; in ip_mc_msfilter() local
2182 for_each_pmc_rtnl(inet, pmc) { in ip_mc_msfilter()
2183 if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr && in ip_mc_msfilter()
2184 pmc->multi.imr_ifindex == imr.imr_ifindex) in ip_mc_msfilter()
2187 if (!pmc) { /* must have a prior join */ in ip_mc_msfilter()
2212 psl = rtnl_dereference(pmc->sflist); in ip_mc_msfilter()
2214 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, in ip_mc_msfilter()
2220 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, in ip_mc_msfilter()
2222 rcu_assign_pointer(pmc->sflist, newpsl); in ip_mc_msfilter()
2223 pmc->sfmode = msf->imsf_fmode; in ip_mc_msfilter()
2238 struct ip_mc_socklist *pmc; in ip_mc_msfget() local
2260 for_each_pmc_rtnl(inet, pmc) { in ip_mc_msfget()
2261 if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr && in ip_mc_msfget()
2262 pmc->multi.imr_ifindex == imr.imr_ifindex) in ip_mc_msfget()
2265 if (!pmc) /* must have a prior join */ in ip_mc_msfget()
2267 msf->imsf_fmode = pmc->sfmode; in ip_mc_msfget()
2268 psl = rtnl_dereference(pmc->sflist); in ip_mc_msfget()
2298 struct ip_mc_socklist *pmc; in ip_mc_gsfget() local
2313 for_each_pmc_rtnl(inet, pmc) { in ip_mc_gsfget()
2314 if (pmc->multi.imr_multiaddr.s_addr == addr && in ip_mc_gsfget()
2315 pmc->multi.imr_ifindex == gsf->gf_interface) in ip_mc_gsfget()
2318 if (!pmc) /* must have a prior join */ in ip_mc_gsfget()
2320 gsf->gf_fmode = pmc->sfmode; in ip_mc_gsfget()
2321 psl = rtnl_dereference(pmc->sflist); in ip_mc_gsfget()
2352 struct ip_mc_socklist *pmc; in ip_mc_sf_allow() local
2362 for_each_pmc_rcu(inet, pmc) { in ip_mc_sf_allow()
2363 if (pmc->multi.imr_multiaddr.s_addr == loc_addr && in ip_mc_sf_allow()
2364 pmc->multi.imr_ifindex == dif) in ip_mc_sf_allow()
2368 if (!pmc) in ip_mc_sf_allow()
2370 psl = rcu_dereference(pmc->sflist); in ip_mc_sf_allow()
2371 ret = (pmc->sfmode == MCAST_EXCLUDE); in ip_mc_sf_allow()
2380 if (pmc->sfmode == MCAST_INCLUDE && i >= psl->sl_count) in ip_mc_sf_allow()
2382 if (pmc->sfmode == MCAST_EXCLUDE && i < psl->sl_count) in ip_mc_sf_allow()