netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH net-next v2 0/8] openvswitch: NAT support.
@ 2015-11-07  0:06 Jarno Rajahalme
  2015-11-07  0:06 ` [RFC PATCH net-next v2 1/8] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netfilter-devel-u79uwXL29TY76Z2rM5mHXA

This series adds NAT support to openvswitch kernel module.  A few
changes are needed to the netfilter code to facilitate this (patches
1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
patch 8 that adds the NAT support for calling into netfilter NAT code
from the openvswitch conntrack action.

Jarno Rajahalme (8):
  netfilter: Remove IP_CT_NEW_REPLY definition.
  netfilter: Factor out nf_ct_get_info().
  netfilter: Allow calling into nat helper without skb_dst.
  openvswitch: Update the CT state key only after nf_conntrack_in().
  openvswitch: Find existing conntrack entry after upcall.
  openvswitch: Handle NF_REPEAT in conntrack action.
  openvswitch: Delay conntrack helper call for new connections.
  openvswitch: Interface with NAT.

 include/net/netfilter/nf_conntrack.h               |  15 +
 include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
 include/uapi/linux/openvswitch.h                   |  47 ++
 net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
 net/netfilter/nf_conntrack_core.c                  |  22 +-
 net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
 net/openvswitch/conntrack.h                        |   3 +-
 8 files changed, 686 insertions(+), 103 deletions(-)

-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 1/8] netfilter: Remove IP_CT_NEW_REPLY definition.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
@ 2015-11-07  0:06 ` Jarno Rajahalme
  2015-11-07  0:06 ` [RFC PATCH net-next v2 2/8] netfilter: Factor out nf_ct_get_info() Jarno Rajahalme
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

Remove the definition of IP_CT_NEW_REPLY from the kernel as it does
not make sense.  This allows the definition of IP_CT_NUMBER to be
simplified as well.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 include/uapi/linux/netfilter/nf_conntrack_common.h | 12 +++++++++---
 net/openvswitch/conntrack.c                        |  2 --
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/netfilter/nf_conntrack_common.h b/include/uapi/linux/netfilter/nf_conntrack_common.h
index 319f471..2f067cf 100644
--- a/include/uapi/linux/netfilter/nf_conntrack_common.h
+++ b/include/uapi/linux/netfilter/nf_conntrack_common.h
@@ -20,9 +20,15 @@ enum ip_conntrack_info {
 
 	IP_CT_ESTABLISHED_REPLY = IP_CT_ESTABLISHED + IP_CT_IS_REPLY,
 	IP_CT_RELATED_REPLY = IP_CT_RELATED + IP_CT_IS_REPLY,
-	IP_CT_NEW_REPLY = IP_CT_NEW + IP_CT_IS_REPLY,	
-	/* Number of distinct IP_CT types (no NEW in reply dirn). */
-	IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
+	/* No NEW in reply direction. */
+
+	/* Number of distinct IP_CT types. */
+	IP_CT_NUMBER
+
+	/* only for userspace compatibility */
+#ifndef __KERNEL__
+	IP_CT_NEW_REPLY = IP_CT_NUMBER;
+#endif
 };
 
 #define NF_CT_STATE_INVALID_BIT			(1 << 0)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index c2cc111..a28a819 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -73,7 +73,6 @@ static u8 ovs_ct_get_state(enum ip_conntrack_info ctinfo)
 	switch (ctinfo) {
 	case IP_CT_ESTABLISHED_REPLY:
 	case IP_CT_RELATED_REPLY:
-	case IP_CT_NEW_REPLY:
 		ct_state |= OVS_CS_F_REPLY_DIR;
 		break;
 	default:
@@ -90,7 +89,6 @@ static u8 ovs_ct_get_state(enum ip_conntrack_info ctinfo)
 		ct_state |= OVS_CS_F_RELATED;
 		break;
 	case IP_CT_NEW:
-	case IP_CT_NEW_REPLY:
 		ct_state |= OVS_CS_F_NEW;
 		break;
 	default:
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 2/8] netfilter: Factor out nf_ct_get_info().
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
  2015-11-07  0:06 ` [RFC PATCH net-next v2 1/8] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
@ 2015-11-07  0:06 ` Jarno Rajahalme
       [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

Define a new inline function to map conntrack status to enum
ip_conntrack_info.  This removes the need to otherwise duplicate this
code in a later patch ("openvswitch: Find existing conntrack entry
after upcall.").

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 include/net/netfilter/nf_conntrack.h | 15 +++++++++++++++
 net/netfilter/nf_conntrack_core.c    | 22 +++-------------------
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index fde4068..b3de10e 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -125,6 +125,21 @@ nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
 			    tuplehash[hash->tuple.dst.dir]);
 }
 
+static inline enum ip_conntrack_info
+nf_ct_get_info(const struct nf_conntrack_tuple_hash *h)
+{
+	const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
+
+	if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
+		return IP_CT_ESTABLISHED_REPLY;
+	/* Once we've had two way comms, always ESTABLISHED. */
+	if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status))
+		return IP_CT_ESTABLISHED;
+	if (test_bit(IPS_EXPECTED_BIT, &ct->status))
+		return IP_CT_RELATED;
+	return IP_CT_NEW;
+}
+
 static inline u_int16_t nf_ct_l3num(const struct nf_conn *ct)
 {
 	return ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3cb3cb8..70ddbd8 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1056,25 +1056,9 @@ resolve_normal_ct(struct net *net, struct nf_conn *tmpl,
 	ct = nf_ct_tuplehash_to_ctrack(h);
 
 	/* It exists; we have (non-exclusive) reference. */
-	if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) {
-		*ctinfo = IP_CT_ESTABLISHED_REPLY;
-		/* Please set reply bit if this packet OK */
-		*set_reply = 1;
-	} else {
-		/* Once we've had two way comms, always ESTABLISHED. */
-		if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
-			pr_debug("nf_conntrack_in: normal packet for %p\n", ct);
-			*ctinfo = IP_CT_ESTABLISHED;
-		} else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
-			pr_debug("nf_conntrack_in: related packet for %p\n",
-				 ct);
-			*ctinfo = IP_CT_RELATED;
-		} else {
-			pr_debug("nf_conntrack_in: new packet for %p\n", ct);
-			*ctinfo = IP_CT_NEW;
-		}
-		*set_reply = 0;
-	}
+	*ctinfo = nf_ct_get_info(h);
+	*set_reply = NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY;
+
 	skb->nfct = &ct->ct_general;
 	skb->nfctinfo = *ctinfo;
 	return ct;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 3/8] netfilter: Allow calling into nat helper without skb_dst.
       [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
@ 2015-11-07  0:06   ` Jarno Rajahalme
  2015-11-07  0:06   ` [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in() Jarno Rajahalme
  1 sibling, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netfilter-devel-u79uwXL29TY76Z2rM5mHXA

NAT checksum recalculation code assumes existence of skb_dst, which
becomes a problem for a later patch in the series ("openvswitch:
Interface with NAT.").  Simplify this by removing the check on
skb_dst, as the checksum will be dealt with later in the stack.

Suggested-by: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 net/ipv4/netfilter/nf_nat_l3proto_ipv4.c | 29 ++++++++---------------------
 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 29 ++++++++---------------------
 2 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c b/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
index 5075b7e..f8aad03 100644
--- a/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
@@ -127,28 +127,15 @@ static void nf_nat_ipv4_csum_recalc(struct sk_buff *skb,
 				    u8 proto, void *data, __sum16 *check,
 				    int datalen, int oldlen)
 {
-	const struct iphdr *iph = ip_hdr(skb);
-	struct rtable *rt = skb_rtable(skb);
-
 	if (skb->ip_summed != CHECKSUM_PARTIAL) {
-		if (!(rt->rt_flags & RTCF_LOCAL) &&
-		    (!skb->dev || skb->dev->features & NETIF_F_V4_CSUM)) {
-			skb->ip_summed = CHECKSUM_PARTIAL;
-			skb->csum_start = skb_headroom(skb) +
-					  skb_network_offset(skb) +
-					  ip_hdrlen(skb);
-			skb->csum_offset = (void *)check - data;
-			*check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
-						    datalen, proto, 0);
-		} else {
-			*check = 0;
-			*check = csum_tcpudp_magic(iph->saddr, iph->daddr,
-						   datalen, proto,
-						   csum_partial(data, datalen,
-								0));
-			if (proto == IPPROTO_UDP && !*check)
-				*check = CSUM_MANGLED_0;
-		}
+		const struct iphdr *iph = ip_hdr(skb);
+
+		skb->ip_summed = CHECKSUM_PARTIAL;
+		skb->csum_start = skb_headroom(skb) + skb_network_offset(skb) +
+			ip_hdrlen(skb);
+		skb->csum_offset = (void *)check - data;
+		*check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, datalen,
+					    proto, 0);
 	} else
 		inet_proto_csum_replace2(check, skb,
 					 htons(oldlen), htons(datalen), true);
diff --git a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
index 238e70c..e0be97e 100644
--- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
@@ -131,28 +131,15 @@ static void nf_nat_ipv6_csum_recalc(struct sk_buff *skb,
 				    u8 proto, void *data, __sum16 *check,
 				    int datalen, int oldlen)
 {
-	const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
-	struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
-
 	if (skb->ip_summed != CHECKSUM_PARTIAL) {
-		if (!(rt->rt6i_flags & RTF_LOCAL) &&
-		    (!skb->dev || skb->dev->features & NETIF_F_V6_CSUM)) {
-			skb->ip_summed = CHECKSUM_PARTIAL;
-			skb->csum_start = skb_headroom(skb) +
-					  skb_network_offset(skb) +
-					  (data - (void *)skb->data);
-			skb->csum_offset = (void *)check - data;
-			*check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr,
-						  datalen, proto, 0);
-		} else {
-			*check = 0;
-			*check = csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr,
-						 datalen, proto,
-						 csum_partial(data, datalen,
-							      0));
-			if (proto == IPPROTO_UDP && !*check)
-				*check = CSUM_MANGLED_0;
-		}
+		const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+
+		skb->ip_summed = CHECKSUM_PARTIAL;
+		skb->csum_start = skb_headroom(skb) + skb_network_offset(skb) +
+			(data - (void *)skb->data);
+		skb->csum_offset = (void *)check - data;
+		*check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr,
+					  datalen, proto, 0);
 	} else
 		inet_proto_csum_replace2(check, skb,
 					 htons(oldlen), htons(datalen), true);
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in().
       [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
  2015-11-07  0:06   ` [RFC PATCH net-next v2 3/8] netfilter: Allow calling into nat helper without skb_dst Jarno Rajahalme
