X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fipv6%2Fmcast.c;h=393b6e6f50a9626e2894c9a5abd8dafd903e5eba;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=51193e0f09a1629627428ffe57b21f7019085e3d;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 51193e0f0..393b6e6f5 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -121,10 +121,10 @@ struct mld2_query { struct in6_addr srcs[0]; }; -struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT; +static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT; /* Big mc list lock for all the sockets */ -static rwlock_t ipv6_sk_mc_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(ipv6_sk_mc_lock); static struct socket *igmp6_socket; @@ -143,12 +143,14 @@ static void mld_clear_delrec(struct inet6_dev *idev); static int sf_setstate(struct ifmcaddr6 *pmc); static void sf_markstate(struct ifmcaddr6 *pmc); static void ip6_mc_clear_src(struct ifmcaddr6 *pmc); -int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, - int sfcount, struct in6_addr *psfsrc, int delta); -int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, - int sfcount, struct in6_addr *psfsrc, int delta); -int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, - struct inet6_dev *idev); +static int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, + int sfmode, int sfcount, struct in6_addr *psfsrc, + int delta); +static int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, + int sfmode, int sfcount, struct in6_addr *psfsrc, + int delta); +static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, + struct inet6_dev *idev); #define IGMP6_UNSOLICITED_IVAL (10*HZ) @@ -247,7 +249,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr) write_lock_bh(&ipv6_sk_mc_lock); for (lnk = &np->ipv6_mc_list; (mc_lst = *lnk) !=NULL ; lnk = &mc_lst->next) { if ((ifindex == 0 || mc_lst->ifindex == ifindex) && - ipv6_addr_cmp(&mc_lst->addr, addr) == 0) { + ipv6_addr_equal(&mc_lst->addr, addr)) { struct net_device *dev; *lnk = mc_lst->next; @@ -272,7 +274,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr) return -ENOENT; } -struct inet6_dev *ip6_mc_find_dev(struct in6_addr *group, int ifindex) +static struct inet6_dev *ip6_mc_find_dev(struct in6_addr *group, int ifindex) { struct net_device *dev = NULL; struct inet6_dev *idev = NULL; @@ -369,7 +371,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk, for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) continue; - if (ipv6_addr_cmp(&pmc->addr, group) == 0) + if (ipv6_addr_equal(&pmc->addr, group)) break; } if (!pmc) /* must have a prior join */ @@ -391,12 +393,12 @@ int ip6_mc_source(int add, int omode, struct sock *sk, goto done; rv = !0; for (i=0; isl_count; i++) { - rv = memcmp(&psl->sl_addr, group, + rv = memcmp(&psl->sl_addr[i], source, sizeof(struct in6_addr)); - if (rv >= 0) + if (rv == 0) break; } - if (!rv) /* source not found */ + if (rv) /* source not found */ goto done; /* update the interface filter */ @@ -437,8 +439,8 @@ int ip6_mc_source(int add, int omode, struct sock *sk, } rv = 1; /* > 0 for insert logic below if sl_count is 0 */ for (i=0; isl_count; i++) { - rv = memcmp(&psl->sl_addr, group, sizeof(struct in6_addr)); - if (rv >= 0) + rv = memcmp(&psl->sl_addr[i], source, sizeof(struct in6_addr)); + if (rv == 0) break; } if (rv == 0) /* address already there is an error */ @@ -485,7 +487,7 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf) for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { if (pmc->ifindex != gsf->gf_interface) continue; - if (ipv6_addr_cmp(&pmc->addr, group) == 0) + if (ipv6_addr_equal(&pmc->addr, group)) break; } if (!pmc) /* must have a prior join */ @@ -556,7 +558,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf, for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { if (pmc->ifindex != gsf->gf_interface) continue; - if (ipv6_addr_cmp(group, &pmc->addr) == 0) + if (ipv6_addr_equal(group, &pmc->addr)) break; } if (!pmc) /* must have a prior join */ @@ -603,7 +605,7 @@ int inet6_mc_check(struct sock *sk, struct in6_addr *mc_addr, read_lock(&ipv6_sk_mc_lock); for (mc = np->ipv6_mc_list; mc; mc = mc->next) { - if (ipv6_addr_cmp(&mc->addr, mc_addr) == 0) + if (ipv6_addr_equal(&mc->addr, mc_addr)) break; } if (!mc) { @@ -617,7 +619,7 @@ int inet6_mc_check(struct sock *sk, struct in6_addr *mc_addr, int i; for (i=0; isl_count; i++) { - if (ipv6_addr_cmp(&psl->sl_addr[i], src_addr) == 0) + if (ipv6_addr_equal(&psl->sl_addr[i], src_addr)) break; } if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count) @@ -709,7 +711,7 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im) return; memset(pmc, 0, sizeof(*pmc)); spin_lock_bh(&im->mca_lock); - pmc->mca_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&pmc->mca_lock); pmc->idev = im->idev; in6_dev_hold(idev); pmc->mca_addr = im->mca_addr; @@ -740,7 +742,7 @@ static void mld_del_delrec(struct inet6_dev *idev, struct in6_addr *pmca) write_lock_bh(&idev->mc_lock); pmc_prev = NULL; for (pmc=idev->mc_tomb; pmc; pmc=pmc->next) { - if (ipv6_addr_cmp(&pmc->mca_addr, pmca) == 0) + if (ipv6_addr_equal(&pmc->mca_addr, pmca)) break; pmc_prev = pmc; } @@ -816,7 +818,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr) } for (mc = idev->mc_list; mc; mc = mc->next) { - if (ipv6_addr_cmp(&mc->mca_addr, addr) == 0) { + if (ipv6_addr_equal(&mc->mca_addr, addr)) { mc->mca_users++; write_unlock_bh(&idev->lock); ip6_mc_add_src(idev, &mc->mca_addr, MCAST_EXCLUDE, 0, @@ -849,7 +851,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr) /* mca_stamp should be updated upon changes */ mc->mca_cstamp = mc->mca_tstamp = jiffies; atomic_set(&mc->mca_refcnt, 2); - mc->mca_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&mc->mca_lock); /* initial mode is (EX, empty) */ mc->mca_sfmode = MCAST_EXCLUDE; @@ -878,7 +880,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, struct in6_addr *addr) write_lock_bh(&idev->lock); for (map = &idev->mc_list; (ma=*map) != NULL; map = &ma->next) { - if (ipv6_addr_cmp(&ma->mca_addr, addr) == 0) { + if (ipv6_addr_equal(&ma->mca_addr, addr)) { if (--ma->mca_users == 0) { *map = ma->next; write_unlock_bh(&idev->lock); @@ -953,7 +955,7 @@ int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *group, if (idev) { read_lock_bh(&idev->lock); for (mc = idev->mc_list; mc; mc=mc->next) { - if (ipv6_addr_cmp(&mc->mca_addr, group) == 0) + if (ipv6_addr_equal(&mc->mca_addr, group)) break; } if (mc) { @@ -962,8 +964,7 @@ int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *group, spin_lock_bh(&mc->mca_lock); for (psf=mc->mca_sources;psf;psf=psf->sf_next) { - if (ipv6_addr_cmp(&psf->sf_addr, - src_addr) == 0) + if (ipv6_addr_equal(&psf->sf_addr, src_addr)) break; } if (psf) @@ -1040,7 +1041,7 @@ static void mld_marksources(struct ifmcaddr6 *pmc, int nsrcs, if (scount == nsrcs) break; for (i=0; isf_addr) == 0) { + if (ipv6_addr_equal(&srcs[i], &psf->sf_addr)) { psf->sf_gsresp = 1; scount++; break; @@ -1135,7 +1136,7 @@ int igmp6_event_query(struct sk_buff *skb) } else { for (ma = idev->mc_list; ma; ma=ma->next) { if (group_type != IPV6_ADDR_ANY && - ipv6_addr_cmp(group, &ma->mca_addr) != 0) + !ipv6_addr_equal(group, &ma->mca_addr)) continue; spin_lock_bh(&ma->mca_lock); if (ma->mca_flags & MAF_TIMER_RUNNING) { @@ -1200,7 +1201,7 @@ int igmp6_event_report(struct sk_buff *skb) read_lock_bh(&idev->lock); for (ma = idev->mc_list; ma; ma=ma->next) { - if (ipv6_addr_cmp(&ma->mca_addr, addrp) == 0) { + if (ipv6_addr_equal(&ma->mca_addr, addrp)) { spin_lock(&ma->mca_lock); if (del_timer(&ma->mca_timer)) atomic_dec(&ma->mca_refcnt); @@ -1695,7 +1696,7 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode, psf_prev = NULL; for (psf=pmc->mca_sources; psf; psf=psf->sf_next) { - if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0) + if (ipv6_addr_equal(&psf->sf_addr, psfsrc)) break; psf_prev = psf; } @@ -1724,8 +1725,9 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode, return rv; } -int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, - int sfcount, struct in6_addr *psfsrc, int delta) +static int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, + int sfmode, int sfcount, struct in6_addr *psfsrc, + int delta) { struct ifmcaddr6 *pmc; int changerec = 0; @@ -1735,7 +1737,7 @@ int ip6_mc_del_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, return -ENODEV; read_lock_bh(&idev->lock); for (pmc=idev->mc_list; pmc; pmc=pmc->next) { - if (ipv6_addr_cmp(pmca, &pmc->mca_addr) == 0) + if (ipv6_addr_equal(pmca, &pmc->mca_addr)) break; } if (!pmc) { @@ -1790,7 +1792,7 @@ static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode, psf_prev = NULL; for (psf=pmc->mca_sources; psf; psf=psf->sf_next) { - if (ipv6_addr_cmp(&psf->sf_addr, psfsrc) == 0) + if (ipv6_addr_equal(&psf->sf_addr, psfsrc)) break; psf_prev = psf; } @@ -1848,8 +1850,9 @@ static int sf_setstate(struct ifmcaddr6 *pmc) /* * Add multicast source filter list to the interface list */ -int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, - int sfcount, struct in6_addr *psfsrc, int delta) +static int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, + int sfmode, int sfcount, struct in6_addr *psfsrc, + int delta) { struct ifmcaddr6 *pmc; int isexclude; @@ -1859,7 +1862,7 @@ int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, return -ENODEV; read_lock_bh(&idev->lock); for (pmc=idev->mc_list; pmc; pmc=pmc->next) { - if (ipv6_addr_cmp(pmca, &pmc->mca_addr) == 0) + if (ipv6_addr_equal(pmca, &pmc->mca_addr)) break; } if (!pmc) { @@ -1882,7 +1885,8 @@ int ip6_mc_add_src(struct inet6_dev *idev, struct in6_addr *pmca, int sfmode, if (err) { int j; - pmc->mca_sfcount[sfmode]--; + if (!delta) + pmc->mca_sfcount[sfmode]--; for (j=0; jmca_sfcount[MCAST_EXCLUDE] != 0)) { @@ -1951,8 +1955,8 @@ static void igmp6_join_group(struct ifmcaddr6 *ma) spin_unlock_bh(&ma->mca_lock); } -int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, - struct inet6_dev *idev) +static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, + struct inet6_dev *idev) { int err; @@ -2071,7 +2075,7 @@ void ipv6_mc_init_dev(struct inet6_dev *idev) struct in6_addr maddr; write_lock_bh(&idev->lock); - idev->mc_lock = RW_LOCK_UNLOCKED; + rwlock_init(&idev->mc_lock); idev->mc_gq_running = 0; init_timer(&idev->mc_gq_timer); idev->mc_gq_timer.data = (unsigned long) idev;