Lines Matching refs:pmc
79 static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
80 static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc);
83 static int sf_setstate(struct ifmcaddr6 *pmc);
84 static void sf_markstate(struct ifmcaddr6 *pmc);
85 static void ip6_mc_clear_src(struct ifmcaddr6 *pmc);
116 #define for_each_pmc_rcu(np, pmc) \ argument
117 for (pmc = rcu_dereference(np->ipv6_mc_list); \
118 pmc != NULL; \
119 pmc = rcu_dereference(pmc->next))
332 struct ipv6_mc_socklist *pmc; in ip6_mc_source() local
357 for_each_pmc_rcu(inet6, pmc) { in ip6_mc_source()
358 if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) in ip6_mc_source()
360 if (ipv6_addr_equal(&pmc->addr, group)) in ip6_mc_source()
363 if (!pmc) { /* must have a prior join */ in ip6_mc_source()
368 if (pmc->sflist) { in ip6_mc_source()
369 if (pmc->sfmode != omode) { in ip6_mc_source()
373 } else if (pmc->sfmode != omode) { in ip6_mc_source()
376 ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0); in ip6_mc_source()
377 pmc->sfmode = omode; in ip6_mc_source()
380 write_lock(&pmc->sflock); in ip6_mc_source()
383 psl = pmc->sflist; in ip6_mc_source()
435 pmc->sflist = psl = newpsl; in ip6_mc_source()
452 write_unlock(&pmc->sflock); in ip6_mc_source()
464 struct ipv6_mc_socklist *pmc; in ip6_mc_msfilter() local
495 for_each_pmc_rcu(inet6, pmc) { in ip6_mc_msfilter()
496 if (pmc->ifindex != gsf->gf_interface) in ip6_mc_msfilter()
498 if (ipv6_addr_equal(&pmc->addr, group)) in ip6_mc_msfilter()
501 if (!pmc) { /* must have a prior join */ in ip6_mc_msfilter()
530 write_lock(&pmc->sflock); in ip6_mc_msfilter()
531 psl = pmc->sflist; in ip6_mc_msfilter()
533 (void) ip6_mc_del_src(idev, group, pmc->sfmode, in ip6_mc_msfilter()
537 (void) ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0); in ip6_mc_msfilter()
538 pmc->sflist = newpsl; in ip6_mc_msfilter()
539 pmc->sfmode = gsf->gf_fmode; in ip6_mc_msfilter()
540 write_unlock(&pmc->sflock); in ip6_mc_msfilter()
555 struct ipv6_mc_socklist *pmc; in ip6_mc_msfget() local
580 for_each_pmc_rcu(inet6, pmc) { in ip6_mc_msfget()
581 if (pmc->ifindex != gsf->gf_interface) in ip6_mc_msfget()
583 if (ipv6_addr_equal(group, &pmc->addr)) in ip6_mc_msfget()
586 if (!pmc) /* must have a prior join */ in ip6_mc_msfget()
588 gsf->gf_fmode = pmc->sfmode; in ip6_mc_msfget()
589 psl = pmc->sflist; in ip6_mc_msfget()
726 struct ifmcaddr6 *pmc; in mld_add_delrec() local
734 pmc = kzalloc(sizeof(*pmc), GFP_ATOMIC); in mld_add_delrec()
735 if (!pmc) in mld_add_delrec()
739 spin_lock_init(&pmc->mca_lock); in mld_add_delrec()
740 pmc->idev = im->idev; in mld_add_delrec()
742 pmc->mca_addr = im->mca_addr; in mld_add_delrec()
743 pmc->mca_crcount = idev->mc_qrv; in mld_add_delrec()
744 pmc->mca_sfmode = im->mca_sfmode; in mld_add_delrec()
745 if (pmc->mca_sfmode == MCAST_INCLUDE) { in mld_add_delrec()
748 pmc->mca_tomb = im->mca_tomb; in mld_add_delrec()
749 pmc->mca_sources = im->mca_sources; in mld_add_delrec()
751 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) in mld_add_delrec()
752 psf->sf_crcount = pmc->mca_crcount; in mld_add_delrec()
757 pmc->next = idev->mc_tomb; in mld_add_delrec()
758 idev->mc_tomb = pmc; in mld_add_delrec()
764 struct ifmcaddr6 *pmc, *pmc_prev; in mld_del_delrec() local
770 for (pmc = idev->mc_tomb; pmc; pmc = pmc->next) { in mld_del_delrec()
771 if (ipv6_addr_equal(&pmc->mca_addr, pmca)) in mld_del_delrec()
773 pmc_prev = pmc; in mld_del_delrec()
775 if (pmc) { in mld_del_delrec()
777 pmc_prev->next = pmc->next; in mld_del_delrec()
779 idev->mc_tomb = pmc->next; in mld_del_delrec()
784 if (pmc) { in mld_del_delrec()
785 im->idev = pmc->idev; in mld_del_delrec()
787 swap(im->mca_tomb, pmc->mca_tomb); in mld_del_delrec()
788 swap(im->mca_sources, pmc->mca_sources); in mld_del_delrec()
794 in6_dev_put(pmc->idev); in mld_del_delrec()
795 ip6_mc_clear_src(pmc); in mld_del_delrec()
796 kfree(pmc); in mld_del_delrec()
803 struct ifmcaddr6 *pmc, *nextpmc; in mld_clear_delrec() local
806 pmc = idev->mc_tomb; in mld_clear_delrec()
810 for (; pmc; pmc = nextpmc) { in mld_clear_delrec()
811 nextpmc = pmc->next; in mld_clear_delrec()
812 ip6_mc_clear_src(pmc); in mld_clear_delrec()
813 in6_dev_put(pmc->idev); in mld_clear_delrec()
814 kfree(pmc); in mld_clear_delrec()
819 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in mld_clear_delrec()
822 spin_lock_bh(&pmc->mca_lock); in mld_clear_delrec()
823 psf = pmc->mca_tomb; in mld_clear_delrec()
824 pmc->mca_tomb = NULL; in mld_clear_delrec()
825 spin_unlock_bh(&pmc->mca_lock); in mld_clear_delrec()
1103 static bool mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs, in mld_xmarksources() argument
1110 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in mld_xmarksources()
1116 pmc->mca_sfcount[MCAST_EXCLUDE] != in mld_xmarksources()
1125 pmc->mca_flags &= ~MAF_GSQUERY; in mld_xmarksources()
1131 static bool mld_marksources(struct ifmcaddr6 *pmc, int nsrcs, in mld_marksources() argument
1137 if (pmc->mca_sfmode == MCAST_EXCLUDE) in mld_marksources()
1138 return mld_xmarksources(pmc, nsrcs, srcs); in mld_marksources()
1143 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in mld_marksources()
1155 pmc->mca_flags &= ~MAF_GSQUERY; in mld_marksources()
1158 pmc->mca_flags |= MAF_GSQUERY; in mld_marksources()
1503 static bool is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type, in is_in() argument
1511 if (!((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp)) { in is_in()
1512 if (pmc->mca_sfmode == MCAST_INCLUDE) in is_in()
1519 return pmc->mca_sfcount[MCAST_EXCLUDE] == in is_in()
1530 if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 || in is_in()
1533 return pmc->mca_sfcount[MCAST_EXCLUDE] == in is_in()
1538 return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted; in is_in()
1540 if (pmc->mca_sfmode == MCAST_INCLUDE) in is_in()
1548 mld_scount(struct ifmcaddr6 *pmc, int type, int gdeleted, int sdeleted) in mld_scount() argument
1553 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in mld_scount()
1554 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) in mld_scount()
1695 static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) in grec_size() argument
1697 return sizeof(struct mld2_grec) + 16 * mld_scount(pmc,type,gdel,sdel); in grec_size()
1700 static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc, in add_grhead() argument
1707 skb = mld_newpack(pmc->idev, mtu); in add_grhead()
1715 pgr->grec_mca = pmc->mca_addr; /* structure copy */ in add_grhead()
1724 static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, in add_grec() argument
1727 struct inet6_dev *idev = pmc->idev; in add_grec()
1735 if (pmc->mca_flags & MAF_NOREPORT) in add_grec()
1749 psf_list = sdeleted ? &pmc->mca_tomb : &pmc->mca_sources; in add_grec()
1759 AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) { in add_grec()
1772 if (!is_in(pmc, psf, type, gdeleted, sdeleted) && !crsend) { in add_grec()
1780 if (((gdeleted && pmc->mca_sfmode == MCAST_EXCLUDE) || in add_grec()
1781 (!gdeleted && pmc->mca_crcount)) && in add_grec()
1803 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
1832 if (pmc->mca_crcount || isquery || crsend) { in add_grec()
1838 skb = add_grhead(skb, pmc, type, &pgr, mtu); in add_grec()
1845 pmc->mca_flags &= ~MAF_GSQUERY; /* clear query state */ in add_grec()
1849 static void mld_send_report(struct inet6_dev *idev, struct ifmcaddr6 *pmc) in mld_send_report() argument
1855 if (!pmc) { in mld_send_report()
1856 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in mld_send_report()
1857 if (pmc->mca_flags & MAF_NOREPORT) in mld_send_report()
1859 spin_lock_bh(&pmc->mca_lock); in mld_send_report()
1860 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_report()
1864 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_report()
1865 spin_unlock_bh(&pmc->mca_lock); in mld_send_report()
1868 spin_lock_bh(&pmc->mca_lock); in mld_send_report()
1869 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_report()
1873 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_report()
1874 spin_unlock_bh(&pmc->mca_lock); in mld_send_report()
1904 struct ifmcaddr6 *pmc, *pmc_prev, *pmc_next; in mld_send_cr() local
1913 for (pmc = idev->mc_tomb; pmc; pmc = pmc_next) { in mld_send_cr()
1914 pmc_next = pmc->next; in mld_send_cr()
1915 if (pmc->mca_sfmode == MCAST_INCLUDE) { in mld_send_cr()
1918 skb = add_grec(skb, pmc, type, 1, 0, 0); in mld_send_cr()
1919 skb = add_grec(skb, pmc, dtype, 1, 1, 0); in mld_send_cr()
1921 if (pmc->mca_crcount) { in mld_send_cr()
1922 if (pmc->mca_sfmode == MCAST_EXCLUDE) { in mld_send_cr()
1924 skb = add_grec(skb, pmc, type, 1, 0, 0); in mld_send_cr()
1926 pmc->mca_crcount--; in mld_send_cr()
1927 if (pmc->mca_crcount == 0) { in mld_send_cr()
1928 mld_clear_zeros(&pmc->mca_tomb); in mld_send_cr()
1929 mld_clear_zeros(&pmc->mca_sources); in mld_send_cr()
1932 if (pmc->mca_crcount == 0 && !pmc->mca_tomb && in mld_send_cr()
1933 !pmc->mca_sources) { in mld_send_cr()
1938 in6_dev_put(pmc->idev); in mld_send_cr()
1939 kfree(pmc); in mld_send_cr()
1941 pmc_prev = pmc; in mld_send_cr()
1946 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in mld_send_cr()
1947 spin_lock_bh(&pmc->mca_lock); in mld_send_cr()
1948 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in mld_send_cr()
1955 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_cr()
1956 skb = add_grec(skb, pmc, dtype, 0, 1, 0); /* deleted sources */ in mld_send_cr()
1959 if (pmc->mca_crcount) { in mld_send_cr()
1960 if (pmc->mca_sfmode == MCAST_EXCLUDE) in mld_send_cr()
1964 skb = add_grec(skb, pmc, type, 0, 0, 0); in mld_send_cr()
1965 pmc->mca_crcount--; in mld_send_cr()
1967 spin_unlock_bh(&pmc->mca_lock); in mld_send_cr()
2074 struct ifmcaddr6 *pmc; in mld_send_initial_cr() local
2082 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in mld_send_initial_cr()
2083 spin_lock_bh(&pmc->mca_lock); in mld_send_initial_cr()
2084 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in mld_send_initial_cr()
2088 skb = add_grec(skb, pmc, type, 0, 0, 1); in mld_send_initial_cr()
2089 spin_unlock_bh(&pmc->mca_lock); in mld_send_initial_cr()
2122 static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode, in ip6_mc_del1_src() argument
2129 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in ip6_mc_del1_src()
2140 struct inet6_dev *idev = pmc->idev; in ip6_mc_del1_src()
2146 pmc->mca_sources = psf->sf_next; in ip6_mc_del1_src()
2147 if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) && in ip6_mc_del1_src()
2150 psf->sf_next = pmc->mca_tomb; in ip6_mc_del1_src()
2151 pmc->mca_tomb = psf; in ip6_mc_del1_src()
2163 struct ifmcaddr6 *pmc; in ip6_mc_del_src() local
2170 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in ip6_mc_del_src()
2171 if (ipv6_addr_equal(pmca, &pmc->mca_addr)) in ip6_mc_del_src()
2174 if (!pmc) { in ip6_mc_del_src()
2179 spin_lock_bh(&pmc->mca_lock); in ip6_mc_del_src()
2180 sf_markstate(pmc); in ip6_mc_del_src()
2182 if (!pmc->mca_sfcount[sfmode]) { in ip6_mc_del_src()
2183 spin_unlock_bh(&pmc->mca_lock); in ip6_mc_del_src()
2187 pmc->mca_sfcount[sfmode]--; in ip6_mc_del_src()
2191 int rv = ip6_mc_del1_src(pmc, sfmode, &psfsrc[i]); in ip6_mc_del_src()
2197 if (pmc->mca_sfmode == MCAST_EXCLUDE && in ip6_mc_del_src()
2198 pmc->mca_sfcount[MCAST_EXCLUDE] == 0 && in ip6_mc_del_src()
2199 pmc->mca_sfcount[MCAST_INCLUDE]) { in ip6_mc_del_src()
2203 pmc->mca_sfmode = MCAST_INCLUDE; in ip6_mc_del_src()
2204 pmc->mca_crcount = idev->mc_qrv; in ip6_mc_del_src()
2205 idev->mc_ifc_count = pmc->mca_crcount; in ip6_mc_del_src()
2206 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) in ip6_mc_del_src()
2208 mld_ifc_event(pmc->idev); in ip6_mc_del_src()
2209 } else if (sf_setstate(pmc) || changerec) in ip6_mc_del_src()
2210 mld_ifc_event(pmc->idev); in ip6_mc_del_src()
2211 spin_unlock_bh(&pmc->mca_lock); in ip6_mc_del_src()
2219 static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode, in ip6_mc_add1_src() argument
2225 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in ip6_mc_add1_src()
2239 pmc->mca_sources = psf; in ip6_mc_add1_src()
2245 static void sf_markstate(struct ifmcaddr6 *pmc) in sf_markstate() argument
2248 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE]; in sf_markstate()
2250 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) in sf_markstate()
2251 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in sf_markstate()
2259 static int sf_setstate(struct ifmcaddr6 *pmc) in sf_setstate() argument
2262 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE]; in sf_setstate()
2263 int qrv = pmc->idev->mc_qrv; in sf_setstate()
2267 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) { in sf_setstate()
2268 if (pmc->mca_sfcount[MCAST_EXCLUDE]) { in sf_setstate()
2277 for (dpsf = pmc->mca_tomb; dpsf; in sf_setstate()
2288 pmc->mca_tomb = dpsf->sf_next; in sf_setstate()
2300 for (dpsf = pmc->mca_tomb; dpsf; dpsf = dpsf->sf_next) in sf_setstate()
2310 dpsf->sf_next = pmc->mca_tomb; in sf_setstate()
2311 pmc->mca_tomb = dpsf; in sf_setstate()
2327 struct ifmcaddr6 *pmc; in ip6_mc_add_src() local
2334 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { in ip6_mc_add_src()
2335 if (ipv6_addr_equal(pmca, &pmc->mca_addr)) in ip6_mc_add_src()
2338 if (!pmc) { in ip6_mc_add_src()
2343 spin_lock_bh(&pmc->mca_lock); in ip6_mc_add_src()
2345 sf_markstate(pmc); in ip6_mc_add_src()
2346 isexclude = pmc->mca_sfmode == MCAST_EXCLUDE; in ip6_mc_add_src()
2348 pmc->mca_sfcount[sfmode]++; in ip6_mc_add_src()
2351 err = ip6_mc_add1_src(pmc, sfmode, &psfsrc[i]); in ip6_mc_add_src()
2359 pmc->mca_sfcount[sfmode]--; in ip6_mc_add_src()
2361 ip6_mc_del1_src(pmc, sfmode, &psfsrc[j]); in ip6_mc_add_src()
2362 } else if (isexclude != (pmc->mca_sfcount[MCAST_EXCLUDE] != 0)) { in ip6_mc_add_src()
2366 if (pmc->mca_sfcount[MCAST_EXCLUDE]) in ip6_mc_add_src()
2367 pmc->mca_sfmode = MCAST_EXCLUDE; in ip6_mc_add_src()
2368 else if (pmc->mca_sfcount[MCAST_INCLUDE]) in ip6_mc_add_src()
2369 pmc->mca_sfmode = MCAST_INCLUDE; in ip6_mc_add_src()
2372 pmc->mca_crcount = idev->mc_qrv; in ip6_mc_add_src()
2373 idev->mc_ifc_count = pmc->mca_crcount; in ip6_mc_add_src()
2374 for (psf = pmc->mca_sources; psf; psf = psf->sf_next) in ip6_mc_add_src()
2377 } else if (sf_setstate(pmc)) in ip6_mc_add_src()
2379 spin_unlock_bh(&pmc->mca_lock); in ip6_mc_add_src()
2384 static void ip6_mc_clear_src(struct ifmcaddr6 *pmc) in ip6_mc_clear_src() argument
2388 for (psf = pmc->mca_tomb; psf; psf = nextpsf) { in ip6_mc_clear_src()
2392 pmc->mca_tomb = NULL; in ip6_mc_clear_src()
2393 for (psf = pmc->mca_sources; psf; psf = nextpsf) { in ip6_mc_clear_src()
2397 pmc->mca_sources = NULL; in ip6_mc_clear_src()
2398 pmc->mca_sfmode = MCAST_EXCLUDE; in ip6_mc_clear_src()
2399 pmc->mca_sfcount[MCAST_INCLUDE] = 0; in ip6_mc_clear_src()
2400 pmc->mca_sfcount[MCAST_EXCLUDE] = 1; in ip6_mc_clear_src()
2624 struct ifmcaddr6 *pmc; in ipv6_mc_rejoin_groups() local
2630 for (pmc = idev->mc_list; pmc; pmc = pmc->next) in ipv6_mc_rejoin_groups()
2631 igmp6_join_group(pmc); in ipv6_mc_rejoin_groups()