linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/2] openvswitch: support asymmetric conntrack
@ 2019-11-08 21:07 Aaron Conole
  2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Aaron Conole @ 2019-11-08 21:07 UTC (permalink / raw)
  To: netdev
  Cc: Pravin B Shelar, David S . Miller, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, dev, linux-kernel

The openvswitch module shares a common conntrack and NAT infrastructure
exposed via netfilter.  It's possible that a packet needs both SNAT and
DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
this because it runs through the NAT table twice - once on ingress and
again after egress.  The openvswitch module doesn't have such capability.

Like netfilter hook infrastructure, we should run through NAT twice to
keep the symmetry.

Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 net/openvswitch/conntrack.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 05249eb45082..283e8f9a5fd2 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -903,6 +903,17 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key,
 	}
 	err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype);
 
+	if (err == NF_ACCEPT &&
+	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
+		if (maniptype == NF_NAT_MANIP_SRC)
+			maniptype = NF_NAT_MANIP_DST;
+		else
+			maniptype = NF_NAT_MANIP_SRC;
+
+		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);
-- 
2.21.0


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

* [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-08 21:07 [PATCH net 1/2] openvswitch: support asymmetric conntrack Aaron Conole
@ 2019-11-08 21:07 ` Aaron Conole
  2019-11-14 14:22   ` Roi Dayan
  2019-11-14 16:29   ` Marcelo Ricardo Leitner
  2019-11-09 22:15 ` [PATCH net 1/2] openvswitch: " Pravin Shelar
  2019-11-12  8:52 ` Nicolas Dichtel
  2 siblings, 2 replies; 17+ messages in thread
From: Aaron Conole @ 2019-11-08 21:07 UTC (permalink / raw)
  To: netdev
  Cc: Pravin B Shelar, David S . Miller, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, dev, linux-kernel

The act_ct TC module shares a common conntrack and NAT infrastructure
exposed via netfilter.  It's possible that a packet needs both SNAT and
DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
this because it runs through the NAT table twice - once on ingress and
again after egress.  The act_ct action doesn't have such capability.

Like netfilter hook infrastructure, we should run through NAT twice to
keep the symmetry.

Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 net/sched/act_ct.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index fcc46025e790..f3232a00970f 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
 			  bool commit)
 {
 #if IS_ENABLED(CONFIG_NF_NAT)
+	int err;
 	enum nf_nat_manip_type maniptype;
 
 	if (!(ct_action & TCA_CT_ACT_NAT))
@@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
 		return NF_ACCEPT;
 	}
 
-	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	if (err == NF_ACCEPT &&
+	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
+		if (maniptype == NF_NAT_MANIP_SRC)
+			maniptype = NF_NAT_MANIP_DST;
+		else
+			maniptype = NF_NAT_MANIP_SRC;
+
+		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	}
+	return err;
 #else
 	return NF_ACCEPT;
 #endif
-- 
2.21.0


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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-08 21:07 [PATCH net 1/2] openvswitch: support asymmetric conntrack Aaron Conole
  2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
@ 2019-11-09 22:15 ` Pravin Shelar
  2019-11-18 20:39   ` Aaron Conole
  2019-11-12  8:52 ` Nicolas Dichtel
  2 siblings, 1 reply; 17+ messages in thread
From: Pravin Shelar @ 2019-11-09 22:15 UTC (permalink / raw)
  To: Aaron Conole
  Cc: Linux Kernel Network Developers, David S . Miller,
	Jamal Hadi Salim, Cong Wang, Jiri Pirko, ovs dev, linux-kernel

On Fri, Nov 8, 2019 at 1:07 PM Aaron Conole <aconole@redhat.com> wrote:
>
> The openvswitch module shares a common conntrack and NAT infrastructure
> exposed via netfilter.  It's possible that a packet needs both SNAT and
> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> this because it runs through the NAT table twice - once on ingress and
> again after egress.  The openvswitch module doesn't have such capability.
>
> Like netfilter hook infrastructure, we should run through NAT twice to
> keep the symmetry.
>
> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
> Signed-off-by: Aaron Conole <aconole@redhat.com>

The patch looks ok. But I am not able apply it. can you fix the encoding.

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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-08 21:07 [PATCH net 1/2] openvswitch: support asymmetric conntrack Aaron Conole
  2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
  2019-11-09 22:15 ` [PATCH net 1/2] openvswitch: " Pravin Shelar
@ 2019-11-12  8:52 ` Nicolas Dichtel
  2019-11-18 21:19   ` Aaron Conole
  2 siblings, 1 reply; 17+ messages in thread
From: Nicolas Dichtel @ 2019-11-12  8:52 UTC (permalink / raw)
  To: Aaron Conole, netdev
  Cc: Pravin B Shelar, David S . Miller, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, dev, linux-kernel

Le 08/11/2019 à 22:07, Aaron Conole a écrit :
> The openvswitch module shares a common conntrack and NAT infrastructure
> exposed via netfilter.  It's possible that a packet needs both SNAT and
> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> this because it runs through the NAT table twice - once on ingress and
> again after egress.  The openvswitch module doesn't have such capability.
> 
> Like netfilter hook infrastructure, we should run through NAT twice to
> keep the symmetry.
> 
> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
> Signed-off-by: Aaron Conole <aconole@redhat.com>
In this case, ovs_ct_find_existing() won't be able to find the conntrack, right?
Inverting the tuple to find the conntrack doesn't work anymore with double NAT.
Am I wrong?


Regards,
Nicolas

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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
@ 2019-11-14 14:22   ` Roi Dayan
  2019-11-14 14:24     ` Paul Blakey
  2019-11-14 16:29   ` Marcelo Ricardo Leitner
  1 sibling, 1 reply; 17+ messages in thread
From: Roi Dayan @ 2019-11-14 14:22 UTC (permalink / raw)
  To: Aaron Conole, netdev
  Cc: Pravin B Shelar, David S . Miller, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, dev, linux-kernel, Paul Blakey



On 2019-11-08 11:07 PM, Aaron Conole wrote:
> The act_ct TC module shares a common conntrack and NAT infrastructure
> exposed via netfilter.  It's possible that a packet needs both SNAT and
> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> this because it runs through the NAT table twice - once on ingress and
> again after egress.  The act_ct action doesn't have such capability.
> 
> Like netfilter hook infrastructure, we should run through NAT twice to
> keep the symmetry.
> 
> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  net/sched/act_ct.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index fcc46025e790..f3232a00970f 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>  			  bool commit)
>  {
>  #if IS_ENABLED(CONFIG_NF_NAT)
> +	int err;
>  	enum nf_nat_manip_type maniptype;
>  
>  	if (!(ct_action & TCA_CT_ACT_NAT))
> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>  		return NF_ACCEPT;
>  	}
>  
> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	if (err == NF_ACCEPT &&
> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> +		if (maniptype == NF_NAT_MANIP_SRC)
> +			maniptype = NF_NAT_MANIP_DST;
> +		else
> +			maniptype = NF_NAT_MANIP_SRC;
> +
> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	}
> +	return err;
>  #else
>  	return NF_ACCEPT;
>  #endif
> 