@ 2015-11-07  0:06   ` Jarno Rajahalme
  1 sibling, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netfilter-devel-u79uwXL29TY76Z2rM5mHXA

Only a successful nf_conntrack_in() call can effect a connection state
change, so if suffices to update the key only after the
nf_conntrack_in() returns.

This change is needed for the later NAT patches.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 net/openvswitch/conntrack.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index a28a819..10f4a6e 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -194,7 +194,6 @@ static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key,
 	struct nf_conn *ct;
 	u32 new_mark;
 
-
 	/* The connection could be invalid, in which case set_mark is no-op. */
 	ct = nf_ct_get(skb, &ctinfo);
 	if (!ct)
@@ -385,6 +384,10 @@ static bool skb_nfct_cached(const struct net *net, const struct sk_buff *skb,
 	return true;
 }
 
+/* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
+ * not done already.  Update key with new CT state after passing the packet
+ * through conntrack.
+ */
 static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 			   const struct ovs_conntrack_info *info,
 			   struct sk_buff *skb)
@@ -410,14 +413,14 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 				    skb) != NF_ACCEPT)
 			return -ENOENT;
 
+		ovs_ct_update_key(skb, key, true);
+
 		if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
 			WARN_ONCE(1, "helper rejected packet");
 			return -EINVAL;
 		}
 	}
 
-	ovs_ct_update_key(skb, key, true);
-
 	return 0;
 }
 
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 5/8] openvswitch: Find existing conntrack entry after upcall.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
                   ` (2 preceding siblings ...)
       [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
@ 2015-11-07  0:06 ` Jarno Rajahalme
  2015-11-07  0:06 ` [RFC PATCH net-next v2 6/8] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

Add a new function ovs_ct_find_existing() to find an existing
conntrack entry for which this packet was already applied to.  This is
only to be called when there is evidence that the packet was already
tracked and committed, but we lost the ct reference due to an
userspace upcall.

ovs_ct_find_existing() is called from skb_nfct_cached(), which can now
hide the fact that the ct reference may have been lost due to an
upcall.  This allows ovs_ct_commit() to be simplified.

This patch is needed by later "openvswitch: Interface with NAT" patch,
as we need to be able to pass the packet through NAT using the
original ct reference also after the reference is lost after an
upcall.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 net/openvswitch/conntrack.c | 95 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 82 insertions(+), 13 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 10f4a6e..0c371d0 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -359,16 +359,87 @@ ovs_ct_expect_find(struct net *net, const struct nf_conntrack_zone *zone,
 	return __nf_ct_expect_find(net, zone, &tuple);
 }
 
+/* Find an existing conntrack entry for which this packet was already applied
+ * to.  This is only called when there is evidence that the packet was already
+ * tracked and commited, but we lost the ct reference due to an userspace
+ * upcall. This means that on entry skb->nfct is NULL.
+ * On success, returns conntrack ptr, sets skb->nfct and ctinfo.
+ * Must be called rcu_read_lock()ed. */
+static struct nf_conn *
+ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone,
+		     u_int8_t l3num, struct sk_buff *skb,
+		     enum ip_conntrack_info *ctinfo)
+{
+	struct nf_conntrack_l3proto *l3proto;
+	struct nf_conntrack_l4proto *l4proto;
+	struct nf_conntrack_tuple tuple;
+	struct nf_conntrack_tuple_hash *h;
+	struct nf_conn *ct;
+	unsigned int dataoff;
+	u_int8_t protonum;
+
+	BUG_ON(skb->nfct != NULL);
+
+	l3proto = __nf_ct_l3proto_find(l3num);
+	if (!l3proto) {
+		pr_debug("ovs_ct_find_existing: Can't get l3proto\n");
+		return NULL;
+	}
+	if (l3proto->get_l4proto(skb, skb_network_offset(skb), &dataoff,
+				 &protonum) <= 0) {
+		pr_debug("ovs_ct_find_existing: Can't get protonum\n");
+		return NULL;
+	}
+	l4proto = __nf_ct_l4proto_find(l3num, protonum);
+	if (!l4proto) {
+		pr_debug("ovs_ct_find_existing: Can't get l4proto\n");
+		return NULL;
+	}
+	if (!nf_ct_get_tuple(skb, skb_network_offset(skb), dataoff, l3num,
+			     protonum, net, &tuple, l3proto, l4proto)) {
+		pr_debug("ovs_ct_find_existing: Can't get tuple\n");
+		return NULL;
+	}
+
+	/* look for tuple match */
+	h = nf_conntrack_find_get(net, zone, &tuple);
+	if (!h)
+		return NULL;   /* Not found. */
+
+	ct = nf_ct_tuplehash_to_ctrack(h);
+
+	*ctinfo = nf_ct_get_info(h);
+	if (*ctinfo == IP_CT_NEW) {
+		/* This should not happen. */
+		WARN_ONCE(1, "ovs_ct_find_existing: new packet for %p\n", ct);
+	}
+	skb->nfct = &ct->ct_general;
+	skb->nfctinfo = *ctinfo;
+	return ct;
+}
+
 /* Determine whether skb->nfct is equal to the result of conntrack lookup. */
-static bool skb_nfct_cached(const struct net *net, const struct sk_buff *skb,
-			    const struct ovs_conntrack_info *info)
+static bool skb_nfct_cached(struct net *net,
+			    const struct sw_flow_key *key,
+			    const struct ovs_conntrack_info *info,
+			    struct sk_buff *skb)
 {
 	enum ip_conntrack_info ctinfo;
 	struct nf_conn *ct;
 
 	ct = nf_ct_get(skb, &ctinfo);
+	/* If no ct, check if we have evidence that an existing conntrack entry
+	 * might be found for this skb.  This happens when we lose a skb->nfct
+	 * due to an upcall.  If the connection was not confirmed, it is not
+	 * cached and needs to be run through conntrack again. */
+	if (!ct && key->ct.state & OVS_CS_F_TRACKED
+	    && !(key->ct.state & OVS_CS_F_INVALID)
+	    && key->ct.zone == info->zone.id)
+		ct = ovs_ct_find_existing(net, &info->zone, info->family, skb,
+					  &ctinfo);
 	if (!ct)
 		return false;
+
 	if (!net_eq(net, read_pnet(&ct->ct_net)))
 		return false;
 	if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct)))
@@ -397,7 +468,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 	 * actually run the packet through conntrack twice unless it's for a
 	 * different zone.
 	 */
