ipmr.c (e905a9edab7f4f14f9213b52234e4a346c690911) | ipmr.c (c376222960ae91d5ffb9197ee36771aaed1d9f90) |
---|---|
1/* 2 * IP multicast routing support for mrouted 3.6/3.8 3 * 4 * (c) 1995 Alan Cox, <alan@redhat.com> 5 * Linux Consultancy and Custom Driver Development 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 227 unchanged lines hidden (view full) --- 236 unregister_netdevice(dev); 237 return NULL; 238} 239#endif 240 241/* 242 * Delete a VIF entry 243 */ | 1/* 2 * IP multicast routing support for mrouted 3.6/3.8 3 * 4 * (c) 1995 Alan Cox, <alan@redhat.com> 5 * Linux Consultancy and Custom Driver Development 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 227 unchanged lines hidden (view full) --- 236 unregister_netdevice(dev); 237 return NULL; 238} 239#endif 240 241/* 242 * Delete a VIF entry 243 */ |
244 | 244 |
245static int vif_delete(int vifi) 246{ 247 struct vif_device *v; 248 struct net_device *dev; 249 struct in_device *in_dev; 250 251 if (vifi < 0 || vifi >= maxvif) 252 return -EADDRNOTAVAIL; --- 151 unchanged lines hidden (view full) --- 404 */ 405 if (reg_vif_num >= 0) 406 return -EADDRINUSE; 407 dev = ipmr_reg_vif(); 408 if (!dev) 409 return -ENOBUFS; 410 break; 411#endif | 245static int vif_delete(int vifi) 246{ 247 struct vif_device *v; 248 struct net_device *dev; 249 struct in_device *in_dev; 250 251 if (vifi < 0 || vifi >= maxvif) 252 return -EADDRNOTAVAIL; --- 151 unchanged lines hidden (view full) --- 404 */ 405 if (reg_vif_num >= 0) 406 return -EADDRINUSE; 407 dev = ipmr_reg_vif(); 408 if (!dev) 409 return -ENOBUFS; 410 break; 411#endif |
412 case VIFF_TUNNEL: | 412 case VIFF_TUNNEL: |
413 dev = ipmr_new_tunnel(vifc); 414 if (!dev) 415 return -ENOBUFS; 416 break; 417 case 0: 418 dev = ip_dev_find(vifc->vifc_lcl_addr.s_addr); 419 if (!dev) 420 return -EADDRNOTAVAIL; --- 53 unchanged lines hidden (view full) --- 474 return c; 475} 476 477/* 478 * Allocate a multicast cache entry 479 */ 480static struct mfc_cache *ipmr_cache_alloc(void) 481{ | 413 dev = ipmr_new_tunnel(vifc); 414 if (!dev) 415 return -ENOBUFS; 416 break; 417 case 0: 418 dev = ip_dev_find(vifc->vifc_lcl_addr.s_addr); 419 if (!dev) 420 return -EADDRNOTAVAIL; --- 53 unchanged lines hidden (view full) --- 474 return c; 475} 476 477/* 478 * Allocate a multicast cache entry 479 */ 480static struct mfc_cache *ipmr_cache_alloc(void) 481{ |
482 struct mfc_cache *c=kmem_cache_alloc(mrt_cachep, GFP_KERNEL); | 482 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); |
483 if(c==NULL) 484 return NULL; | 483 if(c==NULL) 484 return NULL; |
485 memset(c, 0, sizeof(*c)); | |
486 c->mfc_un.res.minvif = MAXVIFS; 487 return c; 488} 489 490static struct mfc_cache *ipmr_cache_alloc_unres(void) 491{ | 485 c->mfc_un.res.minvif = MAXVIFS; 486 return c; 487} 488 489static struct mfc_cache *ipmr_cache_alloc_unres(void) 490{ |
492 struct mfc_cache *c=kmem_cache_alloc(mrt_cachep, GFP_ATOMIC); | 491 struct mfc_cache *c=kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC); |
493 if(c==NULL) 494 return NULL; | 492 if(c==NULL) 493 return NULL; |
495 memset(c, 0, sizeof(*c)); | |
496 skb_queue_head_init(&c->mfc_un.unres.unresolved); 497 c->mfc_un.unres.expires = jiffies + 10*HZ; 498 return c; 499} 500 501/* 502 * A cache entry has gone into a resolved state from queued 503 */ | 494 skb_queue_head_init(&c->mfc_un.unres.unresolved); 495 c->mfc_un.unres.expires = jiffies + 10*HZ; 496 return c; 497} 498 499/* 500 * A cache entry has gone into a resolved state from queued 501 */ |
504 | 502 |
505static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) 506{ 507 struct sk_buff *skb; 508 struct nlmsgerr *e; 509 510 /* 511 * Play the pending entries through our router 512 */ --- 20 unchanged lines hidden (view full) --- 533} 534 535/* 536 * Bounce a cache query up to mrouted. We could use netlink for this but mrouted 537 * expects the following bizarre scheme. 538 * 539 * Called under mrt_lock. 540 */ | 503static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) 504{ 505 struct sk_buff *skb; 506 struct nlmsgerr *e; 507 508 /* 509 * Play the pending entries through our router 510 */ --- 20 unchanged lines hidden (view full) --- 531} 532 533/* 534 * Bounce a cache query up to mrouted. We could use netlink for this but mrouted 535 * expects the following bizarre scheme. 536 * 537 * Called under mrt_lock. 538 */ |
541 | 539 |
542static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) 543{ 544 struct sk_buff *skb; 545 int ihl = pkt->nh.iph->ihl<<2; 546 struct igmphdr *igmp; 547 struct igmpmsg *msg; 548 int ret; 549 --- 14 unchanged lines hidden (view full) --- 564 And all this only to mangle msg->im_msgtype and 565 to set msg->im_mbz to "mbz" :-) 566 */ 567 msg = (struct igmpmsg*)skb_push(skb, sizeof(struct iphdr)); 568 skb->nh.raw = skb->h.raw = (u8*)msg; 569 memcpy(msg, pkt->nh.raw, sizeof(struct iphdr)); 570 msg->im_msgtype = IGMPMSG_WHOLEPKT; 571 msg->im_mbz = 0; | 540static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) 541{ 542 struct sk_buff *skb; 543 int ihl = pkt->nh.iph->ihl<<2; 544 struct igmphdr *igmp; 545 struct igmpmsg *msg; 546 int ret; 547 --- 14 unchanged lines hidden (view full) --- 562 And all this only to mangle msg->im_msgtype and 563 to set msg->im_mbz to "mbz" :-) 564 */ 565 msg = (struct igmpmsg*)skb_push(skb, sizeof(struct iphdr)); 566 skb->nh.raw = skb->h.raw = (u8*)msg; 567 memcpy(msg, pkt->nh.raw, sizeof(struct iphdr)); 568 msg->im_msgtype = IGMPMSG_WHOLEPKT; 569 msg->im_mbz = 0; |
572 msg->im_vif = reg_vif_num; | 570 msg->im_vif = reg_vif_num; |
573 skb->nh.iph->ihl = sizeof(struct iphdr) >> 2; 574 skb->nh.iph->tot_len = htons(ntohs(pkt->nh.iph->tot_len) + sizeof(struct iphdr)); | 571 skb->nh.iph->ihl = sizeof(struct iphdr) >> 2; 572 skb->nh.iph->tot_len = htons(ntohs(pkt->nh.iph->tot_len) + sizeof(struct iphdr)); |
575 } else | 573 } else |
576#endif | 574#endif |
577 { 578 | 575 { 576 |
579 /* 580 * Copy the IP header 581 */ 582 583 skb->nh.iph = (struct iphdr *)skb_put(skb, ihl); 584 memcpy(skb->data,pkt->data,ihl); 585 skb->nh.iph->protocol = 0; /* Flag to the kernel this is a route add */ 586 msg = (struct igmpmsg*)skb->nh.iph; --- 5 unchanged lines hidden (view full) --- 592 */ 593 594 igmp=(struct igmphdr *)skb_put(skb,sizeof(struct igmphdr)); 595 igmp->type = 596 msg->im_msgtype = assert; 597 igmp->code = 0; 598 skb->nh.iph->tot_len=htons(skb->len); /* Fix the length */ 599 skb->h.raw = skb->nh.raw; | 577 /* 578 * Copy the IP header 579 */ 580 581 skb->nh.iph = (struct iphdr *)skb_put(skb, ihl); 582 memcpy(skb->data,pkt->data,ihl); 583 skb->nh.iph->protocol = 0; /* Flag to the kernel this is a route add */ 584 msg = (struct igmpmsg*)skb->nh.iph; --- 5 unchanged lines hidden (view full) --- 590 */ 591 592 igmp=(struct igmphdr *)skb_put(skb,sizeof(struct igmphdr)); 593 igmp->type = 594 msg->im_msgtype = assert; 595 igmp->code = 0; 596 skb->nh.iph->tot_len=htons(skb->len); /* Fix the length */ 597 skb->h.raw = skb->nh.raw; |
600 } | 598 } |
601 602 if (mroute_socket == NULL) { 603 kfree_skb(skb); 604 return -EINVAL; 605 } 606 607 /* 608 * Deliver to mrouted --- 5 unchanged lines hidden (view full) --- 614 } 615 616 return ret; 617} 618 619/* 620 * Queue a packet for resolution. It gets locked cache entry! 621 */ | 599 600 if (mroute_socket == NULL) { 601 kfree_skb(skb); 602 return -EINVAL; 603 } 604 605 /* 606 * Deliver to mrouted --- 5 unchanged lines hidden (view full) --- 612 } 613 614 return ret; 615} 616 617/* 618 * Queue a packet for resolution. It gets locked cache entry! 619 */ |
622 | 620 |
623static int 624ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb) 625{ 626 int err; 627 struct mfc_cache *c; 628 629 spin_lock_bh(&mfc_unres_lock); 630 for (c=mfc_unres_queue; c; c=c->next) { --- 21 unchanged lines hidden (view full) --- 652 c->mfc_parent=-1; 653 c->mfc_origin=skb->nh.iph->saddr; 654 c->mfc_mcastgrp=skb->nh.iph->daddr; 655 656 /* 657 * Reflect first query at mrouted. 658 */ 659 if ((err = ipmr_cache_report(skb, vifi, IGMPMSG_NOCACHE))<0) { | 621static int 622ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb) 623{ 624 int err; 625 struct mfc_cache *c; 626 627 spin_lock_bh(&mfc_unres_lock); 628 for (c=mfc_unres_queue; c; c=c->next) { --- 21 unchanged lines hidden (view full) --- 650 c->mfc_parent=-1; 651 c->mfc_origin=skb->nh.iph->saddr; 652 c->mfc_mcastgrp=skb->nh.iph->daddr; 653 654 /* 655 * Reflect first query at mrouted. 656 */ 657 if ((err = ipmr_cache_report(skb, vifi, IGMPMSG_NOCACHE))<0) { |
660 /* If the report failed throw the cache entry | 658 /* If the report failed throw the cache entry |
661 out - Brad Parker 662 */ 663 spin_unlock_bh(&mfc_unres_lock); 664 665 kmem_cache_free(mrt_cachep, c); 666 kfree_skb(skb); 667 return err; 668 } --- 109 unchanged lines hidden (view full) --- 778 kmem_cache_free(mrt_cachep, uc); 779 } 780 return 0; 781} 782 783/* 784 * Close the multicast socket, and clear the vif tables etc 785 */ | 659 out - Brad Parker 660 */ 661 spin_unlock_bh(&mfc_unres_lock); 662 663 kmem_cache_free(mrt_cachep, c); 664 kfree_skb(skb); 665 return err; 666 } --- 109 unchanged lines hidden (view full) --- 776 kmem_cache_free(mrt_cachep, uc); 777 } 778 return 0; 779} 780 781/* 782 * Close the multicast socket, and clear the vif tables etc 783 */ |
786 | 784 |
787static void mroute_clean_tables(struct sock *sk) 788{ 789 int i; | 785static void mroute_clean_tables(struct sock *sk) 786{ 787 int i; |
790 | 788 |
791 /* 792 * Shut down all active vif entries 793 */ 794 for(i=0; i<maxvif; i++) { 795 if (!(vif_table[i].flags&VIFF_STATIC)) 796 vif_delete(i); 797 } 798 --- 50 unchanged lines hidden (view full) --- 849} 850 851/* 852 * Socket options and virtual interface manipulation. The whole 853 * virtual interface system is a complete heap, but unfortunately 854 * that's how BSD mrouted happens to think. Maybe one day with a proper 855 * MOSPF/PIM router set up we can clean this up. 856 */ | 789 /* 790 * Shut down all active vif entries 791 */ 792 for(i=0; i<maxvif; i++) { 793 if (!(vif_table[i].flags&VIFF_STATIC)) 794 vif_delete(i); 795 } 796 --- 50 unchanged lines hidden (view full) --- 847} 848 849/* 850 * Socket options and virtual interface manipulation. The whole 851 * virtual interface system is a complete heap, but unfortunately 852 * that's how BSD mrouted happens to think. Maybe one day with a proper 853 * MOSPF/PIM router set up we can clean this up. 854 */ |
857 | 855 |
858int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen) 859{ 860 int ret; 861 struct vifctl vif; 862 struct mfcctl mfc; | 856int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen) 857{ 858 int ret; 859 struct vifctl vif; 860 struct mfcctl mfc; |
863 | 861 |
864 if(optname!=MRT_INIT) 865 { 866 if(sk!=mroute_socket && !capable(CAP_NET_ADMIN)) 867 return -EACCES; 868 } 869 870 switch(optname) 871 { --- 24 unchanged lines hidden (view full) --- 896 if (sk!=mroute_socket) 897 return -EACCES; 898 return ip_ra_control(sk, 0, NULL); 899 case MRT_ADD_VIF: 900 case MRT_DEL_VIF: 901 if(optlen!=sizeof(vif)) 902 return -EINVAL; 903 if (copy_from_user(&vif,optval,sizeof(vif))) | 862 if(optname!=MRT_INIT) 863 { 864 if(sk!=mroute_socket && !capable(CAP_NET_ADMIN)) 865 return -EACCES; 866 } 867 868 switch(optname) 869 { --- 24 unchanged lines hidden (view full) --- 894 if (sk!=mroute_socket) 895 return -EACCES; 896 return ip_ra_control(sk, 0, NULL); 897 case MRT_ADD_VIF: 898 case MRT_DEL_VIF: 899 if(optlen!=sizeof(vif)) 900 return -EINVAL; 901 if (copy_from_user(&vif,optval,sizeof(vif))) |
904 return -EFAULT; | 902 return -EFAULT; |
905 if(vif.vifc_vifi >= MAXVIFS) 906 return -ENFILE; 907 rtnl_lock(); 908 if (optname==MRT_ADD_VIF) { 909 ret = vif_add(&vif, sk==mroute_socket); 910 } else { 911 ret = vif_delete(vif.vifc_vifi); 912 } --- 62 unchanged lines hidden (view full) --- 975 default: 976 return -ENOPROTOOPT; 977 } 978} 979 980/* 981 * Getsock opt support for the multicast routing system. 982 */ | 903 if(vif.vifc_vifi >= MAXVIFS) 904 return -ENFILE; 905 rtnl_lock(); 906 if (optname==MRT_ADD_VIF) { 907 ret = vif_add(&vif, sk==mroute_socket); 908 } else { 909 ret = vif_delete(vif.vifc_vifi); 910 } --- 62 unchanged lines hidden (view full) --- 973 default: 974 return -ENOPROTOOPT; 975 } 976} 977 978/* 979 * Getsock opt support for the multicast routing system. 980 */ |
983 | 981 |
984int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen) 985{ 986 int olr; 987 int val; 988 | 982int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen) 983{ 984 int olr; 985 int val; 986 |
989 if(optname!=MRT_VERSION && | 987 if(optname!=MRT_VERSION && |
990#ifdef CONFIG_IP_PIMSM 991 optname!=MRT_PIM && 992#endif 993 optname!=MRT_ASSERT) 994 return -ENOPROTOOPT; 995 996 if (get_user(olr, optlen)) 997 return -EFAULT; 998 999 olr = min_t(unsigned int, olr, sizeof(int)); 1000 if (olr < 0) 1001 return -EINVAL; | 988#ifdef CONFIG_IP_PIMSM 989 optname!=MRT_PIM && 990#endif 991 optname!=MRT_ASSERT) 992 return -ENOPROTOOPT; 993 994 if (get_user(olr, optlen)) 995 return -EFAULT; 996 997 olr = min_t(unsigned int, olr, sizeof(int)); 998 if (olr < 0) 999 return -EINVAL; |
1002 | 1000 |
1003 if(put_user(olr,optlen)) 1004 return -EFAULT; 1005 if(optname==MRT_VERSION) 1006 val=0x0305; 1007#ifdef CONFIG_IP_PIMSM 1008 else if(optname==MRT_PIM) 1009 val=mroute_do_pim; 1010#endif 1011 else 1012 val=mroute_do_assert; 1013 if(copy_to_user(optval,&val,olr)) 1014 return -EFAULT; 1015 return 0; 1016} 1017 1018/* 1019 * The IP multicast ioctl support routines. 1020 */ | 1001 if(put_user(olr,optlen)) 1002 return -EFAULT; 1003 if(optname==MRT_VERSION) 1004 val=0x0305; 1005#ifdef CONFIG_IP_PIMSM 1006 else if(optname==MRT_PIM) 1007 val=mroute_do_pim; 1008#endif 1009 else 1010 val=mroute_do_assert; 1011 if(copy_to_user(optval,&val,olr)) 1012 return -EFAULT; 1013 return 0; 1014} 1015 1016/* 1017 * The IP multicast ioctl support routines. 1018 */ |
1021 | 1019 |
1022int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) 1023{ 1024 struct sioc_sg_req sr; 1025 struct sioc_vif_req vr; 1026 struct vif_device *vif; 1027 struct mfc_cache *c; | 1020int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) 1021{ 1022 struct sioc_sg_req sr; 1023 struct sioc_vif_req vr; 1024 struct vif_device *vif; 1025 struct mfc_cache *c; |
1028 | 1026 |
1029 switch(cmd) 1030 { 1031 case SIOCGETVIFCNT: 1032 if (copy_from_user(&vr,arg,sizeof(vr))) | 1027 switch(cmd) 1028 { 1029 case SIOCGETVIFCNT: 1030 if (copy_from_user(&vr,arg,sizeof(vr))) |
1033 return -EFAULT; | 1031 return -EFAULT; |
1034 if(vr.vifi>=maxvif) 1035 return -EINVAL; 1036 read_lock(&mrt_lock); 1037 vif=&vif_table[vr.vifi]; 1038 if(VIF_EXISTS(vr.vifi)) { 1039 vr.icount=vif->pkt_in; 1040 vr.ocount=vif->pkt_out; 1041 vr.ibytes=vif->bytes_in; --- 49 unchanged lines hidden (view full) --- 1091 .notifier_call = ipmr_device_event, 1092}; 1093 1094/* 1095 * Encapsulate a packet by attaching a valid IPIP header to it. 1096 * This avoids tunnel drivers and other mess and gives us the speed so 1097 * important for multicast video. 1098 */ | 1032 if(vr.vifi>=maxvif) 1033 return -EINVAL; 1034 read_lock(&mrt_lock); 1035 vif=&vif_table[vr.vifi]; 1036 if(VIF_EXISTS(vr.vifi)) { 1037 vr.icount=vif->pkt_in; 1038 vr.ocount=vif->pkt_out; 1039 vr.ibytes=vif->bytes_in; --- 49 unchanged lines hidden (view full) --- 1089 .notifier_call = ipmr_device_event, 1090}; 1091 1092/* 1093 * Encapsulate a packet by attaching a valid IPIP header to it. 1094 * This avoids tunnel drivers and other mess and gives us the speed so 1095 * important for multicast video. 1096 */ |
1099 | 1097 |
1100static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) 1101{ 1102 struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); 1103 1104 iph->version = 4; 1105 iph->tos = skb->nh.iph->tos; 1106 iph->ttl = skb->nh.iph->ttl; 1107 iph->frag_off = 0; --- 81 unchanged lines hidden (view full) --- 1189 IP_INC_STATS_BH(IPSTATS_MIB_FRAGFAILS); 1190 ip_rt_put(rt); 1191 goto out_free; 1192 } 1193 1194 encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len; 1195 1196 if (skb_cow(skb, encap)) { | 1098static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) 1099{ 1100 struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); 1101 1102 iph->version = 4; 1103 iph->tos = skb->nh.iph->tos; 1104 iph->ttl = skb->nh.iph->ttl; 1105 iph->frag_off = 0; --- 81 unchanged lines hidden (view full) --- 1187 IP_INC_STATS_BH(IPSTATS_MIB_FRAGFAILS); 1188 ip_rt_put(rt); 1189 goto out_free; 1190 } 1191 1192 encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len; 1193 1194 if (skb_cow(skb, encap)) { |
1197 ip_rt_put(rt); | 1195 ip_rt_put(rt); |
1198 goto out_free; 1199 } 1200 1201 vif->pkt_out++; 1202 vif->bytes_out+=skb->len; 1203 1204 dst_release(skb->dst); 1205 skb->dst = &rt->u.dst; --- 17 unchanged lines hidden (view full) --- 1223 * interfaces. It is clear, if mrouter runs a multicasting 1224 * program, it should receive packets not depending to what interface 1225 * program is joined. 1226 * If we will not make it, the program will have to join on all 1227 * interfaces. On the other hand, multihoming host (or router, but 1228 * not mrouter) cannot join to more than one interface - it will 1229 * result in receiving multiple packets. 1230 */ | 1196 goto out_free; 1197 } 1198 1199 vif->pkt_out++; 1200 vif->bytes_out+=skb->len; 1201 1202 dst_release(skb->dst); 1203 skb->dst = &rt->u.dst; --- 17 unchanged lines hidden (view full) --- 1221 * interfaces. It is clear, if mrouter runs a multicasting 1222 * program, it should receive packets not depending to what interface 1223 * program is joined. 1224 * If we will not make it, the program will have to join on all 1225 * interfaces. On the other hand, multihoming host (or router, but 1226 * not mrouter) cannot join to more than one interface - it will 1227 * result in receiving multiple packets. 1228 */ |
1231 NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, dev, | 1229 NF_HOOK(PF_INET, NF_IP_FORWARD, skb, skb->dev, dev, |
1232 ipmr_forward_finish); 1233 return; 1234 1235out_free: 1236 kfree_skb(skb); 1237 return; 1238} 1239 --- 44 unchanged lines hidden (view full) --- 1284 1285 if (true_vifi >= 0 && mroute_do_assert && 1286 /* pimsm uses asserts, when switching from RPT to SPT, 1287 so that we cannot check that packet arrived on an oif. 1288 It is bad, but otherwise we would need to move pretty 1289 large chunk of pimd to kernel. Ough... --ANK 1290 */ 1291 (mroute_do_pim || cache->mfc_un.res.ttls[true_vifi] < 255) && | 1230 ipmr_forward_finish); 1231 return; 1232 1233out_free: 1234 kfree_skb(skb); 1235 return; 1236} 1237 --- 44 unchanged lines hidden (view full) --- 1282 1283 if (true_vifi >= 0 && mroute_do_assert && 1284 /* pimsm uses asserts, when switching from RPT to SPT, 1285 so that we cannot check that packet arrived on an oif. 1286 It is bad, but otherwise we would need to move pretty 1287 large chunk of pimd to kernel. Ough... --ANK 1288 */ 1289 (mroute_do_pim || cache->mfc_un.res.ttls[true_vifi] < 255) && |
1292 time_after(jiffies, | 1290 time_after(jiffies, |
1293 cache->mfc_un.res.last_assert + MFC_ASSERT_THRESH)) { 1294 cache->mfc_un.res.last_assert = jiffies; 1295 ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF); 1296 } 1297 goto dont_forward; 1298 } 1299 1300 vif_table[vif].pkt_in++; --- 120 unchanged lines hidden (view full) --- 1421 */ 1422 1423int pim_rcv_v1(struct sk_buff * skb) 1424{ 1425 struct igmphdr *pim; 1426 struct iphdr *encap; 1427 struct net_device *reg_dev = NULL; 1428 | 1291 cache->mfc_un.res.last_assert + MFC_ASSERT_THRESH)) { 1292 cache->mfc_un.res.last_assert = jiffies; 1293 ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF); 1294 } 1295 goto dont_forward; 1296 } 1297 1298 vif_table[vif].pkt_in++; --- 120 unchanged lines hidden (view full) --- 1419 */ 1420 1421int pim_rcv_v1(struct sk_buff * skb) 1422{ 1423 struct igmphdr *pim; 1424 struct iphdr *encap; 1425 struct net_device *reg_dev = NULL; 1426 |
1429 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) | 1427 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) |
1430 goto drop; 1431 1432 pim = (struct igmphdr*)skb->h.raw; 1433 | 1428 goto drop; 1429 1430 pim = (struct igmphdr*)skb->h.raw; 1431 |
1434 if (!mroute_do_pim || | 1432 if (!mroute_do_pim || |
1435 skb->len < sizeof(*pim) + sizeof(*encap) || | 1433 skb->len < sizeof(*pim) + sizeof(*encap) || |
1436 pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER) | 1434 pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER) |
1437 goto drop; 1438 1439 encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr)); 1440 /* 1441 Check that: 1442 a. packet is really destinted to a multicast group 1443 b. packet is not a NULL-REGISTER 1444 c. packet is not truncated 1445 */ 1446 if (!MULTICAST(encap->daddr) || 1447 encap->tot_len == 0 || | 1435 goto drop; 1436 1437 encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr)); 1438 /* 1439 Check that: 1440 a. packet is really destinted to a multicast group 1441 b. packet is not a NULL-REGISTER 1442 c. packet is not truncated 1443 */ 1444 if (!MULTICAST(encap->daddr) || 1445 encap->tot_len == 0 || |
1448 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) | 1446 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) |
1449 goto drop; 1450 1451 read_lock(&mrt_lock); 1452 if (reg_vif_num >= 0) 1453 reg_dev = vif_table[reg_vif_num].dev; 1454 if (reg_dev) 1455 dev_hold(reg_dev); 1456 read_unlock(&mrt_lock); 1457 | 1447 goto drop; 1448 1449 read_lock(&mrt_lock); 1450 if (reg_vif_num >= 0) 1451 reg_dev = vif_table[reg_vif_num].dev; 1452 if (reg_dev) 1453 dev_hold(reg_dev); 1454 read_unlock(&mrt_lock); 1455 |
1458 if (reg_dev == NULL) | 1456 if (reg_dev == NULL) |
1459 goto drop; 1460 1461 skb->mac.raw = skb->nh.raw; 1462 skb_pull(skb, (u8*)encap - skb->data); 1463 skb->nh.iph = (struct iphdr *)skb->data; 1464 skb->dev = reg_dev; 1465 skb->protocol = htons(ETH_P_IP); 1466 skb->ip_summed = 0; --- 14 unchanged lines hidden (view full) --- 1481 1482#ifdef CONFIG_IP_PIMSM_V2 1483static int pim_rcv(struct sk_buff * skb) 1484{ 1485 struct pimreghdr *pim; 1486 struct iphdr *encap; 1487 struct net_device *reg_dev = NULL; 1488 | 1457 goto drop; 1458 1459 skb->mac.raw = skb->nh.raw; 1460 skb_pull(skb, (u8*)encap - skb->data); 1461 skb->nh.iph = (struct iphdr *)skb->data; 1462 skb->dev = reg_dev; 1463 skb->protocol = htons(ETH_P_IP); 1464 skb->ip_summed = 0; --- 14 unchanged lines hidden (view full) --- 1479 1480#ifdef CONFIG_IP_PIMSM_V2 1481static int pim_rcv(struct sk_buff * skb) 1482{ 1483 struct pimreghdr *pim; 1484 struct iphdr *encap; 1485 struct net_device *reg_dev = NULL; 1486 |
1489 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) | 1487 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) |
1490 goto drop; 1491 1492 pim = (struct pimreghdr*)skb->h.raw; | 1488 goto drop; 1489 1490 pim = (struct pimreghdr*)skb->h.raw; |
1493 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) || | 1491 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) || |
1494 (pim->flags&PIM_NULL_REGISTER) || | 1492 (pim->flags&PIM_NULL_REGISTER) || |
1495 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && | 1493 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && |
1496 csum_fold(skb_checksum(skb, 0, skb->len, 0)))) 1497 goto drop; 1498 1499 /* check if the inner packet is destined to mcast group */ 1500 encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr)); 1501 if (!MULTICAST(encap->daddr) || 1502 encap->tot_len == 0 || | 1494 csum_fold(skb_checksum(skb, 0, skb->len, 0)))) 1495 goto drop; 1496 1497 /* check if the inner packet is destined to mcast group */ 1498 encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr)); 1499 if (!MULTICAST(encap->daddr) || 1500 encap->tot_len == 0 || |
1503 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) | 1501 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) |
1504 goto drop; 1505 1506 read_lock(&mrt_lock); 1507 if (reg_vif_num >= 0) 1508 reg_dev = vif_table[reg_vif_num].dev; 1509 if (reg_dev) 1510 dev_hold(reg_dev); 1511 read_unlock(&mrt_lock); 1512 | 1502 goto drop; 1503 1504 read_lock(&mrt_lock); 1505 if (reg_vif_num >= 0) 1506 reg_dev = vif_table[reg_vif_num].dev; 1507 if (reg_dev) 1508 dev_hold(reg_dev); 1509 read_unlock(&mrt_lock); 1510 |
1513 if (reg_dev == NULL) | 1511 if (reg_dev == NULL) |
1514 goto drop; 1515 1516 skb->mac.raw = skb->nh.raw; 1517 skb_pull(skb, (u8*)encap - skb->data); 1518 skb->nh.iph = (struct iphdr *)skb->data; 1519 skb->dev = reg_dev; 1520 skb->protocol = htons(ETH_P_IP); 1521 skb->ip_summed = 0; --- 89 unchanged lines hidden (view full) --- 1611 1612 if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY)) 1613 cache->mfc_flags |= MFC_NOTIFY; 1614 err = ipmr_fill_mroute(skb, cache, rtm); 1615 read_unlock(&mrt_lock); 1616 return err; 1617} 1618 | 1512 goto drop; 1513 1514 skb->mac.raw = skb->nh.raw; 1515 skb_pull(skb, (u8*)encap - skb->data); 1516 skb->nh.iph = (struct iphdr *)skb->data; 1517 skb->dev = reg_dev; 1518 skb->protocol = htons(ETH_P_IP); 1519 skb->ip_summed = 0; --- 89 unchanged lines hidden (view full) --- 1609 1610 if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY)) 1611 cache->mfc_flags |= MFC_NOTIFY; 1612 err = ipmr_fill_mroute(skb, cache, rtm); 1613 read_unlock(&mrt_lock); 1614 return err; 1615} 1616 |
1619#ifdef CONFIG_PROC_FS | 1617#ifdef CONFIG_PROC_FS |
1620/* 1621 * The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif 1622 */ 1623struct ipmr_vif_iter { 1624 int ct; 1625}; 1626 1627static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter, 1628 loff_t pos) 1629{ 1630 for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) { 1631 if(!VIF_EXISTS(iter->ct)) 1632 continue; | 1618/* 1619 * The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif 1620 */ 1621struct ipmr_vif_iter { 1622 int ct; 1623}; 1624 1625static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter, 1626 loff_t pos) 1627{ 1628 for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) { 1629 if(!VIF_EXISTS(iter->ct)) 1630 continue; |
1633 if (pos-- == 0) | 1631 if (pos-- == 0) |
1634 return &vif_table[iter->ct]; 1635 } 1636 return NULL; 1637} 1638 1639static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos) 1640{ 1641 read_lock(&mrt_lock); | 1632 return &vif_table[iter->ct]; 1633 } 1634 return NULL; 1635} 1636 1637static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos) 1638{ 1639 read_lock(&mrt_lock); |
1642 return *pos ? ipmr_vif_seq_idx(seq->private, *pos - 1) | 1640 return *pos ? ipmr_vif_seq_idx(seq->private, *pos - 1) |
1643 : SEQ_START_TOKEN; 1644} 1645 1646static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1647{ 1648 struct ipmr_vif_iter *iter = seq->private; 1649 1650 ++*pos; 1651 if (v == SEQ_START_TOKEN) 1652 return ipmr_vif_seq_idx(iter, 0); | 1641 : SEQ_START_TOKEN; 1642} 1643 1644static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1645{ 1646 struct ipmr_vif_iter *iter = seq->private; 1647 1648 ++*pos; 1649 if (v == SEQ_START_TOKEN) 1650 return ipmr_vif_seq_idx(iter, 0); |
1653 | 1651 |
1654 while (++iter->ct < maxvif) { 1655 if(!VIF_EXISTS(iter->ct)) 1656 continue; 1657 return &vif_table[iter->ct]; 1658 } 1659 return NULL; 1660} 1661 1662static void ipmr_vif_seq_stop(struct seq_file *seq, void *v) 1663{ 1664 read_unlock(&mrt_lock); 1665} 1666 1667static int ipmr_vif_seq_show(struct seq_file *seq, void *v) 1668{ 1669 if (v == SEQ_START_TOKEN) { | 1652 while (++iter->ct < maxvif) { 1653 if(!VIF_EXISTS(iter->ct)) 1654 continue; 1655 return &vif_table[iter->ct]; 1656 } 1657 return NULL; 1658} 1659 1660static void ipmr_vif_seq_stop(struct seq_file *seq, void *v) 1661{ 1662 read_unlock(&mrt_lock); 1663} 1664 1665static int ipmr_vif_seq_show(struct seq_file *seq, void *v) 1666{ 1667 if (v == SEQ_START_TOKEN) { |
1670 seq_puts(seq, | 1668 seq_puts(seq, |
1671 "Interface BytesIn PktsIn BytesOut PktsOut Flags Local Remote\n"); 1672 } else { 1673 const struct vif_device *vif = v; 1674 const char *name = vif->dev ? vif->dev->name : "none"; 1675 1676 seq_printf(seq, 1677 "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n", 1678 vif - vif_table, | 1669 "Interface BytesIn PktsIn BytesOut PktsOut Flags Local Remote\n"); 1670 } else { 1671 const struct vif_device *vif = v; 1672 const char *name = vif->dev ? vif->dev->name : "none"; 1673 1674 seq_printf(seq, 1675 "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n", 1676 vif - vif_table, |
1679 name, vif->bytes_in, vif->pkt_in, | 1677 name, vif->bytes_in, vif->pkt_in, |
1680 vif->bytes_out, vif->pkt_out, 1681 vif->flags, vif->local, vif->remote); 1682 } 1683 return 0; 1684} 1685 1686static struct seq_operations ipmr_vif_seq_ops = { 1687 .start = ipmr_vif_seq_start, 1688 .next = ipmr_vif_seq_next, 1689 .stop = ipmr_vif_seq_stop, 1690 .show = ipmr_vif_seq_show, 1691}; 1692 1693static int ipmr_vif_open(struct inode *inode, struct file *file) 1694{ 1695 struct seq_file *seq; 1696 int rc = -ENOMEM; 1697 struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | 1678 vif->bytes_out, vif->pkt_out, 1679 vif->flags, vif->local, vif->remote); 1680 } 1681 return 0; 1682} 1683 1684static struct seq_operations ipmr_vif_seq_ops = { 1685 .start = ipmr_vif_seq_start, 1686 .next = ipmr_vif_seq_next, 1687 .stop = ipmr_vif_seq_stop, 1688 .show = ipmr_vif_seq_show, 1689}; 1690 1691static int ipmr_vif_open(struct inode *inode, struct file *file) 1692{ 1693 struct seq_file *seq; 1694 int rc = -ENOMEM; 1695 struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); |
1698 | 1696 |
1699 if (!s) 1700 goto out; 1701 1702 rc = seq_open(file, &ipmr_vif_seq_ops); 1703 if (rc) 1704 goto out_kfree; 1705 1706 s->ct = 0; --- 22 unchanged lines hidden (view full) --- 1729 1730 1731static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos) 1732{ 1733 struct mfc_cache *mfc; 1734 1735 it->cache = mfc_cache_array; 1736 read_lock(&mrt_lock); | 1697 if (!s) 1698 goto out; 1699 1700 rc = seq_open(file, &ipmr_vif_seq_ops); 1701 if (rc) 1702 goto out_kfree; 1703 1704 s->ct = 0; --- 22 unchanged lines hidden (view full) --- 1727 1728 1729static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos) 1730{ 1731 struct mfc_cache *mfc; 1732 1733 it->cache = mfc_cache_array; 1734 read_lock(&mrt_lock); |
1737 for (it->ct = 0; it->ct < MFC_LINES; it->ct++) 1738 for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) 1739 if (pos-- == 0) | 1735 for (it->ct = 0; it->ct < MFC_LINES; it->ct++) 1736 for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) 1737 if (pos-- == 0) |
1740 return mfc; 1741 read_unlock(&mrt_lock); 1742 1743 it->cache = &mfc_unres_queue; 1744 spin_lock_bh(&mfc_unres_lock); | 1738 return mfc; 1739 read_unlock(&mrt_lock); 1740 1741 it->cache = &mfc_unres_queue; 1742 spin_lock_bh(&mfc_unres_lock); |
1745 for(mfc = mfc_unres_queue; mfc; mfc = mfc->next) | 1743 for(mfc = mfc_unres_queue; mfc; mfc = mfc->next) |
1746 if (pos-- == 0) 1747 return mfc; 1748 spin_unlock_bh(&mfc_unres_lock); 1749 1750 it->cache = NULL; 1751 return NULL; 1752} 1753 1754 1755static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) 1756{ 1757 struct ipmr_mfc_iter *it = seq->private; 1758 it->cache = NULL; 1759 it->ct = 0; | 1744 if (pos-- == 0) 1745 return mfc; 1746 spin_unlock_bh(&mfc_unres_lock); 1747 1748 it->cache = NULL; 1749 return NULL; 1750} 1751 1752 1753static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) 1754{ 1755 struct ipmr_mfc_iter *it = seq->private; 1756 it->cache = NULL; 1757 it->ct = 0; |
1760 return *pos ? ipmr_mfc_seq_idx(seq->private, *pos - 1) | 1758 return *pos ? ipmr_mfc_seq_idx(seq->private, *pos - 1) |
1761 : SEQ_START_TOKEN; 1762} 1763 1764static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1765{ 1766 struct mfc_cache *mfc = v; 1767 struct ipmr_mfc_iter *it = seq->private; 1768 1769 ++*pos; 1770 1771 if (v == SEQ_START_TOKEN) 1772 return ipmr_mfc_seq_idx(seq->private, 0); 1773 1774 if (mfc->next) 1775 return mfc->next; | 1759 : SEQ_START_TOKEN; 1760} 1761 1762static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1763{ 1764 struct mfc_cache *mfc = v; 1765 struct ipmr_mfc_iter *it = seq->private; 1766 1767 ++*pos; 1768 1769 if (v == SEQ_START_TOKEN) 1770 return ipmr_mfc_seq_idx(seq->private, 0); 1771 1772 if (mfc->next) 1773 return mfc->next; |
1776 1777 if (it->cache == &mfc_unres_queue) | 1774 1775 if (it->cache == &mfc_unres_queue) |
1778 goto end_of_list; 1779 1780 BUG_ON(it->cache != mfc_cache_array); 1781 1782 while (++it->ct < MFC_LINES) { 1783 mfc = mfc_cache_array[it->ct]; 1784 if (mfc) 1785 return mfc; 1786 } 1787 1788 /* exhausted cache_array, show unresolved */ 1789 read_unlock(&mrt_lock); 1790 it->cache = &mfc_unres_queue; 1791 it->ct = 0; | 1776 goto end_of_list; 1777 1778 BUG_ON(it->cache != mfc_cache_array); 1779 1780 while (++it->ct < MFC_LINES) { 1781 mfc = mfc_cache_array[it->ct]; 1782 if (mfc) 1783 return mfc; 1784 } 1785 1786 /* exhausted cache_array, show unresolved */ 1787 read_unlock(&mrt_lock); 1788 it->cache = &mfc_unres_queue; 1789 it->ct = 0; |
1792 | 1790 |
1793 spin_lock_bh(&mfc_unres_lock); 1794 mfc = mfc_unres_queue; | 1791 spin_lock_bh(&mfc_unres_lock); 1792 mfc = mfc_unres_queue; |
1795 if (mfc) | 1793 if (mfc) |
1796 return mfc; 1797 1798 end_of_list: 1799 spin_unlock_bh(&mfc_unres_lock); 1800 it->cache = NULL; 1801 1802 return NULL; 1803} --- 8 unchanged lines hidden (view full) --- 1812 read_unlock(&mrt_lock); 1813} 1814 1815static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) 1816{ 1817 int n; 1818 1819 if (v == SEQ_START_TOKEN) { | 1794 return mfc; 1795 1796 end_of_list: 1797 spin_unlock_bh(&mfc_unres_lock); 1798 it->cache = NULL; 1799 1800 return NULL; 1801} --- 8 unchanged lines hidden (view full) --- 1810 read_unlock(&mrt_lock); 1811} 1812 1813static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) 1814{ 1815 int n; 1816 1817 if (v == SEQ_START_TOKEN) { |
1820 seq_puts(seq, | 1818 seq_puts(seq, |
1821 "Group Origin Iif Pkts Bytes Wrong Oifs\n"); 1822 } else { 1823 const struct mfc_cache *mfc = v; 1824 const struct ipmr_mfc_iter *it = seq->private; | 1819 "Group Origin Iif Pkts Bytes Wrong Oifs\n"); 1820 } else { 1821 const struct mfc_cache *mfc = v; 1822 const struct ipmr_mfc_iter *it = seq->private; |
1825 | 1823 |
1826 seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld", 1827 (unsigned long) mfc->mfc_mcastgrp, 1828 (unsigned long) mfc->mfc_origin, 1829 mfc->mfc_parent, 1830 mfc->mfc_un.res.pkt, 1831 mfc->mfc_un.res.bytes, 1832 mfc->mfc_un.res.wrong_if); 1833 1834 if (it->cache != &mfc_unres_queue) { | 1824 seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld", 1825 (unsigned long) mfc->mfc_mcastgrp, 1826 (unsigned long) mfc->mfc_origin, 1827 mfc->mfc_parent, 1828 mfc->mfc_un.res.pkt, 1829 mfc->mfc_un.res.bytes, 1830 mfc->mfc_un.res.wrong_if); 1831 1832 if (it->cache != &mfc_unres_queue) { |
1835 for(n = mfc->mfc_un.res.minvif; | 1833 for(n = mfc->mfc_un.res.minvif; |
1836 n < mfc->mfc_un.res.maxvif; n++ ) { | 1834 n < mfc->mfc_un.res.maxvif; n++ ) { |
1837 if(VIF_EXISTS(n) | 1835 if(VIF_EXISTS(n) |
1838 && mfc->mfc_un.res.ttls[n] < 255) | 1836 && mfc->mfc_un.res.ttls[n] < 255) |
1839 seq_printf(seq, 1840 " %2d:%-3d", | 1837 seq_printf(seq, 1838 " %2d:%-3d", |
1841 n, mfc->mfc_un.res.ttls[n]); 1842 } 1843 } 1844 seq_putc(seq, '\n'); 1845 } 1846 return 0; 1847} 1848 --- 4 unchanged lines hidden (view full) --- 1853 .show = ipmr_mfc_seq_show, 1854}; 1855 1856static int ipmr_mfc_open(struct inode *inode, struct file *file) 1857{ 1858 struct seq_file *seq; 1859 int rc = -ENOMEM; 1860 struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | 1839 n, mfc->mfc_un.res.ttls[n]); 1840 } 1841 } 1842 seq_putc(seq, '\n'); 1843 } 1844 return 0; 1845} 1846 --- 4 unchanged lines hidden (view full) --- 1851 .show = ipmr_mfc_seq_show, 1852}; 1853 1854static int ipmr_mfc_open(struct inode *inode, struct file *file) 1855{ 1856 struct seq_file *seq; 1857 int rc = -ENOMEM; 1858 struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); |
1861 | 1859 |
1862 if (!s) 1863 goto out; 1864 1865 rc = seq_open(file, &ipmr_mfc_seq_ops); 1866 if (rc) 1867 goto out_kfree; 1868 1869 seq = file->private_data; --- 8 unchanged lines hidden (view full) --- 1878 1879static struct file_operations ipmr_mfc_fops = { 1880 .owner = THIS_MODULE, 1881 .open = ipmr_mfc_open, 1882 .read = seq_read, 1883 .llseek = seq_lseek, 1884 .release = seq_release_private, 1885}; | 1860 if (!s) 1861 goto out; 1862 1863 rc = seq_open(file, &ipmr_mfc_seq_ops); 1864 if (rc) 1865 goto out_kfree; 1866 1867 seq = file->private_data; --- 8 unchanged lines hidden (view full) --- 1876 1877static struct file_operations ipmr_mfc_fops = { 1878 .owner = THIS_MODULE, 1879 .open = ipmr_mfc_open, 1880 .read = seq_read, 1881 .llseek = seq_lseek, 1882 .release = seq_release_private, 1883}; |
1886#endif | 1884#endif |
1887 1888#ifdef CONFIG_IP_PIMSM_V2 1889static struct net_protocol pim_protocol = { 1890 .handler = pim_rcv, 1891}; 1892#endif 1893 1894 1895/* 1896 * Setup for IP multicast routing 1897 */ | 1885 1886#ifdef CONFIG_IP_PIMSM_V2 1887static struct net_protocol pim_protocol = { 1888 .handler = pim_rcv, 1889}; 1890#endif 1891 1892 1893/* 1894 * Setup for IP multicast routing 1895 */ |
1898 | 1896 |
1899void __init ip_mr_init(void) 1900{ 1901 mrt_cachep = kmem_cache_create("ip_mrt_cache", 1902 sizeof(struct mfc_cache), 1903 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, 1904 NULL, NULL); 1905 init_timer(&ipmr_expire_timer); 1906 ipmr_expire_timer.function=ipmr_expire_process; 1907 register_netdevice_notifier(&ip_mr_notifier); | 1897void __init ip_mr_init(void) 1898{ 1899 mrt_cachep = kmem_cache_create("ip_mrt_cache", 1900 sizeof(struct mfc_cache), 1901 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, 1902 NULL, NULL); 1903 init_timer(&ipmr_expire_timer); 1904 ipmr_expire_timer.function=ipmr_expire_process; 1905 register_netdevice_notifier(&ip_mr_notifier); |
1908#ifdef CONFIG_PROC_FS | 1906#ifdef CONFIG_PROC_FS |
1909 proc_net_fops_create("ip_mr_vif", 0, &ipmr_vif_fops); 1910 proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops); | 1907 proc_net_fops_create("ip_mr_vif", 0, &ipmr_vif_fops); 1908 proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops); |
1911#endif | 1909#endif |
1912} | 1910} |