+paul

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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-14 14:22   ` Roi Dayan
@ 2019-11-14 14:24     ` Paul Blakey
  2019-11-18 21:24       ` Aaron Conole
  0 siblings, 1 reply; 17+ messages in thread
From: Paul Blakey @ 2019-11-14 14:24 UTC (permalink / raw)
  To: Roi Dayan, Aaron Conole, netdev
  Cc: Pravin B Shelar, David S . Miller, Jamal Hadi Salim, Cong Wang,
	Jiri Pirko, dev, linux-kernel

On 11/14/2019 4:22 PM, Roi Dayan wrote:
>
> On 2019-11-08 11:07 PM, Aaron Conole wrote:
>> The act_ct TC module shares a common conntrack and NAT infrastructure
>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>> this because it runs through the NAT table twice - once on ingress and
>> again after egress.  The act_ct action doesn't have such capability.
>>
>> Like netfilter hook infrastructure, we should run through NAT twice to
>> keep the symmetry.
>>
>> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
>>
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> ---
>>   net/sched/act_ct.c | 13 ++++++++++++-
>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
>> index fcc46025e790..f3232a00970f 100644
>> --- a/net/sched/act_ct.c
>> +++ b/net/sched/act_ct.c
>> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>   			  bool commit)
>>   {
>>   #if IS_ENABLED(CONFIG_NF_NAT)
>> +	int err;
>>   	enum nf_nat_manip_type maniptype;
>>   
>>   	if (!(ct_action & TCA_CT_ACT_NAT))
>> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>   		return NF_ACCEPT;
>>   	}
>>   
>> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	if (err == NF_ACCEPT &&
>> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
>> +		if (maniptype == NF_NAT_MANIP_SRC)
>> +			maniptype = NF_NAT_MANIP_DST;
>> +		else
>> +			maniptype = NF_NAT_MANIP_SRC;
>> +
>> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	}
>> +	return err;
>>   #else
>>   	return NF_ACCEPT;
>>   #endif
>>
> +paul

Hi Aaron,

I think I understand the issue and this looks good,

Can you describe the scenario to reproduce this?


Thanks,

Paul.




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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
  2019-11-14 14:22   ` Roi Dayan
