ipv6: add a wrapper for ip6_dst_store() with flowi6 checks
authorAlexey Kodanev <alexey.kodanev@oracle.com>
Tue, 3 Apr 2018 12:00:07 +0000 (15:00 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Apr 2018 15:31:57 +0000 (11:31 -0400)
Move commonly used pattern of ip6_dst_store() usage to a separate
function - ip6_sk_dst_store_flow(), which will check the addresses
for equality using the flow information, before saving them.

There is no functional changes in this patch. In addition, it will
be used in the next patch, in ip6_sk_dst_lookup_flow().

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip6_route.h
net/ipv6/datagram.c
net/ipv6/route.c

index 0084013d6bedb4a7a014b1c5811820d02e79789f..08b132381984f9fe748dd0be066bb897c8536b4d 100644 (file)
@@ -214,6 +214,9 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
 #endif
 }
 
+void ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst,
+                          const struct flowi6 *fl6);
+
 static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
 {
        struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
index 88bc2ef7c7a810b19a2ddb75babe3a37219532b0..a02ad100f0d75b487bf029ea0788033900373557 100644 (file)
@@ -106,14 +106,7 @@ int ip6_datagram_dst_update(struct sock *sk, bool fix_sk_saddr)
                }
        }
 
-       ip6_dst_store(sk, dst,
-                     ipv6_addr_equal(&fl6.daddr, &sk->sk_v6_daddr) ?
-                     &sk->sk_v6_daddr : NULL,
-#ifdef CONFIG_IPV6_SUBTREES
-                     ipv6_addr_equal(&fl6.saddr, &np->saddr) ?
-                     &np->saddr :
-#endif
-                     NULL);
+       ip6_sk_dst_store_flow(sk, dst, &fl6);
 
 out:
        fl6_sock_release(flowlabel);
index f239f91d2efbbff52713c8bb144f854fff33e699..49b954d6d0fa44ea0c4427e2918b3ab9c1610fe0 100644 (file)
@@ -2229,6 +2229,23 @@ void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu)
 }
 EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu);
 
+void ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst,
+                          const struct flowi6 *fl6)
+{
+#ifdef CONFIG_IPV6_SUBTREES
+       struct ipv6_pinfo *np = inet6_sk(sk);
+#endif
+
+       ip6_dst_store(sk, dst,
+                     ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ?
+                     &sk->sk_v6_daddr : NULL,
+#ifdef CONFIG_IPV6_SUBTREES
+                     ipv6_addr_equal(&fl6->saddr, &np->saddr) ?
+                     &np->saddr :
+#endif
+                     NULL);
+}
+
 /* Handle redirects */
 struct ip6rd_flowi {
        struct flowi6 fl6;