-	if (!skb_nfct_cached(net, skb, info)) {
+	if (!skb_nfct_cached(net, key, info, skb)) {
 		struct nf_conn *tmpl = info->ct;
 
 		/* Associate skb with specified zone. */
@@ -431,6 +502,13 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 {
 	struct nf_conntrack_expect *exp;
 
+	/* If we pass an expected packet through nf_conntrack_in() the
+	 * expectiation will be removed, but the packet could still be lost in
+	 * upcall processing.  To prevent this from happening we perform an
+	 * explicit expectation lookup.  Expected connections are always new,
+	 * and will be passed through conntrack only when they are committed,
+	 * as it is OK to remove the expectation at that time.
+	 */
 	exp = ovs_ct_expect_find(net, &info->zone, info->family, skb);
 	if (exp) {
 		u8 state;
@@ -453,21 +531,12 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,
 			 const struct ovs_conntrack_info *info,
 			 struct sk_buff *skb)
 {
-	u8 state;
 	int err;
 
-	state = key->ct.state;
-	if (key->ct.zone == info->zone.id &&
-	    ((state & OVS_CS_F_TRACKED) && !(state & OVS_CS_F_NEW))) {
-		/* Previous lookup has shown that this connection is already
-		 * tracked and committed. Skip committing.
-		 */
-		return 0;
-	}
-
 	err = __ovs_ct_lookup(net, key, info, skb);
 	if (err)
 		return err;
+	/* This is a no-op if the connection has already been confirmed. */
 	if (nf_conntrack_confirm(skb) != NF_ACCEPT)
 		return -EINVAL;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 6/8] openvswitch: Handle NF_REPEAT in conntrack action.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
                   ` (3 preceding siblings ...)
  2015-11-07  0:06 ` [RFC PATCH net-next v2 5/8] openvswitch: Find existing conntrack entry after upcall Jarno Rajahalme
@ 2015-11-07  0:06 ` Jarno Rajahalme
  2015-11-07  0:06 ` [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

Repeat the nf_conntrack_in() call when it returns NF_REPEAT.  This
avoids dropping a SYN packet re-opening an existing TCP connection.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 net/openvswitch/conntrack.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 0c371d0..7aa38fa 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -470,6 +470,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 	 */
 	if (!skb_nfct_cached(net, key, info, skb)) {
 		struct nf_conn *tmpl = info->ct;
+		int err;
 
 		/* Associate skb with specified zone. */
 		if (tmpl) {
@@ -480,8 +481,13 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 			skb->nfctinfo = IP_CT_NEW;
 		}
 
-		if (nf_conntrack_in(net, info->family, NF_INET_PRE_ROUTING,
-				    skb) != NF_ACCEPT)
+		/* Repeat if requested, see nf_iterate(). */
+		do {
+			err = nf_conntrack_in(net, info->family,
+					      NF_INET_PRE_ROUTING, skb);
+		} while (err == NF_REPEAT);
+
+		if (err != NF_ACCEPT)
 			return -ENOENT;
 
 		ovs_ct_update_key(skb, key, true);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
                   ` (4 preceding siblings ...)
  2015-11-07  0:06 ` [RFC PATCH net-next v2 6/8] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
@ 2015-11-07  0:06 ` Jarno Rajahalme
       [not found]   ` <1446854768-38299-8-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
  2015-11-07  0:06 ` [RFC PATCH net-next v2 8/8] openvswitch: Interface with NAT Jarno Rajahalme
  2015-11-09 13:31 ` [RFC PATCH net-next v2 0/8] openvswitch: NAT support Patrick McHardy
  7 siblings, 1 reply; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

There is no need to help connections that are not confirmed, so we can
delay helping new connections to the time when they are confirmed.
This change is needed for NAT support, and having this as a separate
patch will make the following NAT patch a bit easier to review.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 net/openvswitch/conntrack.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 7aa38fa..ba44287 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -458,6 +458,7 @@ static bool skb_nfct_cached(struct net *net,
 /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
  * not done already.  Update key with new CT state after passing the packet
  * through conntrack.
+ * Note that invalid packets are accepted while the skb->nfct remains unset!
  */
 static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 			   const struct ovs_conntrack_info *info,
@@ -468,7 +469,11 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 	 * actually run the packet through conntrack twice unless it's for a
 	 * different zone.
 	 */
-	if (!skb_nfct_cached(net, key, info, skb)) {
+	bool cached = skb_nfct_cached(net, key, info, skb);
+	enum ip_conntrack_info ctinfo;
+	struct nf_conn *ct;
+
+	if (!cached) {
 		struct nf_conn *tmpl = info->ct;
 		int err;
 
@@ -491,11 +496,16 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 			return -ENOENT;
 
 		ovs_ct_update_key(skb, key, true);
+	}
 
-		if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
-			WARN_ONCE(1, "helper rejected packet");
-			return -EINVAL;
-		}
+	/* Call the helper right after nf_conntrack_in() for confirmed
+	 * connections, but only when commiting for unconfirmed connections.
+	 */
+	ct = nf_ct_get(skb, &ctinfo);
+	if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit)
+	    && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
+		WARN_ONCE(1, "helper rejected packet");
+		return -EINVAL;
 	}
 
 	return 0;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH net-next v2 8/8] openvswitch: Interface with NAT.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
                   ` (5 preceding siblings ...)
  2015-11-07  0:06 ` [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
@ 2015-11-07  0:06 ` Jarno Rajahalme
  2015-11-09 13:31 ` [RFC PATCH net-next v2 0/8] openvswitch: NAT support Patrick McHardy
  7 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-07  0:06 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, dev, jrajahalme

Extend OVS conntrack interface to cover NAT.  New nested
OVS_CT_ATTR_NAT attribute may be used to include NAT with a CT action.
A bare OVS_CT_ATTR_NAT only mangles existing and expected connections.
If OVS_NAT_ATTR_SRC or OVS_NAT_ATTR_DST is included within the nested
attributes, new (non-committed/non-confirmed) connections are mangled
according to the rest of the nested attributes.

The corresponding OVS userspace patch series includes test cases (in
tests/system-traffic.at) that also serve as example uses.

This work extends on a branch by Thomas Graf at
https://github.com/tgraf/ovs/tree/nat.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
---
 include/uapi/linux/openvswitch.h |  47 ++++
 net/openvswitch/conntrack.c      | 520 +++++++++++++++++++++++++++++++++++++--
 net/openvswitch/conntrack.h      |   3 +-
 3 files changed, 544 insertions(+), 26 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 28ccedd..1a4bbdc 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -454,6 +454,12 @@ struct ovs_key_ct_labels {
 #define OVS_CS_F_REPLY_DIR         0x08 /* Flow is in the reply direction. */
 #define OVS_CS_F_INVALID           0x10 /* Could not track connection. */
 #define OVS_CS_F_TRACKED           0x20 /* Conntrack has occurred. */
+#define OVS_CS_F_SRC_NAT           0x40 /* Packet's source address/port was
+					   mangled by NAT. */
+#define OVS_CS_F_DST_NAT           0x80 /* Packet's destination address/port
+					   was mangled by NAT. */
+
+#define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
 
 /**
  * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
@@ -632,6 +638,8 @@ struct ovs_action_hash {
  * mask. For each bit set in the mask, the corresponding bit in the value is
  * copied to the connection tracking label field in the connection.
  * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
+ * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address
+ * translation (NAT) on the packet.
  */
 enum ovs_ct_attr {
 	OVS_CT_ATTR_UNSPEC,
@@ -641,12 +649,51 @@ enum ovs_ct_attr {
 	OVS_CT_ATTR_LABELS,     /* labels to associate with this connection. */
 	OVS_CT_ATTR_HELPER,     /* netlink helper to assist detection of
 				   related connections. */
+	OVS_CT_ATTR_NAT,        /* Nested OVS_NAT_ATTR_* */
 	__OVS_CT_ATTR_MAX
 };
 
 #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
 
 /**
+ * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT.
+ *
+ * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port).
+ * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination
+ * address/port).  Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be
+ * specified.  Effective only for packets for ct_state NEW connections.
+ * Packets of committed connections are mangled by the NAT action according to
+ * the committed NAT type regardless of the flags specified.  As a corollary, a
+ * NAT action without a NAT type flag will only mangle packets of committed
+ * connections.  The following NAT attributes only apply for NEW
+ * (non-committed) connections, and they may be included only when the CT
+ * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or
+ * @OVS_NAT_ATTR_DST is also included.
+ * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr
+ * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr
+ * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port)
+ * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port)
+ * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots
+ * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5)
+ * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping
+ */
+enum ovs_nat_attr {
+	OVS_NAT_ATTR_UNSPEC,
+	OVS_NAT_ATTR_SRC,
+	OVS_NAT_ATTR_DST,
+	OVS_NAT_ATTR_IP_MIN,
+	OVS_NAT_ATTR_IP_MAX,
+	OVS_NAT_ATTR_PROTO_MIN,
+	OVS_NAT_ATTR_PROTO_MAX,
+	OVS_NAT_ATTR_PERSISTENT,
+	OVS_NAT_ATTR_PROTO_HASH,
+	OVS_NAT_ATTR_PROTO_RANDOM,
+	__OVS_NAT_ATTR_MAX,
+};
+
+#define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
+
+/**
  * enum ovs_action_attr - Action types.
  *
  * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index ba44287..b1f18ae 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -20,6 +20,16 @@
 #include <net/netfilter/nf_conntrack_zones.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 
+#ifdef CONFIG_NF_NAT_NEEDED
+#include <linux/netfilter/nf_nat.h>
+#include <net/netfilter/nf_nat_core.h>
+#include <net/netfilter/nf_nat_l3proto.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+#include <linux/sctp.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#endif
+
 #include "datapath.h"
 #include "conntrack.h"
 #include "flow.h"
@@ -42,15 +52,29 @@ struct md_labels {
 	struct ovs_key_ct_labels mask;
 };
 
+#ifdef CONFIG_NF_NAT_NEEDED
+enum ovs_ct_nat {
+	OVS_CT_NAT = 1 << 0,     /* NAT for committed connections only. */
+	OVS_CT_SRC_NAT = 1 << 1, /* Source NAT for NEW connections. */
+	OVS_CT_DST_NAT = 1 << 2, /* Destination NAT for NEW connections. */
+};
+#endif
+
 /* Conntrack action context for execution. */
 struct ovs_conntrack_info {
 	struct nf_conntrack_helper *helper;
 	struct nf_conntrack_zone zone;
 	struct nf_conn *ct;
 	u8 commit : 1;
+#ifdef CONFIG_NF_NAT_NEEDED
+	u8 nat : 3;                 /* enum ovs_ct_nat */
+#endif
 	u16 family;
 	struct md_mark mark;
 	struct md_labels labels;
+#ifdef CONFIG_NF_NAT_NEEDED
+	struct nf_nat_range range;  /* Only present for SRC NAT and DST NAT. */
+#endif
 };
 
 static u16 key_to_nfproto(const struct sw_flow_key *key)
@@ -135,11 +159,14 @@ static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state,
 	ovs_ct_get_labels(ct, &key->ct.labels);
 }
 
-/* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has
- * previously sent the packet to conntrack via the ct action.
+/* Update 'key' based on skb->nfct.  If 'post_ct' is true, then OVS has
+ * previously sent the packet to conntrack via the ct action.  If
+ * 'keep_nat_flags' is true, the existing NAT flags retained, else they are
+ * initialized from the connection status.
  */
 static void ovs_ct_update_key(const struct sk_buff *skb,
-			      struct sw_flow_key *key, bool post_ct)
+			      struct sw_flow_key *key, bool post_ct,
+			      bool keep_nat_flags)
 {
 	const struct nf_conntrack_zone *zone = &nf_ct_zone_dflt;
 	enum ip_conntrack_info ctinfo;
@@ -149,10 +176,24 @@ static void ovs_ct_update_key(const struct sk_buff *skb,
 	ct = nf_ct_get(skb, &ctinfo);
 	if (ct) {
 		state = ovs_ct_get_state(ctinfo);
+		/* All unconfirmed entries are NEW connections. */
 		if (!nf_ct_is_confirmed(ct))
 			state |= OVS_CS_F_NEW;
+		/* OVS persists the related flag for the duration of the
+		 * connection.
+		 */
 		if (ct->master)
 			state |= OVS_CS_F_RELATED;
+#ifdef CONFIG_NF_NAT_NEEDED
+		if (keep_nat_flags)
+			state |= key->ct.state & OVS_CS_F_NAT_MASK;
+		else {
+			if (ct->status & IPS_SRC_NAT)
+				state |= OVS_CS_F_SRC_NAT;
+			if (ct->status & IPS_DST_NAT)
+				state |= OVS_CS_F_DST_NAT;
+		}
+#endif
 		zone = nf_ct_zone(ct);
 	} else if (post_ct) {
 		state = OVS_CS_F_TRACKED | OVS_CS_F_INVALID;
@@ -160,9 +201,11 @@ static void ovs_ct_update_key(const struct sk_buff *skb,
 	__ovs_ct_update_key(key, state, zone, ct);
 }
 
+/* This is called to initialize CT key fields possibly coming in from the local
+ * stack. */
 void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key)
 {
-	ovs_ct_update_key(skb, key, false);
+	ovs_ct_update_key(skb, key, false, false);
 }
 
 int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb)
@@ -251,6 +294,7 @@ static int ovs_ct_helper(struct sk_buff *skb, u16 proto)
 	enum ip_conntrack_info ctinfo;
 	unsigned int protoff;
 	struct nf_conn *ct;
+	int err;
 
 	ct = nf_ct_get(skb, &ctinfo);
 	if (!ct || ctinfo == IP_CT_RELATED_REPLY)
@@ -287,7 +331,20 @@ static int ovs_ct_helper(struct sk_buff *skb, u16 proto)
 		return NF_DROP;
 	}
 
-	return helper->help(skb, protoff, ct, ctinfo);
+	err = helper->help(skb, protoff, ct, ctinfo);
+	if (err != NF_ACCEPT)
+		return err;
+
+#ifdef CONFIG_NF_NAT_NEEDED
+	/* Adjust seqs after helper.  This is needed due to some helpers (e.g.,
+	 * FTP with NAT) adusting the TCP payload size when mangling IP
+	 * addresses and/or port numbers in the text-based control connection.
+	 */
+	if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)
+	    && !nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
+		return NF_DROP;
+#endif
+	return NF_ACCEPT;
 }
 
 /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero
@@ -455,6 +512,189 @@ static bool skb_nfct_cached(struct net *net,
 	return true;
 }
 
+#ifdef CONFIG_NF_NAT_NEEDED
+/* Modeled after nf_nat_ipv[46]_fn().
+ * range is only used for new, uninitialized NAT state.
+ * Returns either NF_ACCEPT or NF_DROP. */
+static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
+			      enum ip_conntrack_info ctinfo,
+			      const struct nf_nat_range *range,
+			      enum nf_nat_manip_type maniptype)
+{
+	int hooknum, nh_off, err = NF_ACCEPT;
+
+	nh_off = skb_network_offset(skb);
+	skb_pull(skb, nh_off);
+
+	/* See HOOK2MANIP(). */
+	if (maniptype == NF_NAT_MANIP_SRC)
+		hooknum = NF_INET_LOCAL_IN; /* Source NAT */
+	else
+		hooknum = NF_INET_LOCAL_OUT; /* Destination NAT */
+
+	switch (ctinfo) {
+	case IP_CT_RELATED:
+	case IP_CT_RELATED_REPLY:
+		if (skb->protocol == htons(ETH_P_IP)
+		    && ip_hdr(skb)->protocol == IPPROTO_ICMP) {
+			if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo,
+							   hooknum))
+				err = NF_DROP;
+			goto push;
+		} else if (skb->protocol == htons(ETH_P_IPV6)) {
+			__be16 frag_off;
+			u8 nexthdr = ipv6_hdr(skb)->nexthdr;
+			int hdrlen = ipv6_skip_exthdr(skb,
+						      sizeof(struct ipv6hdr),
+						      &nexthdr, &frag_off);
+
+			if (hdrlen >= 0 && nexthdr == IPPROTO_ICMPV6) {
+				if (!nf_nat_icmpv6_reply_translation(skb, ct,
+								     ctinfo,
+								     hooknum,
+								     hdrlen))
+					err = NF_DROP;
+				goto push;
+			}
+		}
+		/* Non-ICMP, fall thru to initialize if needed. */
+	case IP_CT_NEW:
+		/* Seen it before?  This can happen for loopback, retrans,
+		 * or local packets.
+		 */
+		if (!nf_nat_initialized(ct, maniptype)) {
+			/* Initialize according to the NAT action. */
+			err = (range && range->flags & NF_NAT_RANGE_MAP_IPS)
+				/* Action is set up to establish a new
+				 * mapping */
+				? nf_nat_setup_info(ct, range, maniptype)
+				: nf_nat_alloc_null_binding(ct, hooknum);
+			if (err != NF_ACCEPT)
+				goto push;
+		}
+		break;
+
+	case IP_CT_ESTABLISHED:
+	case IP_CT_ESTABLISHED_REPLY:
+		break;
+
+	default:
+		err = NF_DROP;
+		goto push;
+	}
+
+	err = nf_nat_packet(ct, ctinfo, hooknum, skb);
+push:
+	skb_push(skb, nh_off);
+
+	return err;
+}
+
+static void ovs_nat_update_key(struct sw_flow_key *key,
+			       const struct sk_buff *skb,
+			       enum nf_nat_manip_type maniptype)
+{
+	if (maniptype == NF_NAT_MANIP_SRC) {
+		__be16 src;
+
+		key->ct.state |= OVS_CS_F_SRC_NAT;
+		if (key->eth.type == htons(ETH_P_IP))
+			key->ipv4.addr.src = ip_hdr(skb)->saddr;
+		else if (key->eth.type == htons(ETH_P_IPV6))
+			memcpy(&key->ipv6.addr.src, &ipv6_hdr(skb)->saddr,
+			       sizeof(key->ipv6.addr.src));
+		else
+			return;
+
+		if (key->ip.proto == IPPROTO_UDP)
+			src = udp_hdr(skb)->source;
+		else if (key->ip.proto == IPPROTO_TCP)
+			src = tcp_hdr(skb)->source;
+		else if (key->ip.proto == IPPROTO_SCTP)
+			src = sctp_hdr(skb)->source;
+		else
+			return;
+
+		key->tp.src = src;
+	} else {
+		__be16 dst;
+
+		key->ct.state |= OVS_CS_F_DST_NAT;
+		if (key->eth.type == htons(ETH_P_IP))
+			key->ipv4.addr.dst = ip_hdr(skb)->daddr;
+		else if (key->eth.type == htons(ETH_P_IPV6))
+			memcpy(&key->ipv6.addr.dst, &ipv6_hdr(skb)->daddr,
+			       sizeof(key->ipv6.addr.dst));
+		else
+			return;
+
+		if (key->ip.proto == IPPROTO_UDP)
+			dst = udp_hdr(skb)->dest;
+		else if (key->ip.proto == IPPROTO_TCP)
+			dst = tcp_hdr(skb)->dest;
+		else if (key->ip.proto == IPPROTO_SCTP)
+			dst = sctp_hdr(skb)->dest;
+		else
+			return;
+
+		key->tp.dst = dst;
+	}
+}
+
+/* Returns NF_DROP if the packet should be dropped, NF_ACCEPT otherwise. */
+static int ovs_ct_nat(struct net *net, struct sw_flow_key *key,
+		      const struct ovs_conntrack_info *info,
+		      struct sk_buff *skb, struct nf_conn *ct,
+		      enum ip_conntrack_info ctinfo)
+{
+	enum nf_nat_manip_type maniptype;
+	int err;
+
+	if (nf_ct_is_untracked(ct)) {
+		/* A NAT action may only be performed on tracked packets. */
+		return NF_ACCEPT;
+	}
+
+	/* Add NAT extension if not confirmed yet. */
+	if (!nf_ct_is_confirmed(ct) && !nf_ct_nat_ext_add(ct))
+		return NF_ACCEPT;   /* Can't NAT. */
+
+	/* Determine NAT type.
+	 * Check if the NAT type can be deduced from the tracked connection.
+	 * Make sure expected traffic is NATted only when commiting.
+	 */
+	if (info->nat & OVS_CT_NAT && ctinfo != IP_CT_NEW
+	    && ct->status & IPS_NAT_MASK
+	    && (!(ct->status & IPS_EXPECTED_BIT) || info->commit)) {
+		/* NAT an established or related connection like before. */
+		if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY)
+			/* This is the REPLY direction for a connection
+			 * for which NAT was applied in the forward
+			 * direction.  Do the reverse NAT.
+			 */
+			maniptype = ct->status & IPS_SRC_NAT
+				? NF_NAT_MANIP_DST : NF_NAT_MANIP_SRC;
+		else
+			maniptype = ct->status & IPS_SRC_NAT
+				? NF_NAT_MANIP_SRC : NF_NAT_MANIP_DST;
+	}
+	else if (info->nat & OVS_CT_SRC_NAT)
+		maniptype = NF_NAT_MANIP_SRC;
+	else if (info->nat & OVS_CT_DST_NAT)
+		maniptype = NF_NAT_MANIP_DST;
+	else
+		return NF_ACCEPT; /* Connection is not NATed. */
+
+	err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype);
+
+	/* Mark NAT done if successful and update the flow key. */
+	if (err == NF_ACCEPT)
+		ovs_nat_update_key(key, skb, maniptype);
+
+	return err;
+}
+#endif
+
 /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
  * not done already.  Update key with new CT state after passing the packet
  * through conntrack.
