Lines Matching full:im
156 static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im,
158 static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im);
167 static void ip_ma_put(struct ip_mc_list *im) in ip_ma_put() argument
169 if (refcount_dec_and_test(&im->refcnt)) { in ip_ma_put()
170 in_dev_put(im->interface); in ip_ma_put()
171 kfree_rcu(im, rcu); in ip_ma_put()
202 static void igmp_stop_timer(struct ip_mc_list *im) in igmp_stop_timer() argument
204 spin_lock_bh(&im->lock); in igmp_stop_timer()
205 if (del_timer(&im->timer)) in igmp_stop_timer()
206 refcount_dec(&im->refcnt); in igmp_stop_timer()
207 im->tm_running = 0; in igmp_stop_timer()
208 im->reporter = 0; in igmp_stop_timer()
209 im->unsolicit_count = 0; in igmp_stop_timer()
210 spin_unlock_bh(&im->lock); in igmp_stop_timer()
213 /* It must be called with locked im->lock */
214 static void igmp_start_timer(struct ip_mc_list *im, int max_delay) in igmp_start_timer() argument
218 im->tm_running = 1; in igmp_start_timer()
219 if (refcount_inc_not_zero(&im->refcnt)) { in igmp_start_timer()
220 if (mod_timer(&im->timer, jiffies + tv + 2)) in igmp_start_timer()
221 ip_ma_put(im); in igmp_start_timer()
247 static void igmp_mod_timer(struct ip_mc_list *im, int max_delay) in igmp_mod_timer() argument
249 spin_lock_bh(&im->lock); in igmp_mod_timer()
250 im->unsolicit_count = 0; in igmp_mod_timer()
251 if (del_timer(&im->timer)) { in igmp_mod_timer()
252 if ((long)(im->timer.expires-jiffies) < max_delay) { in igmp_mod_timer()
253 add_timer(&im->timer); in igmp_mod_timer()
254 im->tm_running = 1; in igmp_mod_timer()
255 spin_unlock_bh(&im->lock); in igmp_mod_timer()
258 refcount_dec(&im->refcnt); in igmp_mod_timer()
260 igmp_start_timer(im, max_delay); in igmp_mod_timer()
261 spin_unlock_bh(&im->lock); in igmp_mod_timer()
840 struct ip_mc_list *im = from_timer(im, t, timer); in igmp_timer_expire() local
841 struct in_device *in_dev = im->interface; in igmp_timer_expire()
843 spin_lock(&im->lock); in igmp_timer_expire()
844 im->tm_running = 0; in igmp_timer_expire()
846 if (im->unsolicit_count && --im->unsolicit_count) in igmp_timer_expire()
847 igmp_start_timer(im, unsolicited_report_interval(in_dev)); in igmp_timer_expire()
849 im->reporter = 1; in igmp_timer_expire()
850 spin_unlock(&im->lock); in igmp_timer_expire()
853 igmp_send_report(in_dev, im, IGMP_HOST_MEMBERSHIP_REPORT); in igmp_timer_expire()
855 igmp_send_report(in_dev, im, IGMPV2_HOST_MEMBERSHIP_REPORT); in igmp_timer_expire()
857 igmp_send_report(in_dev, im, IGMPV3_HOST_MEMBERSHIP_REPORT); in igmp_timer_expire()
859 ip_ma_put(im); in igmp_timer_expire()
921 struct ip_mc_list *im; in igmp_heard_report() local
933 for_each_pmc_rcu(in_dev, im) { in igmp_heard_report()
934 if (im->multiaddr == group) { in igmp_heard_report()
935 igmp_stop_timer(im); in igmp_heard_report()
949 struct ip_mc_list *im; in igmp_heard_query() local
1046 for_each_pmc_rcu(in_dev, im) { in igmp_heard_query()
1049 if (group && group != im->multiaddr) in igmp_heard_query()
1051 if (im->multiaddr == IGMP_ALL_HOSTS) in igmp_heard_query()
1053 if (ipv4_is_local_multicast(im->multiaddr) && in igmp_heard_query()
1056 spin_lock_bh(&im->lock); in igmp_heard_query()
1057 if (im->tm_running) in igmp_heard_query()
1058 im->gsquery = im->gsquery && mark; in igmp_heard_query()
1060 im->gsquery = mark; in igmp_heard_query()
1061 changed = !im->gsquery || in igmp_heard_query()
1062 igmp_marksources(im, ntohs(ih3->nsrcs), ih3->srcs); in igmp_heard_query()
1063 spin_unlock_bh(&im->lock); in igmp_heard_query()
1065 igmp_mod_timer(im, max_delay); in igmp_heard_query()
1175 static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im, in igmpv3_add_delrec() argument
1191 spin_lock_bh(&im->lock); in igmpv3_add_delrec()
1192 pmc->interface = im->interface; in igmpv3_add_delrec()
1194 pmc->multiaddr = im->multiaddr; in igmpv3_add_delrec()
1196 pmc->sfmode = im->sfmode; in igmpv3_add_delrec()
1200 pmc->tomb = im->tomb; in igmpv3_add_delrec()
1201 pmc->sources = im->sources; in igmpv3_add_delrec()
1202 im->tomb = im->sources = NULL; in igmpv3_add_delrec()
1206 spin_unlock_bh(&im->lock); in igmpv3_add_delrec()
1217 static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im) in igmpv3_del_delrec() argument
1222 __be32 multiaddr = im->multiaddr; in igmpv3_del_delrec()
1239 spin_lock_bh(&im->lock); in igmpv3_del_delrec()
1241 im->interface = pmc->interface; in igmpv3_del_delrec()
1242 if (im->sfmode == MCAST_INCLUDE) { in igmpv3_del_delrec()
1243 swap(im->tomb, pmc->tomb); in igmpv3_del_delrec()
1244 swap(im->sources, pmc->sources); in igmpv3_del_delrec()
1245 for (psf = im->sources; psf; psf = psf->sf_next) in igmpv3_del_delrec()
1249 im->crcount = in_dev->mr_qrv ?: in igmpv3_del_delrec()
1255 spin_unlock_bh(&im->lock); in igmpv3_del_delrec()
1291 static void __igmp_group_dropped(struct ip_mc_list *im, gfp_t gfp) in __igmp_group_dropped() argument
1293 struct in_device *in_dev = im->interface; in __igmp_group_dropped()
1299 if (im->loaded) { in __igmp_group_dropped()
1300 im->loaded = 0; in __igmp_group_dropped()
1301 ip_mc_filter_del(in_dev, im->multiaddr); in __igmp_group_dropped()
1305 if (im->multiaddr == IGMP_ALL_HOSTS) in __igmp_group_dropped()
1307 if (ipv4_is_local_multicast(im->multiaddr) && in __igmp_group_dropped()
1311 reporter = im->reporter; in __igmp_group_dropped()
1312 igmp_stop_timer(im); in __igmp_group_dropped()
1319 igmp_send_report(in_dev, im, IGMP_HOST_LEAVE_MESSAGE); in __igmp_group_dropped()
1323 igmpv3_add_delrec(in_dev, im, gfp); in __igmp_group_dropped()
1330 static void igmp_group_dropped(struct ip_mc_list *im) in igmp_group_dropped() argument
1332 __igmp_group_dropped(im, GFP_KERNEL); in igmp_group_dropped()
1335 static void igmp_group_added(struct ip_mc_list *im) in igmp_group_added() argument
1337 struct in_device *in_dev = im->interface; in igmp_group_added()
1342 if (im->loaded == 0) { in igmp_group_added()
1343 im->loaded = 1; in igmp_group_added()
1344 ip_mc_filter_add(in_dev, im->multiaddr); in igmp_group_added()
1348 if (im->multiaddr == IGMP_ALL_HOSTS) in igmp_group_added()
1350 if (ipv4_is_local_multicast(im->multiaddr) && in igmp_group_added()
1357 im->unsolicit_count = READ_ONCE(net->ipv4.sysctl_igmp_qrv); in igmp_group_added()
1359 spin_lock_bh(&im->lock); in igmp_group_added()
1360 igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY); in igmp_group_added()
1361 spin_unlock_bh(&im->lock); in igmp_group_added()
1370 if (im->sfmode == MCAST_EXCLUDE) in igmp_group_added()
1371 im->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); in igmp_group_added()
1382 static u32 ip_mc_hash(const struct ip_mc_list *im) in ip_mc_hash() argument
1384 return hash_32((__force u32)im->multiaddr, MC_HASH_SZ_LOG); in ip_mc_hash()
1388 struct ip_mc_list *im) in ip_mc_hash_add() argument
1395 hash = ip_mc_hash(im); in ip_mc_hash_add()
1396 im->next_hash = mc_hash[hash]; in ip_mc_hash_add()
1397 rcu_assign_pointer(mc_hash[hash], im); in ip_mc_hash_add()
1410 for_each_pmc_rtnl(in_dev, im) { in ip_mc_hash_add()
1411 hash = ip_mc_hash(im); in ip_mc_hash_add()
1412 im->next_hash = mc_hash[hash]; in ip_mc_hash_add()
1413 RCU_INIT_POINTER(mc_hash[hash], im); in ip_mc_hash_add()
1420 struct ip_mc_list *im) in ip_mc_hash_remove() argument
1427 mc_hash += ip_mc_hash(im); in ip_mc_hash_remove()
1428 while ((aux = rtnl_dereference(*mc_hash)) != im) in ip_mc_hash_remove()
1430 *mc_hash = im->next_hash; in ip_mc_hash_remove()
1440 struct ip_mc_list *im; in ____ip_mc_inc_group() local
1444 for_each_pmc_rtnl(in_dev, im) { in ____ip_mc_inc_group()
1445 if (im->multiaddr == addr) { in ____ip_mc_inc_group()
1446 im->users++; in ____ip_mc_inc_group()
1452 im = kzalloc(sizeof(*im), gfp); in ____ip_mc_inc_group()
1453 if (!im) in ____ip_mc_inc_group()
1456 im->users = 1; in ____ip_mc_inc_group()
1457 im->interface = in_dev; in ____ip_mc_inc_group()
1459 im->multiaddr = addr; in ____ip_mc_inc_group()
1461 im->sfmode = mode; in ____ip_mc_inc_group()
1462 im->sfcount[mode] = 1; in ____ip_mc_inc_group()
1463 refcount_set(&im->refcnt, 1); in ____ip_mc_inc_group()
1464 spin_lock_init(&im->lock); in ____ip_mc_inc_group()
1466 timer_setup(&im->timer, igmp_timer_expire, 0); in ____ip_mc_inc_group()
1469 im->next_rcu = in_dev->mc_list; in ____ip_mc_inc_group()
1471 rcu_assign_pointer(in_dev->mc_list, im); in ____ip_mc_inc_group()
1473 ip_mc_hash_add(in_dev, im); in ____ip_mc_inc_group()
1476 igmpv3_del_delrec(in_dev, im); in ____ip_mc_inc_group()
1478 igmp_group_added(im); in ____ip_mc_inc_group()
1645 struct ip_mc_list *im; in ip_mc_rejoin_groups() local
1651 for_each_pmc_rtnl(in_dev, im) { in ip_mc_rejoin_groups()
1652 if (im->multiaddr == IGMP_ALL_HOSTS) in ip_mc_rejoin_groups()
1654 if (ipv4_is_local_multicast(im->multiaddr) && in ip_mc_rejoin_groups()
1667 igmp_send_report(in_dev, im, type); in ip_mc_rejoin_groups()
2720 struct ip_mc_list *im; in ip_check_mc_rcu() local
2729 for (im = rcu_dereference(mc_hash[hash]); in ip_check_mc_rcu()
2730 im != NULL; in ip_check_mc_rcu()
2731 im = rcu_dereference(im->next_hash)) { in ip_check_mc_rcu()
2732 if (im->multiaddr == mc_addr) in ip_check_mc_rcu()
2736 for_each_pmc_rcu(in_dev, im) { in ip_check_mc_rcu()
2737 if (im->multiaddr == mc_addr) in ip_check_mc_rcu()
2741 if (im && proto == IPPROTO_IGMP) { in ip_check_mc_rcu()
2743 } else if (im) { in ip_check_mc_rcu()
2745 spin_lock_bh(&im->lock); in ip_check_mc_rcu()
2746 for (psf = im->sources; psf; psf = psf->sf_next) { in ip_check_mc_rcu()
2753 im->sfcount[MCAST_EXCLUDE]; in ip_check_mc_rcu()
2755 rv = im->sfcount[MCAST_EXCLUDE] != 0; in ip_check_mc_rcu()
2756 spin_unlock_bh(&im->lock); in ip_check_mc_rcu()
2775 struct ip_mc_list *im = NULL; in igmp_mc_get_first() local
2785 im = rcu_dereference(in_dev->mc_list); in igmp_mc_get_first()
2786 if (im) { in igmp_mc_get_first()
2791 return im; in igmp_mc_get_first()
2794 static struct ip_mc_list *igmp_mc_get_next(struct seq_file *seq, struct ip_mc_list *im) in igmp_mc_get_next() argument
2798 im = rcu_dereference(im->next_rcu); in igmp_mc_get_next()
2799 while (!im) { in igmp_mc_get_next()
2808 im = rcu_dereference(state->in_dev->mc_list); in igmp_mc_get_next()
2810 return im; in igmp_mc_get_next()
2815 struct ip_mc_list *im = igmp_mc_get_first(seq); in igmp_mc_get_idx() local
2816 if (im) in igmp_mc_get_idx()
2817 while (pos && (im = igmp_mc_get_next(seq, im)) != NULL) in igmp_mc_get_idx()
2819 return pos ? NULL : im; in igmp_mc_get_idx()
2831 struct ip_mc_list *im; in igmp_mc_seq_next() local
2833 im = igmp_mc_get_first(seq); in igmp_mc_seq_next()
2835 im = igmp_mc_get_next(seq, v); in igmp_mc_seq_next()
2837 return im; in igmp_mc_seq_next()
2856 struct ip_mc_list *im = v; in igmp_mc_seq_show() local
2869 if (rcu_access_pointer(state->in_dev->mc_list) == im) { in igmp_mc_seq_show()
2874 delta = im->timer.expires - jiffies; in igmp_mc_seq_show()
2877 im->multiaddr, im->users, in igmp_mc_seq_show()
2878 im->tm_running, in igmp_mc_seq_show()
2879 im->tm_running ? jiffies_delta_to_clock_t(delta) : 0, in igmp_mc_seq_show()
2880 im->reporter); in igmp_mc_seq_show()
2896 struct ip_mc_list *im; member
2905 struct ip_mc_list *im = NULL; in igmp_mcf_get_first() local
2909 state->im = NULL; in igmp_mcf_get_first()
2915 im = rcu_dereference(idev->mc_list); in igmp_mcf_get_first()
2916 if (likely(im)) { in igmp_mcf_get_first()
2917 spin_lock_bh(&im->lock); in igmp_mcf_get_first()
2918 psf = im->sources; in igmp_mcf_get_first()
2920 state->im = im; in igmp_mcf_get_first()
2924 spin_unlock_bh(&im->lock); in igmp_mcf_get_first()
2936 spin_unlock_bh(&state->im->lock); in igmp_mcf_get_next()
2937 state->im = state->im->next; in igmp_mcf_get_next()
2938 while (!state->im) { in igmp_mcf_get_next()
2947 state->im = rcu_dereference(state->idev->mc_list); in igmp_mcf_get_next()
2949 if (!state->im) in igmp_mcf_get_next()
2951 spin_lock_bh(&state->im->lock); in igmp_mcf_get_next()
2952 psf = state->im->sources; in igmp_mcf_get_next()
2989 if (likely(state->im)) { in igmp_mcf_seq_stop()
2990 spin_unlock_bh(&state->im->lock); in igmp_mcf_seq_stop()
2991 state->im = NULL; in igmp_mcf_seq_stop()
3010 ntohl(state->im->multiaddr), in igmp_mcf_seq_show()