diff mbox

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

Message ID 1466643644-18600-3-git-send-email-joe@ovn.org
State Accepted
Headers show

Commit Message

Joe Stringer June 23, 2016, 1 a.m. UTC
From: "Eric W. Biederman" <ebiederm@xmission.com>

Upstream commit:
    ipv4: Pass struct net through ip_fragment

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

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

Comments

Jesse Gross June 24, 2016, 9 p.m. UTC | #1
On Wed, Jun 22, 2016 at 6:00 PM, Joe Stringer <joe@ovn.org> wrote:
> 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])])

This might be a good use for Jarno's newly introduced
OVS_FIND_PARAM_IFELSE macro.
Joe Stringer June 24, 2016, 9:27 p.m. UTC | #2
On 24 June 2016 at 14:00, Jesse Gross <jesse@kernel.org> wrote:
> On Wed, Jun 22, 2016 at 6:00 PM, Joe Stringer <joe@ovn.org> wrote:
>> 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])])
>
> This might be a good use for Jarno's newly introduced
> OVS_FIND_PARAM_IFELSE macro.

True, I can update this.
diff mbox

Patch

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+. */