@@ -495,17 +735,45 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 		if (err != NF_ACCEPT)
 			return -ENOENT;
 
-		ovs_ct_update_key(skb, key, true);
+		/* Clear CT state NAT flags to mark that we have not yet done
+		 * NAT after the nf_conntrack_in() call.  We can actually clear
+		 * the whole state, as it will be re-initialized below.
+		 */
+		key->ct.state = 0;
+
+		/* Update the key, but keep the NAT flags. */
+		ovs_ct_update_key(skb, key, true, true);
 	}
 
-	/* Call the helper right after nf_conntrack_in() for confirmed
-	 * connections, but only when commiting for unconfirmed connections.
-	 */
 	ct = nf_ct_get(skb, &ctinfo);
-	if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit)
-	    && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
-		WARN_ONCE(1, "helper rejected packet");
-		return -EINVAL;
+	if (ct) {
+#ifdef CONFIG_NF_NAT_NEEDED
+		/* Packets starting a new connection must be NATted before the
+		 * helper, so that the helper knows about the NAT.  We enforce
+		 * this by delaying both NAT and helper calls for unconfirmed
+		 * connections until the commiting CT action.  For later
+		 * packets NAT and Helper may be called in either order.
+		 *
+		 * NAT will be done only if the CT action has NAT, and only
+		 * once per packet (per zone), as guarded by the NAT bits in
+		 * the key->ct.state.
+		 */
+		if (info->nat && !(key->ct.state & OVS_CS_F_NAT_MASK) &&
+		    (nf_ct_is_confirmed(ct) || info->commit) &&
+		    ovs_ct_nat(net, key, info, skb, ct, ctinfo) != NF_ACCEPT) {
+			WARN_ONCE(1, "NAT rejected packet");
+			return -EINVAL;
+		}
+#endif
+		/* Call the helper whenever nf_conntrack_in() was called for
+		 * confirmed connections, but only when commiting for
+		 * unconfirmed connections.
+		 */
+		if ((nf_ct_is_confirmed(ct) ? !cached : info->commit)
+		    && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
+			WARN_ONCE(1, "helper rejected packet");
+			return -EINVAL;
+		}
 	}
 
 	return 0;
@@ -529,15 +797,13 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
 	if (exp) {
 		u8 state;
 
+		/* NOTE: New connections are NATted and Helped only when
+		 * commited, so we are not calling into NAT here.
+		 */
 		state = OVS_CS_F_TRACKED | OVS_CS_F_NEW | OVS_CS_F_RELATED;
 		__ovs_ct_update_key(key, state, &info->zone, exp->master);
-	} else {
-		int err;
-
-		err = __ovs_ct_lookup(net, key, info, skb);
-		if (err)
-			return err;
-	}
+	} else
+		return __ovs_ct_lookup(net, key, info, skb);
 
 	return 0;
 }
@@ -637,6 +903,131 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name,
 	return 0;
 }
 
