diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-28 00:37:58 -0400 |
---|---|---|
committer | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-03-28 01:00:06 -0400 |
commit | 0736ffc04eec239cce9fd3c6ae5dce54e14c25c7 (patch) | |
tree | e599e32748d4a96578850d089e4da0d277ae8785 /net/ipv6 | |
parent | be01d655d9b07c1350b19bf3d80eae0059254b4b (diff) |
[IPV6] NEIGH: Optimize is_router check.
Our interest is not the whole entry of proxy neighbor but the
NTF_ROUTER flag. Let's test it explicitly.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ndisc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index e77b74edfd63..510aa747a404 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -661,18 +661,19 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) | |||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | static struct pneigh_entry *pndisc_check_router(struct net_device *dev, | 664 | static int pndisc_is_router(const void *pkey, |
665 | struct in6_addr *addr, int *is_router) | 665 | struct net_device *dev) |
666 | { | 666 | { |
667 | struct pneigh_entry *n; | 667 | struct pneigh_entry *n; |
668 | int ret = -1; | ||
668 | 669 | ||
669 | read_lock_bh(&nd_tbl.lock); | 670 | read_lock_bh(&nd_tbl.lock); |
670 | n = __pneigh_lookup(&nd_tbl, dev_net(dev), addr, dev); | 671 | n = __pneigh_lookup(&nd_tbl, dev_net(dev), pkey, dev); |
671 | if (n != NULL) | 672 | if (n) |
672 | *is_router = (n->flags & NTF_ROUTER); | 673 | ret = !!(n->flags & NTF_ROUTER); |
673 | read_unlock_bh(&nd_tbl.lock); | 674 | read_unlock_bh(&nd_tbl.lock); |
674 | 675 | ||
675 | return n; | 676 | return ret; |
676 | } | 677 | } |
677 | 678 | ||
678 | static void ndisc_recv_ns(struct sk_buff *skb) | 679 | static void ndisc_recv_ns(struct sk_buff *skb) |
@@ -688,10 +689,9 @@ static void ndisc_recv_ns(struct sk_buff *skb) | |||
688 | struct inet6_ifaddr *ifp; | 689 | struct inet6_ifaddr *ifp; |
689 | struct inet6_dev *idev = NULL; | 690 | struct inet6_dev *idev = NULL; |
690 | struct neighbour *neigh; | 691 | struct neighbour *neigh; |
691 | struct pneigh_entry *pneigh = NULL; | ||
692 | int dad = ipv6_addr_any(saddr); | 692 | int dad = ipv6_addr_any(saddr); |
693 | int inc; | 693 | int inc; |
694 | int is_router = 0; | 694 | int is_router = -1; |
695 | 695 | ||
696 | if (ipv6_addr_is_multicast(&msg->target)) { | 696 | if (ipv6_addr_is_multicast(&msg->target)) { |
697 | ND_PRINTK2(KERN_WARNING | 697 | ND_PRINTK2(KERN_WARNING |
@@ -790,8 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) | |||
790 | if (ipv6_chk_acast_addr(dev_net(dev), dev, &msg->target) || | 790 | if (ipv6_chk_acast_addr(dev_net(dev), dev, &msg->target) || |
791 | (idev->cnf.forwarding && | 791 | (idev->cnf.forwarding && |
792 | (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) && | 792 | (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) && |
793 | (pneigh = pndisc_check_router(dev, &msg->target, | 793 | (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) { |
794 | &is_router)) != NULL)) { | ||
795 | if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && | 794 | if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && |
796 | skb->pkt_type != PACKET_HOST && | 795 | skb->pkt_type != PACKET_HOST && |
797 | inc != 0 && | 796 | inc != 0 && |
@@ -812,7 +811,8 @@ static void ndisc_recv_ns(struct sk_buff *skb) | |||
812 | goto out; | 811 | goto out; |
813 | } | 812 | } |
814 | 813 | ||
815 | is_router = !!(pneigh ? is_router : idev->cnf.forwarding); | 814 | if (is_router < 0) |
815 | is_router = !!idev->cnf.forwarding; | ||
816 | 816 | ||
817 | if (dad) { | 817 | if (dad) { |
818 | struct in6_addr maddr; | 818 | struct in6_addr maddr; |