Commit cf6b1982 authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller

[IPV6] ROUTE: Introduce a helper to check route validity.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Acked-by: default avatarVille Nuorvala <vnuorval@tcs.hut.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af184765
...@@ -726,6 +726,14 @@ fail: ...@@ -726,6 +726,14 @@ fail:
return err; return err;
} }
static inline int ip6_rt_check(struct rt6key *rt_key,
struct in6_addr *fl_addr,
struct in6_addr *addr_cache)
{
return ((rt_key->plen != 128 || !ipv6_addr_equal(fl_addr, &rt_key->addr)) &&
(addr_cache == NULL || !ipv6_addr_equal(fl_addr, addr_cache)));
}
static struct dst_entry *ip6_sk_dst_check(struct sock *sk, static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
struct dst_entry *dst, struct dst_entry *dst,
struct flowi *fl) struct flowi *fl)
...@@ -741,8 +749,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk, ...@@ -741,8 +749,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
* that we do not support routing by source, TOS, * that we do not support routing by source, TOS,
* and MSG_DONTROUTE --ANK (980726) * and MSG_DONTROUTE --ANK (980726)
* *
* 1. If route was host route, check that * 1. ip6_rt_check(): If route was host route,
* cached destination is current. * check that cached destination is current.
* If it is network route, we still may * If it is network route, we still may
* check its validity using saved pointer * check its validity using saved pointer
* to the last used address: daddr_cache. * to the last used address: daddr_cache.
...@@ -753,11 +761,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk, ...@@ -753,11 +761,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
* sockets. * sockets.
* 2. oif also should be the same. * 2. oif also should be the same.
*/ */
if (((rt->rt6i_dst.plen != 128 || if (ip6_rt_check(&rt->rt6i_dst, &fl->fl6_dst, np->daddr_cache) ||
!ipv6_addr_equal(&fl->fl6_dst, &rt->rt6i_dst.addr)) (fl->oif && fl->oif != dst->dev->ifindex)) {
&& (np->daddr_cache == NULL ||
!ipv6_addr_equal(&fl->fl6_dst, np->daddr_cache)))
|| (fl->oif && fl->oif != dst->dev->ifindex)) {
dst_release(dst); dst_release(dst);
dst = NULL; dst = NULL;
} }
......
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