+#ifdef CONFIG_NF_NAT_NEEDED
+static int parse_nat(const struct nlattr *attr,
+		     struct ovs_conntrack_info *info, bool log)
+{
+	struct nlattr *a;
+	int rem;
+	bool have_ip_max = false;
+	bool have_proto_max = false;
+	bool ip_vers = (info->family == NFPROTO_IPV6);
+
+	nla_for_each_nested(a, attr, rem) {
+		static const u16 ovs_nat_attr_lens[OVS_NAT_ATTR_MAX + 1][2] = {
+			[OVS_NAT_ATTR_SRC] = {0, 0},
+			[OVS_NAT_ATTR_DST] = {0, 0},
+			[OVS_NAT_ATTR_IP_MIN] = {sizeof(struct in_addr),
+						 sizeof(struct in6_addr)},
+			[OVS_NAT_ATTR_IP_MAX] = {sizeof(struct in_addr),
+						 sizeof(struct in6_addr)},
+			[OVS_NAT_ATTR_PROTO_MIN] = {sizeof(u16),sizeof(u16)},
+			[OVS_NAT_ATTR_PROTO_MAX] = {sizeof(u16),sizeof(u16)},
+			[OVS_NAT_ATTR_PERSISTENT] = {0, 0},
+			[OVS_NAT_ATTR_PROTO_HASH] = {0, 0},
+			[OVS_NAT_ATTR_PROTO_RANDOM] = {0, 0},
+		};
+		int type = nla_type(a);
+
+		if (type > OVS_NAT_ATTR_MAX) {
+			OVS_NLERR(log, "Unknown nat attribute (type=%d, max=%d).\n",
+			type, OVS_NAT_ATTR_MAX);
+			return -EINVAL;
+		}
+
+		if (ovs_nat_attr_lens[type][ip_vers] != nla_len(a)) {
+			OVS_NLERR(log, "NAT attribute type has unexpected "
+				  " length (type=%d, length=%d, expected=%d).\n",
+				  type, nla_len(a),
+				  ovs_nat_attr_lens[type][ip_vers]);
+			return -EINVAL;
+		}
+
+		switch (type) {
+		case OVS_NAT_ATTR_SRC:
+		case OVS_NAT_ATTR_DST:
+			if (info->nat) {
+				OVS_NLERR(log, "Only one type of NAT may be "
+					  "specified.\n");
+				return -ERANGE;
+			}
+			info->nat |= OVS_CT_NAT;
+			info->nat |= ((type == OVS_NAT_ATTR_SRC)
+					? OVS_CT_SRC_NAT : OVS_CT_DST_NAT);
+			break;
+
+		case OVS_NAT_ATTR_IP_MIN:
+			nla_memcpy(&info->range.min_addr, a, nla_len(a));
+			info->range.flags |= NF_NAT_RANGE_MAP_IPS;
+			break;
+
+		case OVS_NAT_ATTR_IP_MAX:
+			have_ip_max = true;
+			nla_memcpy(&info->range.max_addr, a,
+				   sizeof(info->range.max_addr));
+			info->range.flags |= NF_NAT_RANGE_MAP_IPS;
+			break;
+
+		case OVS_NAT_ATTR_PROTO_MIN:
+			info->range.min_proto.all = htons(nla_get_u16(a));
+			info->range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+			break;
+
+		case OVS_NAT_ATTR_PROTO_MAX:
+			have_proto_max = true;
+			info->range.max_proto.all = htons(nla_get_u16(a));
+			info->range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+			break;
+
+		case OVS_NAT_ATTR_PERSISTENT:
+			info->range.flags |= NF_NAT_RANGE_PERSISTENT;
+			break;
+
+		case OVS_NAT_ATTR_PROTO_HASH:
+			info->range.flags |= NF_NAT_RANGE_PROTO_RANDOM;
+			break;
+
+		case OVS_NAT_ATTR_PROTO_RANDOM:
+			info->range.flags |= NF_NAT_RANGE_PROTO_RANDOM_FULLY;
+			break;
+
+		default:
+			OVS_NLERR(log, "Unknown nat attribute (%d).\n", type);
+			return -EINVAL;
+		}
+	}
+
+	if (rem > 0) {
+		OVS_NLERR(log, "NAT attribute has %d unknown bytes.\n", rem);
+		return -EINVAL;
+	}
+	if (!info->nat) {
+		/* Do not allow flags if no type is given. */
+		if (info->range.flags) {
+			OVS_NLERR(log, "NAT flags may be given only when NAT "
+				  "range (SRC or DST) is also specified.\n");
+			return -EINVAL;
+		}
+		info->nat = OVS_CT_NAT;   /* NAT existing connections. */
+	} else if (!info->commit) {
+		OVS_NLERR(log, "NAT attributes may be specified only "
+			  "when CT COMMIT flag is also specified.\n");
+		return -EINVAL;
+	}
+	/* Allow missing IP_MAX. */
+	if (info->range.flags & NF_NAT_RANGE_MAP_IPS && !have_ip_max) {
+		memcpy(&info->range.max_addr, &info->range.min_addr,
+		       sizeof(info->range.max_addr));
+	}
+	/* Allow missing PROTO_MAX. */
+	if (info->range.flags & NF_NAT_RANGE_PROTO_SPECIFIED
+	    && !have_proto_max) {
+		info->range.max_proto.all = info->range.min_proto.all;
+	}
+	return 0;
+}
+#endif
+
 static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = {
 	[OVS_CT_ATTR_COMMIT]	= { .minlen = 0, .maxlen = 0 },
 	[OVS_CT_ATTR_ZONE]	= { .minlen = sizeof(u16),
@@ -646,7 +1037,11 @@ static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = {
 	[OVS_CT_ATTR_LABELS]	= { .minlen = sizeof(struct md_labels),
 				    .maxlen = sizeof(struct md_labels) },
 	[OVS_CT_ATTR_HELPER]	= { .minlen = 1,
-				    .maxlen = NF_CT_HELPER_NAME_LEN }
+				    .maxlen = NF_CT_HELPER_NAME_LEN },
+#ifdef CONFIG_NF_NAT_NEEDED
+	/* NAT length is checked when parsing the nested attributes. */
+	[OVS_CT_ATTR_NAT]	= { .minlen = 0, .maxlen = SIZE_MAX },
+#endif
 };
 
 static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
@@ -657,8 +1052,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
 
 	nla_for_each_nested(a, attr, rem) {
 		int type = nla_type(a);
-		int maxlen = ovs_ct_attr_lens[type].maxlen;
-		int minlen = ovs_ct_attr_lens[type].minlen;
+		size_t maxlen = ovs_ct_attr_lens[type].maxlen;
+		size_t minlen = ovs_ct_attr_lens[type].minlen;
 
 		if (type > OVS_CT_ATTR_MAX) {
 			OVS_NLERR(log,
@@ -668,7 +1063,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
 		}
 		if (nla_len(a) < minlen || nla_len(a) > maxlen) {
 			OVS_NLERR(log,
-				  "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
+				  "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%lu)",
 				  type, nla_len(a), maxlen);
 			return -EINVAL;
 		}
@@ -713,6 +1108,14 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
 				return -EINVAL;
 			}
 			break;
+#ifdef CONFIG_NF_NAT_NEEDED
+		case OVS_CT_ATTR_NAT: {
+			int err = parse_nat(a, info, log);
+			if (err)
+				return err;
+			break;
+		}
+#endif
 		default:
 			OVS_NLERR(log, "Unknown conntrack attr (%d)",
 				  type);
@@ -798,6 +1201,70 @@ err_free_ct:
 	return err;
 }
 
+#ifdef CONFIG_NF_NAT_NEEDED
+static bool ovs_ct_nat_to_attr(const struct ovs_conntrack_info *info,
+			       struct sk_buff *skb)
+{
+	struct nlattr *start;
+
+	start = nla_nest_start(skb, OVS_CT_ATTR_NAT);
+	if (!start)
+		return false;
+
+	if (info->nat & OVS_CT_SRC_NAT) {
+		if (nla_put_flag(skb, OVS_NAT_ATTR_SRC))
+			return false;
+	} else if (info->nat & OVS_CT_DST_NAT) {
+		if (nla_put_flag(skb, OVS_NAT_ATTR_DST))
+			return false;
+	} else {
+		goto out;
+	}
+
+	if (info->range.flags & NF_NAT_RANGE_MAP_IPS) {
+		if (info->family == NFPROTO_IPV4) {
+			if (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MIN,
+					info->range.min_addr.ip) ||
+			    (info->range.max_addr.ip != info->range.min_addr.ip
+			     && (nla_put_in_addr(skb, OVS_NAT_ATTR_IP_MAX,
+						 info->range.max_addr.ip))))
+				return false;
+		} else if (info->family == NFPROTO_IPV6) {
+			if (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MIN,
+					     &info->range.min_addr.in6) ||
+			    (memcmp(&info->range.max_addr.in6,
+				    &info->range.min_addr.in6,
+				    sizeof info->range.max_addr.in6)
+			     && (nla_put_in6_addr(skb, OVS_NAT_ATTR_IP_MAX,
+						  &info->range.max_addr.in6))))
+				return false;
+		} else
+			return false;
+	}
+	if (info->range.flags & NF_NAT_RANGE_PROTO_SPECIFIED &&
+	    (nla_put_u16(skb, OVS_NAT_ATTR_PROTO_MIN,
+			 ntohs(info->range.min_proto.all))
+	     || (info->range.max_proto.all != info->range.min_proto.all
+		 && nla_put_u16(skb, OVS_NAT_ATTR_PROTO_MAX,
+				ntohs(info->range.max_proto.all)))))
+		return false;
+
+	if (info->range.flags & NF_NAT_RANGE_PERSISTENT &&
+	    nla_put_flag(skb, OVS_NAT_ATTR_PERSISTENT))
+		return false;
+	if (info->range.flags & NF_NAT_RANGE_PROTO_RANDOM &&
+	    nla_put_flag(skb, OVS_NAT_ATTR_PROTO_HASH))
+		return false;
+	if (info->range.flags & NF_NAT_RANGE_PROTO_RANDOM_FULLY &&
+	    nla_put_flag(skb, OVS_NAT_ATTR_PROTO_RANDOM))
+		return false;
+out:
+	nla_nest_end(skb, start);
+
+	return true;
+}
+#endif
+
 int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info,
 			  struct sk_buff *skb)
 {
@@ -826,7 +1293,10 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info,
 				   ct_info->helper->name))
 			return -EMSGSIZE;
 	}
-
+#ifdef CONFIG_NF_NAT_NEEDED
+	if (ct_info->nat && !ovs_ct_nat_to_attr(ct_info, skb))
+		return -EMSGSIZE;
+#endif
 	nla_nest_end(skb, start);
 
 	return 0;
diff --git a/net/openvswitch/conntrack.h b/net/openvswitch/conntrack.h
index a7544f4..8f6230b 100644
--- a/net/openvswitch/conntrack.h
+++ b/net/openvswitch/conntrack.h
@@ -37,7 +37,8 @@ void ovs_ct_free_action(const struct nlattr *a);
 
 #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
 			   OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
-			   OVS_CS_F_INVALID | OVS_CS_F_TRACKED)
+			   OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
+			   OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
 #else
 #include <linux/errno.h>
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections.
       [not found]   ` <1446854768-38299-8-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
@ 2015-11-09 13:26     ` Patrick McHardy
  2015-11-10 20:58       ` Jarno Rajahalme
  0 siblings, 1 reply; 15+ messages in thread
From: Patrick McHardy @ 2015-11-09 13:26 UTC (permalink / raw)
  To: Jarno Rajahalme
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA

On 06.11, Jarno Rajahalme wrote:
> There is no need to help connections that are not confirmed, so we can
> delay helping new connections to the time when they are confirmed.
> This change is needed for NAT support, and having this as a separate
> patch will make the following NAT patch a bit easier to review.

For the first packet a helper receives the connection is always unconfirmed.
It makes no sense to confirm it if the helper drops the packet.

> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
> ---
>  net/openvswitch/conntrack.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index 7aa38fa..ba44287 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -458,6 +458,7 @@ static bool skb_nfct_cached(struct net *net,
>  /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
>   * not done already.  Update key with new CT state after passing the packet
>   * through conntrack.
> + * Note that invalid packets are accepted while the skb->nfct remains unset!
>   */
>  static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>  			   const struct ovs_conntrack_info *info,
> @@ -468,7 +469,11 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>  	 * actually run the packet through conntrack twice unless it's for a
>  	 * different zone.
>  	 */
> -	if (!skb_nfct_cached(net, key, info, skb)) {
> +	bool cached = skb_nfct_cached(net, key, info, skb);
> +	enum ip_conntrack_info ctinfo;
> +	struct nf_conn *ct;
> +
> +	if (!cached) {
>  		struct nf_conn *tmpl = info->ct;
>  		int err;
>  
> @@ -491,11 +496,16 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>  			return -ENOENT;
>  
>  		ovs_ct_update_key(skb, key, true);
> +	}
>  
> -		if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
> -			WARN_ONCE(1, "helper rejected packet");
> -			return -EINVAL;
> -		}
> +	/* Call the helper right after nf_conntrack_in() for confirmed
> +	 * connections, but only when commiting for unconfirmed connections.
> +	 */
> +	ct = nf_ct_get(skb, &ctinfo);
> +	if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit)
> +	    && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
> +		WARN_ONCE(1, "helper rejected packet");
> +		return -EINVAL;
>  	}
>  
>  	return 0;
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 0/8] openvswitch: NAT support.
  2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
                   ` (6 preceding siblings ...)
  2015-11-07  0:06 ` [RFC PATCH net-next v2 8/8] openvswitch: Interface with NAT Jarno Rajahalme
@ 2015-11-09 13:31 ` Patrick McHardy
       [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
  2015-11-09 23:48   ` Jarno Rajahalme
  7 siblings, 2 replies; 15+ messages in thread
From: Patrick McHardy @ 2015-11-09 13:31 UTC (permalink / raw)
  To: Jarno Rajahalme; +Cc: netdev, netfilter-devel, dev

On 06.11, Jarno Rajahalme wrote:
> This series adds NAT support to openvswitch kernel module.  A few
> changes are needed to the netfilter code to facilitate this (patches
> 1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
> patch 8 that adds the NAT support for calling into netfilter NAT code
> from the openvswitch conntrack action.

I'm missing some high level description, especially how it is invoked, how
it makes sure expectations of the NAT code about its invocation are met
(it is my understanding that OVS simply invokes this based on actions
specified by the user) and how it interacts with the remaining netfilter
features.

> Jarno Rajahalme (8):
>   netfilter: Remove IP_CT_NEW_REPLY definition.
>   netfilter: Factor out nf_ct_get_info().
>   netfilter: Allow calling into nat helper without skb_dst.
>   openvswitch: Update the CT state key only after nf_conntrack_in().
>   openvswitch: Find existing conntrack entry after upcall.
>   openvswitch: Handle NF_REPEAT in conntrack action.
>   openvswitch: Delay conntrack helper call for new connections.
>   openvswitch: Interface with NAT.
> 
>  include/net/netfilter/nf_conntrack.h               |  15 +
>  include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
>  include/uapi/linux/openvswitch.h                   |  47 ++
>  net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
>  net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
>  net/netfilter/nf_conntrack_core.c                  |  22 +-
>  net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
>  net/openvswitch/conntrack.h                        |   3 +-
>  8 files changed, 686 insertions(+), 103 deletions(-)
> 
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 0/8] openvswitch: NAT support.
       [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
@ 2015-11-09 23:21     ` Jarno Rajahalme
  2015-11-09 23:45     ` Jarno Rajahalme
  1 sibling, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-09 23:21 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, Linux Netdev List,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA


> On Nov 9, 2015, at 5:31 AM, Patrick McHardy <kaber@trash.net> wrote:
> 
> On 06.11, Jarno Rajahalme wrote:
>> This series adds NAT support to openvswitch kernel module.  A few
>> changes are needed to the netfilter code to facilitate this (patches
>> 1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
>> patch 8 that adds the NAT support for calling into netfilter NAT code
>> from the openvswitch conntrack action.
> 
> I'm missing some high level description, especially how it is invoked, how
> it makes sure expectations of the NAT code about its invocation are met
> (it is my understanding that OVS simply invokes this based on actions
> specified by the user) and how it interacts with the remaining netfilter
> features.
> 

The corresponding OVS userspace patches contain the new test cases for the NAT features (http://openvswitch.org/pipermail/dev/2015-November/061920.html) in tests/system-traffic.at <http://system-traffic.at/>. I’ll walk through two of them below.
Test case: conntrack - simple SNAT
In these tests ports 1 and 2 are in different namespaces. The flow table below allows all IPv4 traffic between port 1 to port 2, but IP connections from port 1 to port 2 are source NATted:
    in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
    in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
    in_port=2,ct_state=+trk,ct_zone=1,ip,action=1
This flow table matches all IPv4 traffic from port 1, runs them through conntrack in zone 1 and NATs them. The NAT is initialized to do source IP mapping to the given range for the first packet of each connection, after which the new connection is committed. For further packets of already tracked connections NAT is done according to the connection state and the commit is a no-op. Each packet that is not flagged as a drop by the CT action is forwarded to port 2. The CT action does an implicit fragmentation reassembly, so that only complete packets are run through conntrack. Reassembled packets are re-fragmented on output.

The IPv4 traffic coming from port 2 is first matched for the non-tracked state (-trk), which means that the packet has not been through a CT action yet. Such traffic is run trough the conntrack in zone 1 and all packets associated with a NATted connection are NATted also in the return direction. After the packet has been through conntrack it is recirculated back to table 0 (which is the default table, so all the rules above are in table 0). The CT action changes the ‘trk’ flag to being set, so the packets after recirculation match the third rule (+trk), and the packet is output on port 1. Since also the ct_zone is matched, only packets that were actually tracked by conntrack can match the 3rd rule and output to 1.

I’m skipped the rules for ARP handling in this walkthrough, but the test case has rules to match on the ARP request on the NATted address and reply to it.

The above is verified with a HTTP request and a subsequent conntrack entry listing in the test case:
    dnl HTTP requests from p0->p1 should work fine.
    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
    NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])

    AT_CHECK([conntrack -L 2>&1 | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl
    TIME_WAIT src=10.1.1.1 dst=10.1.1.2 sport=<cleared> dport=<cleared> src=10.1.1.2 dst=10.1.1.2XX sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 zone=1 use=1
    ])

As a second example, I’ll walk through a test case of NAT with FTP on IPv6:

As before, ports 1 (p0) and 2 (p1) reside in different namespaces (‘at_ns0’ and ‘at_ns1’, respectively). A static neighbor cache entry for the NATted address is created in at_ns1. In a more realistic scenario a controller would need to implement a ND proxy instead:
    ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
    NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
    ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
    dnl Would be nice if NAT could translate neighbor discovery messages, too.
    NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])

The OpenFlow rules are split into two tables (table 0 and table 1).

Table 0 tracks all IPv6 traffic and drops all other traffic. Packets are recirculated to table 1 after conntrack. Existing connections are NATted before recirculation:
    table=0 priority=10 ip6, action=ct(nat,table=1)
    table=0 priority=0 action=drop
Table 1:

FTP control connections from the “private” address to port 21 are output to port 1 after being tracked, NATted, and committed (== confirmed).
    table=1 in_port=1 ct_state=+new tcp6 ipv6_src=fc00::1 tp_dst=21  action=ct(alg=ftp,commit,nat(src=fc00::240)),2
The matches on the source/dest IP address below are not really needed, but in the test case they are to make sure the NATting actually happens.

Related TCP connections to the reverse direction are NATted, committed and output to port 1:
    table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1
Packets on established TCP connections are allowed both ways (the CT action in table 0 NATted these before recirculation, so we see the mapped address going from port 1 to port 2, and the reverse-mapped (== original) address on return traffic):
    table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240   action=2
    table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1     action=1 
We pass icmp6 packets both ways:
    table=1 priority=100 in_port=1 icmp6, action=2
    table=1 priority=100 in_port=2 icmp6, action=1
Everything else is dropped:
    table=1 priority=0, action=drop
Functionality is verified with a Python FTP server in at_ns1 and wget to it from at_ns0:
    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])

    dnl FTP requests from p0->p1 should work fine.
    NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2 <ftp://[[fc00::2>]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-proxy --no-remove-listing -o wget0.log -d])
Both the control connection and the data connection were NATted:

    AT_CHECK([conntrack -L -f ipv6 2>&1 | FORMAT_CT(fc00::2) | grep -v "FIN" | grep -v "CLOSE"], [0], [dnl
    TIME_WAIT src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 helper=ftp use=2
    TIME_WAIT src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 use=1
    ])
The flow tables in the test cases are OpenFlow tables, which are translated to kernel flows by ovs-vswitchd. I have included the relevant kernel datapath flows generated in the IPv6 NAT test case above below for your reference. Please note that the kernel port numbers are different from the OpenFlow port numbers, as each bridge has it’s own range of OpenFlow port numbers, but they all share the same kernel datapath. In this case OpenFlow port 1 is kernel port 2, and OpenFlow port 2 is kernel port 3. Kernel flows are all in the same table and they have no priorities (so they should have mutually exclusive matches). Recirculation IDs are allocated on-demand, here the recirculation ID 1 deals with traffic to the original direction and 2 to the return direction (recirc_id(0) designates no recirculation). ovs_vswitchd always exact matches IP frag, so since the test traffic had no fragments, you’ll see (frag=no) in each flow below. Also, the packet that causes the flow to be created is executed independently (but with the same actions) of the newly created flow, so the kernel datapath flow counts do not reflect the first packet (OpenFlow counters do), this explains 0 counts on some flows below:

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:2541, used:0.048s, flags:SFPR., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(2),ct_state(+new),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.072s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3
    recirc_id(0x1),in_port(2),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:4, bytes:344, used:0.048s, flags:F., actions:3
    recirc_id(0x1),in_port(2),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:12, bytes:1145, used:0.048s, flags:FP., actions:3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:26, bytes:4939, used:0.048s, flags:SFP., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(3),ct_state(+new+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2
    recirc_id(0x2),in_port(3),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:12, bytes:1323, used:0.048s, flags:SFP., actions:2
    recirc_id(0x2),in_port(3),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:3, bytes:1113, used:0.048s, flags:FP., actions:2


The generated matches depend on the order of processing of rules in the OpenFlow tables, which can be influenced by specifying rule priorities to OpenFlow rules. For example, with a different set of priorities the datapath rules become (In this test run the first IP (ICMPv6) packet was received from at_ns1, so the recirc_ids are reversed from above, ICMPv6 flows not included here.):

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:27, bytes:2455, used:0.040s, flags:SFPR., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(2),ct_state(+est),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:16, bytes:1497, used:0.040s, flags:SFP., actions:3
    recirc_id(0x2),in_port(2),ct_state(+new-est),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.108s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:5111, used:0.040s, flags:SFP., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(3),ct_state(+est),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:19, bytes:4281, used:0.040s, flags:SFP., actions:2
    recirc_id(0x1),in_port(3),ct_state(+new-est+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2

Hope this helps,

  Jarno

>> Jarno Rajahalme (8):
>>  netfilter: Remove IP_CT_NEW_REPLY definition.
>>  netfilter: Factor out nf_ct_get_info().
>>  netfilter: Allow calling into nat helper without skb_dst.
>>  openvswitch: Update the CT state key only after nf_conntrack_in().
>>  openvswitch: Find existing conntrack entry after upcall.
>>  openvswitch: Handle NF_REPEAT in conntrack action.
>>  openvswitch: Delay conntrack helper call for new connections.
>>  openvswitch: Interface with NAT.
>> 
>> include/net/netfilter/nf_conntrack.h               |  15 +
>> include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
>> include/uapi/linux/openvswitch.h                   |  47 ++
>> net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
>> net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
>> net/netfilter/nf_conntrack_core.c                  |  22 +-
>> net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
>> net/openvswitch/conntrack.h                        |   3 +-
>> 8 files changed, 686 insertions(+), 103 deletions(-)
>> 
>> -- 
>> 2.1.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
>> the body of a message to majordomo@vger.kernel.org <mailto:majordomo@vger.kernel.org>
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html <http://vger.kernel.org/majordomo-info.html>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 0/8] openvswitch: NAT support.
       [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
  2015-11-09 23:21     ` Jarno Rajahalme
@ 2015-11-09 23:45     ` Jarno Rajahalme
  1 sibling, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-09 23:45 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, Linux Netdev List,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA

[Resending from my new address]

> On Nov 9, 2015, at 5:31 AM, Patrick McHardy <kaber@trash.net <mailto:kaber@trash.net>> wrote:
> 
> On 06.11, Jarno Rajahalme wrote:
>> This series adds NAT support to openvswitch kernel module.  A few
>> changes are needed to the netfilter code to facilitate this (patches
>> 1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
>> patch 8 that adds the NAT support for calling into netfilter NAT code
>> from the openvswitch conntrack action.
> 
> I'm missing some high level description, especially how it is invoked, how
> it makes sure expectations of the NAT code about its invocation are met
> (it is my understanding that OVS simply invokes this based on actions
> specified by the user) and how it interacts with the remaining netfilter
> features.
> 

The corresponding OVS userspace patches contain the new test cases for the NAT features (http://openvswitch.org/pipermail/dev/2015-November/061920.html <http://openvswitch.org/pipermail/dev/2015-November/061920.html>) in tests/system-traffic.at <http://system-traffic.at/>. I’ll walk through two of them below.
Test case: conntrack - simple SNAT
In these tests ports 1 and 2 are in different namespaces. The flow table below allows all IPv4 traffic between port 1 to port 2, but IP connections from port 1 to port 2 are source NATted:
    in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
    in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
    in_port=2,ct_state=+trk,ct_zone=1,ip,action=1
This flow table matches all IPv4 traffic from port 1, runs them through conntrack in zone 1 and NATs them. The NAT is initialized to do source IP mapping to the given range for the first packet of each connection, after which the new connection is committed. For further packets of already tracked connections NAT is done according to the connection state and the commit is a no-op. Each packet that is not flagged as a drop by the CT action is forwarded to port 2. The CT action does an implicit fragmentation reassembly, so that only complete packets are run through conntrack. Reassembled packets are re-fragmented on output.

The IPv4 traffic coming from port 2 is first matched for the non-tracked state (-trk), which means that the packet has not been through a CT action yet. Such traffic is run trough the conntrack in zone 1 and all packets associated with a NATted connection are NATted also in the return direction. After the packet has been through conntrack it is recirculated back to table 0 (which is the default table, so all the rules above are in table 0). The CT action changes the ‘trk’ flag to being set, so the packets after recirculation match the third rule (+trk), and the packet is output on port 1. Since also the ct_zone is matched, only packets that were actually tracked by conntrack can match the 3rd rule and output to 1.

I’m skipped the rules for ARP handling in this walkthrough, but the test case has rules to match on the ARP request on the NATted address and reply to it.

The above is verified with a HTTP request and a subsequent conntrack entry listing in the test case:
    dnl HTTP requests from p0->p1 should work fine.
    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
    NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])

    AT_CHECK([conntrack -L 2>&1 | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl
    TIME_WAIT src=10.1.1.1 dst=10.1.1.2 sport=<cleared> dport=<cleared> src=10.1.1.2 dst=10.1.1.2XX sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 zone=1 use=1
    ])

As a second example, I’ll walk through a test case of NAT with FTP on IPv6:

As before, ports 1 (p0) and 2 (p1) reside in different namespaces (‘at_ns0’ and ‘at_ns1’, respectively). A static neighbor cache entry for the NATted address is created in at_ns1. In a more realistic scenario a controller would need to implement a ND proxy instead:
    ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
    NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
    ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
    dnl Would be nice if NAT could translate neighbor discovery messages, too.
    NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])

The OpenFlow rules are split into two tables (table 0 and table 1).

Table 0 tracks all IPv6 traffic and drops all other traffic. Packets are recirculated to table 1 after conntrack. Existing connections are NATted before recirculation:
    table=0 priority=10 ip6, action=ct(nat,table=1)
    table=0 priority=0 action=drop
Table 1:

FTP control connections from the “private” address to port 21 are output to port 1 after being tracked, NATted, and committed (== confirmed).
    table=1 in_port=1 ct_state=+new tcp6 ipv6_src=fc00::1 tp_dst=21  action=ct(alg=ftp,commit,nat(src=fc00::240)),2
The matches on the source/dest IP address below are not really needed, but in the test case they are to make sure the NATting actually happens.

Related TCP connections to the reverse direction are NATted, committed and output to port 1:
    table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1
Packets on established TCP connections are allowed both ways (the CT action in table 0 NATted these before recirculation, so we see the mapped address going from port 1 to port 2, and the reverse-mapped (== original) address on return traffic):
    table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240   action=2
    table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1     action=1 
We pass icmp6 packets both ways:
    table=1 priority=100 in_port=1 icmp6, action=2
    table=1 priority=100 in_port=2 icmp6, action=1
Everything else is dropped:
    table=1 priority=0, action=drop
Functionality is verified with a Python FTP server in at_ns1 and wget to it from at_ns0:
    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])

    dnl FTP requests from p0->p1 should work fine.
    NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2 <ftp://[[fc00::2>]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-proxy --no-remove-listing -o wget0.log -d])
Both the control connection and the data connection were NATted:
    AT_CHECK([conntrack -L -f ipv6 2>&1 | FORMAT_CT(fc00::2) | grep -v "FIN" | grep -v "CLOSE"], [0], [dnl
    TIME_WAIT src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 helper=ftp use=2
    TIME_WAIT src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 use=1
    ])
The flow tables in the test cases are OpenFlow tables, which are translated to kernel flows by ovs-vswitchd. I have included the relevant kernel datapath flows generated in the IPv6 NAT test case above below for your reference. Please note that the kernel port numbers are different from the OpenFlow port numbers, as each bridge has it’s own range of OpenFlow port numbers, but they all share the same kernel datapath. In this case OpenFlow port 1 is kernel port 2, and OpenFlow port 2 is kernel port 3. Kernel flows are all in the same table and they have no priorities (so they should have mutually exclusive matches). Recirculation IDs are allocated on-demand, here the recirculation ID 1 deals with traffic to the original direction and 2 to the return direction (recirc_id(0) designates no recirculation). ovs_vswitchd always exact matches IP frag, so since the test traffic had no fragments, you’ll see (frag=no) in each flow below. Also, the packet that causes the flow to be created is executed independently (but with the same actions) of the newly created flow, so the kernel datapath flow counts do not reflect the first packet (OpenFlow counters do), this explains 0 counts on some flows below:

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:2541, used:0.048s, flags:SFPR., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(2),ct_state(+new),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.072s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3
    recirc_id(0x1),in_port(2),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:4, bytes:344, used:0.048s, flags:F., actions:3
    recirc_id(0x1),in_port(2),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:12, bytes:1145, used:0.048s, flags:FP., actions:3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:26, bytes:4939, used:0.048s, flags:SFP., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(3),ct_state(+new+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2
    recirc_id(0x2),in_port(3),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:12, bytes:1323, used:0.048s, flags:SFP., actions:2
    recirc_id(0x2),in_port(3),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:3, bytes:1113, used:0.048s, flags:FP., actions:2


The generated matches depend on the order of processing of rules in the OpenFlow tables, which can be influenced by specifying rule priorities to OpenFlow rules. For example, with a different set of priorities the datapath rules become (In this test run the first IP (ICMPv6) packet was received from at_ns1, so the recirc_ids are reversed from above, ICMPv6 flows not included here.):

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:27, bytes:2455, used:0.040s, flags:SFPR., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(2),ct_state(+est),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:16, bytes:1497, used:0.040s, flags:SFP., actions:3
    recirc_id(0x2),in_port(2),ct_state(+new-est),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.108s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:5111, used:0.040s, flags:SFP., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(3),ct_state(+est),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:19, bytes:4281, used:0.040s, flags:SFP., actions:2
    recirc_id(0x1),in_port(3),ct_state(+new-est+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2

Hope this helps,

  Jarno

>> Jarno Rajahalme (8):
>>  netfilter: Remove IP_CT_NEW_REPLY definition.
>>  netfilter: Factor out nf_ct_get_info().
>>  netfilter: Allow calling into nat helper without skb_dst.
>>  openvswitch: Update the CT state key only after nf_conntrack_in().
>>  openvswitch: Find existing conntrack entry after upcall.
>>  openvswitch: Handle NF_REPEAT in conntrack action.
>>  openvswitch: Delay conntrack helper call for new connections.
>>  openvswitch: Interface with NAT.
>> 
>> include/net/netfilter/nf_conntrack.h               |  15 +
>> include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
>> include/uapi/linux/openvswitch.h                   |  47 ++
>> net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
>> net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
>> net/netfilter/nf_conntrack_core.c                  |  22 +-
>> net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
>> net/openvswitch/conntrack.h                        |   3 +-
>> 8 files changed, 686 insertions(+), 103 deletions(-)
>> 
>> -- 
>> 2.1.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
>> the body of a message to majordomo@vger.kernel.org <mailto:majordomo@vger.kernel.org>
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html <http://vger.kernel.org/majordomo-info.html>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 0/8] openvswitch: NAT support.
  2015-11-09 13:31 ` [RFC PATCH net-next v2 0/8] openvswitch: NAT support Patrick McHardy
       [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
@ 2015-11-09 23:48   ` Jarno Rajahalme
  1 sibling, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-09 23:48 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Linux Netdev List, netfilter-devel, dev

[Resending as plain text]

> On Nov 9, 2015, at 5:31 AM, Patrick McHardy <kaber@trash.net> wrote:
> 
> On 06.11, Jarno Rajahalme wrote:
>> This series adds NAT support to openvswitch kernel module.  A few
>> changes are needed to the netfilter code to facilitate this (patches
>> 1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
>> patch 8 that adds the NAT support for calling into netfilter NAT code
>> from the openvswitch conntrack action.
> 
> I'm missing some high level description, especially how it is invoked, how
> it makes sure expectations of the NAT code about its invocation are met
> (it is my understanding that OVS simply invokes this based on actions
> specified by the user) and how it interacts with the remaining netfilter
> features.
> 

The corresponding OVS userspace patches contain the new test cases for the NAT features (http://openvswitch.org/pipermail/dev/2015-November/061920.html) in tests/system-traffic.at. I’ll walk through two of them below.

Test case: conntrack - simple SNAT

In these tests ports 1 and 2 are in different namespaces. The flow table below allows all IPv4 traffic between port 1 to port 2, but IP connections from port 1 to port 2 are source NATted:

    in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
    in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
    in_port=2,ct_state=+trk,ct_zone=1,ip,action=1

This flow table matches all IPv4 traffic from port 1, runs them through conntrack in zone 1 and NATs them. The NAT is initialized to do source IP mapping to the given range for the first packet of each connection, after which the new connection is committed. For further packets of already tracked connections NAT is done according to the connection state and the commit is a no-op. Each packet that is not flagged as a drop by the CT action is forwarded to port 2. The CT action does an implicit fragmentation reassembly, so that only complete packets are run through conntrack. Reassembled packets are re-fragmented on output.

The IPv4 traffic coming from port 2 is first matched for the non-tracked state (-trk), which means that the packet has not been through a CT action yet. Such traffic is run trough the conntrack in zone 1 and all packets associated with a NATted connection are NATted also in the return direction. After the packet has been through conntrack it is recirculated back to table 0 (which is the default table, so all the rules above are in table 0). The CT action changes the ‘trk’ flag to being set, so the packets after recirculation match the third rule (+trk), and the packet is output on port 1. Since also the ct_zone is matched, only packets that were actually tracked by conntrack can match the 3rd rule and output to 1.

I’m skipped the rules for ARP handling in this walkthrough, but the test case has rules to match on the ARP request on the NATted address and reply to it.

The above is verified with a HTTP request and a subsequent conntrack entry listing in the test case:

    dnl HTTP requests from p0->p1 should work fine.
    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
    NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])

    AT_CHECK([conntrack -L 2>&1 | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl
    TIME_WAIT src=10.1.1.1 dst=10.1.1.2 sport=<cleared> dport=<cleared> src=10.1.1.2 dst=10.1.1.2XX sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 zone=1 use=1
    ])


As a second example, I’ll walk through a test case of NAT with FTP on IPv6:

As before, ports 1 (p0) and 2 (p1) reside in different namespaces (‘at_ns0’ and ‘at_ns1’, respectively). A static neighbor cache entry for the NATted address is created in at_ns1. In a more realistic scenario a controller would need to implement a ND proxy instead:

    ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
    NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
    ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
    dnl Would be nice if NAT could translate neighbor discovery messages, too.
    NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])


The OpenFlow rules are split into two tables (table 0 and table 1).

Table 0 tracks all IPv6 traffic and drops all other traffic. Packets are recirculated to table 1 after conntrack. Existing connections are NATted before recirculation:

    table=0 priority=10 ip6, action=ct(nat,table=1)
    table=0 priority=0 action=drop

Table 1:

FTP control connections from the “private” address to port 21 are output to port 1 after being tracked, NATted, and committed (== confirmed).

    table=1 in_port=1 ct_state=+new tcp6 ipv6_src=fc00::1 tp_dst=21  action=ct(alg=ftp,commit,nat(src=fc00::240)),2

The matches on the source/dest IP address below are not really needed, but in the test case they are to make sure the NATting actually happens.

Related TCP connections to the reverse direction are NATted, committed and output to port 1:

    table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1

Packets on established TCP connections are allowed both ways (the CT action in table 0 NATted these before recirculation, so we see the mapped address going from port 1 to port 2, and the reverse-mapped (== original) address on return traffic):

    table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240   action=2
    table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1     action=1 

We pass icmp6 packets both ways:

    table=1 priority=100 in_port=1 icmp6, action=2
    table=1 priority=100 in_port=2 icmp6, action=1

Everything else is dropped:

    table=1 priority=0, action=drop

Functionality is verified with a Python FTP server in at_ns1 and wget to it from at_ns0:

    NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])

    dnl FTP requests from p0->p1 should work fine.
    NS_CHECK_EXEC([at_ns0], [wget 
ftp://[[fc00::2
]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-proxy --no-remove-listing -o wget0.log -d])

Both the control connection and the data connection were NATted:

    AT_CHECK([conntrack -L -f ipv6 2>&1 | FORMAT_CT(fc00::2) | grep -v "FIN" | grep -v "CLOSE"], [0], [dnl
    TIME_WAIT src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 helper=ftp use=2
    TIME_WAIT src=fc00::2 dst=fc00::240 sport=<cleared> dport=<cleared> src=fc00::1 dst=fc00::2 sport=<cleared> dport=<cleared> [[ASSURED]] mark=0 use=1
    ])

The flow tables in the test cases are OpenFlow tables, which are translated to kernel flows by ovs-vswitchd. I have included the relevant kernel datapath flows generated in the IPv6 NAT test case above below for your reference. Please note that the kernel port numbers are different from the OpenFlow port numbers, as each bridge has it’s own range of OpenFlow port numbers, but they all share the same kernel datapath. In this case OpenFlow port 1 is kernel port 2, and OpenFlow port 2 is kernel port 3. Kernel flows are all in the same table and they have no priorities (so they should have mutually exclusive matches). Recirculation IDs are allocated on-demand, here the recirculation ID 1 deals with traffic to the original direction and 2 to the return direction (recirc_id(0) designates no recirculation). ovs_vswitchd always exact matches IP frag, so since the test traffic had no fragments, you’ll see (frag=no) in each flow below. Also, the packet that causes the flow to be created is executed independently (but with the same actions) of the newly created flow, so the kernel datapath flow counts do not reflect the first packet (OpenFlow counters do), this explains 0 counts on some flows below:

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:2541, used:0.048s, flags:SFPR., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(2),ct_state(+new),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.072s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3
    recirc_id(0x1),in_port(2),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:4, bytes:344, used:0.048s, flags:F., actions:3
    recirc_id(0x1),in_port(2),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:12, bytes:1145, used:0.048s, flags:FP., actions:3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:26, bytes:4939, used:0.048s, flags:SFP., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(3),ct_state(+new+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2
    recirc_id(0x2),in_port(3),ct_state(-new+est-rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:12, bytes:1323, used:0.048s, flags:SFP., actions:2
    recirc_id(0x2),in_port(3),ct_state(-new+est+rel),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:3, bytes:1113, used:0.048s, flags:FP., actions:2


The generated matches depend on the order of processing of rules in the OpenFlow tables, which can be influenced by specifying rule priorities to OpenFlow rules. For example, with a different set of priorities the datapath rules become (In this test run the first IP (ICMPv6) packet was received from at_ns1, so the recirc_ids are reversed from above, ICMPv6 flows not included here.):

    recirc_id(0),in_port(2),eth_type(0x86dd),ipv6(frag=no), packets:27, bytes:2455, used:0.040s, flags:SFPR., actions:ct(nat),recirc(0x2)
    recirc_id(0x2),in_port(2),ct_state(+est),eth_type(0x86dd),ipv6(src=fc00::240,proto=6,frag=no), packets:16, bytes:1497, used:0.040s, flags:SFP., actions:3
    recirc_id(0x2),in_port(2),ct_state(+new-est),eth_type(0x86dd),ipv6(src=fc00::1,proto=6,frag=no),tcp(dst=21), packets:1, bytes:94, used:0.108s, flags:S, actions:ct(commit,helper=ftp,nat(src=fc00::240)),3

    recirc_id(0),in_port(3),eth_type(0x86dd),ipv6(frag=no), packets:28, bytes:5111, used:0.040s, flags:SFP., actions:ct(nat),recirc(0x1)
    recirc_id(0x1),in_port(3),ct_state(+est),eth_type(0x86dd),ipv6(dst=fc00::1,proto=6,frag=no), packets:19, bytes:4281, used:0.040s, flags:SFP., actions:2
    recirc_id(0x1),in_port(3),ct_state(+new-est+rel),eth_type(0x86dd),ipv6(dst=fc00::240,proto=6,frag=no), packets:0, bytes:0, used:never, actions:ct(commit,nat),2

Hope this helps,

  Jarno

>> Jarno Rajahalme (8):
>>  netfilter: Remove IP_CT_NEW_REPLY definition.
>>  netfilter: Factor out nf_ct_get_info().
>>  netfilter: Allow calling into nat helper without skb_dst.
>>  openvswitch: Update the CT state key only after nf_conntrack_in().
>>  openvswitch: Find existing conntrack entry after upcall.
>>  openvswitch: Handle NF_REPEAT in conntrack action.
>>  openvswitch: Delay conntrack helper call for new connections.
>>  openvswitch: Interface with NAT.
>> 
>> include/net/netfilter/nf_conntrack.h               |  15 +
>> include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
>> include/uapi/linux/openvswitch.h                   |  47 ++
>> net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
>> net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
>> net/netfilter/nf_conntrack_core.c                  |  22 +-
>> net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
>> net/openvswitch/conntrack.h                        |   3 +-
>> 8 files changed, 686 insertions(+), 103 deletions(-)
>> 
>> -- 
>> 2.1.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections.
  2015-11-09 13:26     ` Patrick McHardy
@ 2015-11-10 20:58       ` Jarno Rajahalme
  0 siblings, 0 replies; 15+ messages in thread
From: Jarno Rajahalme @ 2015-11-10 20:58 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netdev, netfilter-devel, dev


> On Nov 9, 2015, at 5:26 AM, Patrick McHardy <kaber@trash.net> wrote:
> 
> On 06.11, Jarno Rajahalme wrote:
>> There is no need to help connections that are not confirmed, so we can
>> delay helping new connections to the time when they are confirmed.
>> This change is needed for NAT support, and having this as a separate
>> patch will make the following NAT patch a bit easier to review.
> 
> For the first packet a helper receives the connection is always unconfirmed.
> It makes no sense to confirm it if the helper drops the packet.
> 

Right, the nf_conntrack_confirm() call is still done only if helper accepts the packet.

The issue this patch deals with is that in a fairly typical pattern the packet will be passed through conntrack by a CT action and then recirculated (for matching on the connection state, using the RECIRC action), and later an another CT action is used to confirm the connection, possibly with NAT. Before this patch, __ovs_ct_lookup() would have passed the packet through the helper in the first step, while the NAT call would only happen with the second step, i.e., in the wrong order. With this patch the helper for new connections is called with the second step, after calling the NAT code (as added by the patch 8/8). For non-new packets we must call the helper with the first conntrack lookup, as there typically are no later CT actions for packet belonging to existing connections. For new connections we know that if the first CT action does not have the ‘commit’ flag (which causes nf_conntrack_confirm() to be called), we can safely postpone the helper call, as there has to be a later CT action for the connection to be confirmed.

  Jarno

>> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
>> ---
>> net/openvswitch/conntrack.c | 20 +++++++++++++++-----
>> 1 file changed, 15 insertions(+), 5 deletions(-)
>> 
>> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
>> index 7aa38fa..ba44287 100644
>> --- a/net/openvswitch/conntrack.c
>> +++ b/net/openvswitch/conntrack.c
>> @@ -458,6 +458,7 @@ static bool skb_nfct_cached(struct net *net,
>> /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
>>  * not done already.  Update key with new CT state after passing the packet
>>  * through conntrack.
>> + * Note that invalid packets are accepted while the skb->nfct remains unset!
>>  */
>> static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>> 			   const struct ovs_conntrack_info *info,
>> @@ -468,7 +469,11 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>> 	 * actually run the packet through conntrack twice unless it's for a
>> 	 * different zone.
>> 	 */
>> -	if (!skb_nfct_cached(net, key, info, skb)) {
>> +	bool cached = skb_nfct_cached(net, key, info, skb);
>> +	enum ip_conntrack_info ctinfo;
>> +	struct nf_conn *ct;
>> +
>> +	if (!cached) {
>> 		struct nf_conn *tmpl = info->ct;
>> 		int err;
>> 
>> @@ -491,11 +496,16 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
>> 			return -ENOENT;
>> 
>> 		ovs_ct_update_key(skb, key, true);
>> +	}
>> 
>> -		if (ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
>> -			WARN_ONCE(1, "helper rejected packet");
>> -			return -EINVAL;
>> -		}
>> +	/* Call the helper right after nf_conntrack_in() for confirmed
>> +	 * connections, but only when commiting for unconfirmed connections.
>> +	 */
>> +	ct = nf_ct_get(skb, &ctinfo);
>> +	if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit)
>> +	    && ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
>> +		WARN_ONCE(1, "helper rejected packet");
>> +		return -EINVAL;
>> 	}
>> 
>> 	return 0;
>> -- 
>> 2.1.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> 

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-11-10 20:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-07  0:06 [RFC PATCH net-next v2 0/8] openvswitch: NAT support Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 1/8] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 2/8] netfilter: Factor out nf_ct_get_info() Jarno Rajahalme
     [not found] ` <1446854768-38299-1-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2015-11-07  0:06   ` [RFC PATCH net-next v2 3/8] netfilter: Allow calling into nat helper without skb_dst Jarno Rajahalme
2015-11-07  0:06   ` [RFC PATCH net-next v2 4/8] openvswitch: Update the CT state key only after nf_conntrack_in() Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 5/8] openvswitch: Find existing conntrack entry after upcall Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 6/8] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 7/8] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
     [not found]   ` <1446854768-38299-8-git-send-email-jrajahalme-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2015-11-09 13:26     ` Patrick McHardy
2015-11-10 20:58       ` Jarno Rajahalme
2015-11-07  0:06 ` [RFC PATCH net-next v2 8/8] openvswitch: Interface with NAT Jarno Rajahalme
2015-11-09 13:31 ` [RFC PATCH net-next v2 0/8] openvswitch: NAT support Patrick McHardy
     [not found]   ` <20151109133122.GC8098-uXGAPMMVk8YB9AHHLWeGtNQXobZC6xk2@public.gmane.org>
2015-11-09 23:21     ` Jarno Rajahalme
2015-11-09 23:45     ` Jarno Rajahalme
2015-11-09 23:48   ` Jarno Rajahalme

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).