[ovs-dev,branch-2.7,14/25] datapath: add and use nf_ct_set helper

Submitted by Jarno Rajahalme on March 15, 2017, 11:31 p.m.

Details

Message ID 1489620689-122370-15-git-send-email-jarno@ovn.org
State Superseded
Headers show

Commit Message

Jarno Rajahalme March 15, 2017, 11:31 p.m.
From: Florian Westphal <fw@strlen.de>

Upstream commit:

    commit c74454fadd5ea6fc866ffe2c417a0dba56b2bf1c
    Author: Florian Westphal <fw@strlen.de>
    Date:   Mon Jan 23 18:21:57 2017 +0100

    netfilter: add and use nf_ct_set helper

    Add a helper to assign a nf_conn entry and the ctinfo bits to an sk_buff.
    This avoids changing code in followup patch that merges skb->nfct and
    skb->nfctinfo into skb->_nfct.

    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
---
 acinclude.m4                                               | 2 ++
 datapath/conntrack.c                                       | 6 ++----
 datapath/linux/compat/include/net/netfilter/nf_conntrack.h | 8 ++++++++
 3 files changed, 12 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/acinclude.m4 b/acinclude.m4
index ea5dfe9..751dc63 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -531,6 +531,8 @@  AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
                   [nf_ct_get_tuplepr], [struct.net],
                   [OVS_DEFINE([HAVE_NF_CT_GET_TUPLEPR_TAKES_STRUCT_NET])])
+  OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
+                  [nf_ct_set])
   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],
diff --git a/datapath/conntrack.c b/datapath/conntrack.c
index ec354c3..6b8414c 100644
--- a/datapath/conntrack.c
+++ b/datapath/conntrack.c
@@ -501,8 +501,7 @@  ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone,
 
 	ct = nf_ct_tuplehash_to_ctrack(h);
 
-	skb->nfct = &ct->ct_general;
-	skb->nfctinfo = ovs_ct_get_info(h);
+	nf_ct_set(skb, ct, ovs_ct_get_info(h));
 	return ct;
 }
 
@@ -766,8 +765,7 @@  static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 			if (skb_nfct(skb))
 				nf_conntrack_put(skb_nfct(skb));
 			nf_conntrack_get(&tmpl->ct_general);
-			skb->nfct = &tmpl->ct_general;
-			skb->nfctinfo = IP_CT_NEW;
+			nf_ct_set(skb, tmpl, IP_CT_NEW);
 		}
 
 		err = nf_conntrack_in(net, info->family,
diff --git a/datapath/linux/compat/include/net/netfilter/nf_conntrack.h b/datapath/linux/compat/include/net/netfilter/nf_conntrack.h
index e02e20b..bb40b0f 100644
--- a/datapath/linux/compat/include/net/netfilter/nf_conntrack.h
+++ b/datapath/linux/compat/include/net/netfilter/nf_conntrack.h
@@ -14,4 +14,12 @@  static inline bool rpl_nf_ct_get_tuplepr(const struct sk_buff *skb,
 #define nf_ct_get_tuplepr rpl_nf_ct_get_tuplepr
 #endif
 
+#ifndef HAVE_NF_CT_SET
+static inline void
+nf_ct_set(struct sk_buff *skb, struct nf_conn *ct, enum ip_conntrack_info info)
+{
+       skb->nfct = &ct->ct_general;
+       skb->nfctinfo = info;
+}
+#endif
 #endif /* _NF_CONNTRACK_WRAPPER_H */