@@ -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+
729737static 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