diff options
author | Eelco Chaudron <echaudro@redhat.com> | 2021-05-18 06:17:48 -0400 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-03-18 17:29:31 +0100 |
commit | 69645206b829ea7299f96a0e828e6ec161453553 (patch) | |
tree | 7d5fe77132f2fc5ab731c0bf9fc489e5f79e1b5e | |
parent | 9fa59d4569715e50c38150070bbc63ffeae0a394 (diff) | |
download | openvswitch-69645206b829ea7299f96a0e828e6ec161453553.tar.gz |
ofproto-dpif-xlate: Avoid successive ct_clear datapath actions.
Due to flow lookup optimizations, especially in the resubmit/clone cases,
we might end up with multiple ct_clear actions, which are not necessary.
This patch only adds the ct_clear action to the datapath if any ct state
is tracked.
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r-- | ofproto/ofproto-dpif-xlate.c | 4 | ||||
-rw-r--r-- | tests/ofproto-dpif.at | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 0189a1ae8..2ec1f4eb8 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -7139,7 +7139,9 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, break; case OFPACT_CT_CLEAR: - compose_ct_clear_action(ctx); + if (ctx->conntracked) { + compose_ct_clear_action(ctx); + } break; case OFPACT_NAT: diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 0dc2ef7dc..70a4f6b8a 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -10708,6 +10708,31 @@ dnl NXT_PACKET_IN (xid=0x0): table_id=1 cookie=0x0 total_len=106 in_port=2 (via action) data_len=106 (unbuffered) udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:0a,dl_dst=50:54:00:00:00:09,nw_src=10.1.1.2,nw_dst=10.1.1.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=2,tp_dst=1 udp_csum:553 ]) + +dnl The next test verifies that ct_clear at the datapath only gets executed +dnl if conntrack information is present. +AT_DATA([flows.txt], [dnl +table=0 in_port=1 actions=ct_clear,ct_clear,ct_clear,p2 +]) +AT_CHECK([ovs-ofctl del-flows br0]) +AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) +AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=p1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: 2 +]) +AT_DATA([flows.txt], [dnl +table=0 in_port=1 ip actions=ct_clear,ct(table=1) +table=1 in_port=1 actions=ct_clear,ct_clear,goto_table:2 +table=2 in_port=1 actions=ct_clear,p2 +]) +AT_CHECK([ovs-ofctl del-flows br0]) +AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) +AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=p1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2'], [0], [stdout]) +AT_CHECK([grep Datapath stdout | sed 's/recirc(.*)/recirc(X)/'], [0], + [Datapath actions: ct,recirc(X) +Datapath actions: ct_clear,2 +]) + OVS_VSWITCHD_STOP AT_CLEANUP |