@ 2019-11-14 16:29   ` Marcelo Ricardo Leitner
  2019-11-18 21:21     ` Aaron Conole
  1 sibling, 1 reply; 17+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-11-14 16:29 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel, paulb

On Fri, Nov 08, 2019 at 04:07:14PM -0500, Aaron Conole wrote:
> The act_ct TC module shares a common conntrack and NAT infrastructure
> exposed via netfilter.  It's possible that a packet needs both SNAT and
> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> this because it runs through the NAT table twice - once on ingress and
> again after egress.  The act_ct action doesn't have such capability.
> 
> Like netfilter hook infrastructure, we should run through NAT twice to
> keep the symmetry.
> 
> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  net/sched/act_ct.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index fcc46025e790..f3232a00970f 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>  			  bool commit)
>  {
>  #if IS_ENABLED(CONFIG_NF_NAT)
> +	int err;
>  	enum nf_nat_manip_type maniptype;
>  
>  	if (!(ct_action & TCA_CT_ACT_NAT))
> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>  		return NF_ACCEPT;
>  	}
>  
> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	if (err == NF_ACCEPT &&
> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> +		if (maniptype == NF_NAT_MANIP_SRC)
> +			maniptype = NF_NAT_MANIP_DST;
> +		else
> +			maniptype = NF_NAT_MANIP_SRC;
> +
> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	}

I keep thinking about this and I'm not entirely convinced that this
shouldn't be simpler. More like:

if (DNAT)
	DNAT
if (SNAT)
	SNAT

So it always does DNAT before SNAT, similarly to what iptables would
do on PRE/POSTROUTING chains.

> +	return err;
>  #else
>  	return NF_ACCEPT;
>  #endif
> -- 
> 2.21.0
> 

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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-09 22:15 ` [PATCH net 1/2] openvswitch: " Pravin Shelar
@ 2019-11-18 20:39   ` Aaron Conole
  2019-11-25 15:38     ` Aaron Conole
  0 siblings, 1 reply; 17+ messages in thread
From: Aaron Conole @ 2019-11-18 20:39 UTC (permalink / raw)
  To: Pravin Shelar
  Cc: Linux Kernel Network Developers, David S . Miller,
	Jamal Hadi Salim, Cong Wang, Jiri Pirko, ovs dev, linux-kernel

Pravin Shelar <pshelar@ovn.org> writes:

> On Fri, Nov 8, 2019 at 1:07 PM Aaron Conole <aconole@redhat.com> wrote:
>>
>> The openvswitch module shares a common conntrack and NAT infrastructure
>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>> this because it runs through the NAT table twice - once on ingress and
>> again after egress.  The openvswitch module doesn't have such capability.
>>
>> Like netfilter hook infrastructure, we should run through NAT twice to
>> keep the symmetry.
>>
>> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>
> The patch looks ok. But I am not able apply it. can you fix the encoding.

Hrrm.  I didn't make any special changes (just used git send-email).  I
will look at spinning a second patch.


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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-12  8:52 ` Nicolas Dichtel
@ 2019-11-18 21:19   ` Aaron Conole
  2019-11-28  8:22     ` Nicolas Dichtel
  0 siblings, 1 reply; 17+ messages in thread
From: Aaron Conole @ 2019-11-18 21:19 UTC (permalink / raw)
  To: Nicolas Dichtel
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel

Nicolas Dichtel <nicolas.dichtel@6wind.com> writes:

> Le 08/11/2019 à 22:07, Aaron Conole a écrit :
>> The openvswitch module shares a common conntrack and NAT infrastructure
>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>> this because it runs through the NAT table twice - once on ingress and
>> again after egress.  The openvswitch module doesn't have such capability.
>> 
>> Like netfilter hook infrastructure, we should run through NAT twice to
>> keep the symmetry.
>> 
>> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
> In this case, ovs_ct_find_existing() won't be able to find the
> conntrack, right?

vswitchd normally won't allow both actions to get programmed.  Even the
kernel module won't allow it, so this really will only happen when the
connection gets established via the nf_hook path, and then needs to be
processed via openvswitch.  In those cases, the tuple lookup should be
correct, because the nf_nat table should contain the correct tuple data,
and the skbuff should have the correct tuples in the packet data to
begin with.

> Inverting the tuple to find the conntrack doesn't work anymore with double NAT.
> Am I wrong?

I think since the packet was double-NAT on the way out (via nf_hook
path), then the incoming reply will have the correct NAT tuples and the
lookup will happen just fine.  Just that during processing, both
transformations aren't applied.

Makes sense?

> Regards,
> Nicolas


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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-14 16:29   ` Marcelo Ricardo Leitner
@ 2019-11-18 21:21     ` Aaron Conole
  2019-11-18 22:40       ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 17+ messages in thread
From: Aaron Conole @ 2019-11-18 21:21 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel, paulb

Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:

> On Fri, Nov 08, 2019 at 04:07:14PM -0500, Aaron Conole wrote:
>> The act_ct TC module shares a common conntrack and NAT infrastructure
>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>> this because it runs through the NAT table twice - once on ingress and
>> again after egress.  The act_ct action doesn't have such capability.
>> 
>> Like netfilter hook infrastructure, we should run through NAT twice to
>> keep the symmetry.
>> 
>> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
>> 
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> ---
>>  net/sched/act_ct.c | 13 ++++++++++++-
>>  1 file changed, 12 insertions(+), 1 deletion(-)
>> 
>> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
>> index fcc46025e790..f3232a00970f 100644
>> --- a/net/sched/act_ct.c
>> +++ b/net/sched/act_ct.c
>> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>  			  bool commit)
>>  {
>>  #if IS_ENABLED(CONFIG_NF_NAT)
>> +	int err;
>>  	enum nf_nat_manip_type maniptype;
>>  
>>  	if (!(ct_action & TCA_CT_ACT_NAT))
>> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>  		return NF_ACCEPT;
>>  	}
>>  
>> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	if (err == NF_ACCEPT &&
>> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
>> +		if (maniptype == NF_NAT_MANIP_SRC)
>> +			maniptype = NF_NAT_MANIP_DST;
>> +		else
>> +			maniptype = NF_NAT_MANIP_SRC;
>> +
>> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> +	}
>
> I keep thinking about this and I'm not entirely convinced that this
> shouldn't be simpler. More like:
>
> if (DNAT)
> 	DNAT
> if (SNAT)
> 	SNAT
>
> So it always does DNAT before SNAT, similarly to what iptables would
> do on PRE/POSTROUTING chains.

I can rewrite the whole function, but I wanted to start with the smaller
fix that worked.  I also think it needs more testing then (since it's
something of a rewrite of the function).

I guess it's not too important - do you think it gives any readability
to do it this way?  If so, I can respin the patch changing it like you
describe.

>> +	return err;
>>  #else
>>  	return NF_ACCEPT;
>>  #endif
>> -- 
>> 2.21.0
>> 


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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-14 14:24     ` Paul Blakey
@ 2019-11-18 21:24       ` Aaron Conole
  0 siblings, 0 replies; 17+ messages in thread
From: Aaron Conole @ 2019-11-18 21:24 UTC (permalink / raw)
  To: Paul Blakey
  Cc: Roi Dayan, netdev, Pravin B Shelar, David S . Miller,
	Jamal Hadi Salim, Cong Wang, Jiri Pirko, dev, linux-kernel

Paul Blakey <paulb@mellanox.com> writes:

> On 11/14/2019 4:22 PM, Roi Dayan wrote:
>>
>> On 2019-11-08 11:07 PM, Aaron Conole wrote:
>>> The act_ct TC module shares a common conntrack and NAT infrastructure
>>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>>> this because it runs through the NAT table twice - once on ingress and
>>> again after egress.  The act_ct action doesn't have such capability.
>>>
>>> Like netfilter hook infrastructure, we should run through NAT twice to
>>> keep the symmetry.
>>>
>>> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
>>>
>>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>>> ---
>>>   net/sched/act_ct.c | 13 ++++++++++++-
>>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
>>> index fcc46025e790..f3232a00970f 100644
>>> --- a/net/sched/act_ct.c
>>> +++ b/net/sched/act_ct.c
>>> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>>   			  bool commit)
>>>   {
>>>   #if IS_ENABLED(CONFIG_NF_NAT)
>>> +	int err;
>>>   	enum nf_nat_manip_type maniptype;
>>>   
>>>   	if (!(ct_action & TCA_CT_ACT_NAT))
>>> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>>>   		return NF_ACCEPT;
>>>   	}
>>>   
>>> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>>> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>>> +	if (err == NF_ACCEPT &&
>>> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
>>> +		if (maniptype == NF_NAT_MANIP_SRC)
>>> +			maniptype = NF_NAT_MANIP_DST;
>>> +		else
>>> +			maniptype = NF_NAT_MANIP_SRC;
>>> +
>>> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>>> +	}
>>> +	return err;
>>>   #else
>>>   	return NF_ACCEPT;
>>>   #endif
>>>
>> +paul
>
> Hi Aaron,
>
> I think I understand the issue and this looks good,
>
> Can you describe the scenario to reproduce this?

It reproduces with OpenShift 3.10, which makes forward direction packets
between namespaces pump through a tun device that applies NAT rules to
rewrite the dest.  Limit the namespace number of ephemeral sockets using
by editing net.ipv4.ip_local_port_range in the client namespace, and
connect to the server namespace.  That's the mechanism for OvS.  But for
TC I guess there wouldn't be anything convenient avaiable.

I'll try to script up something that doesn't use openshift.

>
> Thanks,
>
> Paul.


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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-18 21:21     ` Aaron Conole
@ 2019-11-18 22:40       ` Marcelo Ricardo Leitner
  2019-11-22 20:39         ` Aaron Conole
  0 siblings, 1 reply; 17+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-11-18 22:40 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel, paulb,
	Florian Westphal

On Mon, Nov 18, 2019 at 04:21:39PM -0500, Aaron Conole wrote:
> Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:
> 
> > On Fri, Nov 08, 2019 at 04:07:14PM -0500, Aaron Conole wrote:
> >> The act_ct TC module shares a common conntrack and NAT infrastructure
> >> exposed via netfilter.  It's possible that a packet needs both SNAT and
> >> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> >> this because it runs through the NAT table twice - once on ingress and
> >> again after egress.  The act_ct action doesn't have such capability.
> >> 
> >> Like netfilter hook infrastructure, we should run through NAT twice to
> >> keep the symmetry.
> >> 
> >> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
> >> 
> >> Signed-off-by: Aaron Conole <aconole@redhat.com>
> >> ---
> >>  net/sched/act_ct.c | 13 ++++++++++++-
> >>  1 file changed, 12 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> >> index fcc46025e790..f3232a00970f 100644
> >> --- a/net/sched/act_ct.c
> >> +++ b/net/sched/act_ct.c
> >> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
> >>  			  bool commit)
> >>  {
> >>  #if IS_ENABLED(CONFIG_NF_NAT)
> >> +	int err;
> >>  	enum nf_nat_manip_type maniptype;
> >>  
> >>  	if (!(ct_action & TCA_CT_ACT_NAT))
> >> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
> >>  		return NF_ACCEPT;
> >>  	}
> >>  
> >> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> +	if (err == NF_ACCEPT &&
> >> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> >> +		if (maniptype == NF_NAT_MANIP_SRC)
> >> +			maniptype = NF_NAT_MANIP_DST;
> >> +		else
> >> +			maniptype = NF_NAT_MANIP_SRC;
> >> +
> >> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> +	}
> >
> > I keep thinking about this and I'm not entirely convinced that this
> > shouldn't be simpler. More like:
> >
> > if (DNAT)
> > 	DNAT
> > if (SNAT)
> > 	SNAT
> >
> > So it always does DNAT before SNAT, similarly to what iptables would
> > do on PRE/POSTROUTING chains.
> 
> I can rewrite the whole function, but I wanted to start with the smaller
> fix that worked.  I also think it needs more testing then (since it's
> something of a rewrite of the function).
> 
> I guess it's not too important - do you think it gives any readability
> to do it this way?  If so, I can respin the patch changing it like you
> describe.

I didn't mean a rewrite, but just to never handle SNAT before DNAT. So
the fix here would be like:

-	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	if (err == NF_ACCEPT && maniptype == NF_NAT_MANIP_DST &&
+	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
+		maniptype = NF_NAT_MANIP_SRC;
+		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
+	}
+	return err;

> >> +	return err;
> >>  #else
> >>  	return NF_ACCEPT;
> >>  #endif
> >> -- 
> >> 2.21.0
> >> 
> 

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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-18 22:40       ` Marcelo Ricardo Leitner
@ 2019-11-22 20:39         ` Aaron Conole
  2019-11-22 20:43           ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 17+ messages in thread
From: Aaron Conole @ 2019-11-22 20:39 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel, paulb,
	Florian Westphal

Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:

> On Mon, Nov 18, 2019 at 04:21:39PM -0500, Aaron Conole wrote:
>> Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:
>> 
>> > On Fri, Nov 08, 2019 at 04:07:14PM -0500, Aaron Conole wrote:
>> >> The act_ct TC module shares a common conntrack and NAT infrastructure
>> >> exposed via netfilter.  It's possible that a packet needs both SNAT and
>> >> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>> >> this because it runs through the NAT table twice - once on ingress and
>> >> again after egress.  The act_ct action doesn't have such capability.
>> >> 
>> >> Like netfilter hook infrastructure, we should run through NAT twice to
>> >> keep the symmetry.
>> >> 
>> >> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
>> >> 
>> >> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> >> ---
>> >>  net/sched/act_ct.c | 13 ++++++++++++-
>> >>  1 file changed, 12 insertions(+), 1 deletion(-)
>> >> 
>> >> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
>> >> index fcc46025e790..f3232a00970f 100644
>> >> --- a/net/sched/act_ct.c
>> >> +++ b/net/sched/act_ct.c
>> >> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>> >>  			  bool commit)
>> >>  {
>> >>  #if IS_ENABLED(CONFIG_NF_NAT)
>> >> +	int err;
>> >>  	enum nf_nat_manip_type maniptype;
>> >>  
>> >>  	if (!(ct_action & TCA_CT_ACT_NAT))
>> >> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
>> >>  		return NF_ACCEPT;
>> >>  	}
>> >>  
>> >> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> >> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> >> +	if (err == NF_ACCEPT &&
>> >> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
>> >> +		if (maniptype == NF_NAT_MANIP_SRC)
>> >> +			maniptype = NF_NAT_MANIP_DST;
>> >> +		else
>> >> +			maniptype = NF_NAT_MANIP_SRC;
>> >> +
>> >> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
>> >> +	}
>> >
>> > I keep thinking about this and I'm not entirely convinced that this
>> > shouldn't be simpler. More like:
>> >
>> > if (DNAT)
>> > 	DNAT
>> > if (SNAT)
>> > 	SNAT
>> >
>> > So it always does DNAT before SNAT, similarly to what iptables would
>> > do on PRE/POSTROUTING chains.
>> 
>> I can rewrite the whole function, but I wanted to start with the smaller
>> fix that worked.  I also think it needs more testing then (since it's
>> something of a rewrite of the function).
>> 
>> I guess it's not too important - do you think it gives any readability
>> to do it this way?  If so, I can respin the patch changing it like you
>> describe.
>
> I didn't mean a rewrite, but just to never handle SNAT before DNAT. So
> the fix here would be like:
>
> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	if (err == NF_ACCEPT && maniptype == NF_NAT_MANIP_DST &&
> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> +		maniptype = NF_NAT_MANIP_SRC;
> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> +	}
> +	return err;

But the maniptype of the first call could be NAT_MANIP_SRC.  In fact,
that's what I see if the packet is reply direction && !related.

So, we need the block to invert the manipulation type.  Otherwise, we
miss the DNAT manipulation.

So I don't think I can use that block.

>> >> +	return err;
>> >>  #else
>> >>  	return NF_ACCEPT;
>> >>  #endif
>> >> -- 
>> >> 2.21.0
>> >> 
>> 


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

* Re: [PATCH net 2/2] act_ct: support asymmetric conntrack
  2019-11-22 20:39         ` Aaron Conole
@ 2019-11-22 20:43           ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 17+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-11-22 20:43 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel, paulb,
	Florian Westphal

On Fri, Nov 22, 2019 at 03:39:16PM -0500, Aaron Conole wrote:
> Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:
> 
> > On Mon, Nov 18, 2019 at 04:21:39PM -0500, Aaron Conole wrote:
> >> Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> writes:
> >> 
> >> > On Fri, Nov 08, 2019 at 04:07:14PM -0500, Aaron Conole wrote:
> >> >> The act_ct TC module shares a common conntrack and NAT infrastructure
> >> >> exposed via netfilter.  It's possible that a packet needs both SNAT and
> >> >> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> >> >> this because it runs through the NAT table twice - once on ingress and
> >> >> again after egress.  The act_ct action doesn't have such capability.
> >> >> 
> >> >> Like netfilter hook infrastructure, we should run through NAT twice to
> >> >> keep the symmetry.
> >> >> 
> >> >> Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
> >> >> 
> >> >> Signed-off-by: Aaron Conole <aconole@redhat.com>
> >> >> ---
> >> >>  net/sched/act_ct.c | 13 ++++++++++++-
> >> >>  1 file changed, 12 insertions(+), 1 deletion(-)
> >> >> 
> >> >> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> >> >> index fcc46025e790..f3232a00970f 100644
> >> >> --- a/net/sched/act_ct.c
> >> >> +++ b/net/sched/act_ct.c
> >> >> @@ -329,6 +329,7 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
> >> >>  			  bool commit)
> >> >>  {
> >> >>  #if IS_ENABLED(CONFIG_NF_NAT)
> >> >> +	int err;
> >> >>  	enum nf_nat_manip_type maniptype;
> >> >>  
> >> >>  	if (!(ct_action & TCA_CT_ACT_NAT))
> >> >> @@ -359,7 +360,17 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
> >> >>  		return NF_ACCEPT;
> >> >>  	}
> >> >>  
> >> >> -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> >> +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> >> +	if (err == NF_ACCEPT &&
> >> >> +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> >> >> +		if (maniptype == NF_NAT_MANIP_SRC)
> >> >> +			maniptype = NF_NAT_MANIP_DST;
> >> >> +		else
> >> >> +			maniptype = NF_NAT_MANIP_SRC;
> >> >> +
> >> >> +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> >> >> +	}
> >> >
> >> > I keep thinking about this and I'm not entirely convinced that this
> >> > shouldn't be simpler. More like:
> >> >
> >> > if (DNAT)
> >> > 	DNAT
> >> > if (SNAT)
> >> > 	SNAT
> >> >
> >> > So it always does DNAT before SNAT, similarly to what iptables would
> >> > do on PRE/POSTROUTING chains.
> >> 
> >> I can rewrite the whole function, but I wanted to start with the smaller
> >> fix that worked.  I also think it needs more testing then (since it's
> >> something of a rewrite of the function).
> >> 
> >> I guess it's not too important - do you think it gives any readability
> >> to do it this way?  If so, I can respin the patch changing it like you
> >> describe.
> >
> > I didn't mean a rewrite, but just to never handle SNAT before DNAT. So
> > the fix here would be like:
> >
> > -	return ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> > +	err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> > +	if (err == NF_ACCEPT && maniptype == NF_NAT_MANIP_DST &&
> > +	    ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
> > +		maniptype = NF_NAT_MANIP_SRC;
> > +		err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
> > +	}
> > +	return err;
> 
> But the maniptype of the first call could be NAT_MANIP_SRC.  In fact,
> that's what I see if the packet is reply direction && !related.

Interesting, ok.

> 
> So, we need the block to invert the manipulation type.  Otherwise, we
> miss the DNAT manipulation.
> 
> So I don't think I can use that block.

Thanks for digging on it.

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> 
> >> >> +	return err;
> >> >>  #else
> >> >>  	return NF_ACCEPT;
> >> >>  #endif
> >> >> -- 
> >> >> 2.21.0
> >> >> 
> >> 
> 

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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-18 20:39   ` Aaron Conole
@ 2019-11-25 15:38     ` Aaron Conole
  2019-11-26  4:07       ` Pravin Shelar
  0 siblings, 1 reply; 17+ messages in thread
From: Aaron Conole @ 2019-11-25 15:38 UTC (permalink / raw)
  To: Pravin Shelar
  Cc: Linux Kernel Network Developers, David S . Miller,
	Jamal Hadi Salim, Cong Wang, Jiri Pirko, ovs dev, linux-kernel

Aaron Conole <aconole@redhat.com> writes:

> Pravin Shelar <pshelar@ovn.org> writes:
>
>> On Fri, Nov 8, 2019 at 1:07 PM Aaron Conole <aconole@redhat.com> wrote:
>>>
>>> The openvswitch module shares a common conntrack and NAT infrastructure
>>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>>> this because it runs through the NAT table twice - once on ingress and
>>> again after egress.  The openvswitch module doesn't have such capability.
>>>
>>> Like netfilter hook infrastructure, we should run through NAT twice to
>>> keep the symmetry.
>>>
>>> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
>>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>>
>> The patch looks ok. But I am not able apply it. can you fix the encoding.
>
> Hrrm.  I didn't make any special changes (just used git send-email).  I
> will look at spinning a second patch.

Pravin,

I tried the following:

  10:36:59 aconole@dhcp-25 {(312434617cb1...)} ~/git/linux$ curl http://patchwork.ozlabs.org/patch/1192219/mbox/ > test.patch
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  100  4827  100  4827    0     0   8824      0 --:--:-- --:--:-- --:--:--  8808
  10:37:21 aconole@dhcp-25 {(312434617cb1...)} ~/git/linux$ git am test.patch
  Applying: openvswitch: support asymmetric conntrack
  10:37:24 aconole@dhcp-25 {(f759cc2b7323...)} ~/git/linux$ 


Can you check your mailer settings?  The patchwork mbox worked fine, and
I was able to apply from my own mbox as well.

-Aaron


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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-25 15:38     ` Aaron Conole
@ 2019-11-26  4:07       ` Pravin Shelar
  0 siblings, 0 replies; 17+ messages in thread
From: Pravin Shelar @ 2019-11-26  4:07 UTC (permalink / raw)
  To: Aaron Conole
  Cc: Linux Kernel Network Developers, David S . Miller,
	Jamal Hadi Salim, Cong Wang, Jiri Pirko, ovs dev, linux-kernel

Downloading from patchwork is working for me. Its strange other
patches in my mailbox does not has this issue.

Thanks.

On Mon, Nov 25, 2019 at 7:39 AM Aaron Conole <aconole@redhat.com> wrote:
>
> Aaron Conole <aconole@redhat.com> writes:
>
> > Pravin Shelar <pshelar@ovn.org> writes:
> >
> >> On Fri, Nov 8, 2019 at 1:07 PM Aaron Conole <aconole@redhat.com> wrote:
> >>>
> >>> The openvswitch module shares a common conntrack and NAT infrastructure
> >>> exposed via netfilter.  It's possible that a packet needs both SNAT and
> >>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
> >>> this because it runs through the NAT table twice - once on ingress and
> >>> again after egress.  The openvswitch module doesn't have such capability.
> >>>
> >>> Like netfilter hook infrastructure, we should run through NAT twice to
> >>> keep the symmetry.
> >>>
> >>> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
> >>> Signed-off-by: Aaron Conole <aconole@redhat.com>
> >>
> >> The patch looks ok. But I am not able apply it. can you fix the encoding.
> >
> > Hrrm.  I didn't make any special changes (just used git send-email).  I
> > will look at spinning a second patch.
>
> Pravin,
>
> I tried the following:
>
>   10:36:59 aconole@dhcp-25 {(312434617cb1...)} ~/git/linux$ curl http://patchwork.ozlabs.org/patch/1192219/mbox/ > test.patch
>     % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
>                                    Dload  Upload   Total   Spent    Left  Speed
>   100  4827  100  4827    0     0   8824      0 --:--:-- --:--:-- --:--:--  8808
>   10:37:21 aconole@dhcp-25 {(312434617cb1...)} ~/git/linux$ git am test.patch
>   Applying: openvswitch: support asymmetric conntrack
>   10:37:24 aconole@dhcp-25 {(f759cc2b7323...)} ~/git/linux$
>
>
> Can you check your mailer settings?  The patchwork mbox worked fine, and
> I was able to apply from my own mbox as well.
>
> -Aaron
>

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

* Re: [PATCH net 1/2] openvswitch: support asymmetric conntrack
  2019-11-18 21:19   ` Aaron Conole
