diff options
Diffstat (limited to 'net/ipv4/ipmr.c')
-rw-r--r-- | net/ipv4/ipmr.c | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index ecb5422ea237..e6d11abd7841 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -241,7 +241,7 @@ failure: | |||
241 | /* | 241 | /* |
242 | * Delete a VIF entry | 242 | * Delete a VIF entry |
243 | */ | 243 | */ |
244 | 244 | ||
245 | static int vif_delete(int vifi) | 245 | static int vif_delete(int vifi) |
246 | { | 246 | { |
247 | struct vif_device *v; | 247 | struct vif_device *v; |
@@ -409,7 +409,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock) | |||
409 | return -ENOBUFS; | 409 | return -ENOBUFS; |
410 | break; | 410 | break; |
411 | #endif | 411 | #endif |
412 | case VIFF_TUNNEL: | 412 | case VIFF_TUNNEL: |
413 | dev = ipmr_new_tunnel(vifc); | 413 | dev = ipmr_new_tunnel(vifc); |
414 | if (!dev) | 414 | if (!dev) |
415 | return -ENOBUFS; | 415 | return -ENOBUFS; |
@@ -479,20 +479,18 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp) | |||
479 | */ | 479 | */ |
480 | static struct mfc_cache *ipmr_cache_alloc(void) | 480 | static struct mfc_cache *ipmr_cache_alloc(void) |
481 | { | 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) | 483 | if(c==NULL) |
484 | return NULL; | 484 | return NULL; |
485 | memset(c, 0, sizeof(*c)); | ||
486 | c->mfc_un.res.minvif = MAXVIFS; | 485 | c->mfc_un.res.minvif = MAXVIFS; |
487 | return c; | 486 | return c; |
488 | } | 487 | } |
489 | 488 | ||
490 | static struct mfc_cache *ipmr_cache_alloc_unres(void) | 489 | static struct mfc_cache *ipmr_cache_alloc_unres(void) |
491 | { | 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) | 492 | if(c==NULL) |
494 | return NULL; | 493 | return NULL; |
495 | memset(c, 0, sizeof(*c)); | ||
496 | skb_queue_head_init(&c->mfc_un.unres.unresolved); | 494 | skb_queue_head_init(&c->mfc_un.unres.unresolved); |
497 | c->mfc_un.unres.expires = jiffies + 10*HZ; | 495 | c->mfc_un.unres.expires = jiffies + 10*HZ; |
498 | return c; | 496 | return c; |
@@ -501,7 +499,7 @@ static struct mfc_cache *ipmr_cache_alloc_unres(void) | |||
501 | /* | 499 | /* |
502 | * A cache entry has gone into a resolved state from queued | 500 | * A cache entry has gone into a resolved state from queued |
503 | */ | 501 | */ |
504 | 502 | ||
505 | static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) | 503 | static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) |
506 | { | 504 | { |
507 | struct sk_buff *skb; | 505 | struct sk_buff *skb; |
@@ -538,7 +536,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) | |||
538 | * | 536 | * |
539 | * Called under mrt_lock. | 537 | * Called under mrt_lock. |
540 | */ | 538 | */ |
541 | 539 | ||
542 | static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | 540 | static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) |
543 | { | 541 | { |
544 | struct sk_buff *skb; | 542 | struct sk_buff *skb; |
@@ -569,13 +567,13 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
569 | memcpy(msg, pkt->nh.raw, sizeof(struct iphdr)); | 567 | memcpy(msg, pkt->nh.raw, sizeof(struct iphdr)); |
570 | msg->im_msgtype = IGMPMSG_WHOLEPKT; | 568 | msg->im_msgtype = IGMPMSG_WHOLEPKT; |
571 | msg->im_mbz = 0; | 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; | 571 | skb->nh.iph->ihl = sizeof(struct iphdr) >> 2; |
574 | skb->nh.iph->tot_len = htons(ntohs(pkt->nh.iph->tot_len) + sizeof(struct iphdr)); | 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 | { | 575 | { |
578 | 576 | ||
579 | /* | 577 | /* |
580 | * Copy the IP header | 578 | * Copy the IP header |
581 | */ | 579 | */ |
@@ -597,7 +595,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
597 | igmp->code = 0; | 595 | igmp->code = 0; |
598 | skb->nh.iph->tot_len=htons(skb->len); /* Fix the length */ | 596 | skb->nh.iph->tot_len=htons(skb->len); /* Fix the length */ |
599 | skb->h.raw = skb->nh.raw; | 597 | skb->h.raw = skb->nh.raw; |
600 | } | 598 | } |
601 | 599 | ||
602 | if (mroute_socket == NULL) { | 600 | if (mroute_socket == NULL) { |
603 | kfree_skb(skb); | 601 | kfree_skb(skb); |
@@ -619,7 +617,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
619 | /* | 617 | /* |
620 | * Queue a packet for resolution. It gets locked cache entry! | 618 | * Queue a packet for resolution. It gets locked cache entry! |
621 | */ | 619 | */ |
622 | 620 | ||
623 | static int | 621 | static int |
624 | ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb) | 622 | ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb) |
625 | { | 623 | { |
@@ -657,7 +655,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb) | |||
657 | * Reflect first query at mrouted. | 655 | * Reflect first query at mrouted. |
658 | */ | 656 | */ |
659 | if ((err = ipmr_cache_report(skb, vifi, IGMPMSG_NOCACHE))<0) { | 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 | 659 | out - Brad Parker |
662 | */ | 660 | */ |
663 | spin_unlock_bh(&mfc_unres_lock); | 661 | spin_unlock_bh(&mfc_unres_lock); |
@@ -783,11 +781,11 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock) | |||
783 | /* | 781 | /* |
784 | * Close the multicast socket, and clear the vif tables etc | 782 | * Close the multicast socket, and clear the vif tables etc |
785 | */ | 783 | */ |
786 | 784 | ||
787 | static void mroute_clean_tables(struct sock *sk) | 785 | static void mroute_clean_tables(struct sock *sk) |
788 | { | 786 | { |
789 | int i; | 787 | int i; |
790 | 788 | ||
791 | /* | 789 | /* |
792 | * Shut down all active vif entries | 790 | * Shut down all active vif entries |
793 | */ | 791 | */ |
@@ -854,13 +852,13 @@ static void mrtsock_destruct(struct sock *sk) | |||
854 | * that's how BSD mrouted happens to think. Maybe one day with a proper | 852 | * 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. | 853 | * MOSPF/PIM router set up we can clean this up. |
856 | */ | 854 | */ |
857 | 855 | ||
858 | int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen) | 856 | int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int optlen) |
859 | { | 857 | { |
860 | int ret; | 858 | int ret; |
861 | struct vifctl vif; | 859 | struct vifctl vif; |
862 | struct mfcctl mfc; | 860 | struct mfcctl mfc; |
863 | 861 | ||
864 | if(optname!=MRT_INIT) | 862 | if(optname!=MRT_INIT) |
865 | { | 863 | { |
866 | if(sk!=mroute_socket && !capable(CAP_NET_ADMIN)) | 864 | if(sk!=mroute_socket && !capable(CAP_NET_ADMIN)) |
@@ -901,7 +899,7 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt | |||
901 | if(optlen!=sizeof(vif)) | 899 | if(optlen!=sizeof(vif)) |
902 | return -EINVAL; | 900 | return -EINVAL; |
903 | if (copy_from_user(&vif,optval,sizeof(vif))) | 901 | if (copy_from_user(&vif,optval,sizeof(vif))) |
904 | return -EFAULT; | 902 | return -EFAULT; |
905 | if(vif.vifc_vifi >= MAXVIFS) | 903 | if(vif.vifc_vifi >= MAXVIFS) |
906 | return -ENFILE; | 904 | return -ENFILE; |
907 | rtnl_lock(); | 905 | rtnl_lock(); |
@@ -980,13 +978,13 @@ int ip_mroute_setsockopt(struct sock *sk,int optname,char __user *optval,int opt | |||
980 | /* | 978 | /* |
981 | * Getsock opt support for the multicast routing system. | 979 | * Getsock opt support for the multicast routing system. |
982 | */ | 980 | */ |
983 | 981 | ||
984 | int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen) | 982 | int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __user *optlen) |
985 | { | 983 | { |
986 | int olr; | 984 | int olr; |
987 | int val; | 985 | int val; |
988 | 986 | ||
989 | if(optname!=MRT_VERSION && | 987 | if(optname!=MRT_VERSION && |
990 | #ifdef CONFIG_IP_PIMSM | 988 | #ifdef CONFIG_IP_PIMSM |
991 | optname!=MRT_PIM && | 989 | optname!=MRT_PIM && |
992 | #endif | 990 | #endif |
@@ -999,7 +997,7 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u | |||
999 | olr = min_t(unsigned int, olr, sizeof(int)); | 997 | olr = min_t(unsigned int, olr, sizeof(int)); |
1000 | if (olr < 0) | 998 | if (olr < 0) |
1001 | return -EINVAL; | 999 | return -EINVAL; |
1002 | 1000 | ||
1003 | if(put_user(olr,optlen)) | 1001 | if(put_user(olr,optlen)) |
1004 | return -EFAULT; | 1002 | return -EFAULT; |
1005 | if(optname==MRT_VERSION) | 1003 | if(optname==MRT_VERSION) |
@@ -1018,19 +1016,19 @@ int ip_mroute_getsockopt(struct sock *sk,int optname,char __user *optval,int __u | |||
1018 | /* | 1016 | /* |
1019 | * The IP multicast ioctl support routines. | 1017 | * The IP multicast ioctl support routines. |
1020 | */ | 1018 | */ |
1021 | 1019 | ||
1022 | int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) | 1020 | int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg) |
1023 | { | 1021 | { |
1024 | struct sioc_sg_req sr; | 1022 | struct sioc_sg_req sr; |
1025 | struct sioc_vif_req vr; | 1023 | struct sioc_vif_req vr; |
1026 | struct vif_device *vif; | 1024 | struct vif_device *vif; |
1027 | struct mfc_cache *c; | 1025 | struct mfc_cache *c; |
1028 | 1026 | ||
1029 | switch(cmd) | 1027 | switch(cmd) |
1030 | { | 1028 | { |
1031 | case SIOCGETVIFCNT: | 1029 | case SIOCGETVIFCNT: |
1032 | if (copy_from_user(&vr,arg,sizeof(vr))) | 1030 | if (copy_from_user(&vr,arg,sizeof(vr))) |
1033 | return -EFAULT; | 1031 | return -EFAULT; |
1034 | if(vr.vifi>=maxvif) | 1032 | if(vr.vifi>=maxvif) |
1035 | return -EINVAL; | 1033 | return -EINVAL; |
1036 | read_lock(&mrt_lock); | 1034 | read_lock(&mrt_lock); |
@@ -1096,7 +1094,7 @@ static struct notifier_block ip_mr_notifier={ | |||
1096 | * This avoids tunnel drivers and other mess and gives us the speed so | 1094 | * This avoids tunnel drivers and other mess and gives us the speed so |
1097 | * important for multicast video. | 1095 | * important for multicast video. |
1098 | */ | 1096 | */ |
1099 | 1097 | ||
1100 | static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) | 1098 | static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) |
1101 | { | 1099 | { |
1102 | struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); | 1100 | struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); |
@@ -1194,7 +1192,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi) | |||
1194 | encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len; | 1192 | encap += LL_RESERVED_SPACE(dev) + rt->u.dst.header_len; |
1195 | 1193 | ||
1196 | if (skb_cow(skb, encap)) { | 1194 | if (skb_cow(skb, encap)) { |
1197 | ip_rt_put(rt); | 1195 | ip_rt_put(rt); |
1198 | goto out_free; | 1196 | goto out_free; |
1199 | } | 1197 | } |
1200 | 1198 | ||
@@ -1228,7 +1226,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi) | |||
1228 | * not mrouter) cannot join to more than one interface - it will | 1226 | * not mrouter) cannot join to more than one interface - it will |
1229 | * result in receiving multiple packets. | 1227 | * result in receiving multiple packets. |
1230 | */ | 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); | 1230 | ipmr_forward_finish); |
1233 | return; | 1231 | return; |
1234 | 1232 | ||
@@ -1289,7 +1287,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local | |||
1289 | large chunk of pimd to kernel. Ough... --ANK | 1287 | large chunk of pimd to kernel. Ough... --ANK |
1290 | */ | 1288 | */ |
1291 | (mroute_do_pim || cache->mfc_un.res.ttls[true_vifi] < 255) && | 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)) { | 1291 | cache->mfc_un.res.last_assert + MFC_ASSERT_THRESH)) { |
1294 | cache->mfc_un.res.last_assert = jiffies; | 1292 | cache->mfc_un.res.last_assert = jiffies; |
1295 | ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF); | 1293 | ipmr_cache_report(skb, true_vifi, IGMPMSG_WRONGVIF); |
@@ -1426,14 +1424,14 @@ int pim_rcv_v1(struct sk_buff * skb) | |||
1426 | struct iphdr *encap; | 1424 | struct iphdr *encap; |
1427 | struct net_device *reg_dev = NULL; | 1425 | struct net_device *reg_dev = NULL; |
1428 | 1426 | ||
1429 | if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) | 1427 | if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) |
1430 | goto drop; | 1428 | goto drop; |
1431 | 1429 | ||
1432 | pim = (struct igmphdr*)skb->h.raw; | 1430 | pim = (struct igmphdr*)skb->h.raw; |
1433 | 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; | 1435 | goto drop; |
1438 | 1436 | ||
1439 | encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr)); | 1437 | encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr)); |
@@ -1445,7 +1443,7 @@ int pim_rcv_v1(struct sk_buff * skb) | |||
1445 | */ | 1443 | */ |
1446 | if (!MULTICAST(encap->daddr) || | 1444 | if (!MULTICAST(encap->daddr) || |
1447 | encap->tot_len == 0 || | 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; | 1447 | goto drop; |
1450 | 1448 | ||
1451 | read_lock(&mrt_lock); | 1449 | read_lock(&mrt_lock); |
@@ -1455,7 +1453,7 @@ int pim_rcv_v1(struct sk_buff * skb) | |||
1455 | dev_hold(reg_dev); | 1453 | dev_hold(reg_dev); |
1456 | read_unlock(&mrt_lock); | 1454 | read_unlock(&mrt_lock); |
1457 | 1455 | ||
1458 | if (reg_dev == NULL) | 1456 | if (reg_dev == NULL) |
1459 | goto drop; | 1457 | goto drop; |
1460 | 1458 | ||
1461 | skb->mac.raw = skb->nh.raw; | 1459 | skb->mac.raw = skb->nh.raw; |
@@ -1486,13 +1484,13 @@ static int pim_rcv(struct sk_buff * skb) | |||
1486 | struct iphdr *encap; | 1484 | struct iphdr *encap; |
1487 | struct net_device *reg_dev = NULL; | 1485 | struct net_device *reg_dev = NULL; |
1488 | 1486 | ||
1489 | if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) | 1487 | if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) |
1490 | goto drop; | 1488 | goto drop; |
1491 | 1489 | ||
1492 | pim = (struct pimreghdr*)skb->h.raw; | 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)))) | 1494 | csum_fold(skb_checksum(skb, 0, skb->len, 0)))) |
1497 | goto drop; | 1495 | goto drop; |
1498 | 1496 | ||
@@ -1500,7 +1498,7 @@ static int pim_rcv(struct sk_buff * skb) | |||
1500 | encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr)); | 1498 | encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr)); |
1501 | if (!MULTICAST(encap->daddr) || | 1499 | if (!MULTICAST(encap->daddr) || |
1502 | encap->tot_len == 0 || | 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; | 1502 | goto drop; |
1505 | 1503 | ||
1506 | read_lock(&mrt_lock); | 1504 | read_lock(&mrt_lock); |
@@ -1510,7 +1508,7 @@ static int pim_rcv(struct sk_buff * skb) | |||
1510 | dev_hold(reg_dev); | 1508 | dev_hold(reg_dev); |
1511 | read_unlock(&mrt_lock); | 1509 | read_unlock(&mrt_lock); |
1512 | 1510 | ||
1513 | if (reg_dev == NULL) | 1511 | if (reg_dev == NULL) |
1514 | goto drop; | 1512 | goto drop; |
1515 | 1513 | ||
1516 | skb->mac.raw = skb->nh.raw; | 1514 | skb->mac.raw = skb->nh.raw; |
@@ -1616,7 +1614,7 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait) | |||
1616 | return err; | 1614 | return err; |
1617 | } | 1615 | } |
1618 | 1616 | ||
1619 | #ifdef CONFIG_PROC_FS | 1617 | #ifdef CONFIG_PROC_FS |
1620 | /* | 1618 | /* |
1621 | * The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif | 1619 | * The /proc interfaces to multicast routing /proc/ip_mr_cache /proc/ip_mr_vif |
1622 | */ | 1620 | */ |
@@ -1630,7 +1628,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter, | |||
1630 | for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) { | 1628 | for (iter->ct = 0; iter->ct < maxvif; ++iter->ct) { |
1631 | if(!VIF_EXISTS(iter->ct)) | 1629 | if(!VIF_EXISTS(iter->ct)) |
1632 | continue; | 1630 | continue; |
1633 | if (pos-- == 0) | 1631 | if (pos-- == 0) |
1634 | return &vif_table[iter->ct]; | 1632 | return &vif_table[iter->ct]; |
1635 | } | 1633 | } |
1636 | return NULL; | 1634 | return NULL; |
@@ -1639,7 +1637,7 @@ static struct vif_device *ipmr_vif_seq_idx(struct ipmr_vif_iter *iter, | |||
1639 | static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos) | 1637 | static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos) |
1640 | { | 1638 | { |
1641 | read_lock(&mrt_lock); | 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; | 1641 | : SEQ_START_TOKEN; |
1644 | } | 1642 | } |
1645 | 1643 | ||
@@ -1650,7 +1648,7 @@ static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1650 | ++*pos; | 1648 | ++*pos; |
1651 | if (v == SEQ_START_TOKEN) | 1649 | if (v == SEQ_START_TOKEN) |
1652 | return ipmr_vif_seq_idx(iter, 0); | 1650 | return ipmr_vif_seq_idx(iter, 0); |
1653 | 1651 | ||
1654 | while (++iter->ct < maxvif) { | 1652 | while (++iter->ct < maxvif) { |
1655 | if(!VIF_EXISTS(iter->ct)) | 1653 | if(!VIF_EXISTS(iter->ct)) |
1656 | continue; | 1654 | continue; |
@@ -1667,7 +1665,7 @@ static void ipmr_vif_seq_stop(struct seq_file *seq, void *v) | |||
1667 | static int ipmr_vif_seq_show(struct seq_file *seq, void *v) | 1665 | static int ipmr_vif_seq_show(struct seq_file *seq, void *v) |
1668 | { | 1666 | { |
1669 | if (v == SEQ_START_TOKEN) { | 1667 | if (v == SEQ_START_TOKEN) { |
1670 | seq_puts(seq, | 1668 | seq_puts(seq, |
1671 | "Interface BytesIn PktsIn BytesOut PktsOut Flags Local Remote\n"); | 1669 | "Interface BytesIn PktsIn BytesOut PktsOut Flags Local Remote\n"); |
1672 | } else { | 1670 | } else { |
1673 | const struct vif_device *vif = v; | 1671 | const struct vif_device *vif = v; |
@@ -1676,7 +1674,7 @@ static int ipmr_vif_seq_show(struct seq_file *seq, void *v) | |||
1676 | seq_printf(seq, | 1674 | seq_printf(seq, |
1677 | "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n", | 1675 | "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n", |
1678 | vif - vif_table, | 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, | 1678 | vif->bytes_out, vif->pkt_out, |
1681 | vif->flags, vif->local, vif->remote); | 1679 | vif->flags, vif->local, vif->remote); |
1682 | } | 1680 | } |
@@ -1695,7 +1693,7 @@ static int ipmr_vif_open(struct inode *inode, struct file *file) | |||
1695 | struct seq_file *seq; | 1693 | struct seq_file *seq; |
1696 | int rc = -ENOMEM; | 1694 | int rc = -ENOMEM; |
1697 | struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | 1695 | struct ipmr_vif_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); |
1698 | 1696 | ||
1699 | if (!s) | 1697 | if (!s) |
1700 | goto out; | 1698 | goto out; |
1701 | 1699 | ||
@@ -1714,7 +1712,7 @@ out_kfree: | |||
1714 | 1712 | ||
1715 | } | 1713 | } |
1716 | 1714 | ||
1717 | static struct file_operations ipmr_vif_fops = { | 1715 | static const struct file_operations ipmr_vif_fops = { |
1718 | .owner = THIS_MODULE, | 1716 | .owner = THIS_MODULE, |
1719 | .open = ipmr_vif_open, | 1717 | .open = ipmr_vif_open, |
1720 | .read = seq_read, | 1718 | .read = seq_read, |
@@ -1734,15 +1732,15 @@ static struct mfc_cache *ipmr_mfc_seq_idx(struct ipmr_mfc_iter *it, loff_t pos) | |||
1734 | 1732 | ||
1735 | it->cache = mfc_cache_array; | 1733 | it->cache = mfc_cache_array; |
1736 | read_lock(&mrt_lock); | 1734 | read_lock(&mrt_lock); |
1737 | for (it->ct = 0; it->ct < MFC_LINES; it->ct++) | 1735 | for (it->ct = 0; it->ct < MFC_LINES; it->ct++) |
1738 | for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) | 1736 | for(mfc = mfc_cache_array[it->ct]; mfc; mfc = mfc->next) |
1739 | if (pos-- == 0) | 1737 | if (pos-- == 0) |
1740 | return mfc; | 1738 | return mfc; |
1741 | read_unlock(&mrt_lock); | 1739 | read_unlock(&mrt_lock); |
1742 | 1740 | ||
1743 | it->cache = &mfc_unres_queue; | 1741 | it->cache = &mfc_unres_queue; |
1744 | spin_lock_bh(&mfc_unres_lock); | 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) | 1744 | if (pos-- == 0) |
1747 | return mfc; | 1745 | return mfc; |
1748 | spin_unlock_bh(&mfc_unres_lock); | 1746 | spin_unlock_bh(&mfc_unres_lock); |
@@ -1757,7 +1755,7 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) | |||
1757 | struct ipmr_mfc_iter *it = seq->private; | 1755 | struct ipmr_mfc_iter *it = seq->private; |
1758 | it->cache = NULL; | 1756 | it->cache = NULL; |
1759 | it->ct = 0; | 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; | 1759 | : SEQ_START_TOKEN; |
1762 | } | 1760 | } |
1763 | 1761 | ||
@@ -1773,8 +1771,8 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1773 | 1771 | ||
1774 | if (mfc->next) | 1772 | if (mfc->next) |
1775 | return mfc->next; | 1773 | return mfc->next; |
1776 | 1774 | ||
1777 | if (it->cache == &mfc_unres_queue) | 1775 | if (it->cache == &mfc_unres_queue) |
1778 | goto end_of_list; | 1776 | goto end_of_list; |
1779 | 1777 | ||
1780 | BUG_ON(it->cache != mfc_cache_array); | 1778 | BUG_ON(it->cache != mfc_cache_array); |
@@ -1789,10 +1787,10 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1789 | read_unlock(&mrt_lock); | 1787 | read_unlock(&mrt_lock); |
1790 | it->cache = &mfc_unres_queue; | 1788 | it->cache = &mfc_unres_queue; |
1791 | it->ct = 0; | 1789 | it->ct = 0; |
1792 | 1790 | ||
1793 | spin_lock_bh(&mfc_unres_lock); | 1791 | spin_lock_bh(&mfc_unres_lock); |
1794 | mfc = mfc_unres_queue; | 1792 | mfc = mfc_unres_queue; |
1795 | if (mfc) | 1793 | if (mfc) |
1796 | return mfc; | 1794 | return mfc; |
1797 | 1795 | ||
1798 | end_of_list: | 1796 | end_of_list: |
@@ -1817,12 +1815,12 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) | |||
1817 | int n; | 1815 | int n; |
1818 | 1816 | ||
1819 | if (v == SEQ_START_TOKEN) { | 1817 | if (v == SEQ_START_TOKEN) { |
1820 | seq_puts(seq, | 1818 | seq_puts(seq, |
1821 | "Group Origin Iif Pkts Bytes Wrong Oifs\n"); | 1819 | "Group Origin Iif Pkts Bytes Wrong Oifs\n"); |
1822 | } else { | 1820 | } else { |
1823 | const struct mfc_cache *mfc = v; | 1821 | const struct mfc_cache *mfc = v; |
1824 | const struct ipmr_mfc_iter *it = seq->private; | 1822 | const struct ipmr_mfc_iter *it = seq->private; |
1825 | 1823 | ||
1826 | seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld", | 1824 | seq_printf(seq, "%08lX %08lX %-3d %8ld %8ld %8ld", |
1827 | (unsigned long) mfc->mfc_mcastgrp, | 1825 | (unsigned long) mfc->mfc_mcastgrp, |
1828 | (unsigned long) mfc->mfc_origin, | 1826 | (unsigned long) mfc->mfc_origin, |
@@ -1832,12 +1830,12 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) | |||
1832 | mfc->mfc_un.res.wrong_if); | 1830 | mfc->mfc_un.res.wrong_if); |
1833 | 1831 | ||
1834 | if (it->cache != &mfc_unres_queue) { | 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, | 1837 | seq_printf(seq, |
1840 | " %2d:%-3d", | 1838 | " %2d:%-3d", |
1841 | n, mfc->mfc_un.res.ttls[n]); | 1839 | n, mfc->mfc_un.res.ttls[n]); |
1842 | } | 1840 | } |
1843 | } | 1841 | } |
@@ -1858,7 +1856,7 @@ static int ipmr_mfc_open(struct inode *inode, struct file *file) | |||
1858 | struct seq_file *seq; | 1856 | struct seq_file *seq; |
1859 | int rc = -ENOMEM; | 1857 | int rc = -ENOMEM; |
1860 | struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); | 1858 | struct ipmr_mfc_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); |
1861 | 1859 | ||
1862 | if (!s) | 1860 | if (!s) |
1863 | goto out; | 1861 | goto out; |
1864 | 1862 | ||
@@ -1876,14 +1874,14 @@ out_kfree: | |||
1876 | 1874 | ||
1877 | } | 1875 | } |
1878 | 1876 | ||
1879 | static struct file_operations ipmr_mfc_fops = { | 1877 | static const struct file_operations ipmr_mfc_fops = { |
1880 | .owner = THIS_MODULE, | 1878 | .owner = THIS_MODULE, |
1881 | .open = ipmr_mfc_open, | 1879 | .open = ipmr_mfc_open, |
1882 | .read = seq_read, | 1880 | .read = seq_read, |
1883 | .llseek = seq_lseek, | 1881 | .llseek = seq_lseek, |
1884 | .release = seq_release_private, | 1882 | .release = seq_release_private, |
1885 | }; | 1883 | }; |
1886 | #endif | 1884 | #endif |
1887 | 1885 | ||
1888 | #ifdef CONFIG_IP_PIMSM_V2 | 1886 | #ifdef CONFIG_IP_PIMSM_V2 |
1889 | static struct net_protocol pim_protocol = { | 1887 | static struct net_protocol pim_protocol = { |
@@ -1895,7 +1893,7 @@ static struct net_protocol pim_protocol = { | |||
1895 | /* | 1893 | /* |
1896 | * Setup for IP multicast routing | 1894 | * Setup for IP multicast routing |
1897 | */ | 1895 | */ |
1898 | 1896 | ||
1899 | void __init ip_mr_init(void) | 1897 | void __init ip_mr_init(void) |
1900 | { | 1898 | { |
1901 | mrt_cachep = kmem_cache_create("ip_mrt_cache", | 1899 | mrt_cachep = kmem_cache_create("ip_mrt_cache", |
@@ -1905,8 +1903,8 @@ void __init ip_mr_init(void) | |||
1905 | init_timer(&ipmr_expire_timer); | 1903 | init_timer(&ipmr_expire_timer); |
1906 | ipmr_expire_timer.function=ipmr_expire_process; | 1904 | ipmr_expire_timer.function=ipmr_expire_process; |
1907 | register_netdevice_notifier(&ip_mr_notifier); | 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); | 1907 | proc_net_fops_create("ip_mr_vif", 0, &ipmr_vif_fops); |
1910 | proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops); | 1908 | proc_net_fops_create("ip_mr_cache", 0, &ipmr_mfc_fops); |
1911 | #endif | 1909 | #endif |
1912 | } | 1910 | } |