[ovs-dev] [PATCH 2/4] compat: ipv4: Pass struct net through ip_fragment.

Joe Stringer joe at ovn.org
Thu Jun 23 01:00:42 UTC 2016


From: "Eric W. Biederman" <ebiederm at xmission.com>

Upstream commit:
    ipv4: Pass struct net through ip_fragment

    Signed-off-by: "Eric W. Biederman" <ebiederm at xmission.com>

Upstream: 694869b3c544 ("ipv4: Pass struct net through ip_fragment")
Signed-off-by: Joe Stringer <joe at ovn.org>
---
 acinclude.m4                           |  3 ++-
 datapath/actions.c                     |  2 +-
 datapath/linux/compat/include/net/ip.h | 19 +++++++++++++++----
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 52d0209ab88a..8760948fcf9b 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -408,7 +408,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                   [OVS_DEFINE([HAVE_INET_GET_LOCAL_PORT_RANGE_USING_NET])])
   OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_defrag.*net],
                   [OVS_DEFINE([HAVE_IP_DEFRAG_TAKES_NET])])
-  OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_do_fragment])
+  OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_do_fragment.*net],
+                  [OVS_DEFINE([HAVE_IP_DO_FRAGMENT_USING_NET])])
   OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_skb_dst_mtu])
 
   OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [IPSKB_FRAG_PMTU],
diff --git a/datapath/actions.c b/datapath/actions.c
index 7f439f471104..b398f73aabca 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -702,7 +702,7 @@ static void ovs_fragment(struct net *net, struct vport *vport,
 		skb_dst_set_noref(skb, &ovs_dst);
 		IPCB(skb)->frag_max_size = mru;
 
-		ip_do_fragment(skb->sk, skb, ovs_vport_output);
+		ip_do_fragment(net, skb->sk, skb, ovs_vport_output);
 		refdst_drop(orig_dst);
 	} else if (ethertype == htons(ETH_P_IPV6)) {
 		const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops();
diff --git a/datapath/linux/compat/include/net/ip.h b/datapath/linux/compat/include/net/ip.h
index c283ad0a76d2..29a4d43a1151 100644
--- a/datapath/linux/compat/include/net/ip.h
+++ b/datapath/linux/compat/include/net/ip.h
@@ -81,8 +81,9 @@ static inline bool ip_defrag_user_in_between(u32 user,
 }
 #endif /* < v4.2 */
 
-#ifndef HAVE_IP_DO_FRAGMENT
-static inline int rpl_ip_do_fragment(struct sock *sk, struct sk_buff *skb,
+#ifndef HAVE_IP_DO_FRAGMENT_USING_NET
+static inline int rpl_ip_do_fragment(struct net *net, struct sock *sk,
+				     struct sk_buff *skb,
 				     int (*output)(OVS_VPORT_OUTPUT_PARAMS))
 {
 	unsigned int mtu = ip_skb_dst_mtu(skb);
@@ -95,7 +96,7 @@ static inline int rpl_ip_do_fragment(struct sock *sk, struct sk_buff *skb,
 		      IPCB(skb)->frag_max_size > mtu))) {
 
 		pr_warn("Dropping packet in ip_do_fragment()\n");
-		IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
+		IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
 		kfree_skb(skb);
 		return -EMSGSIZE;
 	}
@@ -107,7 +108,7 @@ static inline int rpl_ip_do_fragment(struct sock *sk, struct sk_buff *skb,
 #endif
 }
 #define ip_do_fragment rpl_ip_do_fragment
-#endif /* IP_DO_FRAGMENT */
+#endif /* IP_DO_FRAGMENT_USING_NET */
 
 /* If backporting IP defrag, then init/exit functions need to be called from
  * compat_{in,ex}it() to prepare the backported fragmentation cache. In this
@@ -120,6 +121,16 @@ void rpl_ipfrag_fini(void);
 
 #else /* HAVE_CORRECT_MRU_HANDLING */
 
+#ifndef HAVE_IP_DO_FRAGMENT_USING_NET
+static inline int rpl_ip_do_fragment(struct net *net, struct sock *sk,
+				     struct sk_buff *skb,
+				     int (*output)(OVS_VPORT_OUTPUT_PARAMS))
+{
+	return ip_do_fragment(sk, skb, output);
+}
+#define ip_do_fragment rpl_ip_do_fragment
+#endif
+
 /* We have no good way to detect the presence of upstream commit 8282f27449bf
  * ("inet: frag: Always orphan skbs inside ip_defrag()"), but it should be
  * always included in kernels 4.5+. */
-- 
2.8.2




More information about the dev mailing list