@ 2019-11-28  8:22     ` Nicolas Dichtel
  0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Dichtel @ 2019-11-28  8:22 UTC (permalink / raw)
  To: Aaron Conole
  Cc: netdev, Pravin B Shelar, David S . Miller, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, dev, linux-kernel

Le 18/11/2019 à 22:19, Aaron Conole a écrit :
> Nicolas Dichtel <nicolas.dichtel@6wind.com> writes:
> 
>> Le 08/11/2019 à 22:07, Aaron Conole a écrit :
>>> The openvswitch module shares a common conntrack and NAT infrastructure
>>> exposed via netfilter.  It's possible that a packet needs both SNAT and
>>> DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
>>> this because it runs through the NAT table twice - once on ingress and
>>> again after egress.  The openvswitch module doesn't have such capability.
>>>
>>> Like netfilter hook infrastructure, we should run through NAT twice to
>>> keep the symmetry.
>>>
>>> Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
>>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> In this case, ovs_ct_find_existing() won't be able to find the
>> conntrack, right?
> 
> vswitchd normally won't allow both actions to get programmed.  Even the
> kernel module won't allow it, so this really will only happen when the
> connection gets established via the nf_hook path, and then needs to be
> processed via openvswitch.  In those cases, the tuple lookup should be
> correct, because the nf_nat table should contain the correct tuple data,
> and the skbuff should have the correct tuples in the packet data to
> begin with.
> 
>> Inverting the tuple to find the conntrack doesn't work anymore with double NAT.
>> Am I wrong?
> 
> I think since the packet was double-NAT on the way out (via nf_hook
> path), then the incoming reply will have the correct NAT tuples and the
> lookup will happen just fine.  Just that during processing, both
> transformations aren't applied.
Ok, I didn't look deeply, thank you for the explanation.

Regards,
Nicolas

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

end of thread, other threads:[~2019-11-28  8:22 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 21:07 [PATCH net 1/2] openvswitch: support asymmetric conntrack Aaron Conole
2019-11-08 21:07 ` [PATCH net 2/2] act_ct: " Aaron Conole
2019-11-14 14:22   ` Roi Dayan
2019-11-14 14:24     ` Paul Blakey
2019-11-18 21:24       ` Aaron Conole
2019-11-14 16:29   ` Marcelo Ricardo Leitner
2019-11-18 21:21     ` Aaron Conole
2019-11-18 22:40       ` Marcelo Ricardo Leitner
2019-11-22 20:39         ` Aaron Conole
2019-11-22 20:43           ` Marcelo Ricardo Leitner
2019-11-09 22:15 ` [PATCH net 1/2] openvswitch: " Pravin Shelar
2019-11-18 20:39   ` Aaron Conole
2019-11-25 15:38     ` Aaron Conole
2019-11-26  4:07       ` Pravin Shelar
2019-11-12  8:52 ` Nicolas Dichtel
2019-11-18 21:19   ` Aaron Conole
2019-11-28  8:22     ` Nicolas Dichtel

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).