compat: Add a struct net parameter to l4_pkt_to_tuple.
authorJoe Stringer <joe@ovn.org>
Mon, 2 May 2016 18:19:10 +0000 (11:19 -0700)
committerJoe Stringer <joe@ovn.org>
Tue, 3 May 2016 00:06:36 +0000 (17:06 -0700)
Upstream commit:
    netfilter: nf_conntrack: Add a struct net parameter to l4_pkt_to_tuple

    As gre does not have the srckey in the packet gre_pkt_to_tuple
    needs to perform a lookup in it's per network namespace tables.

    Pass in the proper network namespace to all pkt_to_tuple
    implementations to ensure gre (and any similar protocols) can get this
    right.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Upstream: a31f1adc0948 ("netfilter: nf_conntrack: Add a struct net
parameter to l4_pkt_to_tuple")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
acinclude.m4
datapath/conntrack.c
datapath/linux/Modules.mk
datapath/linux/compat/include/net/netfilter/nf_conntrack.h [new file with mode: 0644]

index acd7ce7..3982056 100644 (file)
@@ -426,6 +426,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
                   [tmpl_alloc.*conntrack_zone],
                   [OVS_DEFINE([HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE])])
+  OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
+                  [l3num.*struct.net],
+                  [OVS_DEFINE([HAVE_NF_CT_GET_TUPLEPR_TAKES_STRUCT_NET])])
   OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h],
                   [nf_ct_zone_init])
   OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_labels.h],
index 0338f9f..c365e2e 100644 (file)
@@ -373,7 +373,7 @@ ovs_ct_expect_find(struct net *net, const struct nf_conntrack_zone *zone,
 {
        struct nf_conntrack_tuple tuple;
 
-       if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), proto, &tuple))
+       if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), proto, net, &tuple))
                return NULL;
        return __nf_ct_expect_find(net, zone, &tuple);
 }
index 6ab52a7..7e334cb 100644 (file)
@@ -99,6 +99,7 @@ openvswitch_headers += \
        linux/compat/include/net/stt.h \
        linux/compat/include/net/vrf.h \
        linux/compat/include/net/vxlan.h \
+       linux/compat/include/net/netfilter/nf_conntrack.h \
        linux/compat/include/net/netfilter/nf_conntrack_core.h \
        linux/compat/include/net/netfilter/nf_conntrack_expect.h \
        linux/compat/include/net/netfilter/nf_conntrack_labels.h \
diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack.h
new file mode 100644 (file)
index 0000000..e02e20b
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _NF_CONNTRACK_WRAPPER_H
+#define _NF_CONNTRACK_WRAPPER_H
+
+#include_next <net/netfilter/nf_conntrack.h>
+
+#ifndef HAVE_NF_CT_GET_TUPLEPR_TAKES_STRUCT_NET
+static inline bool rpl_nf_ct_get_tuplepr(const struct sk_buff *skb,
+                                        unsigned int nhoff,
+                                        u_int16_t l3num, struct net *net,
+                                        struct nf_conntrack_tuple *tuple)
+{
+       return nf_ct_get_tuplepr(skb, nhoff, l3num, tuple);
+}
+#define nf_ct_get_tuplepr rpl_nf_ct_get_tuplepr
+#endif
+
+#endif /* _NF_CONNTRACK_WRAPPER_H */