Skip to content

Commit 13c62f5

Browse files
marceloleitnerdavem330
authored andcommitted
net/sched: act_ct: handle DNAT tuple collision
This this the counterpart of 8aa7b52 ("openvswitch: handle DNAT tuple collision") for act_ct. From that commit changelog: """ With multiple DNAT rules it's possible that after destination translation the resulting tuples collide. ... Netfilter handles this case by allocating a null binding for SNAT at egress by default. Perform the same operation in openvswitch for DNAT if no explicit SNAT is requested by the user and allocate a null binding for SNAT for packets in the "original" direction. """ Fixes: 95219af ("act_ct: support asymmetric conntrack") Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d2e381c commit 13c62f5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

net/sched/act_ct.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -904,14 +904,19 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
904904
}
905905

906906
err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
907-
if (err == NF_ACCEPT &&
908-
ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) {
909-
if (maniptype == NF_NAT_MANIP_SRC)
910-
maniptype = NF_NAT_MANIP_DST;
911-
else
912-
maniptype = NF_NAT_MANIP_SRC;
913-
914-
err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
907+
if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) {
908+
if (ct->status & IPS_SRC_NAT) {
909+
if (maniptype == NF_NAT_MANIP_SRC)
910+
maniptype = NF_NAT_MANIP_DST;
911+
else
912+
maniptype = NF_NAT_MANIP_SRC;
913+
914+
err = ct_nat_execute(skb, ct, ctinfo, range,
915+
maniptype);
916+
} else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) {
917+
err = ct_nat_execute(skb, ct, ctinfo, NULL,
918+
NF_NAT_MANIP_SRC);
919+
}
915920
}
916921
return err;
917922
#else

0 commit comments

Comments
 (0)