Commit 0736ffc0 authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki

[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: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
parent be01d655
...@@ -661,18 +661,19 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) ...@@ -661,18 +661,19 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
} }
} }
static struct pneigh_entry *pndisc_check_router(struct net_device *dev, static int pndisc_is_router(const void *pkey,
struct in6_addr *addr, int *is_router) struct net_device *dev)
{ {
struct pneigh_entry *n; struct pneigh_entry *n;
int ret = -1;
read_lock_bh(&nd_tbl.lock); read_lock_bh(&nd_tbl.lock);
n = __pneigh_lookup(&nd_tbl, dev_net(dev), addr, dev); n = __pneigh_lookup(&nd_tbl, dev_net(dev), pkey, dev);
if (n != NULL) if (n)
*is_router = (n->flags & NTF_ROUTER); ret = !!(n->flags & NTF_ROUTER);
read_unlock_bh(&nd_tbl.lock); read_unlock_bh(&nd_tbl.lock);
return n; return ret;
} }
static void ndisc_recv_ns(struct sk_buff *skb) static void ndisc_recv_ns(struct sk_buff *skb)
...@@ -688,10 +689,9 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -688,10 +689,9 @@ static void ndisc_recv_ns(struct sk_buff *skb)
struct inet6_ifaddr *ifp; struct inet6_ifaddr *ifp;
struct inet6_dev *idev = NULL; struct inet6_dev *idev = NULL;
struct neighbour *neigh; struct neighbour *neigh;
struct pneigh_entry *pneigh = NULL;
int dad = ipv6_addr_any(saddr); int dad = ipv6_addr_any(saddr);
int inc; int inc;
int is_router = 0; int is_router = -1;
if (ipv6_addr_is_multicast(&msg->target)) { if (ipv6_addr_is_multicast(&msg->target)) {
ND_PRINTK2(KERN_WARNING ND_PRINTK2(KERN_WARNING
...@@ -790,8 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -790,8 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
if (ipv6_chk_acast_addr(dev_net(dev), dev, &msg->target) || if (ipv6_chk_acast_addr(dev_net(dev), dev, &msg->target) ||
(idev->cnf.forwarding && (idev->cnf.forwarding &&
(ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) && (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) &&
(pneigh = pndisc_check_router(dev, &msg->target, (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
&is_router)) != NULL)) {
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
skb->pkt_type != PACKET_HOST && skb->pkt_type != PACKET_HOST &&
inc != 0 && inc != 0 &&
...@@ -812,7 +811,8 @@ static void ndisc_recv_ns(struct sk_buff *skb) ...@@ -812,7 +811,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
goto out; goto out;
} }
is_router = !!(pneigh ? is_router : idev->cnf.forwarding); if (is_router < 0)
is_router = !!idev->cnf.forwarding;
if (dad) { if (dad) {
struct in6_addr maddr; struct in6_addr maddr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment