Lines Matching refs:pmc
79 static int sf_setstate(struct ifmcaddr6 *pmc);
80 static void sf_markstate(struct ifmcaddr6 *pmc);
81 static void ip6_mc_clear_src(struct ifmcaddr6 *pmc);
117 #define for_each_pmc_socklock(np, sk, pmc) \ argument
118 for (pmc = sock_dereference((np)->ipv6_mc_list, sk); \
119 pmc; \
120 pmc = sock_dereference(pmc->next, sk))
122 #define for_each_pmc_rcu(np, pmc) \ argument
123 for (pmc = rcu_dereference((np)->ipv6_mc_list); \
124 pmc; \
125 pmc = rcu_dereference(pmc->next))
365 struct ipv6_mc_socklist *pmc; in ip6_mc_source() local
387 for_each_pmc_socklock(inet6, sk, pmc) { in ip6_mc_source()
388 if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) in ip6_mc_source()
390 if (ipv6_addr_equal(&pmc->addr, group)) in ip6_mc_source()
393 if (!pmc) { /* must have a prior join */ in ip6_mc_source()
398 if (rcu_access_pointer(pmc->sflist)) { in ip6_mc_source()
399 if (pmc->sfmode != omode) { in ip6_mc_source()
403 } else if (pmc->sfmode != omode) { in ip6_mc_source()
406 ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0); in ip6_mc_source()
407 pmc->sfmode = omode; in ip6_mc_source()
410 psl = sock_dereference(pmc->sflist, sk); in ip6_mc_source()
464 rcu_assign_pointer(pmc->sflist, newpsl); in ip6_mc_source()
492 struct ipv6_mc_socklist *pmc; in ip6_mc_msfilter() local
519 for_each_pmc_socklock(inet6, sk, pmc) { in ip6_mc_msfilter()
520 if (pmc->ifindex != gsf->gf_interface) in ip6_mc_msfilter()
522 if (ipv6_addr_equal(&pmc->addr, group)) in ip6_mc_msfilter()
525 if (!pmc) { /* must have a prior join */ in ip6_mc_msfilter()
562 psl = sock_dereference(pmc->sflist, sk); in ip6_mc_msfilter()
564 ip6_mc_del_src(idev, group, pmc->sfmode, in ip6_mc_msfilter()
569 ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0); in ip6_mc_msfilter()
571 rcu_assign_pointer(pmc->sflist, newpsl); in ip6_mc_msfilter()
574 pmc->sfmode = gsf->gf_fmode; in ip6_mc_msfilter()
587 struct ipv6_mc_socklist *pmc; in ip6_mc_msfget() local
600 for_each_pmc_socklock(inet6, sk, pmc) { in ip6_mc_msfget()
601 if (pmc->ifindex != gsf->gf_interface) in ip6_mc_msfget()
603 if (ipv6_addr_equal(group, &pmc->addr)) in ip6_mc_msfget()
606 if (!pmc) /* must have a prior join */ in ip6_mc_msfget()
609 gsf->gf_fmode = pmc->sfmode; in ip6_mc_msfget()
610 psl = sock_dereference(pmc->sflist, sk); in ip6_mc_msfget()
734 struct ifmcaddr6 *pmc; in mld_add_delrec() local
742 pmc = kzalloc(sizeof(*pmc), GFP_KERNEL); in mld_add_delrec()
743 if (!pmc) in mld_add_delrec()
746 pmc->idev = im->idev; in mld_add_delrec()
748 pmc->mca_addr = im->mca_addr; in mld_add_delrec()
749 pmc->mca_crcount = idev->mc_qrv; in mld_add_delrec()
750 pmc->mca_sfmode = im->mca_sfmode; in mld_add_delrec()
751 if (pmc->mca_sfmode == MCAST_INCLUDE) { in mld_add_delrec()
754 rcu_assign_pointer(pmc->mca_tomb, in mld_add_delrec()
756 rcu_assign_pointer(pmc->mca_sources, in mld_add_delrec()
761 for_each_psf_mclock(pmc, psf) in mld_add_delrec()
762 psf->sf_crcount = pmc->mca_crcount; in mld_add_delrec()
765 rcu_assign_pointer(pmc->next, idev->mc_tomb); in mld_add_delrec()
766 rcu_assign_pointer(idev->mc_tomb, pmc); in mld_add_delrec()
774 struct ifmcaddr6 *pmc, *pmc_prev; in mld_del_delrec() local
777 for_each_mc_tomb(idev, pmc) { in mld_del_delrec()
778 if (ipv6_addr_equal(&pmc->mca_addr, pmca)) in mld_del_delrec()
780 pmc_prev = pmc; in mld_del_delrec()
782 if (pmc) { in mld_del_delrec()
784 rcu_assign_pointer(pmc_prev->next, pmc->next); in mld_del_delrec()
786 rcu_assign_pointer(idev->mc_tomb, pmc->next); in mld_del_delrec()
789 if (pmc) { in mld_del_delrec()
790 im->idev = pmc->idev; in mld_del_delrec()
793 mc_dereference(pmc->mca_tomb, pmc->idev), in mld_del_delrec()
795 rcu_assign_pointer(pmc->mca_tomb, tomb); in mld_del_delrec()
798 mc_dereference(pmc->mca_sources, pmc->idev), in mld_del_delrec()
800 rcu_assign_pointer(pmc->mca_sources, sources); in mld_del_delrec()
806 in6_dev_put(pmc->idev); in mld_del_delrec()
807 ip6_mc_clear_src(pmc); in mld_del_delrec()
808 kfree_rcu(pmc, rcu); in mld_del_delrec()
815 struct ifmcaddr6 *pmc, *nextpmc; in mld_clear_delrec() local
817 pmc = mc_dereference(idev->mc_tomb, idev); in mld_clear_delrec()
820 for (; pmc; pmc = nextpmc) { in mld_clear_delrec()
821 nextpmc = mc_dereference(pmc->next, idev); in mld_clear_delrec()
822 ip6_mc_clear_src(pmc); in mld_clear_delrec()
823 in6_dev_put(pmc->idev); in mld_clear_delrec()
824 kfree_rcu(pmc, rcu); in mld_clear_delrec()
828 for_each_mc_mclock(idev, pmc) { in mld_clear_delrec()
831 psf = mc_dereference(pmc->mca_tomb, idev); in mld_clear_delrec()
832 RCU_INIT_POINTER(pmc->mca_tomb, NULL); in mld_clear_delrec()
1143 static bool mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs, in mld_xmarksources() argument
1150 for_each_psf_mclock(pmc, psf) { in mld_xmarksources()
1156 pmc->mca_sfcount[MCAST_EXCLUDE] != in mld_xmarksources()
1165 pmc->mca_flags &= ~MAF_GSQUERY; in mld_xmarksources()
1172 static bool mld_marksources(struct ifmcaddr6 *pmc, int nsrcs, in mld_marksources() argument
1178 if (pmc->mca_sfmode == MCAST_EXCLUDE) in mld_marksources()
1179 return mld_xmarksources(pmc, nsrcs, srcs); in mld_marksources()
1184 for_each_psf_mclock(pmc, psf) { in mld_marksources()
1196 pmc->mca_flags &= ~MAF_GSQUERY; in mld_marksources()
1199 pmc->mca_flags |= MAF_GSQUERY; in mld_marksources()
1644 static bool is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type, in is_in() argument
1652 if (!((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp)) { in is_in()
1653 if (pmc->mca_sfmode == MCAST_INCLUDE) in is_in()
1660 return pmc->mca_sfcount[MCAST_EXCLUDE] == in is_in()
1671 if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 || in is_in()
1674 return pmc->mca_sfcount[MCAST_EXCLUDE] == in is_in()
1679 return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted; in is_in()
1681 if (pmc->mca_sfmode == MCAST_INCLUDE) in is_in()
1689 mld_scount(struct ifmcaddr6 *pmc, int type, int gdeleted, int sdeleted) in mld_scount() argument
1694 for_each_psf_mclock(pmc, psf) { in mld_scount()
1695 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) in mld_scount()
1843 static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) in grec_size() argument
1845 return sizeof(struct mld2_grec) + 16 * mld_scount(pmc,type,gdel,sdel); in grec_size()
1848 static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc, in add_grhead() argument
1855 skb = mld_newpack(pmc->idev, mtu); in add_grhead()
1863 pgr->grec_mca = pmc->mca_addr; /* structure copy */ in add_grhead()
1873 static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, in add_grec() argument
1880 struct inet6_dev *idev = pmc->idev; in add_grec()
1886 if (pmc->mca_flags & MAF_NOREPORT) in add_grec()
1900 psf_list = sdeleted ? &pmc->mca_tomb : &pmc->mca_sources; in add_grec()
1910 AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) { in add_grec()
1925 if (!is_in(pmc, psf, type, gdeleted, sdeleted) && !crsend) { in add_grec()
1933 if (((gdeleted && pmc->mca_sfmode == MCAST_EXCLUDE) || in add_grec()
1934 (!gdeleted && pmc->mca_crcount)) && in add_grec()
1956 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
1987 if (pmc->mca_crcount || isquery || crsend) { in add_grec()
1993 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
2000 pmc->mca_flags &= ~MAF_GSQUERY; /* clear query state */ in add_grec()
2005 static void mld_send_report(struct inet6_dev *idev, struct ifmcaddr6 *pmc) in mld_send_report() argument
2010 if (!pmc) { in mld_send_report()
2011 for_each_mc_mclock(idev, pmc) { in mld_send_report()
2012 if (pmc->mca_flags & MAF_NOREPORT) in mld_send_report()
2014 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_report()
2018 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_report()
2021 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_report()
2025 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_report()
2061 struct ifmcaddr6 *pmc, *pmc_prev, *pmc_next; in mld_send_cr() local
2067 for (pmc = mc_dereference(idev->mc_tomb, idev); in mld_send_cr()
2068 pmc; in mld_send_cr()
2069 pmc = pmc_next) { in mld_send_cr()
2070 pmc_next = mc_dereference(pmc->next, idev); in mld_send_cr()
2071 if (pmc->mca_sfmode == MCAST_INCLUDE) { in mld_send_cr()
2074 skb = add_grec(skb, pmc, type, 1, 0, 0); in mld_send_cr()
2075 skb = add_grec(skb, pmc, dtype, 1, 1, 0); in mld_send_cr()
2077 if (pmc->mca_crcount) { in mld_send_cr()
2078 if (pmc->mca_sfmode == MCAST_EXCLUDE) { in mld_send_cr()
2080 skb = add_grec(skb, pmc, type, 1, 0, 0); in mld_send_cr()
2082 pmc->mca_crcount--; in mld_send_cr()
2083 if (pmc->mca_crcount == 0) { in mld_send_cr()
2084 mld_clear_zeros(&pmc->mca_tomb, idev); in mld_send_cr()
2085 mld_clear_zeros(&pmc->mca_sources, idev); in mld_send_cr()
2088 if (pmc->mca_crcount == 0 && in mld_send_cr()
2089 !rcu_access_pointer(pmc->mca_tomb) && in mld_send_cr()
2090 !rcu_access_pointer(pmc->mca_sources)) { in mld_send_cr()
2095 in6_dev_put(pmc->idev); in mld_send_cr()
2096 kfree_rcu(pmc, rcu); in mld_send_cr()
2098 pmc_prev = pmc; in mld_send_cr()
2102 for_each_mc_mclock(idev, pmc) { in mld_send_cr()
2103 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in mld_send_cr()
2110 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_cr()
2111 skb = add_grec(skb, pmc, dtype, 0, 1, 0); /* deleted sources */ in mld_send_cr()
2114 if (pmc->mca_crcount) { in mld_send_cr()
2115 if (pmc->mca_sfmode == MCAST_EXCLUDE) in mld_send_cr()
2119 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_cr()
2120 pmc->mca_crcount--; in mld_send_cr()
2226 struct ifmcaddr6 *pmc; in mld_send_initial_cr() local
2233 for_each_mc_mclock(idev, pmc) { in mld_send_initial_cr()
2234 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_initial_cr()
2238 skb = add_grec(skb, pmc, type, 0, 0, 1); in mld_send_initial_cr()
2276 static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode, in ip6_mc_del1_src() argument
2283 for_each_psf_mclock(pmc, psf) { in ip6_mc_del1_src()
2294 struct inet6_dev *idev = pmc->idev; in ip6_mc_del1_src()
2301 rcu_assign_pointer(pmc->mca_sources, in ip6_mc_del1_src()
2304 if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) && in ip6_mc_del1_src()
2308 mc_dereference(pmc->mca_tomb, idev)); in ip6_mc_del1_src()
2309 rcu_assign_pointer(pmc->mca_tomb, psf); in ip6_mc_del1_src()
2323 struct ifmcaddr6 *pmc; in ip6_mc_del_src() local
2330 for_each_mc_mclock(idev, pmc) { in ip6_mc_del_src()
2331 if (ipv6_addr_equal(pmca, &pmc->mca_addr)) in ip6_mc_del_src()
2334 if (!pmc) in ip6_mc_del_src()
2337 sf_markstate(pmc); in ip6_mc_del_src()
2339 if (!pmc->mca_sfcount[sfmode]) in ip6_mc_del_src()
2342 pmc->mca_sfcount[sfmode]--; in ip6_mc_del_src()
2346 int rv = ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]); in ip6_mc_del_src()
2352 if (pmc->mca_sfmode == MCAST_EXCLUDE && in ip6_mc_del_src()
2353 pmc->mca_sfcount[MCAST_EXCLUDE] == 0 && in ip6_mc_del_src()
2354 pmc->mca_sfcount[MCAST_INCLUDE]) { in ip6_mc_del_src()
2358 pmc->mca_sfmode = MCAST_INCLUDE; in ip6_mc_del_src()
2359 pmc->mca_crcount = idev->mc_qrv; in ip6_mc_del_src()
2360 idev->mc_ifc_count = pmc->mca_crcount; in ip6_mc_del_src()
2361 for_each_psf_mclock(pmc, psf) in ip6_mc_del_src()
2363 mld_ifc_event(pmc->idev); in ip6_mc_del_src()
2364 } else if (sf_setstate(pmc) || changerec) { in ip6_mc_del_src()
2365 mld_ifc_event(pmc->idev); in ip6_mc_del_src()
2375 static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode, in ip6_mc_add1_src() argument
2381 for_each_psf_mclock(pmc, psf) { in ip6_mc_add1_src()
2395 rcu_assign_pointer(pmc->mca_sources, psf); in ip6_mc_add1_src()
2403 static void sf_markstate(struct ifmcaddr6 *pmc) in sf_markstate() argument
2406 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE]; in sf_markstate()
2408 for_each_psf_mclock(pmc, psf) { in sf_markstate()
2409 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in sf_markstate()
2420 static int sf_setstate(struct ifmcaddr6 *pmc) in sf_setstate() argument
2423 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE]; in sf_setstate()
2424 int qrv = pmc->idev->mc_qrv; in sf_setstate()
2428 for_each_psf_mclock(pmc, psf) { in sf_setstate()
2429 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in sf_setstate()
2438 for_each_psf_tomb(pmc, dpsf) { in sf_setstate()
2448 pmc->idev)); in sf_setstate()
2450 rcu_assign_pointer(pmc->mca_tomb, in sf_setstate()
2452 pmc->idev)); in sf_setstate()
2465 for_each_psf_tomb(pmc, dpsf) in sf_setstate()
2475 mc_dereference(pmc->mca_tomb, pmc->idev)); in sf_setstate()
2476 rcu_assign_pointer(pmc->mca_tomb, dpsf); in sf_setstate()
2493 struct ifmcaddr6 *pmc; in ip6_mc_add_src() local
2500 for_each_mc_mclock(idev, pmc) { in ip6_mc_add_src()
2501 if (ipv6_addr_equal(pmca, &pmc->mca_addr)) in ip6_mc_add_src()
2504 if (!pmc) in ip6_mc_add_src()
2507 sf_markstate(pmc); in ip6_mc_add_src()
2508 isexclude = pmc->mca_sfmode == MCAST_EXCLUDE; in ip6_mc_add_src()
2510 pmc->mca_sfcount[sfmode]++; in ip6_mc_add_src()
2513 err = ip6_mc_add1_src(pmc, sfmode, &psfsrc[i]); in ip6_mc_add_src()
2521 pmc->mca_sfcount[sfmode]--; in ip6_mc_add_src()
2523 ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]); in ip6_mc_add_src()
2524 } else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) { in ip6_mc_add_src()
2528 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in ip6_mc_add_src()
2529 pmc->mca_sfmode = MCAST_EXCLUDE; in ip6_mc_add_src()
2530 else if (pmc->mca_sfcount[MCAST_INCLUDE]) in ip6_mc_add_src()
2531 pmc->mca_sfmode = MCAST_INCLUDE; in ip6_mc_add_src()
2534 pmc->mca_crcount = idev->mc_qrv; in ip6_mc_add_src()
2535 idev->mc_ifc_count = pmc->mca_crcount; in ip6_mc_add_src()
2536 for_each_psf_mclock(pmc, psf) in ip6_mc_add_src()
2539 } else if (sf_setstate(pmc)) { in ip6_mc_add_src()
2546 static void ip6_mc_clear_src(struct ifmcaddr6 *pmc) in ip6_mc_clear_src() argument
2550 for (psf = mc_dereference(pmc->mca_tomb, pmc->idev); in ip6_mc_clear_src()
2553 nextpsf = mc_dereference(psf->sf_next, pmc->idev); in ip6_mc_clear_src()
2556 RCU_INIT_POINTER(pmc->mca_tomb, NULL); in ip6_mc_clear_src()
2557 for (psf = mc_dereference(pmc->mca_sources, pmc->idev); in ip6_mc_clear_src()
2560 nextpsf = mc_dereference(psf->sf_next, pmc->idev); in ip6_mc_clear_src()
2563 RCU_INIT_POINTER(pmc->mca_sources, NULL); in ip6_mc_clear_src()
2564 pmc->mca_sfmode = MCAST_EXCLUDE; in ip6_mc_clear_src()
2565 pmc->mca_sfcount[MCAST_INCLUDE] = 0; in ip6_mc_clear_src()
2566 pmc->mca_sfcount[MCAST_EXCLUDE] = 1; in ip6_mc_clear_src()
2822 struct ifmcaddr6 *pmc; in ipv6_mc_rejoin_groups() local
2828 for_each_mc_mclock(idev, pmc) in ipv6_mc_rejoin_groups()
2829 igmp6_join_group(pmc); in ipv6_mc_rejoin_groups()