aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2006-08-23 20:19:18 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 17:55:44 -0400
commitcf6b1982599cbb60f410adeda659b0b29cdf7ad7 (patch)
tree37d6b5ad9cc071a99bf175f707f2a1a969763941
parentaf184765848c280c7e6190f45c827c5ea3881126 (diff)
[IPV6] ROUTE: Introduce a helper to check route validity.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Acked-by: Ville Nuorvala <vnuorval@tcs.hut.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/ip6_output.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 65514f21c186..0a18cb6b1cbb 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -726,6 +726,14 @@ fail:
726 return err; 726 return err;
727} 727}
728 728
729static inline int ip6_rt_check(struct rt6key *rt_key,
730 struct in6_addr *fl_addr,
731 struct in6_addr *addr_cache)
732{
733 return ((rt_key->plen != 128 || !ipv6_addr_equal(fl_addr, &rt_key->addr)) &&
734 (addr_cache == NULL || !ipv6_addr_equal(fl_addr, addr_cache)));
735}
736
729static struct dst_entry *ip6_sk_dst_check(struct sock *sk, 737static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
730 struct dst_entry *dst, 738 struct dst_entry *dst,
731 struct flowi *fl) 739 struct flowi *fl)
@@ -741,8 +749,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
741 * that we do not support routing by source, TOS, 749 * that we do not support routing by source, TOS,
742 * and MSG_DONTROUTE --ANK (980726) 750 * and MSG_DONTROUTE --ANK (980726)
743 * 751 *
744 * 1. If route was host route, check that 752 * 1. ip6_rt_check(): If route was host route,
745 * cached destination is current. 753 * check that cached destination is current.
746 * If it is network route, we still may 754 * If it is network route, we still may
747 * check its validity using saved pointer 755 * check its validity using saved pointer
748 * to the last used address: daddr_cache. 756 * to the last used address: daddr_cache.
@@ -753,11 +761,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
753 * sockets. 761 * sockets.
754 * 2. oif also should be the same. 762 * 2. oif also should be the same.
755 */ 763 */
756 if (((rt->rt6i_dst.plen != 128 || 764 if (ip6_rt_check(&rt->rt6i_dst, &fl->fl6_dst, np->daddr_cache) ||
757 !ipv6_addr_equal(&fl->fl6_dst, &rt->rt6i_dst.addr)) 765 (fl->oif && fl->oif != dst->dev->ifindex)) {
758 && (np->daddr_cache == NULL ||
759 !ipv6_addr_equal(&fl->fl6_dst, np->daddr_cache)))
760 || (fl->oif && fl->oif != dst->dev->ifindex)) {
761 dst_release(dst); 766 dst_release(dst);
762 dst = NULL; 767 dst = NULL;
763 } 768 }