73 #include <linux/module.h>
74 #include <linux/slab.h>
75 #include <asm/uaccess.h>
76 #include <linux/types.h>
77 #include <linux/kernel.h>
79 #include <linux/string.h>
80 #include <linux/socket.h>
84 #include <linux/netdevice.h>
87 #include <linux/igmp.h>
88 #include <linux/if_arp.h>
89 #include <linux/rtnetlink.h>
99 #include <linux/netfilter_ipv4.h>
100 #ifdef CONFIG_IP_MROUTE
101 #include <linux/mroute.h>
103 #ifdef CONFIG_PROC_FS
108 #define IP_MAX_MEMBERSHIPS 20
109 #define IP_MAX_MSF 10
111 #ifdef CONFIG_IP_MULTICAST
114 #define IGMP_V1_Router_Present_Timeout (400*HZ)
115 #define IGMP_V2_Router_Present_Timeout (400*HZ)
116 #define IGMP_Unsolicited_Report_Interval (10*HZ)
117 #define IGMP_Query_Response_Interval (10*HZ)
118 #define IGMP_Unsolicited_Report_Count 2
121 #define IGMP_Initial_Report_Delay (1)
130 #define IGMP_V1_SEEN(in_dev) \
131 (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 1 || \
132 IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 1 || \
133 ((in_dev)->mr_v1_seen && \
134 time_before(jiffies, (in_dev)->mr_v1_seen)))
135 #define IGMP_V2_SEEN(in_dev) \
136 (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 2 || \
137 IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 2 || \
138 ((in_dev)->mr_v2_seen && \
139 time_before(jiffies, (in_dev)->mr_v2_seen)))
141 static void igmpv3_add_delrec(
struct in_device *in_dev,
struct ip_mc_list *im);
142 static void igmpv3_del_delrec(
struct in_device *in_dev,
__be32 multiaddr);
143 static void igmpv3_clear_delrec(
struct in_device *in_dev);
144 static int sf_setstate(
struct ip_mc_list *pmc);
145 static void sf_markstate(
struct ip_mc_list *pmc);
147 static void ip_mc_clear_src(
struct ip_mc_list *pmc);
148 static int ip_mc_add_src(
struct in_device *in_dev,
__be32 *pmca,
int sfmode,
159 #define for_each_pmc_rcu(in_dev, pmc) \
160 for (pmc = rcu_dereference(in_dev->mc_list); \
162 pmc = rcu_dereference(pmc->next_rcu))
164 #define for_each_pmc_rtnl(in_dev, pmc) \
165 for (pmc = rtnl_dereference(in_dev->mc_list); \
167 pmc = rtnl_dereference(pmc->next_rcu))
169 #ifdef CONFIG_IP_MULTICAST
175 static void igmp_stop_timer(
struct ip_mc_list *im)
177 spin_lock_bh(&im->
lock);
183 spin_unlock_bh(&im->
lock);
187 static void igmp_start_timer(
struct ip_mc_list *im,
int max_delay)
196 static void igmp_gq_start_timer(
struct in_device *in_dev)
200 in_dev->mr_gq_running = 1;
201 if (!
mod_timer(&in_dev->mr_gq_timer, jiffies+tv+2))
205 static void igmp_ifc_start_timer(
struct in_device *in_dev,
int delay)
209 if (!
mod_timer(&in_dev->mr_ifc_timer, jiffies+tv+2))
213 static void igmp_mod_timer(
struct ip_mc_list *im,
int max_delay)
215 spin_lock_bh(&im->
lock);
218 if ((
long)(im->
timer.expires-jiffies) < max_delay) {
221 spin_unlock_bh(&im->
lock);
226 igmp_start_timer(im, max_delay);
227 spin_unlock_bh(&im->
lock);
235 #define IGMP_SIZE (sizeof(struct igmphdr)+sizeof(struct iphdr)+4)
239 int gdeleted,
int sdeleted)
244 if (gdeleted || sdeleted)
259 if (gdeleted || sdeleted)
263 if (gdeleted || sdeleted)
276 return gdeleted || (psf->
sf_crcount && sdeleted);
277 return psf->
sf_crcount && !gdeleted && !sdeleted;
283 igmp_scount(
struct ip_mc_list *pmc,
int type,
int gdeleted,
int sdeleted)
289 if (!is_in(pmc, psf, type, gdeleted, sdeleted))
296 #define igmp_skb_size(skb) (*(unsigned int *)((skb)->cb))
304 struct net *
net = dev_net(dev);
310 skb = alloc_skb(size + hlen + tlen,
318 igmp_skb_size(skb) =
size;
328 skb_dst_set(skb, &rt->
dst);
331 skb_reserve(skb, hlen);
333 skb_reset_network_header(skb);
338 pip->ihl = (
sizeof(
struct iphdr)+4)>>2;
342 pip->
daddr = fl4.daddr;
343 pip->
saddr = fl4.saddr;
346 ip_select_ident(pip, &rt->
dst,
NULL);
348 ((
u8 *)&pip[1])[1] = 4;
349 ((
u8 *)&pip[1])[2] = 0;
350 ((
u8 *)&pip[1])[3] = 0;
354 pig = igmpv3_report_hdr(skb);
363 static int igmpv3_sendpack(
struct sk_buff *skb)
365 struct igmphdr *pig = igmp_hdr(skb);
373 static int grec_size(
struct ip_mc_list *pmc,
int type,
int gdel,
int sdel)
375 return sizeof(
struct igmpv3_grec) + 4*igmp_scount(pmc, type, gdel, sdel);
386 skb = igmpv3_newpack(dev, dev->
mtu);
394 pih = igmpv3_report_hdr(skb);
400 #define AVAILABLE(skb) ((skb) ? ((skb)->dev ? igmp_skb_size(skb) - (skb)->len : \
401 skb_tailroom(skb)) : 0)
404 int type,
int gdeleted,
int sdeleted)
409 struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list;
427 pih = skb ? igmpv3_report_hdr(skb) :
NULL;
431 if (pih && pih->
ngrec &&
432 AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) {
434 igmpv3_sendpack(skb);
435 skb = igmpv3_newpack(dev, dev->
mtu);
440 for (psf=*psf_list; psf; psf=psf_next) {
445 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) {
456 if (truncate && !first)
461 igmpv3_sendpack(skb);
462 skb = igmpv3_newpack(dev, dev->
mtu);
467 skb = add_grhead(skb, pmc, type, &pgr);
478 if ((sdeleted || gdeleted) && psf->
sf_crcount == 0) {
498 igmpv3_sendpack(skb);
501 skb = add_grhead(skb, pmc, type, &pgr);
512 static int igmpv3_send_report(
struct in_device *in_dev,
struct ip_mc_list *pmc)
522 spin_lock_bh(&pmc->
lock);
527 skb = add_grec(skb, pmc, type, 0, 0);
528 spin_unlock_bh(&pmc->
lock);
532 spin_lock_bh(&pmc->
lock);
537 skb = add_grec(skb, pmc, type, 0, 0);
538 spin_unlock_bh(&pmc->
lock);
542 return igmpv3_sendpack(skb);
548 static void igmpv3_clear_zeros(
struct ip_sf_list **ppsf)
553 for (psf=*ppsf; psf; psf = psf_next) {
566 static void igmpv3_send_cr(
struct in_device *in_dev)
573 spin_lock_bh(&in_dev->mc_tomb_lock);
577 for (pmc=in_dev->mc_tomb; pmc; pmc=pmc_next) {
578 pmc_next = pmc->
next;
582 skb = add_grec(skb, pmc, type, 1, 0);
583 skb = add_grec(skb, pmc, dtype, 1, 1);
588 skb = add_grec(skb, pmc, type, 1, 0);
592 igmpv3_clear_zeros(&pmc->
tomb);
593 igmpv3_clear_zeros(&pmc->
sources);
598 pmc_prev->
next = pmc_next;
600 in_dev->mc_tomb = pmc_next;
606 spin_unlock_bh(&in_dev->mc_tomb_lock);
610 spin_lock_bh(&pmc->
lock);
618 skb = add_grec(skb, pmc, type, 0, 0);
619 skb = add_grec(skb, pmc, dtype, 0, 1);
627 skb = add_grec(skb, pmc, type, 0, 0);
630 spin_unlock_bh(&pmc->
lock);
636 (
void) igmpv3_sendpack(skb);
639 static int igmp_send_report(
struct in_device *in_dev,
struct ip_mc_list *pmc,
647 struct net *net = dev_net(dev);
654 return igmpv3_send_report(in_dev, pmc);
660 rt = ip_route_output_ports(net, &fl4,
NULL, dst, 0,
668 skb = alloc_skb(IGMP_SIZE + hlen + tlen,
GFP_ATOMIC);
674 skb_dst_set(skb, &rt->
dst);
676 skb_reserve(skb, hlen);
678 skb_reset_network_header(skb);
683 iph->ihl = (
sizeof(
struct iphdr)+4)>>2;
688 iph->
saddr = fl4.saddr;
690 ip_select_ident(iph, &rt->
dst,
NULL);
692 ((
u8 *)&iph[1])[1] = 4;
693 ((
u8 *)&iph[1])[2] = 0;
694 ((
u8 *)&iph[1])[3] = 0;
706 static void igmp_gq_timer_expire(
unsigned long data)
708 struct in_device *in_dev = (
struct in_device *)data;
710 in_dev->mr_gq_running = 0;
711 igmpv3_send_report(in_dev,
NULL);
712 __in_dev_put(in_dev);
715 static void igmp_ifc_timer_expire(
unsigned long data)
717 struct in_device *in_dev = (
struct in_device *)data;
719 igmpv3_send_cr(in_dev);
720 if (in_dev->mr_ifc_count) {
721 in_dev->mr_ifc_count--;
722 igmp_ifc_start_timer(in_dev, IGMP_Unsolicited_Report_Interval);
724 __in_dev_put(in_dev);
729 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))
731 in_dev->mr_ifc_count = in_dev->mr_qrv ? in_dev->mr_qrv :
732 IGMP_Unsolicited_Report_Count;
733 igmp_ifc_start_timer(in_dev, 1);
737 static void igmp_timer_expire(
unsigned long data)
740 struct in_device *in_dev = im->
interface;
742 spin_lock(&im->
lock);
747 igmp_start_timer(im, IGMP_Unsolicited_Report_Interval);
750 spin_unlock(&im->
lock);
752 if (IGMP_V1_SEEN(in_dev))
754 else if (IGMP_V2_SEEN(in_dev))
763 static int igmp_xmarksources(
struct ip_mc_list *pmc,
int nsrcs,
__be32 *srcs)
772 for (i=0; i<nsrcs; i++) {
790 static int igmp_marksources(
struct ip_mc_list *pmc,
int nsrcs,
__be32 *srcs)
796 return igmp_xmarksources(pmc, nsrcs, srcs);
803 for (i=0; i<nsrcs; i++)
819 static bool igmp_heard_report(
struct in_device *in_dev,
__be32 group)
840 static bool igmp_heard_query(
struct in_device *in_dev,
struct sk_buff *skb,
843 struct igmphdr *ih = igmp_hdr(skb);
855 max_delay = IGMP_Query_Response_Interval;
857 IGMP_V1_Router_Present_Timeout;
863 IGMP_V2_Router_Present_Timeout;
866 in_dev->mr_ifc_count = 0;
868 __in_dev_put(in_dev);
870 igmpv3_clear_delrec(in_dev);
871 }
else if (len < 12) {
873 }
else if (IGMP_V1_SEEN(in_dev)) {
875 max_delay = IGMP_Query_Response_Interval;
877 }
else if (IGMP_V2_SEEN(in_dev)) {
891 ih3 = igmpv3_query_hdr(skb);
896 ih3 = igmpv3_query_hdr(skb);
902 in_dev->mr_maxdelay = max_delay;
904 in_dev->mr_qrv = ih3->qrv;
908 igmp_gq_start_timer(in_dev);
912 mark = ih3->
nsrcs != 0;
933 spin_lock_bh(&im->
lock);
940 spin_unlock_bh(&im->
lock);
942 igmp_mod_timer(im, max_delay);
953 struct in_device *in_dev = __in_dev_get_rcu(skb->
dev);
960 if (!pskb_may_pull(skb,
sizeof(
struct igmphdr)))
965 if (!csum_fold(skb->
csum))
977 dropped = igmp_heard_query(in_dev, skb, len);
982 if (rt_is_output_route(skb_rtable(skb)))
987 dropped = igmp_heard_report(in_dev, ih->
group);
990 #ifdef CONFIG_IP_PIMSM_V1
1019 static void ip_mc_filter_add(
struct in_device *in_dev,
__be32 addr)
1039 static void ip_mc_filter_del(
struct in_device *in_dev,
__be32 addr)
1048 #ifdef CONFIG_IP_MULTICAST
1052 static void igmpv3_add_delrec(
struct in_device *in_dev,
struct ip_mc_list *im)
1065 spin_lock_bh(&im->
lock);
1067 in_dev_hold(in_dev);
1069 pmc->
crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
1070 IGMP_Unsolicited_Report_Count;
1081 spin_unlock_bh(&im->
lock);
1083 spin_lock_bh(&in_dev->mc_tomb_lock);
1084 pmc->
next = in_dev->mc_tomb;
1085 in_dev->mc_tomb = pmc;
1086 spin_unlock_bh(&in_dev->mc_tomb_lock);
1089 static void igmpv3_del_delrec(
struct in_device *in_dev,
__be32 multiaddr)
1094 spin_lock_bh(&in_dev->mc_tomb_lock);
1096 for (pmc=in_dev->mc_tomb; pmc; pmc=pmc->
next) {
1105 in_dev->mc_tomb = pmc->
next;
1107 spin_unlock_bh(&in_dev->mc_tomb_lock);
1109 for (psf=pmc->
tomb; psf; psf=psf_next) {
1118 static void igmpv3_clear_delrec(
struct in_device *in_dev)
1122 spin_lock_bh(&in_dev->mc_tomb_lock);
1123 pmc = in_dev->mc_tomb;
1124 in_dev->mc_tomb =
NULL;
1125 spin_unlock_bh(&in_dev->mc_tomb_lock);
1127 for (; pmc; pmc = nextpmc) {
1128 nextpmc = pmc->
next;
1129 ip_mc_clear_src(pmc);
1138 spin_lock_bh(&pmc->
lock);
1141 spin_unlock_bh(&pmc->
lock);
1142 for (; psf; psf=psf_next) {
1151 static void igmp_group_dropped(
struct ip_mc_list *im)
1153 struct in_device *in_dev = im->
interface;
1154 #ifdef CONFIG_IP_MULTICAST
1160 ip_mc_filter_del(in_dev, im->
multiaddr);
1163 #ifdef CONFIG_IP_MULTICAST
1168 igmp_stop_timer(im);
1170 if (!in_dev->dead) {
1171 if (IGMP_V1_SEEN(in_dev))
1173 if (IGMP_V2_SEEN(in_dev)) {
1179 igmpv3_add_delrec(in_dev, im);
1186 static void igmp_group_added(
struct ip_mc_list *im)
1188 struct in_device *in_dev = im->
interface;
1192 ip_mc_filter_add(in_dev, im->
multiaddr);
1195 #ifdef CONFIG_IP_MULTICAST
1201 if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) {
1202 spin_lock_bh(&im->
lock);
1203 igmp_start_timer(im, IGMP_Initial_Report_Delay);
1204 spin_unlock_bh(&im->
lock);
1209 im->
crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
1210 IGMP_Unsolicited_Report_Count;
1245 in_dev_hold(in_dev);
1252 #ifdef CONFIG_IP_MULTICAST
1254 im->unsolicit_count = IGMP_Unsolicited_Report_Count;
1257 im->next_rcu = in_dev->mc_list;
1261 #ifdef CONFIG_IP_MULTICAST
1262 igmpv3_del_delrec(in_dev, im->multiaddr);
1264 igmp_group_added(im);
1278 #ifdef CONFIG_IP_MULTICAST
1289 if (IGMP_V1_SEEN(in_dev))
1291 else if (IGMP_V2_SEEN(in_dev))
1295 igmp_send_report(in_dev, im, type);
1312 for (ip = &in_dev->mc_list;
1316 if (--i->
users == 0) {
1319 igmp_group_dropped(i);
1343 igmp_group_dropped(pmc);
1353 igmp_group_added(pmc);
1365 igmp_group_dropped(pmc);
1367 #ifdef CONFIG_IP_MULTICAST
1368 in_dev->mr_ifc_count = 0;
1370 __in_dev_put(in_dev);
1371 in_dev->mr_gq_running = 0;
1373 __in_dev_put(in_dev);
1374 igmpv3_clear_delrec(in_dev);
1384 in_dev->mc_tomb =
NULL;
1385 #ifdef CONFIG_IP_MULTICAST
1386 in_dev->mr_gq_running = 0;
1387 setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire,
1388 (
unsigned long)in_dev);
1389 in_dev->mr_ifc_count = 0;
1390 in_dev->mc_count = 0;
1391 setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire,
1392 (
unsigned long)in_dev);
1393 in_dev->mr_qrv = IGMP_Unsolicited_Report_Count;
1410 igmp_group_added(pmc);
1437 static struct in_device *ip_mc_find_dev(
struct net *net,
struct ip_mreqn *
imr)
1453 struct rtable *rt = ip_route_output(net,
1463 idev = __in_dev_get_rtnl(dev);
1475 static int ip_mc_del1_src(
struct ip_mc_list *pmc,
int sfmode,
1487 if (!psf || psf->
sf_count[sfmode] == 0) {
1496 #ifdef CONFIG_IP_MULTICAST
1497 struct in_device *in_dev = pmc->
interface;
1505 #ifdef CONFIG_IP_MULTICAST
1507 !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
1508 psf->
sf_crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
1509 IGMP_Unsolicited_Report_Count;
1520 #ifndef CONFIG_IP_MULTICAST
1521 #define igmp_ifc_event(x) do { } while (0)
1524 static int ip_mc_del_src(
struct in_device *in_dev,
__be32 *pmca,
int sfmode,
1543 spin_lock_bh(&pmc->
lock);
1545 #ifdef CONFIG_IP_MULTICAST
1556 int rv = ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
1558 changerec |= rv > 0;
1565 #ifdef CONFIG_IP_MULTICAST
1571 #ifdef CONFIG_IP_MULTICAST
1572 pmc->
crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
1573 IGMP_Unsolicited_Report_Count;
1574 in_dev->mr_ifc_count = pmc->
crcount;
1578 }
else if (sf_setstate(pmc) || changerec) {
1583 spin_unlock_bh(&pmc->
lock);
1590 static int ip_mc_add1_src(
struct ip_mc_list *pmc,
int sfmode,
1618 #ifdef CONFIG_IP_MULTICAST
1619 static void sf_markstate(
struct ip_mc_list *pmc)
1633 static int sf_setstate(
struct ip_mc_list *pmc)
1696 static int ip_mc_add_src(
struct in_device *in_dev,
__be32 *pmca,
int sfmode,
1715 spin_lock_bh(&pmc->
lock);
1718 #ifdef CONFIG_IP_MULTICAST
1726 err = ip_mc_add1_src(pmc, sfmode, &psfsrc[i]);
1736 (
void) ip_mc_del1_src(pmc, sfmode, &psfsrc[j]);
1738 #ifdef CONFIG_IP_MULTICAST
1748 #ifdef CONFIG_IP_MULTICAST
1751 pmc->
crcount = in_dev->mr_qrv ? in_dev->mr_qrv :
1752 IGMP_Unsolicited_Report_Count;
1753 in_dev->mr_ifc_count = pmc->
crcount;
1757 }
else if (sf_setstate(pmc)) {
1761 spin_unlock_bh(&pmc->
lock);
1765 static void ip_mc_clear_src(
struct ip_mc_list *pmc)
1769 for (psf=pmc->
tomb; psf; psf=nextpsf) {
1774 for (psf=pmc->
sources; psf; psf=nextpsf) {
1793 struct in_device *in_dev;
1795 struct net *net = sock_net(sk);
1799 if (!ipv4_is_multicast(addr))
1804 in_dev = ip_mc_find_dev(net, imr);
1815 if (i->multi.imr_multiaddr.s_addr == addr &&
1816 i->multi.imr_ifindex == ifindex)
1841 struct in_device *in_dev)
1848 return ip_mc_del_src(in_dev, &iml->
multi.imr_multiaddr.s_addr,
1851 err = ip_mc_del_src(in_dev, &iml->
multi.imr_multiaddr.s_addr,
1869 struct in_device *in_dev;
1870 struct net *net = sock_net(sk);
1876 in_dev = ip_mc_find_dev(net, imr);
1881 if (iml->
multi.imr_multiaddr.s_addr != group)
1884 if (iml->
multi.imr_ifindex != ifindex)
1887 iml->
multi.imr_address.s_addr)
1890 (
void) ip_mc_leave_src(sk, iml, in_dev);
1916 struct in_device *in_dev =
NULL;
1919 struct net *net = sock_net(sk);
1923 if (!ipv4_is_multicast(addr))
1931 in_dev = ip_mc_find_dev(net, &imr);
1940 if ((pmc->
multi.imr_multiaddr.s_addr ==
1951 if (pmc->
sfmode != omode) {
1955 }
else if (pmc->
sfmode != omode) {
2052 struct in_device *in_dev;
2055 struct net *net = sock_net(sk);
2058 if (!ipv4_is_multicast(addr))
2069 in_dev = ip_mc_find_dev(net, &imr);
2133 struct ip_msfilter __user *optval,
int __user *optlen)
2139 struct in_device *in_dev;
2142 struct net *net = sock_net(sk);
2144 if (!ipv4_is_multicast(addr))
2152 in_dev = ip_mc_find_dev(net, &imr);
2177 len = copycount *
sizeof(psl->
sl_addr[0]);
2193 struct group_filter __user *optval,
int __user *optlen)
2206 if (!ipv4_is_multicast(addr))
2214 if (pmc->
multi.imr_multiaddr.s_addr == addr &&
2230 for (i=0; i<copycount; i++) {
2234 memset(&ss, 0,
sizeof(ss));
2236 psin->sin_addr.s_addr = psl->
sl_addr[
i];
2237 if (
copy_to_user(&optval->gf_slist[i], &ss,
sizeof(ss)))
2258 if (!ipv4_is_multicast(loc_addr))
2263 if (pmc->
multi.imr_multiaddr.s_addr == loc_addr &&
2264 pmc->
multi.imr_ifindex == dif)
2276 if (psl->
sl_addr[i] == rmt_addr)
2299 struct net *net = sock_net(sk);
2306 struct in_device *in_dev;
2310 (
void) ip_mc_leave_src(sk, iml, in_dev);
2351 #if defined(CONFIG_PROC_FS)
2352 struct igmp_mc_iter_state {
2355 struct in_device *in_dev;
2358 #define igmp_mc_seq_private(seq) ((struct igmp_mc_iter_state *)(seq)->private)
2362 struct net *net = seq_file_net(seq);
2364 struct igmp_mc_iter_state *
state = igmp_mc_seq_private(seq);
2366 state->in_dev =
NULL;
2368 struct in_device *in_dev;
2370 in_dev = __in_dev_get_rcu(state->dev);
2375 state->in_dev = in_dev;
2384 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2388 state->dev = next_net_device_rcu(state->dev);
2390 state->in_dev =
NULL;
2393 state->in_dev = __in_dev_get_rcu(state->dev);
2403 struct ip_mc_list *im = igmp_mc_get_first(seq);
2405 while (pos && (im = igmp_mc_get_next(seq, im)) !=
NULL)
2407 return pos ?
NULL : im;
2410 static void *igmp_mc_seq_start(
struct seq_file *seq, loff_t *pos)
2417 static void *igmp_mc_seq_next(
struct seq_file *seq,
void *
v, loff_t *pos)
2421 im = igmp_mc_get_first(seq);
2423 im = igmp_mc_get_next(seq, v);
2428 static void igmp_mc_seq_stop(
struct seq_file *seq,
void *v)
2431 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2433 state->in_dev =
NULL;
2438 static int igmp_mc_seq_show(
struct seq_file *seq,
void *v)
2442 "Idx\tDevice : Count Querier\tGroup Users Timer\tReporter\n");
2445 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2449 #ifdef CONFIG_IP_MULTICAST
2450 querier = IGMP_V1_SEEN(state->in_dev) ?
"V1" :
2451 IGMP_V2_SEEN(state->in_dev) ?
"V2" :
2459 state->dev->ifindex, state->dev->name, state->in_dev->mc_count, querier);
2464 "\t\t\t\t%08X %5d %d:%08lX\t\t%d\n",
2467 im->
tm_running ? jiffies_delta_to_clock_t(delta) : 0,
2474 .
start = igmp_mc_seq_start,
2475 .next = igmp_mc_seq_next,
2476 .stop = igmp_mc_seq_stop,
2477 .show = igmp_mc_seq_show,
2483 sizeof(
struct igmp_mc_iter_state));
2488 .open = igmp_mc_seq_open,
2494 struct igmp_mcf_iter_state {
2497 struct in_device *
idev;
2501 #define igmp_mcf_seq_private(seq) ((struct igmp_mcf_iter_state *)(seq)->private)
2505 struct net *net = seq_file_net(seq);
2508 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2513 struct in_device *
idev;
2514 idev = __in_dev_get_rcu(state->dev);
2519 spin_lock_bh(&im->
lock);
2526 spin_unlock_bh(&im->
lock);
2534 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2538 spin_unlock_bh(&state->im->lock);
2539 state->im = state->im->next;
2540 while (!state->im) {
2541 state->dev = next_net_device_rcu(state->dev);
2546 state->idev = __in_dev_get_rcu(state->dev);
2553 spin_lock_bh(&state->im->lock);
2554 psf = state->im->sources;
2562 struct ip_sf_list *psf = igmp_mcf_get_first(seq);
2564 while (pos && (psf = igmp_mcf_get_next(seq, psf)) !=
NULL)
2566 return pos ?
NULL : psf;
2569 static void *igmp_mcf_seq_start(
struct seq_file *seq, loff_t *pos)
2576 static void *igmp_mcf_seq_next(
struct seq_file *seq,
void *v, loff_t *pos)
2580 psf = igmp_mcf_get_first(seq);
2582 psf = igmp_mcf_get_next(seq, v);
2587 static void igmp_mcf_seq_stop(
struct seq_file *seq,
void *v)
2590 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2592 spin_unlock_bh(&state->im->lock);
2600 static int igmp_mcf_seq_show(
struct seq_file *seq,
void *v)
2603 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2608 "%10s %10s %6s %6s\n",
"Idx",
2610 "SRC",
"INC",
"EXC");
2614 "0x%08x %6lu %6lu\n",
2615 state->dev->ifindex, state->dev->name,
2616 ntohl(state->im->multiaddr),
2625 .
start = igmp_mcf_seq_start,
2626 .next = igmp_mcf_seq_next,
2627 .stop = igmp_mcf_seq_stop,
2628 .show = igmp_mcf_seq_show,
2631 static int igmp_mcf_seq_open(
struct inode *inode,
struct file *file)
2634 sizeof(
struct igmp_mcf_iter_state));
2639 .open = igmp_mcf_seq_open,
2645 static int __net_init igmp_net_init(
struct net *net)
2663 static void __net_exit igmp_net_exit(
struct net *net)
2670 .
init = igmp_net_init,
2671 .exit = igmp_net_exit,