Skip to content

Commit cf6b198

Browse files
yoshfujiDavid S. Miller
authored andcommitted
[IPV6] ROUTE: Introduce a helper to check route validity.
Signed-off-by: YOSHIFUJI Hideaki <[email protected]> Acked-by: Ville Nuorvala <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent af18476 commit cf6b198

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

net/ipv6/ip6_output.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,14 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
726726
return err;
727727
}
728728

729+
static 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+
729737
static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
730738
struct dst_entry *dst,
731739
struct flowi *fl)
@@ -741,8 +749,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
741749
* that we do not support routing by source, TOS,
742750
* and MSG_DONTROUTE --ANK (980726)
743751
*
744-
* 1. If route was host route, check that
745-
* cached destination is current.
752+
* 1. ip6_rt_check(): If route was host route,
753+
* check that cached destination is current.
746754
* If it is network route, we still may
747755
* check its validity using saved pointer
748756
* to the last used address: daddr_cache.
@@ -753,11 +761,8 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
753761
* sockets.
754762
* 2. oif also should be the same.
755763
*/
756-
if (((rt->rt6i_dst.plen != 128 ||
757-
!ipv6_addr_equal(&fl->fl6_dst, &rt->rt6i_dst.addr))
758-
&& (np->daddr_cache == NULL ||
759-
!ipv6_addr_equal(&fl->fl6_dst, np->daddr_cache)))
760-
|| (fl->oif && fl->oif != dst->dev->ifindex)) {
764+
if (ip6_rt_check(&rt->rt6i_dst, &fl->fl6_dst, np->daddr_cache) ||
765+
(fl->oif && fl->oif != dst->dev->ifindex)) {
761766
dst_release(dst);
762767
dst = NULL;
763768
}

0 commit comments

Comments
 (0)