Skip to contentSkip to conversation

net/sched: act_ct: add nat mangle action only for NAT-conntrack

PATCH Applied [email protected] 3 participants 3 messages May 30, 2020 – May 31, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/sched: act_ct: add nat mangle action only for NAT-conntrack

From: wenxu <[email protected]>

Currently add nat mangle action with comparing invert and ori tuple. It is better to check IPS_NAT_MASK flags first to avoid non necessary memcmp for non-NAT conntrack.

---
 net/sched/act_ct.c | 3 +++
 1 file changed, 3 insertions(+)
net/sched/act_ct.c +3 -0
index 1a76639..2057735 100644
@@ -199,6 +199,9 @@ static int tcf_ct_flow_table_add_action_nat(struct net *net,
 	const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
 	struct nf_conntrack_tuple target;
 
+	if (!(ct->status & IPS_NAT_MASK))
+		return 0;
+
 	nf_ct_invert_tuple(&target, &ct->tuplehash[!dir].tuple);
 
 	switch (tuple->src.l3num) {
Signature · 1 line
1.8.3.1
Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · On Sat, May 30, 2020 at 01:54:51PM +0800, [email protected] wrote:

From: wenxu <[email protected]>

Currently add nat mangle action with comparing invert and ori tuple.

                                                Nit, "orig" ---^
Quoted 4 lines

It is better to check IPS_NAT_MASK flags first to avoid non necessary memcmp for non-NAT conntrack.

Quoted 21 lines
---
 net/sched/act_ct.c | 3 +++
 1 file changed, 3 insertions(+)
net/sched/act_ct.c +3 -0
index 1a76639..2057735 100644
@@ -199,6 +199,9 @@ static int tcf_ct_flow_table_add_action_nat(struct net *net,
 	const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
 	struct nf_conntrack_tuple target;
 
+	if (!(ct->status & IPS_NAT_MASK))
+		return 0;
+
 	nf_ct_invert_tuple(&target, &ct->tuplehash[!dir].tuple);
 
 	switch (tuple->src.l3num) {
Signature · 1 line
1.8.3.1