2 * IP multicast routing support for mrouted 3.6/3.8
4 * (c) 1995 Alan Cox, <alan@redhat.com>
5 * Linux Consultancy and Custom Driver Development
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 * Version: $Id: ipmr.c,v 1.65 2001/10/31 21:55:54 davem Exp $
15 * Michael Chastain : Incorrect size of copying.
16 * Alan Cox : Added the cache manager code
17 * Alan Cox : Fixed the clone/copy bug and device race.
18 * Mike McLagan : Routing by source
19 * Malcolm Beattie : Buffer handling fixes.
20 * Alexey Kuznetsov : Double buffer free and other fixes.
21 * SVR Anand : Fixed several multicast bugs and problems.
22 * Alexey Kuznetsov : Status, optimisations and more.
23 * Brad Parker : Better behaviour on mrouted upcall
25 * Carlos Picoto : PIMv1 Support
26 * Pavlin Ivanov Radoslavov: PIMv2 Registers must checksum only PIM header
27 * Relax this requrement to work with older peers.
31 #include <asm/system.h>
32 #include <asm/uaccess.h>
33 #include <linux/types.h>
34 #include <linux/capability.h>
35 #include <linux/errno.h>
36 #include <linux/timer.h>
38 #include <linux/kernel.h>
39 #include <linux/fcntl.h>
40 #include <linux/stat.h>
41 #include <linux/socket.h>
43 #include <linux/inet.h>
44 #include <linux/netdevice.h>
45 #include <linux/inetdevice.h>
46 #include <linux/igmp.h>
47 #include <linux/proc_fs.h>
48 #include <linux/seq_file.h>
49 #include <linux/mroute.h>
50 #include <linux/init.h>
51 #include <linux/if_ether.h>
53 #include <net/protocol.h>
54 #include <linux/skbuff.h>
55 #include <net/route.h>
60 #include <linux/notifier.h>
61 #include <linux/if_arp.h>
62 #include <linux/netfilter_ipv4.h>
64 #include <net/checksum.h>
65 #include <net/netlink.h>
67 #if defined(CONFIG_IP_PIMSM_V1) || defined(CONFIG_IP_PIMSM_V2)
68 #define CONFIG_IP_PIMSM 1
71 static struct sock *mroute_socket;
74 /* Big lock, protecting vif table, mrt cache and mroute socket state.
75 Note that the changes are semaphored via rtnl_lock.
78 static DEFINE_RWLOCK(mrt_lock);
81 * Multicast router control variables
84 static struct vif_device vif_table[MAXVIFS]; /* Devices */
87 #define VIF_EXISTS(idx) (vif_table[idx].dev != NULL)
89 static int mroute_do_assert; /* Set in PIM assert */
90 static int mroute_do_pim;
92 static struct mfc_cache *mfc_cache_array[MFC_LINES]; /* Forwarding cache */
94 static struct mfc_cache *mfc_unres_queue; /* Queue of unresolved entries */
95 static atomic_t cache_resolve_queue_len; /* Size of unresolved */
97 /* Special spinlock for queue of unresolved entries */
98 static DEFINE_SPINLOCK(mfc_unres_lock);
100 /* We return to original Alan's scheme. Hash table of resolved
101 entries is changed only in process context and protected
102 with weak lock mrt_lock. Queue of unresolved entries is protected
103 with strong spinlock mfc_unres_lock.
105 In this case data path is free of exclusive locks at all.
108 static struct kmem_cache *mrt_cachep __read_mostly;
110 static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local);
111 static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert);
112 static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm);
114 #ifdef CONFIG_IP_PIMSM_V2
115 static struct net_protocol pim_protocol;
118 static struct timer_list ipmr_expire_timer;
120 /* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */
123 struct net_device *ipmr_new_tunnel(struct vifctl *v)
125 struct net_device *dev;
127 dev = __dev_get_by_name("tunl0");
133 struct ip_tunnel_parm p;
134 struct in_device *in_dev;
136 memset(&p, 0, sizeof(p));
137 p.iph.daddr = v->vifc_rmt_addr.s_addr;
138 p.iph.saddr = v->vifc_lcl_addr.s_addr;
141 p.iph.protocol = IPPROTO_IPIP;
142 sprintf(p.name, "dvmrp%d", v->vifc_vifi);
143 ifr.ifr_ifru.ifru_data = (void*)&p;
145 oldfs = get_fs(); set_fs(KERNEL_DS);
146 err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
151 if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) {
152 dev->flags |= IFF_MULTICAST;
154 in_dev = __in_dev_get_rtnl(dev);
158 ipv4_devconf_setall(in_dev);
159 IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0;
168 /* allow the register to be completed before unregistering. */
172 unregister_netdevice(dev);
176 #ifdef CONFIG_IP_PIMSM
178 static int reg_vif_num = -1;
180 static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)
182 read_lock(&mrt_lock);
183 ((struct net_device_stats*)netdev_priv(dev))->tx_bytes += skb->len;
184 ((struct net_device_stats*)netdev_priv(dev))->tx_packets++;
185 ipmr_cache_report(skb, reg_vif_num, IGMPMSG_WHOLEPKT);
186 read_unlock(&mrt_lock);
191 static struct net_device_stats *reg_vif_get_stats(struct net_device *dev)
193 return (struct net_device_stats*)netdev_priv(dev);
196 static void reg_vif_setup(struct net_device *dev)
198 dev->type = ARPHRD_PIMREG;
199 dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8;
200 dev->flags = IFF_NOARP;
201 dev->hard_start_xmit = reg_vif_xmit;
202 dev->get_stats = reg_vif_get_stats;
203 dev->destructor = free_netdev;
206 static struct net_device *ipmr_reg_vif(void)
208 struct net_device *dev;
209 struct in_device *in_dev;
211 dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
217 if (register_netdevice(dev)) {
224 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
229 ipv4_devconf_setall(in_dev);
230 IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0;
239 /* allow the register to be completed before unregistering. */
243 unregister_netdevice(dev);
252 static int vif_delete(int vifi)
254 struct vif_device *v;
255 struct net_device *dev;
256 struct in_device *in_dev;
258 if (vifi < 0 || vifi >= maxvif)
259 return -EADDRNOTAVAIL;
261 v = &vif_table[vifi];
263 write_lock_bh(&mrt_lock);
268 write_unlock_bh(&mrt_lock);
269 return -EADDRNOTAVAIL;
272 #ifdef CONFIG_IP_PIMSM
273 if (vifi == reg_vif_num)
277 if (vifi+1 == maxvif) {
279 for (tmp=vifi-1; tmp>=0; tmp--) {
286 write_unlock_bh(&mrt_lock);
288 dev_set_allmulti(dev, -1);
290 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
291 IPV4_DEVCONF(in_dev->cnf, MC_FORWARDING)--;
292 ip_rt_multicast_event(in_dev);
295 if (v->flags&(VIFF_TUNNEL|VIFF_REGISTER))
296 unregister_netdevice(dev);
302 /* Destroy an unresolved cache entry, killing queued skbs
303 and reporting error to netlink readers.
306 static void ipmr_destroy_unres(struct mfc_cache *c)
311 atomic_dec(&cache_resolve_queue_len);
313 while ((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) {
314 if (ip_hdr(skb)->version == 0) {
315 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
316 nlh->nlmsg_type = NLMSG_ERROR;
317 nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nlmsgerr));
318 skb_trim(skb, nlh->nlmsg_len);
320 e->error = -ETIMEDOUT;
321 memset(&e->msg, 0, sizeof(e->msg));
323 rtnl_unicast(skb, NETLINK_CB(skb).pid);
328 kmem_cache_free(mrt_cachep, c);
332 /* Single timer process for all the unresolved queue. */
334 static void ipmr_expire_process(unsigned long dummy)
337 unsigned long expires;
338 struct mfc_cache *c, **cp;
340 if (!spin_trylock(&mfc_unres_lock)) {
341 mod_timer(&ipmr_expire_timer, jiffies+HZ/10);
345 if (atomic_read(&cache_resolve_queue_len) == 0)
350 cp = &mfc_unres_queue;
352 while ((c=*cp) != NULL) {
353 if (time_after(c->mfc_un.unres.expires, now)) {
354 unsigned long interval = c->mfc_un.unres.expires - now;
355 if (interval < expires)
363 ipmr_destroy_unres(c);
366 if (atomic_read(&cache_resolve_queue_len))
367 mod_timer(&ipmr_expire_timer, jiffies + expires);
370 spin_unlock(&mfc_unres_lock);
373 /* Fill oifs list. It is called under write locked mrt_lock. */
375 static void ipmr_update_thresholds(struct mfc_cache *cache, unsigned char *ttls)
379 cache->mfc_un.res.minvif = MAXVIFS;
380 cache->mfc_un.res.maxvif = 0;
381 memset(cache->mfc_un.res.ttls, 255, MAXVIFS);
383 for (vifi=0; vifi<maxvif; vifi++) {
384 if (VIF_EXISTS(vifi) && ttls[vifi] && ttls[vifi] < 255) {
385 cache->mfc_un.res.ttls[vifi] = ttls[vifi];
386 if (cache->mfc_un.res.minvif > vifi)
387 cache->mfc_un.res.minvif = vifi;
388 if (cache->mfc_un.res.maxvif <= vifi)
389 cache->mfc_un.res.maxvif = vifi + 1;
394 static int vif_add(struct vifctl *vifc, int mrtsock)
396 int vifi = vifc->vifc_vifi;
397 struct vif_device *v = &vif_table[vifi];
398 struct net_device *dev;
399 struct in_device *in_dev;
402 if (VIF_EXISTS(vifi))
405 switch (vifc->vifc_flags) {
406 #ifdef CONFIG_IP_PIMSM
409 * Special Purpose VIF in PIM
410 * All the packets will be sent to the daemon
412 if (reg_vif_num >= 0)
414 dev = ipmr_reg_vif();
420 dev = ipmr_new_tunnel(vifc);
425 dev = ip_dev_find(vifc->vifc_lcl_addr.s_addr);
427 return -EADDRNOTAVAIL;
434 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
435 return -EADDRNOTAVAIL;
436 IPV4_DEVCONF(in_dev->cnf, MC_FORWARDING)++;
437 dev_set_allmulti(dev, +1);
438 ip_rt_multicast_event(in_dev);
441 * Fill in the VIF structures
443 v->rate_limit=vifc->vifc_rate_limit;
444 v->local=vifc->vifc_lcl_addr.s_addr;
445 v->remote=vifc->vifc_rmt_addr.s_addr;
446 v->flags=vifc->vifc_flags;
448 v->flags |= VIFF_STATIC;
449 v->threshold=vifc->vifc_threshold;
454 v->link = dev->ifindex;
455 if (v->flags&(VIFF_TUNNEL|VIFF_REGISTER))
456 v->link = dev->iflink;
458 /* And finish update writing critical data */
459 write_lock_bh(&mrt_lock);
462 #ifdef CONFIG_IP_PIMSM
463 if (v->flags&VIFF_REGISTER)
468 write_unlock_bh(&mrt_lock);
472 static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
474 int line=MFC_HASH(mcastgrp,origin);
477 for (c=mfc_cache_array[line]; c; c = c->next) {
478 if (c->mfc_origin==origin && c->mfc_mcastgrp==mcastgrp)
485 * Allocate a multicast cache entry
487 static struct mfc_cache *ipmr_cache_alloc(void)
489 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
492 c->mfc_un.res.minvif = MAXVIFS;
496 static struct mfc_cache *ipmr_cache_alloc_unres(void)
498 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
501 skb_queue_head_init(&c->mfc_un.unres.unresolved);
502 c->mfc_un.unres.expires = jiffies + 10*HZ;
507 * A cache entry has gone into a resolved state from queued
510 static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
516 * Play the pending entries through our router
519 while ((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) {
520 if (ip_hdr(skb)->version == 0) {
521 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
523 if (ipmr_fill_mroute(skb, c, NLMSG_DATA(nlh)) > 0) {
524 nlh->nlmsg_len = (skb_tail_pointer(skb) -
527 nlh->nlmsg_type = NLMSG_ERROR;
528 nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nlmsgerr));
529 skb_trim(skb, nlh->nlmsg_len);
531 e->error = -EMSGSIZE;
532 memset(&e->msg, 0, sizeof(e->msg));
535 rtnl_unicast(skb, NETLINK_CB(skb).pid);
537 ip_mr_forward(skb, c, 0);
542 * Bounce a cache query up to mrouted. We could use netlink for this but mrouted
543 * expects the following bizarre scheme.
545 * Called under mrt_lock.
548 static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
551 const int ihl = ip_hdrlen(pkt);
552 struct igmphdr *igmp;
556 #ifdef CONFIG_IP_PIMSM
557 if (assert == IGMPMSG_WHOLEPKT)
558 skb = skb_realloc_headroom(pkt, sizeof(struct iphdr));
561 skb = alloc_skb(128, GFP_ATOMIC);
566 #ifdef CONFIG_IP_PIMSM
567 if (assert == IGMPMSG_WHOLEPKT) {
568 /* Ugly, but we have no choice with this interface.
569 Duplicate old header, fix ihl, length etc.
570 And all this only to mangle msg->im_msgtype and
571 to set msg->im_mbz to "mbz" :-)
573 skb_push(skb, sizeof(struct iphdr));
574 skb_reset_network_header(skb);
575 skb_reset_transport_header(skb);
576 msg = (struct igmpmsg *)skb_network_header(skb);
577 memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
578 msg->im_msgtype = IGMPMSG_WHOLEPKT;
580 msg->im_vif = reg_vif_num;
581 ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2;
582 ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) +
583 sizeof(struct iphdr));
592 skb->network_header = skb->tail;
594 skb_copy_to_linear_data(skb, pkt->data, ihl);
595 ip_hdr(skb)->protocol = 0; /* Flag to the kernel this is a route add */
596 msg = (struct igmpmsg *)skb_network_header(skb);
598 skb->dst = dst_clone(pkt->dst);
604 igmp=(struct igmphdr *)skb_put(skb,sizeof(struct igmphdr));
606 msg->im_msgtype = assert;
608 ip_hdr(skb)->tot_len = htons(skb->len); /* Fix the length */
609 skb->transport_header = skb->network_header;
612 if (mroute_socket == NULL) {
620 if ((ret=sock_queue_rcv_skb(mroute_socket,skb))<0) {
622 printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n");
630 * Queue a packet for resolution. It gets locked cache entry!
634 ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
638 const struct iphdr *iph = ip_hdr(skb);
640 spin_lock_bh(&mfc_unres_lock);
641 for (c=mfc_unres_queue; c; c=c->next) {
642 if (c->mfc_mcastgrp == iph->daddr &&
643 c->mfc_origin == iph->saddr)
649 * Create a new entry if allowable
652 if (atomic_read(&cache_resolve_queue_len)>=10 ||
653 (c=ipmr_cache_alloc_unres())==NULL) {
654 spin_unlock_bh(&mfc_unres_lock);
661 * Fill in the new cache entry
664 c->mfc_origin = iph->saddr;
665 c->mfc_mcastgrp = iph->daddr;
668 * Reflect first query at mrouted.
670 if ((err = ipmr_cache_report(skb, vifi, IGMPMSG_NOCACHE))<0) {
671 /* If the report failed throw the cache entry
674 spin_unlock_bh(&mfc_unres_lock);
676 kmem_cache_free(mrt_cachep, c);
681 atomic_inc(&cache_resolve_queue_len);
682 c->next = mfc_unres_queue;
685 mod_timer(&ipmr_expire_timer, c->mfc_un.unres.expires);
689 * See if we can append the packet
691 if (c->mfc_un.unres.unresolved.qlen>3) {
695 skb_queue_tail(&c->mfc_un.unres.unresolved,skb);
699 spin_unlock_bh(&mfc_unres_lock);
704 * MFC cache manipulation by user space mroute daemon
707 static int ipmr_mfc_delete(struct mfcctl *mfc)
710 struct mfc_cache *c, **cp;
712 line=MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
714 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) {
715 if (c->mfc_origin == mfc->mfcc_origin.s_addr &&
716 c->mfc_mcastgrp == mfc->mfcc_mcastgrp.s_addr) {
717 write_lock_bh(&mrt_lock);
719 write_unlock_bh(&mrt_lock);
721 kmem_cache_free(mrt_cachep, c);
728 static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
731 struct mfc_cache *uc, *c, **cp;
733 line=MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
735 for (cp=&mfc_cache_array[line]; (c=*cp) != NULL; cp = &c->next) {
736 if (c->mfc_origin == mfc->mfcc_origin.s_addr &&
737 c->mfc_mcastgrp == mfc->mfcc_mcastgrp.s_addr)
742 write_lock_bh(&mrt_lock);
743 c->mfc_parent = mfc->mfcc_parent;
744 ipmr_update_thresholds(c, mfc->mfcc_ttls);
746 c->mfc_flags |= MFC_STATIC;
747 write_unlock_bh(&mrt_lock);
751 if (!MULTICAST(mfc->mfcc_mcastgrp.s_addr))
754 c=ipmr_cache_alloc();
758 c->mfc_origin=mfc->mfcc_origin.s_addr;
759 c->mfc_mcastgrp=mfc->mfcc_mcastgrp.s_addr;
760 c->mfc_parent=mfc->mfcc_parent;
761 ipmr_update_thresholds(c, mfc->mfcc_ttls);
763 c->mfc_flags |= MFC_STATIC;
765 write_lock_bh(&mrt_lock);
766 c->next = mfc_cache_array[line];
767 mfc_cache_array[line] = c;
768 write_unlock_bh(&mrt_lock);
771 * Check to see if we resolved a queued list. If so we
772 * need to send on the frames and tidy up.
774 spin_lock_bh(&mfc_unres_lock);
775 for (cp = &mfc_unres_queue; (uc=*cp) != NULL;
777 if (uc->mfc_origin == c->mfc_origin &&
778 uc->mfc_mcastgrp == c->mfc_mcastgrp) {
780 if (atomic_dec_and_test(&cache_resolve_queue_len))
781 del_timer(&ipmr_expire_timer);
785 spin_unlock_bh(&mfc_unres_lock);
788 ipmr_cache_resolve(uc, c);
789 kmem_cache_free(mrt_cachep, uc);
795 * Close the multicast socket, and clear the vif tables etc
798 static void mroute_clean_tables(struct sock *sk)
803 * Shut down all active vif entries
805 for (i=0; i<maxvif; i++) {
806 if (!(vif_table[i].flags&VIFF_STATIC))
813 for (i=0;i<MFC_LINES;i++) {
814 struct mfc_cache *c, **cp;
816 cp = &mfc_cache_array[i];
817 while ((c = *cp) != NULL) {
818 if (c->mfc_flags&MFC_STATIC) {
822 write_lock_bh(&mrt_lock);
824 write_unlock_bh(&mrt_lock);
826 kmem_cache_free(mrt_cachep, c);
830 if (atomic_read(&cache_resolve_queue_len) != 0) {
833 spin_lock_bh(&mfc_unres_lock);
834 while (mfc_unres_queue != NULL) {
836 mfc_unres_queue = c->next;
837 spin_unlock_bh(&mfc_unres_lock);
839 ipmr_destroy_unres(c);
841 spin_lock_bh(&mfc_unres_lock);
843 spin_unlock_bh(&mfc_unres_lock);
847 static void mrtsock_destruct(struct sock *sk)
850 if (sk == mroute_socket) {
851 IPV4_DEVCONF_ALL(MC_FORWARDING)--;
853 write_lock_bh(&mrt_lock);
855 write_unlock_bh(&mrt_lock);
857 mroute_clean_tables(sk);
863 * Socket options and virtual interface manipulation. The whole
864 * virtual interface system is a complete heap, but unfortunately
865 * that's how BSD mrouted happens to think. Maybe one day with a proper
866 * MOSPF/PIM router set up we can clean this up.
869 int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen)
875 if (optname != MRT_INIT) {
876 if (sk != mroute_socket && !capable(CAP_NET_ADMIN))
882 if (sk->sk_type != SOCK_RAW ||
883 inet_sk(sk)->num != IPPROTO_IGMP)
885 if (optlen!=sizeof(int))
894 ret = ip_ra_control(sk, 1, mrtsock_destruct);
896 write_lock_bh(&mrt_lock);
898 write_unlock_bh(&mrt_lock);
900 IPV4_DEVCONF_ALL(MC_FORWARDING)++;
905 if (sk!=mroute_socket)
907 return ip_ra_control(sk, 0, NULL);
910 if (optlen!=sizeof(vif))
912 if (copy_from_user(&vif,optval,sizeof(vif)))
914 if (vif.vifc_vifi >= MAXVIFS)
917 if (optname==MRT_ADD_VIF) {
918 ret = vif_add(&vif, sk==mroute_socket);
920 ret = vif_delete(vif.vifc_vifi);
926 * Manipulate the forwarding caches. These live
927 * in a sort of kernel/user symbiosis.
931 if (optlen!=sizeof(mfc))
933 if (copy_from_user(&mfc,optval, sizeof(mfc)))
936 if (optname==MRT_DEL_MFC)
937 ret = ipmr_mfc_delete(&mfc);
939 ret = ipmr_mfc_add(&mfc, sk==mroute_socket);
943 * Control PIM assert.
948 if (get_user(v,(int __user *)optval))
950 mroute_do_assert=(v)?1:0;
953 #ifdef CONFIG_IP_PIMSM
957 if (get_user(v,(int __user *)optval))
962 if (v != mroute_do_pim) {
964 mroute_do_assert = v;
965 #ifdef CONFIG_IP_PIMSM_V2
967 ret = inet_add_protocol(&pim_protocol,
970 ret = inet_del_protocol(&pim_protocol,
981 * Spurious command, or MRT_VERSION which you cannot
990 * Getsock opt support for the multicast routing system.
993 int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen)
998 if (optname!=MRT_VERSION &&
999 #ifdef CONFIG_IP_PIMSM
1002 optname!=MRT_ASSERT)
1003 return -ENOPROTOOPT;
1005 if (get_user(olr, optlen))
1008 olr = min_t(unsigned int, olr, sizeof(int));
1012 if (put_user(olr,optlen))
1014 if (optname==MRT_VERSION)
1016 #ifdef CONFIG_IP_PIMSM
1017 else if (optname==MRT_PIM)
1021 val=mroute_do_assert;
1022 if (copy_to_user(optval,&val,olr))
1028 * The IP multicast ioctl support routines.
1031 int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
1033 struct sioc_sg_req sr;
1034 struct sioc_vif_req vr;
1035 struct vif_device *vif;
1036 struct mfc_cache *c;
1040 if (copy_from_user(&vr,arg,sizeof(vr)))
1042 if (vr.vifi>=maxvif)
1044 read_lock(&mrt_lock);
1045 vif=&vif_table[vr.vifi];
1046 if (VIF_EXISTS(vr.vifi)) {
1047 vr.icount=vif->pkt_in;
1048 vr.ocount=vif->pkt_out;
1049 vr.ibytes=vif->bytes_in;
1050 vr.obytes=vif->bytes_out;
1051 read_unlock(&mrt_lock);
1053 if (copy_to_user(arg,&vr,sizeof(vr)))
1057 read_unlock(&mrt_lock);
1058 return -EADDRNOTAVAIL;
1060 if (copy_from_user(&sr,arg,sizeof(sr)))
1063 read_lock(&mrt_lock);
1064 c = ipmr_cache_find(sr.src.s_addr, sr.grp.s_addr);
1066 sr.pktcnt = c->mfc_un.res.pkt;
1067 sr.bytecnt = c->mfc_un.res.bytes;
1068 sr.wrong_if = c->mfc_un.res.wrong_if;
1069 read_unlock(&mrt_lock);
1071 if (copy_to_user(arg,&sr,sizeof(sr)))
1075 read_unlock(&mrt_lock);
1076 return -EADDRNOTAVAIL;
1078 return -ENOIOCTLCMD;
1083 static int ipmr_device_event(struct notifier_block *this, unsigned long event, void *ptr)
1085 struct vif_device *v;
1087 if (event != NETDEV_UNREGISTER)
1090 for (ct=0;ct<maxvif;ct++,v++) {
1098 static struct notifier_block ip_mr_notifier={
1099 .notifier_call = ipmr_device_event,
1103 * Encapsulate a packet by attaching a valid IPIP header to it.
1104 * This avoids tunnel drivers and other mess and gives us the speed so
1105 * important for multicast video.
1108 static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
1111 struct iphdr *old_iph = ip_hdr(skb);
1113 skb_push(skb, sizeof(struct iphdr));
1114 skb->transport_header = skb->network_header;
1115 skb_reset_network_header(skb);
1119 iph->tos = old_iph->tos;
1120 iph->ttl = old_iph->ttl;
1124 iph->protocol = IPPROTO_IPIP;
1126 iph->tot_len = htons(skb->len);
1127 ip_select_ident(iph, skb->dst, NULL);
1130 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
1134 static inline int ipmr_forward_finish(struct sk_buff *skb)
1136 struct ip_options * opt = &(IPCB(skb)->opt);
1138 IP_INC_STATS_BH(IPSTATS_MIB_OUTFORWDATAGRAMS);
1140 if (unlikely(opt->optlen))
1141 ip_forward_options(skb);
1143 return dst_output(skb);
1147 * Processing handlers for ipmr_forward
1150 static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
1152 const struct iphdr *iph = ip_hdr(skb);
1153 struct vif_device *vif = &vif_table[vifi];
1154 struct net_device *dev;
1158 if (vif->dev == NULL)
1161 #ifdef CONFIG_IP_PIMSM
1162 if (vif->flags & VIFF_REGISTER) {
1164 vif->bytes_out+=skb->len;
1165 ((struct net_device_stats*)netdev_priv(vif->dev))->tx_bytes += skb->len;
1166 ((struct net_device_stats*)netdev_priv(vif->dev))->tx_packets++;
1167 ipmr_cache_report(skb, vifi, IGMPMSG_WHOLEPKT);
1173 if (vif->flags&VIFF_TUNNEL) {
1174 struct flowi fl = { .oif = vif->link,
1176 { .daddr = vif->remote,
1177 .saddr = vif->local,
1178 .tos = RT_TOS(iph->tos) } },
1179 .proto = IPPROTO_IPIP };
1180 if (ip_route_output_key(&rt, &fl))
1182 encap = sizeof(struct iphdr);
1184 struct flowi fl = { .oif = vif->link,
1186 { .daddr = iph->daddr,
1187 .tos = RT_TOS(iph->tos) } },
1188 .proto = IPPROTO_IPIP };
1189 if (ip_route_output_key(&rt, &fl))
1193 dev = rt->u.dst.dev;
1195 if (skb->len+encap > dst_mtu(&rt->u.dst) && (ntohs(iph->frag_off) & IP_DF)) {
1196 /* Do not fragment multicasts. Alas, IPv4 does not
1197 allow to send ICMP, so that packets will disappear
1201 IP_INC_STATS_BH(IPSTATS_MIB_FRAGFAILS);
1206 encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len;
1208 if (skb_cow(skb, encap)) {
1214 vif->bytes_out+=skb->len;
1216 dst_release(skb->dst);
1217 skb->dst = &rt->u.dst;
1218 ip_decrease_ttl(ip_hdr(skb));
1220 /* FIXME: forward and output firewalls used to be called here.
1221 * What do we do with netfilter? -- RR */
1222 if (vif->flags & VIFF_TUNNEL) {
1223 ip_encap(skb, vif->local, vif->remote);
1224 /* FIXME: extra output firewall step used to be here. --RR */
1225 ((struct ip_tunnel *)netdev_priv(vif->dev))->stat.tx_packets++;
1226 ((struct ip_tunnel *)netdev_priv(vif->dev))->stat.tx_bytes+=skb->len;
1229 IPCB(skb)->flags |= IPSKB_FORWARDED;
1232 * RFC1584 teaches, that DVMRP/PIM router must deliver packets locally
1233 * not only before forwarding, but after forwarding on all output
1234 * interfaces. It is clear, if mrouter runs a multicasting
1235 * program, it should receive packets not depending to what interface
1236 * program is joined.
1237 * If we will not make it, the program will have to join on all
1238 * interfaces. On the other hand, multihoming host (or router, but
1239 * not mrouter) cannot join to more than one interface - it will
1240 * result in receiving multiple packets.
1242 NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, dev,
1243 ipmr_forward_finish);
1251 static int ipmr_find_vif(struct net_device *dev)
1254 for (ct=maxvif-1; ct>=0; ct--) {
1255 if (vif_table[ct].dev == dev)
1261 /* "local" means that we should preserve one skb (for local delivery) */
1263 static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local)
1268 vif = cache->mfc_parent;
1269 cache->mfc_un.res.pkt++;
1270 cache->mfc_un.res.bytes += skb->len;
1273 * Wrong interface: drop packet and (maybe) send PIM assert.
1275 if (vif_table[vif].dev != skb->dev) {
1278 if (((struct rtable*)skb->dst)->fl.iif == 0) {
1279 /* It is our own packet, looped back.
1280 Very complicated situation...
1282 The best workaround until routing daemons will be
1283 fixed is not to redistribute packet, if it was
1284 send through wrong interface. It means, that
1285 multicast applications WILL NOT work for
1286 (S,G), which have default multicast route pointing
1287 to wrong oif. In any case, it is not a good
1288 idea to use multicasting applications on router.
1293 cache->mfc_un.res.wrong_if++;
1294 true_vifi = ipmr_find_vif(skb->dev);
1296 if (true_vifi >= 0 && mroute_do_assert &&
1297 /* pimsm uses asserts, when switching from RPT to SPT,
1298 so that we cannot check that packet arrived on an oif.
1299 It is bad, but otherwise we would need to move pretty
1300 large chunk of pimd to kernel. Ough... --ANK
1302 (mroute_do_pim || cache->mfc_un.res.ttls[true_vifi] < 255) &&
1304 cache->mfc_un.res.last_assert + MFC_ASSERT_THRESH)) {
1305 cache->mfc_un.res.last_assert = jiffies;
1306 ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF);
1311 vif_table[vif].pkt_in++;
1312 vif_table[vif].bytes_in+=skb->len;
1317 for (ct = cache->mfc_un.res.maxvif-1; ct >= cache->mfc_un.res.minvif; ct--) {
1318 if (ip_hdr(skb)->ttl > cache->mfc_un.res.ttls[ct]) {
1320 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
1322 ipmr_queue_xmit(skb2, cache, psend);
1329 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
1331 ipmr_queue_xmit(skb2, cache, psend);
1333 ipmr_queue_xmit(skb, cache, psend);
1346 * Multicast packets for forwarding arrive here
1349 int ip_mr_input(struct sk_buff *skb)
1351 struct mfc_cache *cache;
1352 int local = ((struct rtable*)skb->dst)->rt_flags&RTCF_LOCAL;
1354 /* Packet is looped back after forward, it should not be
1355 forwarded second time, but still can be delivered locally.
1357 if (IPCB(skb)->flags&IPSKB_FORWARDED)
1361 if (IPCB(skb)->opt.router_alert) {
1362 if (ip_call_ra_chain(skb))
1364 } else if (ip_hdr(skb)->protocol == IPPROTO_IGMP){
1365 /* IGMPv1 (and broken IGMPv2 implementations sort of
1366 Cisco IOS <= 11.2(8)) do not put router alert
1367 option to IGMP packets destined to routable
1368 groups. It is very bad, because it means
1369 that we can forward NO IGMP messages.
1371 read_lock(&mrt_lock);
1372 if (mroute_socket) {
1374 raw_rcv(mroute_socket, skb);
1375 read_unlock(&mrt_lock);
1378 read_unlock(&mrt_lock);
1382 read_lock(&mrt_lock);
1383 cache = ipmr_cache_find(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr);
1386 * No usable cache entry
1392 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
1393 ip_local_deliver(skb);
1395 read_unlock(&mrt_lock);
1401 vif = ipmr_find_vif(skb->dev);
1403 int err = ipmr_cache_unresolved(vif, skb);
1404 read_unlock(&mrt_lock);
1408 read_unlock(&mrt_lock);
1413 ip_mr_forward(skb, cache, local);
1415 read_unlock(&mrt_lock);
1418 return ip_local_deliver(skb);
1424 return ip_local_deliver(skb);
1429 #ifdef CONFIG_IP_PIMSM_V1
1431 * Handle IGMP messages of PIMv1
1434 int pim_rcv_v1(struct sk_buff * skb)
1436 struct igmphdr *pim;
1437 struct iphdr *encap;
1438 struct net_device *reg_dev = NULL;
1440 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
1443 pim = igmp_hdr(skb);
1445 if (!mroute_do_pim ||
1446 skb->len < sizeof(*pim) + sizeof(*encap) ||
1447 pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER)
1450 encap = (struct iphdr *)(skb_transport_header(skb) +
1451 sizeof(struct igmphdr));
1454 a. packet is really destinted to a multicast group
1455 b. packet is not a NULL-REGISTER
1456 c. packet is not truncated
1458 if (!MULTICAST(encap->daddr) ||
1459 encap->tot_len == 0 ||
1460 ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
1463 read_lock(&mrt_lock);
1464 if (reg_vif_num >= 0)
1465 reg_dev = vif_table[reg_vif_num].dev;
1468 read_unlock(&mrt_lock);
1470 if (reg_dev == NULL)
1473 skb->mac_header = skb->network_header;
1474 skb_pull(skb, (u8*)encap - skb->data);
1475 skb_reset_network_header(skb);
1477 skb->protocol = htons(ETH_P_IP);
1479 skb->pkt_type = PACKET_HOST;
1480 dst_release(skb->dst);
1482 ((struct net_device_stats*)netdev_priv(reg_dev))->rx_bytes += skb->len;
1483 ((struct net_device_stats*)netdev_priv(reg_dev))->rx_packets++;
1494 #ifdef CONFIG_IP_PIMSM_V2
1495 static int pim_rcv(struct sk_buff * skb)
1497 struct pimreghdr *pim;
1498 struct iphdr *encap;
1499 struct net_device *reg_dev = NULL;
1501 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
1504 pim = (struct pimreghdr *)skb_transport_header(skb);
1505 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
1506 (pim->flags&PIM_NULL_REGISTER) ||
1507 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
1508 csum_fold(skb_checksum(skb, 0, skb->len, 0))))
1511 /* check if the inner packet is destined to mcast group */
1512 encap = (struct iphdr *)(skb_transport_header(skb) +
1513 sizeof(struct pimreghdr));
1514 if (!MULTICAST(encap->daddr) ||
1515 encap->tot_len == 0 ||
1516 ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
1519 read_lock(&mrt_lock);
1520 if (reg_vif_num >= 0)
1521 reg_dev = vif_table[reg_vif_num].dev;
1524 read_unlock(&mrt_lock);
1526 if (reg_dev == NULL)
1529 skb->mac_header = skb->network_header;
1530 skb_pull(skb, (u8*)encap - skb->data);
1531 skb_reset_network_header(skb);
1533 skb->protocol = htons(ETH_P_IP);
1535 skb->pkt_type = PACKET_HOST;
1536 dst_release(skb->dst);
1537 ((struct net_device_stats*)netdev_priv(reg_dev))->rx_bytes += skb->len;
1538 ((struct net_device_stats*)netdev_priv(reg_dev))->rx_packets++;
1551 ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm)
1554 struct rtnexthop *nhp;
1555 struct net_device *dev = vif_table[c->mfc_parent].dev;
1556 u8 *b = skb_tail_pointer(skb);
1557 struct rtattr *mp_head;
1560 RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex);
1562 mp_head = (struct rtattr*)skb_put(skb, RTA_LENGTH(0));
1564 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
1565 if (c->mfc_un.res.ttls[ct] < 255) {
1566 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
1567 goto rtattr_failure;
1568 nhp = (struct rtnexthop*)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
1569 nhp->rtnh_flags = 0;
1570 nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
1571 nhp->rtnh_ifindex = vif_table[ct].dev->ifindex;
1572 nhp->rtnh_len = sizeof(*nhp);
1575 mp_head->rta_type = RTA_MULTIPATH;
1576 mp_head->rta_len = skb_tail_pointer(skb) - (u8 *)mp_head;
1577 rtm->rtm_type = RTN_MULTICAST;
1585 int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
1588 struct mfc_cache *cache;
1589 struct rtable *rt = (struct rtable*)skb->dst;
1591 read_lock(&mrt_lock);
1592 cache = ipmr_cache_find(rt->rt_src, rt->rt_dst);
1595 struct sk_buff *skb2;
1597 struct net_device *dev;
1601 read_unlock(&mrt_lock);
1606 if (dev == NULL || (vif = ipmr_find_vif(dev)) < 0) {
1607 read_unlock(&mrt_lock);
1610 skb2 = skb_clone(skb, GFP_ATOMIC);
1612 read_unlock(&mrt_lock);
1616 skb_push(skb2, sizeof(struct iphdr));
1617 skb_reset_network_header(skb2);
1619 iph->ihl = sizeof(struct iphdr) >> 2;
1620 iph->saddr = rt->rt_src;
1621 iph->daddr = rt->rt_dst;
1623 err = ipmr_cache_unresolved(vif, skb2);
1624 read_unlock(&mrt_lock);
1628 if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY))
1629 cache->mfc_flags |= MFC_NOTIFY;
1630 err = ipmr_fill_mroute(skb, cache, rtm);
1631 read_unlock(&mrt_lock);
1635 #ifdef CONFIG_PROC_FS
1637 * The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif
1639 struct ipmr_vif_iter {
1643 static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter,
1646 for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) {
1647 if (!VIF_EXISTS(iter->ct))
1650 return &vif_table[iter->ct];
1655 static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
1657 read_lock(&mrt_lock);
1658 return *pos ? ipmr_vif_seq_idx(seq->private, *pos - 1)
1662 static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1664 struct ipmr_vif_iter *iter = seq->private;
1667 if (v == SEQ_START_TOKEN)
1668 return ipmr_vif_seq_idx(iter, 0);
1670 while (++iter->ct < maxvif) {
1671 if (!VIF_EXISTS(iter->ct))
1673 return &vif_table[iter->ct];
1678 static void ipmr_vif_seq_stop(struct seq_file *seq, void *v)
1680 read_unlock(&mrt_lock);
1683 static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
1685 if (v == SEQ_START_TOKEN) {
1687 "Interface BytesIn PktsIn BytesOut PktsOut Flags Local Remote\n");
1689 const struct vif_device *vif = v;
1690 const char *name = vif->dev ? vif->dev->name : "none";
1693 "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n",
1695 name, vif->bytes_in, vif->pkt_in,
1696 vif->bytes_out, vif->pkt_out,
1697 vif->flags, vif->local, vif->remote);
1702 static const struct seq_operations ipmr_vif_seq_ops = {
1703 .start = ipmr_vif_seq_start,
1704 .next = ipmr_vif_seq_next,
1705 .stop = ipmr_vif_seq_stop,
1706 .show = ipmr_vif_seq_show,
1709 static int ipmr_vif_open(struct inode *inode, struct file *file)
1711 struct seq_file *seq;
1713 struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
1718 rc = seq_open(file, &ipmr_vif_seq_ops);
1723 seq = file->private_data;
1733 static const struct file_operations ipmr_vif_fops = {
1734 .owner = THIS_MODULE,
1735 .open = ipmr_vif_open,
1737 .llseek = seq_lseek,
1738 .release = seq_release_private,
1741 struct ipmr_mfc_iter {
1742 struct mfc_cache **cache;
1747 static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos)
1749 struct mfc_cache *mfc;
1751 it->cache = mfc_cache_array;
1752 read_lock(&mrt_lock);
1753 for (it->ct = 0; it->ct < MFC_LINES; it->ct++)
1754 for (mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next)
1757 read_unlock(&mrt_lock);
1759 it->cache = &mfc_unres_queue;
1760 spin_lock_bh(&mfc_unres_lock);
1761 for (mfc = mfc_unres_queue; mfc; mfc = mfc->next)
1764 spin_unlock_bh(&mfc_unres_lock);
1771 static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
1773 struct ipmr_mfc_iter *it = seq->private;
1776 return *pos ? ipmr_mfc_seq_idx(seq->private, *pos - 1)
1780 static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1782 struct mfc_cache *mfc = v;
1783 struct ipmr_mfc_iter *it = seq->private;
1787 if (v == SEQ_START_TOKEN)
1788 return ipmr_mfc_seq_idx(seq->private, 0);
1793 if (it->cache == &mfc_unres_queue)
1796 BUG_ON(it->cache != mfc_cache_array);
1798 while (++it->ct < MFC_LINES) {
1799 mfc = mfc_cache_array[it->ct];
1804 /* exhausted cache_array, show unresolved */
1805 read_unlock(&mrt_lock);
1806 it->cache = &mfc_unres_queue;
1809 spin_lock_bh(&mfc_unres_lock);
1810 mfc = mfc_unres_queue;
1815 spin_unlock_bh(&mfc_unres_lock);
1821 static void ipmr_mfc_seq_stop(struct seq_file *seq, void *v)
1823 struct ipmr_mfc_iter *it = seq->private;
1825 if (it->cache == &mfc_unres_queue)
1826 spin_unlock_bh(&mfc_unres_lock);
1827 else if (it->cache == mfc_cache_array)
1828 read_unlock(&mrt_lock);
1831 static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
1835 if (v == SEQ_START_TOKEN) {
1837 "Group Origin Iif Pkts Bytes Wrong Oifs\n");
1839 const struct mfc_cache *mfc = v;
1840 const struct ipmr_mfc_iter *it = seq->private;
1842 seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld",
1843 (unsigned long) mfc->mfc_mcastgrp,
1844 (unsigned long) mfc->mfc_origin,
1846 mfc->mfc_un.res.pkt,
1847 mfc->mfc_un.res.bytes,
1848 mfc->mfc_un.res.wrong_if);
1850 if (it->cache != &mfc_unres_queue) {
1851 for (n = mfc->mfc_un.res.minvif;
1852 n < mfc->mfc_un.res.maxvif; n++ ) {
1854 && mfc->mfc_un.res.ttls[n] < 255)
1857 n, mfc->mfc_un.res.ttls[n]);
1860 seq_putc(seq, '\n');
1865 static const struct seq_operations ipmr_mfc_seq_ops = {
1866 .start = ipmr_mfc_seq_start,
1867 .next = ipmr_mfc_seq_next,
1868 .stop = ipmr_mfc_seq_stop,
1869 .show = ipmr_mfc_seq_show,
1872 static int ipmr_mfc_open(struct inode *inode, struct file *file)
1874 struct seq_file *seq;
1876 struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL);
1881 rc = seq_open(file, &ipmr_mfc_seq_ops);
1885 seq = file->private_data;
1895 static const struct file_operations ipmr_mfc_fops = {
1896 .owner = THIS_MODULE,
1897 .open = ipmr_mfc_open,
1899 .llseek = seq_lseek,
1900 .release = seq_release_private,
1904 #ifdef CONFIG_IP_PIMSM_V2
1905 static struct net_protocol pim_protocol = {
1912 * Setup for IP multicast routing
1915 void __init ip_mr_init(void)
1917 mrt_cachep = kmem_cache_create("ip_mrt_cache",
1918 sizeof(struct mfc_cache),
1919 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
1921 init_timer(&ipmr_expire_timer);
1922 ipmr_expire_timer.function=ipmr_expire_process;
1923 register_netdevice_notifier(&ip_mr_notifier);
1924 #ifdef CONFIG_PROC_FS
1925 proc_net_fops_create("ip_mr_vif", 0, &ipmr_vif_fops);
1926 proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops);