get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1556762/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1556762,
    "url": "http://patchwork.ozlabs.org/api/patches/1556762/",
    "web_url": "http://patchwork.ozlabs.org/project/ovn/patch/20211118181331.93028-1-numans@ovn.org/",
    "project": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/projects/68/",
        "name": "Open Virtual Network development",
        "link_name": "ovn",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20211118181331.93028-1-numans@ovn.org>",
    "list_archive_url": null,
    "date": "2021-11-18T18:13:31",
    "name": "[ovs-dev,v2,2/2] northd: Use ct_(snat/dnat)_in_czone action for distributed routers.",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "991d3c9a6a9f68430649cadf39a0cb3df31e6740",
    "submitter": {
        "id": 77669,
        "url": "http://patchwork.ozlabs.org/api/people/77669/",
        "name": "Numan Siddique",
        "email": "numans@ovn.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/ovn/patch/20211118181331.93028-1-numans@ovn.org/mbox/",
    "series": [
        {
            "id": 272745,
            "url": "http://patchwork.ozlabs.org/api/series/272745/",
            "web_url": "http://patchwork.ozlabs.org/project/ovn/list/?series=272745",
            "date": "2021-11-18T18:13:05",
            "name": "[ovs-dev,v2,1/2] actions: Add new actions - ct_dnat_in_czone and ct_snat_in_czone.",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/272745/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1556762/comments/",
    "check": "fail",
    "checks": "http://patchwork.ozlabs.org/api/patches/1556762/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=140.211.166.138; helo=smtp1.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
        "Received": [
            "from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hw7GY4xWTz9sPf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 19 Nov 2021 05:13:57 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id E9B2E80D32;\n\tThu, 18 Nov 2021 18:13:55 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n\tby localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 1BjxdMscOT4y; Thu, 18 Nov 2021 18:13:53 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp1.osuosl.org (Postfix) with ESMTPS id 6432180C9B;\n\tThu, 18 Nov 2021 18:13:52 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 3133CC0031;\n\tThu, 18 Nov 2021 18:13:52 +0000 (UTC)",
            "from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 5AF56C002E\n for <dev@openvswitch.org>; Thu, 18 Nov 2021 18:13:51 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 29FD9405D6\n for <dev@openvswitch.org>; Thu, 18 Nov 2021 18:13:49 +0000 (UTC)",
            "from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id JtI0FJWyUWxv for <dev@openvswitch.org>;\n Thu, 18 Nov 2021 18:13:46 +0000 (UTC)",
            "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n [217.70.183.198])\n by smtp4.osuosl.org (Postfix) with ESMTPS id EE75140386\n for <dev@openvswitch.org>; Thu, 18 Nov 2021 18:13:45 +0000 (UTC)",
            "(Authenticated sender: numans@ovn.org)\n by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id ED535C000F;\n Thu, 18 Nov 2021 18:13:42 +0000 (UTC)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "From": "numans@ovn.org",
        "To": "dev@openvswitch.org",
        "Date": "Thu, 18 Nov 2021 13:13:31 -0500",
        "Message-Id": "<20211118181331.93028-1-numans@ovn.org>",
        "X-Mailer": "git-send-email 2.33.1",
        "MIME-Version": "1.0",
        "Subject": "[ovs-dev] [PATCH ovn v2 2/2] northd: Use ct_(snat/dnat)_in_czone\n\taction for distributed routers.",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "From: Numan Siddique <numans@ovn.org>\n\nMake of use of these new actions for the distributed routers\nfor NAT.  These new actions ensure that both sNAT and dNAT\nhappens in the same zone.  This approach solves a couple of\nproblems:\n\n - The datapath flows generated for external traffic which requires\n   dNAT (N -> S) or sNAT (S -> N) are completely HWOL'able.\n\n - Since there is only one zone, it would avoid multiple recirculations\n   (improving the performance).\n\nIf the packet needs to be both sNATted and dNATted (for hairpin traffic\nwith source and destination on the same chassis), then sNAT is done\nin a separate zone.  To detect this scenario, this patch adds a few\nextra logical flows.  For each dnat_and_snat entry prior to this patch\novn-northd was generating 9 logical flows and with this patch it now\ngenerates 12 logical flows.\n\nSimilar approach can be taken for gateway routers.\n\nReported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1984953\nSigned-off-by: Numan Siddique <numans@ovn.org>\n---\n\nv1 -> v2\n------\n  * Rebased and resolved conflicts.\n\n include/ovn/logical-fields.h |   1 +\n lib/logical-fields.c         |   4 +\n northd/northd.c              | 147 +++++++--\n northd/ovn-northd.8.xml      | 201 +++++++++---\n tests/ovn-northd.at          | 575 +++++++++++++++++++----------------\n tests/ovn.at                 |   2 +-\n tests/system-ovn.at          |  64 ++--\n 7 files changed, 607 insertions(+), 387 deletions(-)",
    "diff": "diff --git a/include/ovn/logical-fields.h b/include/ovn/logical-fields.h\nindex c9675f81c..2118f7933 100644\n--- a/include/ovn/logical-fields.h\n+++ b/include/ovn/logical-fields.h\n@@ -70,6 +70,7 @@ enum mff_log_flags_bits {\n     MLF_LOOKUP_FDB_BIT = 8,\n     MLF_SKIP_SNAT_FOR_LB_BIT = 9,\n     MLF_LOCALPORT_BIT = 10,\n+    MLF_USE_SNAT_ZONE = 11,\n };\n \n /* MFF_LOG_FLAGS_REG flag assignments */\ndiff --git a/lib/logical-fields.c b/lib/logical-fields.c\nindex 7b3d431e0..352a48c89 100644\n--- a/lib/logical-fields.c\n+++ b/lib/logical-fields.c\n@@ -125,6 +125,10 @@ ovn_init_symtab(struct shash *symtab)\n              MLF_SKIP_SNAT_FOR_LB_BIT);\n     expr_symtab_add_subfield(symtab, \"flags.skip_snat_for_lb\", NULL,\n                              flags_str);\n+    snprintf(flags_str, sizeof flags_str, \"flags[%d]\",\n+             MLF_USE_SNAT_ZONE);\n+    expr_symtab_add_subfield(symtab, \"flags.use_snat_zone\", NULL,\n+                             flags_str);\n \n     /* Connection tracking state. */\n     expr_symtab_add_field_scoped(symtab, \"ct_mark\", MFF_CT_MARK, NULL, false,\ndiff --git a/northd/northd.c b/northd/northd.c\nindex 0ff61deec..e4d051a94 100644\n--- a/northd/northd.c\n+++ b/northd/northd.c\n@@ -159,11 +159,14 @@ enum ovn_stage {\n     PIPELINE_STAGE(ROUTER, IN,  ARP_REQUEST,     18, \"lr_in_arp_request\")  \\\n                                                                       \\\n     /* Logical router egress stages. */                               \\\n-    PIPELINE_STAGE(ROUTER, OUT, UNDNAT,      0, \"lr_out_undnat\")        \\\n-    PIPELINE_STAGE(ROUTER, OUT, POST_UNDNAT, 1, \"lr_out_post_undnat\")   \\\n-    PIPELINE_STAGE(ROUTER, OUT, SNAT,        2, \"lr_out_snat\")          \\\n-    PIPELINE_STAGE(ROUTER, OUT, EGR_LOOP,    3, \"lr_out_egr_loop\")      \\\n-    PIPELINE_STAGE(ROUTER, OUT, DELIVERY,    4, \"lr_out_delivery\")\n+    PIPELINE_STAGE(ROUTER, OUT, CHECK_DNAT_LOCAL,   0,                       \\\n+                   \"lr_out_chk_dnat_local\")                                  \\\n+    PIPELINE_STAGE(ROUTER, OUT, UNDNAT,             1, \"lr_out_undnat\")      \\\n+    PIPELINE_STAGE(ROUTER, OUT, POST_UNDNAT,        2, \"lr_out_post_undnat\") \\\n+    PIPELINE_STAGE(ROUTER, OUT, SNAT,               3, \"lr_out_snat\")        \\\n+    PIPELINE_STAGE(ROUTER, OUT, POST_SNAT,          4, \"lr_out_post_snat\")   \\\n+    PIPELINE_STAGE(ROUTER, OUT, EGR_LOOP,           5, \"lr_out_egr_loop\")    \\\n+    PIPELINE_STAGE(ROUTER, OUT, DELIVERY,           6, \"lr_out_delivery\")\n \n #define PIPELINE_STAGE(DP_TYPE, PIPELINE, STAGE, TABLE, NAME)   \\\n     S_##DP_TYPE##_##PIPELINE##_##STAGE                          \\\n@@ -210,6 +213,7 @@ enum ovn_stage {\n #define REGBIT_PKT_LARGER        \"reg9[1]\"\n #define REGBIT_LOOKUP_NEIGHBOR_RESULT \"reg9[2]\"\n #define REGBIT_LOOKUP_NEIGHBOR_IP_RESULT \"reg9[3]\"\n+#define REGBIT_DST_NAT_IP_LOCAL \"reg9[4]\"\n \n /* Register to store the eth address associated to a router port for packets\n  * received in S_ROUTER_IN_ADMISSION.\n@@ -9568,9 +9572,10 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip,\n                                     undnat_match_p, est_actions,\n                                     &lb->nlb->header_);\n         } else {\n-            ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_UNDNAT, 120,\n-                                    undnat_match_p, \"ct_dnat;\",\n-                                    &lb->nlb->header_);\n+            ovn_lflow_add_with_hint(\n+                lflows, od, S_ROUTER_OUT_UNDNAT, 120, undnat_match_p,\n+                od->is_gw_router ? \"ct_dnat;\" : \"ct_dnat_in_czone;\",\n+                &lb->nlb->header_);\n         }\n         free(undnat_match_p);\n next:\n@@ -9865,7 +9870,7 @@ lrouter_nat_add_ext_ip_match(struct ovn_datapath *od,\n         uint16_t priority;\n \n         /* Priority of logical flows corresponding to exempted_ext_ips is\n-         * +1 of the corresponding regulr NAT rule.\n+         * +2 of the corresponding regular NAT rule.\n          * For example, if we have following NAT rule and we associate\n          * exempted external ips to it:\n          * \"ovn-nbctl lr-nat-add router dnat_and_snat 10.15.24.139 50.0.0.11\"\n@@ -9873,17 +9878,17 @@ lrouter_nat_add_ext_ip_match(struct ovn_datapath *od,\n          * And now we associate exempted external ip address set to it.\n          * Now corresponding to above rule we will have following logical\n          * flows:\n-         * lr_out_snat...priority=162, match=(..ip4.dst == $exempt_range),\n+         * lr_out_snat...priority=163, match=(..ip4.dst == $exempt_range),\n          *                             action=(next;)\n          * lr_out_snat...priority=161, match=(..), action=(ct_snat(....);)\n          *\n          */\n         if (is_src) {\n             /* S_ROUTER_IN_DNAT uses priority 100 */\n-            priority = 100 + 1;\n+            priority = 100 + 2;\n         } else {\n             /* S_ROUTER_OUT_SNAT uses priority (mask + 1 + 128 + 1) */\n-            priority = count_1bits(ntohl(mask)) + 2;\n+            priority = count_1bits(ntohl(mask)) + 3;\n \n             if (!od->is_gw_router) {\n                 priority += 128;\n@@ -12268,9 +12273,9 @@ build_lrouter_in_unsnat_flow(struct hmap *lflows, struct ovn_datapath *od,\n         /* Traffic received on l3dgw_port is subject to NAT. */\n         ds_clear(match);\n         ds_clear(actions);\n-        ds_put_format(match, \"ip && ip%s.dst == %s && inport == %s\",\n-                      is_v6 ? \"6\" : \"4\", nat->external_ip,\n-                      od->l3dgw_ports[0]->json_key);\n+        ds_put_format(match, \"ip && ip%s.dst == %s && inport == %s && \"\n+                      \"flags.loopback == 0\", is_v6 ? \"6\" : \"4\",\n+                      nat->external_ip, od->l3dgw_ports[0]->json_key);\n         if (!distributed && od->n_l3dgw_ports) {\n             /* Flows for NAT rules that are centralized are only\n             * programmed on the gateway chassis. */\n@@ -12282,12 +12287,31 @@ build_lrouter_in_unsnat_flow(struct hmap *lflows, struct ovn_datapath *od,\n             ds_put_format(actions, \"ip%s.dst=%s; next;\",\n                           is_v6 ? \"6\" : \"4\", nat->logical_ip);\n         } else {\n-            ds_put_cstr(actions, \"ct_snat;\");\n+            ds_put_cstr(actions, \"ct_snat_in_czone;\");\n         }\n \n         ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_UNSNAT,\n                                 100, ds_cstr(match), ds_cstr(actions),\n                                 &nat->header_);\n+\n+        if (!stateless) {\n+            ds_clear(match);\n+            ds_clear(actions);\n+            ds_put_format(match, \"ip && ip%s.dst == %s && inport == %s && \"\n+                          \"flags.loopback == 1 && flags.use_snat_zone == 1\",\n+                          is_v6 ? \"6\" : \"4\", nat->external_ip,\n+                          od->l3dgw_ports[0]->json_key);\n+            if (!distributed && od->n_l3dgw_ports) {\n+                /* Flows for NAT rules that are centralized are only\n+                * programmed on the gateway chassis. */\n+                ds_put_format(match, \" && is_chassis_resident(%s)\",\n+                            od->l3dgw_ports[0]->cr_port->json_key);\n+            }\n+            ds_put_cstr(actions, \"ct_snat;\");\n+            ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_UNSNAT,\n+                                    100, ds_cstr(match), ds_cstr(actions),\n+                                    &nat->header_);\n+        }\n     }\n }\n \n@@ -12364,7 +12388,7 @@ build_lrouter_in_dnat_flow(struct hmap *lflows, struct ovn_datapath *od,\n                 ds_put_format(actions, \"ip%s.dst=%s; next;\",\n                               is_v6 ? \"6\" : \"4\", nat->logical_ip);\n             } else {\n-                ds_put_format(actions, \"ct_dnat(%s\", nat->logical_ip);\n+                ds_put_format(actions, \"ct_dnat_in_czone(%s\", nat->logical_ip);\n                 if (nat->external_port_range[0]) {\n                     ds_put_format(actions, \",%s\", nat->external_port_range);\n                 }\n@@ -12417,7 +12441,8 @@ build_lrouter_out_undnat_flow(struct hmap *lflows, struct ovn_datapath *od,\n         ds_put_format(actions, \"ip%s.src=%s; next;\",\n                       is_v6 ? \"6\" : \"4\", nat->external_ip);\n     } else {\n-        ds_put_format(actions, \"ct_dnat;\");\n+        ds_put_format(actions,\n+                      od->is_gw_router ? \"ct_dnat;\" : \"ct_dnat_in_czone;\");\n     }\n \n     ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_UNDNAT, 100,\n@@ -12425,6 +12450,36 @@ build_lrouter_out_undnat_flow(struct hmap *lflows, struct ovn_datapath *od,\n                             &nat->header_);\n }\n \n+static void\n+build_lrouter_out_is_dnat_local(struct hmap *lflows, struct ovn_datapath *od,\n+                                const struct nbrec_nat *nat, struct ds *match,\n+                                struct ds *actions, bool distributed,\n+                                bool is_v6)\n+{\n+    /* Note that this only applies for NAT on a distributed router.\n+     */\n+    if (!od->n_l3dgw_ports) {\n+        return;\n+    }\n+\n+    ds_clear(match);\n+    ds_put_format(match, \"ip && ip%s.dst == %s && \",\n+                  is_v6 ? \"6\" : \"4\", nat->external_ip);\n+    if (distributed) {\n+        ds_put_format(match, \"is_chassis_resident(\\\"%s\\\")\", nat->logical_port);\n+    } else {\n+        ds_put_format(match, \"is_chassis_resident(%s)\",\n+                      od->l3dgw_ports[0]->cr_port->json_key);\n+    }\n+\n+    ds_clear(actions);\n+    ds_put_cstr(actions, REGBIT_DST_NAT_IP_LOCAL\" = 1; next;\");\n+\n+    ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_CHECK_DNAT_LOCAL,\n+                            50, ds_cstr(match), ds_cstr(actions),\n+                            &nat->header_);\n+}\n+\n static void\n build_lrouter_out_snat_flow(struct hmap *lflows, struct ovn_datapath *od,\n                             const struct nbrec_nat *nat, struct ds *match,\n@@ -12478,16 +12533,19 @@ build_lrouter_out_snat_flow(struct hmap *lflows, struct ovn_datapath *od,\n         ds_put_format(match, \"ip && ip%s.src == %s && outport == %s\",\n                       is_v6 ? \"6\" : \"4\", nat->logical_ip,\n                       od->l3dgw_ports[0]->json_key);\n-        if (!distributed && od->n_l3dgw_ports) {\n-            /* Flows for NAT rules that are centralized are only\n-            * programmed on the gateway chassis. */\n-            priority += 128;\n-            ds_put_format(match, \" && is_chassis_resident(%s)\",\n-                          od->l3dgw_ports[0]->cr_port->json_key);\n-        } else if (distributed) {\n-            priority += 128;\n-            ds_put_format(match, \" && is_chassis_resident(\\\"%s\\\")\",\n-                          nat->logical_port);\n+        if (od->n_l3dgw_ports) {\n+            if (distributed) {\n+                ovs_assert(nat->logical_port);\n+                priority += 128;\n+                ds_put_format(match, \" && is_chassis_resident(\\\"%s\\\")\",\n+                              nat->logical_port);\n+            } else {\n+                /* Flows for NAT rules that are centralized are only\n+                * programmed on the gateway chassis. */\n+                priority += 128;\n+                ds_put_format(match, \" && is_chassis_resident(%s)\",\n+                              od->l3dgw_ports[0]->cr_port->json_key);\n+            }\n         }\n         ds_clear(actions);\n \n@@ -12505,7 +12563,7 @@ build_lrouter_out_snat_flow(struct hmap *lflows, struct ovn_datapath *od,\n             ds_put_format(actions, \"ip%s.src=%s; next;\",\n                           is_v6 ? \"6\" : \"4\", nat->external_ip);\n         } else {\n-            ds_put_format(actions, \"ct_snat(%s\",\n+            ds_put_format(actions, \"ct_snat_in_czone(%s\",\n                         nat->external_ip);\n             if (nat->external_port_range[0]) {\n                 ds_put_format(actions, \",%s\", nat->external_port_range);\n@@ -12519,6 +12577,24 @@ build_lrouter_out_snat_flow(struct hmap *lflows, struct ovn_datapath *od,\n         ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_SNAT,\n                                 priority, ds_cstr(match),\n                                 ds_cstr(actions), &nat->header_);\n+\n+        if (!stateless) {\n+            ds_put_cstr(match, \" && \"REGBIT_DST_NAT_IP_LOCAL\" == 1\");\n+            ds_clear(actions);\n+            if (distributed) {\n+                ds_put_format(actions, \"eth.src = \"ETH_ADDR_FMT\"; \",\n+                              ETH_ADDR_ARGS(mac));\n+            }\n+            ds_put_format(actions,  REGBIT_DST_NAT_IP_LOCAL\" = 0; ct_snat(%s\",\n+                          nat->external_ip);\n+            if (nat->external_port_range[0]) {\n+                ds_put_format(actions, \",%s\", nat->external_port_range);\n+            }\n+            ds_put_format(actions, \");\");\n+            ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_SNAT,\n+                                    priority + 1, ds_cstr(match),\n+                                    ds_cstr(actions), &nat->header_);\n+        }\n     }\n }\n \n@@ -12749,10 +12825,13 @@ build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows,\n     /* Packets are allowed by default. */\n     ovn_lflow_add(lflows, od, S_ROUTER_IN_DEFRAG, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_IN_UNSNAT, 0, \"1\", \"next;\");\n+    ovn_lflow_add(lflows, od, S_ROUTER_OUT_CHECK_DNAT_LOCAL, 0, \"1\",\n+                  REGBIT_DST_NAT_IP_LOCAL\" = 0; next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_OUT_SNAT, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_IN_DNAT, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_OUT_UNDNAT, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_OUT_POST_UNDNAT, 0, \"1\", \"next;\");\n+    ovn_lflow_add(lflows, od, S_ROUTER_OUT_POST_SNAT, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_OUT_EGR_LOOP, 0, \"1\", \"next;\");\n     ovn_lflow_add(lflows, od, S_ROUTER_IN_ECMP_STATEFUL, 0, \"1\", \"next;\");\n \n@@ -12765,8 +12844,7 @@ build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows,\n      * not committed, it would produce ongoing datapath flows with the ct.new\n      * flag set. Some NICs are unable to offload these flows.\n      */\n-    if ((od->is_gw_router || od->n_l3dgw_ports) &&\n-        (od->nbr->n_nat || od->has_lb_vip)) {\n+    if (od->is_gw_router && (od->nbr->n_nat || od->has_lb_vip)) {\n         ovn_lflow_add(lflows, od, S_ROUTER_OUT_UNDNAT, 50,\n                       \"ip\", \"flags.loopback = 1; ct_dnat;\");\n         ovn_lflow_add(lflows, od, S_ROUTER_OUT_POST_UNDNAT, 50,\n@@ -12839,6 +12917,10 @@ build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows,\n             }\n         }\n \n+        /* S_ROUTER_OUT_DNAT_LOCAL */\n+        build_lrouter_out_is_dnat_local(lflows, od, nat, match, actions,\n+                                        distributed, is_v6);\n+\n         /* S_ROUTER_OUT_UNDNAT */\n         build_lrouter_out_undnat_flow(lflows, od, nat, match, actions, distributed,\n                                       mac, is_v6);\n@@ -12912,7 +12994,8 @@ build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows,\n                           \"clone { ct_clear; \"\n                           \"inport = outport; outport = \\\"\\\"; \"\n                           \"eth.dst <-> eth.src; \"\n-                          \"flags = 0; flags.loopback = 1; \");\n+                          \"flags = 0; flags.loopback = 1; \"\n+                          \"flags.use_snat_zone = \"REGBIT_DST_NAT_IP_LOCAL\"; \");\n             for (int j = 0; j < MFF_N_LOG_REGS; j++) {\n                 ds_put_format(actions, \"reg%d = 0; \", j);\n             }\ndiff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml\nindex 21d83718c..fc9d51ea7 100644\n--- a/northd/ovn-northd.8.xml\n+++ b/northd/ovn-northd.8.xml\n@@ -2879,23 +2879,65 @@ icmp6 {\n         <p>\n           For each configuration in the OVN Northbound database, that asks\n           to change the source IP address of a packet from <var>A</var> to\n-          <var>B</var>, a priority-100 flow matches <code>ip &amp;&amp;\n-          ip4.dst == <var>B</var> &amp;&amp; inport == <var>GW</var></code> or\n-          <code>ip &amp;&amp;\n-          ip6.dst == <var>B</var> &amp;&amp; inport == <var>GW</var></code>\n-          where <var>GW</var> is the logical router gateway port, with an\n-          action <code>ct_snat;</code>. If the NAT rule is of type\n-          dnat_and_snat and has <code>stateless=true</code> in the\n-          options, then the action would be <code>ip4/6.dst=\n-          (<var>B</var>)</code>.\n+          <var>B</var>, two priority-100 flows are added.\n         </p>\n \n         <p>\n           If the NAT rule cannot be handled in a distributed manner, then\n-          the priority-100 flow above is only programmed on the\n+          the below priority-100 flows are only programmed on the\n           gateway chassis.\n         </p>\n \n+        <ul>\n+          <li>\n+            <p>\n+              The first flow matches <code>ip &amp;&amp;\n+              ip4.dst == <var>B</var> &amp;&amp; inport == <var>GW</var>\n+              &amp;&amp; flags.loopback == 0</code> or\n+              <code>ip &amp;&amp;\n+              ip6.dst == <var>B</var> &amp;&amp; inport == <var>GW</var>\n+              &amp;&amp; flags.loopback == 0</code>\n+              where <var>GW</var> is the logical router gateway port, with an\n+              action <code>ct_snat_in_czone;</code> to unSNAT in the common\n+              zone.  If the NAT rule is of type dnat_and_snat and has\n+              <code>stateless=true</code> in the options, then the action\n+              would be <code>ip4/6.dst=(<var>B</var>)</code>.\n+            </p>\n+\n+            <p>\n+              If the NAT entry is of type <code>snat</code>, then there is an\n+              additional match <code>is_chassis_resident(<var>cr-GW</var>)\n+              </code> where <var>cr-GW</var> is the chassis resident port of\n+              <var>GW</var>.\n+            </p>\n+          </li>\n+\n+          <li>\n+            <p>\n+              The second flow matches <code>ip &amp;&amp;\n+              ip4.dst == <var>B</var> &amp;&amp; inport == <var>GW</var>\n+              &amp;&amp; flags.loopback == 1 &amp;&amp;\n+              flags.use_snat_zone == 1</code> or\n+              <code>ip &amp;&amp;\n+              ip6.dst == <var>B</var> &amp;&amp; inport == <var>GW</var>\n+              &amp;&amp; flags.loopback == 0 &amp;&amp;\n+              flags.use_snat_zone == 1</code>\n+              where <var>GW</var> is the logical router gateway port, with an\n+              action <code>ct_snat;</code> to unSNAT in the snat zone. If the\n+              NAT rule is of type dnat_and_snat and has\n+              <code>stateless=true</code> in the options, then the action\n+              would be <code>ip4/6.dst=(<var>B</var>)</code>.\n+            </p>\n+\n+            <p>\n+              If the NAT entry is of type <code>snat</code>, then there is an\n+              additional match <code>is_chassis_resident(<var>cr-GW</var>)\n+              </code> where <var>cr-GW</var> is the chassis resident port of\n+              <var>GW</var>.\n+            </p>\n+          </li>\n+        </ul>\n+\n         <p>\n           A priority-0 logical flow with match <code>1</code> has actions\n           <code>next;</code>.\n@@ -4031,7 +4073,43 @@ nd_ns {\n       </li>\n     </ul>\n \n-    <h3>Egress Table 0: UNDNAT</h3>\n+    <h3>Egress Table 0: Check DNAT local </h3>\n+\n+    <p>\n+      This table checks if the packet needs to be DNATed in the router ingress\n+      table <code>lr_out_dnat</code> after it is SNATed  and looped back\n+      to the ingress pipeline.  This check is done only for routers configured\n+      with distributed gateway ports and NAT entries.  This check is done\n+      so that SNAT and DNAT is done in different zones instead of a common\n+      zone.\n+    </p>\n+\n+    <ul>\n+      <li>\n+        <p>\n+          For each NAT rule in the OVN Northbound database on a\n+          distributed router, a priority-50 logical flow with match\n+          <code>ip4.dst == <var>E</var> &amp;&amp;\n+          is_chassis_resident(<var>P</var>)</code>, where <var>E</var> is the\n+          external IP address specified in the NAT rule, <var>GW</var>\n+          is the logical router distributed gateway port. For dnat_and_snat\n+          NAT rule, <var>P</var> is the logical port specified in the NAT rule.\n+          If <ref column=\"logical_port\"\n+          table=\"NAT\" db=\"OVN_Northbound\"/> column of\n+          <ref table=\"NAT\" db=\"OVN_Northbound\"/> table is NOT set, then\n+          <var>P</var> is the <code>chassisredirect port</code> of\n+          <var>GW</var> with the actions:\n+          <code>REGBIT_DST_NAT_IP_LOCAL = 1; next; </code>\n+        </p>\n+      </li>\n+\n+      <li>\n+        A priority-0 logical flow with match <code>1</code> has actions\n+        <code>REGBIT_DST_NAT_IP_LOCAL = 0; next;</code>.\n+      </li>\n+    </ul>\n+\n+    <h3>Egress Table 1: UNDNAT</h3>\n \n     <p>\n       This is for already established connections' reverse traffic.\n@@ -4040,6 +4118,23 @@ nd_ns {\n       is unDNATed here.\n     </p>\n \n+    <ul>\n+      <li>\n+        A priority-0 logical flow with match <code>1</code> has actions\n+        <code>next;</code>.\n+      </li>\n+    </ul>\n+\n+    <h3>Egress Table 1: UNDNAT on Gateway Routers</h3>\n+\n+    <ul>\n+      <li>\n+        For all IP packets, a priority-50 flow with an action\n+        <code>flags.loopback = 1; ct_dnat;</code>.\n+      </li>\n+    </ul>\n+\n+    <h3>Egress Table 1: UNDNAT on Distributed Routers</h3>\n     <ul>\n       <li>\n         <p>\n@@ -4050,9 +4145,9 @@ nd_ns {\n           gateway chassis that matches\n           <code>ip &amp;&amp; ip4.src == <var>B</var> &amp;&amp;\n           outport == <var>GW</var></code>, where <var>GW</var> is the logical\n-          router gateway port with an action <code>ct_dnat;</code>. If the\n-          backend IPv4 address <var>B</var> is also configured with L4 port\n-          <var>PORT</var> of protocol <var>P</var>, then the\n+          router gateway port with an action <code>ct_dnat_in_czone;</code>.\n+          If the backend IPv4 address <var>B</var> is also configured with\n+          L4 port <var>PORT</var> of protocol <var>P</var>, then the\n           match also includes <code>P.src</code> == <var>PORT</var>.  These\n           flows are not added for load balancers with IPv6 <var>VIPs</var>.\n         </p>\n@@ -4072,7 +4167,7 @@ nd_ns {\n           matches <code>ip &amp;&amp; ip4.src == <var>B</var>\n           &amp;&amp; outport == <var>GW</var></code>, where <var>GW</var>\n           is the logical router gateway port, with an action\n-          <code>ct_dnat;</code>. If the NAT rule is of type\n+          <code>ct_dnat_in_czone;</code>. If the NAT rule is of type\n           dnat_and_snat and has <code>stateless=true</code> in the\n           options, then the action would be <code>ip4/6.src=\n           (<var>B</var>)</code>.\n@@ -4081,7 +4176,7 @@ nd_ns {\n         <p>\n           If the NAT rule cannot be handled in a distributed manner, then\n           the priority-100 flow above is only programmed on the\n-          gateway chassis.\n+          gateway chassis with the action <code>ct_dnat_in_czone</code>.\n         </p>\n \n         <p>\n@@ -4094,26 +4189,17 @@ nd_ns {\n         </p>\n       </li>\n \n-      <li>\n-        For all IP packets, a priority-50 flow with an action\n-        <code>flags.loopback = 1; ct_dnat;</code>.\n-      </li>\n-\n-      <li>\n-        A priority-0 logical flow with match <code>1</code> has actions\n-        <code>next;</code>.\n-      </li>\n     </ul>\n \n-    <h3>Egress Table 1: Post UNDNAT</h3>\n+    <h3>Egress Table 2: Post UNDNAT</h3>\n \n     <p>\n       <ul>\n         <li>\n           A priority-50 logical flow is added that commits any untracked flows\n-          from the previous table <code>lr_out_undnat</code>. This flow\n-          matches on <code>ct.new &amp;&amp; ip</code> with action\n-          <code>ct_commit { } ; next; </code>.\n+          from the previous table <code>lr_out_undnat</code> for Gateway\n+          routers.  This flow matches on <code>ct.new &amp;&amp; ip</code>\n+          with action <code>ct_commit { } ; next; </code>.\n         </li>\n \n         <li>\n@@ -4124,7 +4210,7 @@ nd_ns {\n       </ul>\n     </p>\n \n-    <h3>Egress Table 2: SNAT</h3>\n+    <h3>Egress Table 3: SNAT</h3>\n \n     <p>\n       Packets that are configured to be SNATed get their source IP address\n@@ -4140,7 +4226,7 @@ nd_ns {\n       </li>\n     </ul>\n \n-    <p>Egress Table 2: SNAT on Gateway Routers</p>\n+    <p>Egress Table 3: SNAT on Gateway Routers</p>\n \n     <ul>\n       <li>\n@@ -4239,7 +4325,7 @@ nd_ns {\n       </li>\n     </ul>\n \n-    <p>Egress Table 2: SNAT on Distributed Routers</p>\n+    <p>Egress Table 3: SNAT on Distributed Routers</p>\n \n     <ul>\n       <li>\n@@ -4247,28 +4333,46 @@ nd_ns {\n           For each configuration in the OVN Northbound database, that asks\n           to change the source IP address of a packet from an IP address of\n           <var>A</var> or to change the source IP address of a packet that\n-          belongs to network <var>A</var> to <var>B</var>, a flow matches\n-          <code>ip &amp;&amp; ip4.src == <var>A</var> &amp;&amp;\n-          outport == <var>GW</var></code>, where <var>GW</var> is the\n-          logical router gateway port, with an action\n-          <code>ct_snat(<var>B</var>);</code>.  The priority of the flow\n-          is calculated based on the mask of <var>A</var>, with matches\n-          having larger masks getting higher priorities. If the NAT rule\n-          is of type dnat_and_snat and has <code>stateless=true</code>\n-          in the options, then the action would be <code>ip4/6.src=\n-          (<var>B</var>)</code>.\n+          belongs to network <var>A</var> to <var>B</var>, two flows are\n+          added.  The priority of these flows are calculated based on the\n+          mask of <var>A</var>, with matches having larger masks getting\n+          higher priorities.\n         </p>\n \n         <p>\n           If the NAT rule cannot be handled in a distributed manner, then\n-          the flow above is only programmed on the\n-          gateway chassis increasing flow priority by 128 in\n-          order to be run first\n+          the below flows are only programmed on the gateway chassis increasing\n+          flow priority by 128 in order to be run first.\n         </p>\n \n+        <ul>\n+          <li>\n+            The first flow is added with the match\n+            <code>ip &amp;&amp; ip4.src == <var>A</var> &amp;&amp;\n+            outport == <var>GW</var></code>, where <var>GW</var> is the\n+            logical router gateway port, with an action\n+            <code>ct_snat_in_czone(<var>B</var>);</code> to SNATed in the\n+            common zone.  If the NAT rule is of type dnat_and_snat and has\n+            <code>stateless=true</code> in the options, then the action\n+            would be <code>ip4/6.src=(<var>B</var>)</code>.\n+          </li>\n+\n+          <li>\n+            The second flow is added with the match\n+            <code>ip &amp;&amp; ip4.src == <var>A</var> &amp;&amp;\n+            outport == <var>GW</var> &amp;&amp;\n+            REGBIT_DST_NAT_IP_LOCAL == 0</code>, where <var>GW</var> is the\n+            logical router gateway port, with an action\n+            <code>ct_snat(<var>B</var>);</code> to SNAT in the snat zone.\n+            If the NAT rule is of type dnat_and_snat and has\n+            <code>stateless=true</code> in the options, then the action would\n+            be <code>ip4/6.src=(<var>B</var>)</code>.\n+          </li>\n+        </ul>\n+\n         <p>\n           If the NAT rule can be handled in a distributed manner, then\n-          there is an additional action\n+          there is an additional action (for both the flows)\n           <code>eth.src = <var>EA</var>;</code>, where <var>EA</var>\n           is the ethernet address associated with the IP address\n           <var>A</var> in the NAT rule.  This allows upstream MAC\n@@ -4299,7 +4403,7 @@ nd_ns {\n       </li>\n     </ul>\n \n-    <h3>Egress Table 3: Egress Loopback</h3>\n+    <h3>Egress Table 4: Egress Loopback</h3>\n \n     <p>\n       For distributed logical routers where one of the logical router\n@@ -4344,6 +4448,7 @@ clone {\n     outport = \"\";\n     flags = 0;\n     flags.loopback = 1;\n+    flags.use_snat_zone = REGBIT_DST_NAT_IP_LOCAL;\n     reg0 = 0;\n     reg1 = 0;\n     ...\n@@ -4368,7 +4473,7 @@ clone {\n       </li>\n     </ul>\n \n-    <h3>Egress Table 4: Delivery</h3>\n+    <h3>Egress Table 5: Delivery</h3>\n \n     <p>\n       Packets that reach this table are ready for delivery.  It contains:\ndiff --git a/tests/ovn-northd.at b/tests/ovn-northd.at\nindex 85b47a18f..70ec5e2e3 100644\n--- a/tests/ovn-northd.at\n+++ b/tests/ovn-northd.at\n@@ -877,25 +877,25 @@ check_flow_match_sets() {\n echo\n echo \"IPv4: stateful\"\n ovn-nbctl --wait=sb lr-nat-add R1 dnat_and_snat  172.16.1.1 50.0.0.11\n-check_flow_match_sets 2 2 3 0 0 0 0\n+check_flow_match_sets 3 4 2 0 0 0 0\n ovn-nbctl lr-nat-del R1 dnat_and_snat  172.16.1.1\n \n echo\n echo \"IPv4: stateless\"\n ovn-nbctl --wait=sb --stateless lr-nat-add R1 dnat_and_snat  172.16.1.1 50.0.0.11\n-check_flow_match_sets 2 0 1 2 2 0 0\n+check_flow_match_sets 2 0 0 2 2 0 0\n ovn-nbctl lr-nat-del R1 dnat_and_snat  172.16.1.1\n \n echo\n echo \"IPv6: stateful\"\n ovn-nbctl --wait=sb lr-nat-add R1 dnat_and_snat fd01::1 fd11::2\n-check_flow_match_sets 2 2 3 0 0 0 0\n+check_flow_match_sets 3 4 2 0 0 0 0\n ovn-nbctl lr-nat-del R1 dnat_and_snat  fd01::1\n \n echo\n echo \"IPv6: stateless\"\n ovn-nbctl --wait=sb --stateless lr-nat-add R1 dnat_and_snat fd01::1 fd11::2\n-check_flow_match_sets 2 0 1 0 0 2 2\n+check_flow_match_sets 2 0 0 0 0 2 2\n \n AT_CLEANUP\n ])\n@@ -924,9 +924,9 @@ echo \"CR-LRP UUID is: \" $uuid\n ovn-nbctl --portrange lr-nat-add R1 dnat_and_snat  172.16.1.1 50.0.0.11 1-3000\n \n AT_CAPTURE_FILE([sbflows])\n-OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows && test 2 = `grep -c lr_in_unsnat sbflows`])\n+OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows && test 3 = `grep -c lr_in_unsnat sbflows`])\n AT_CHECK([grep -c 'ct_snat.*3000' sbflows && grep -c 'ct_dnat.*3000' sbflows],\n-  [0], [1\n+  [0], [2\n 1\n ])\n \n@@ -934,9 +934,9 @@ ovn-nbctl lr-nat-del R1 dnat_and_snat  172.16.1.1\n ovn-nbctl --wait=sb --portrange lr-nat-add R1 snat  172.16.1.1 50.0.0.11 1-3000\n \n AT_CAPTURE_FILE([sbflows2])\n-OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows2 && test 2 = `grep -c lr_in_unsnat sbflows`])\n+OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows2 && test 3 = `grep -c lr_in_unsnat sbflows`])\n AT_CHECK([grep -c 'ct_snat.*3000' sbflows2 && grep -c 'ct_dnat.*3000' sbflows2],\n-  [1], [1\n+  [1], [2\n 0\n ])\n \n@@ -944,7 +944,7 @@ ovn-nbctl lr-nat-del R1 snat  172.16.1.1\n ovn-nbctl --wait=sb --portrange --stateless lr-nat-add R1 dnat_and_snat  172.16.1.2 50.0.0.12 1-3000\n \n AT_CAPTURE_FILE([sbflows3])\n-OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows3 && test 3 = `grep -c lr_in_unsnat sbflows3`])\n+OVS_WAIT_UNTIL([ovn-sbctl dump-flows R1 > sbflows3 && test 4 = `grep -c lr_in_unsnat sbflows3`])\n AT_CHECK([grep 'ct_[s]dnat.*172\\.16\\.1\\.2.*3000' sbflows3], [1])\n \n ovn-nbctl lr-nat-del R1 dnat_and_snat  172.16.1.1\n@@ -1008,17 +1008,20 @@ AT_CAPTURE_FILE([drflows])\n ovn-sbctl dump-flows CR > crflows\n AT_CAPTURE_FILE([crflows])\n \n-AT_CHECK([\n-  grep -c lr_out_snat drflows\n-  grep -c lr_out_snat crflows\n-  grep lr_out_snat drflows | grep \"ip4.src == 50.0.0.11\" | grep -c \"ip4.dst == $allowed_range\"\n-  grep lr_out_snat crflows | grep \"ip4.src == 50.0.0.11\" | grep -c \"ip4.dst == $allowed_range\"], [0], [dnl\n-3\n-3\n-1\n-1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $allowed_range), action=(ct_snat_in_czone(172.16.1.1);)\n+  table=??(lr_out_snat        ), priority=162  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $allowed_range && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.16.1.1);)\n+])\n+\n+AT_CHECK([grep -e \"lr_out_snat\" crflows | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $allowed_range), action=(ct_snat(172.16.1.1);)\n ])\n \n+\n # SNAT with DISALLOWED_IPs\n check ovn-nbctl lr-nat-del DR snat  50.0.0.11\n check ovn-nbctl lr-nat-del CR snat  50.0.0.11\n@@ -1036,19 +1039,19 @@ AT_CAPTURE_FILE([drflows2])\n ovn-sbctl dump-flows CR > crflows2\n AT_CAPTURE_FILE([crflows2])\n \n-AT_CHECK([\n-  grep -c lr_out_snat drflows2\n-  grep -c lr_out_snat crflows2\n-  grep lr_out_snat drflows2 | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep -c \"priority=162\"\n-  grep lr_out_snat drflows2 | grep \"ip4.src == 50.0.0.11\" | grep -c \"priority=161\"\n-  grep lr_out_snat crflows2 | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep -c \"priority=34\"\n-  grep lr_out_snat crflows2 | grep \"ip4.src == 50.0.0.11\" | grep -c \"priority=33\"], [0], [dnl\n-4\n-4\n-1\n-1\n-1\n-1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows2 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\")), action=(ct_snat_in_czone(172.16.1.1);)\n+  table=??(lr_out_snat        ), priority=162  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.16.1.1);)\n+  table=??(lr_out_snat        ), priority=163  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $disallowed_range), action=(next;)\n+])\n+\n+AT_CHECK([grep -e \"lr_out_snat\" crflows2 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11), action=(ct_snat(172.16.1.1);)\n+  table=??(lr_out_snat        ), priority=35   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $disallowed_range), action=(next;)\n ])\n \n # Stateful FIP with ALLOWED_IPs\n@@ -1059,25 +1062,24 @@ check ovn-nbctl lr-nat-add DR dnat_and_snat  172.16.1.2 50.0.0.11\n check ovn-nbctl lr-nat-add CR dnat_and_snat  172.16.1.2 50.0.0.11\n \n check ovn-nbctl lr-nat-update-ext-ip DR dnat_and_snat 172.16.1.2 allowed_range\n-check ovn-nbctl lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 allowed_range\n+check ovn-nbctl --wait=sb lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 allowed_range\n \n-ovn-nbctl show DR\n-ovn-sbctl dump-flows DR\n-ovn-nbctl show CR\n-ovn-sbctl dump-flows CR\n-\n-OVS_WAIT_UNTIL([test 3 = `ovn-sbctl dump-flows DR | grep lr_out_snat | \\\n-wc -l`])\n-OVS_WAIT_UNTIL([test 3 = `ovn-sbctl dump-flows CR | grep lr_out_snat | \\\n-wc -l`])\n+ovn-sbctl dump-flows DR > drflows3\n+AT_CAPTURE_FILE([drflows2])\n+ovn-sbctl dump-flows CR > crflows3\n+AT_CAPTURE_FILE([crflows2])\n \n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $allowed_range\" | wc -l], [0], [1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows3 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $allowed_range), action=(ct_snat_in_czone(172.16.1.2);)\n+  table=??(lr_out_snat        ), priority=162  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $allowed_range && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.16.1.2);)\n ])\n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $allowed_range\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $allowed_range\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $allowed_range\" | wc -l], [0], [1\n+\n+AT_CHECK([grep -e \"lr_out_snat\" crflows3 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $allowed_range), action=(ct_snat(172.16.1.2);)\n ])\n \n # Stateful FIP with DISALLOWED_IPs\n@@ -1088,26 +1090,26 @@ ovn-nbctl lr-nat-add DR dnat_and_snat  172.16.1.2 50.0.0.11\n ovn-nbctl lr-nat-add CR dnat_and_snat  172.16.1.2 50.0.0.11\n \n ovn-nbctl --is-exempted lr-nat-update-ext-ip DR dnat_and_snat 172.16.1.2 disallowed_range\n-ovn-nbctl --is-exempted lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 disallowed_range\n+check ovn-nbctl --wait=sb --is-exempted lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 disallowed_range\n \n-ovn-nbctl show DR\n-ovn-sbctl dump-flows DR\n-ovn-nbctl show CR\n-ovn-sbctl dump-flows CR\n-\n-OVS_WAIT_UNTIL([test 4 = `ovn-sbctl dump-flows DR | grep lr_out_snat | \\\n-wc -l`])\n-OVS_WAIT_UNTIL([test 4 = `ovn-sbctl dump-flows CR | grep lr_out_snat | \\\n-wc -l`])\n+ovn-sbctl dump-flows DR > drflows4\n+AT_CAPTURE_FILE([drflows2])\n+ovn-sbctl dump-flows CR > crflows4\n+AT_CAPTURE_FILE([crflows2])\n \n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep \"priority=162\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $disallowed_range\" | grep \"priority=101\" | wc -l], [0], [1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows4 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\")), action=(ct_snat_in_czone(172.16.1.2);)\n+  table=??(lr_out_snat        ), priority=162  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.16.1.2);)\n+  table=??(lr_out_snat        ), priority=163  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $disallowed_range), action=(next;)\n ])\n \n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep \"priority=34\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $disallowed_range\" | grep \"priority=101\" | wc -l], [0], [1\n+AT_CHECK([grep -e \"lr_out_snat\" crflows4 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11), action=(ct_snat(172.16.1.2);)\n+  table=??(lr_out_snat        ), priority=35   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $disallowed_range), action=(next;)\n ])\n \n # Stateless FIP with DISALLOWED_IPs\n@@ -1120,24 +1122,21 @@ ovn-nbctl --stateless lr-nat-add CR dnat_and_snat  172.16.1.2 50.0.0.11\n ovn-nbctl lr-nat-update-ext-ip DR dnat_and_snat 172.16.1.2 allowed_range\n ovn-nbctl lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 allowed_range\n \n-ovn-nbctl show DR\n-ovn-sbctl dump-flows DR\n-\n-ovn-nbctl show CR\n-ovn-sbctl dump-flows CR\n-\n-OVS_WAIT_UNTIL([test 3 = `ovn-sbctl dump-flows DR | grep lr_out_snat | \\\n-wc -l`])\n-OVS_WAIT_UNTIL([test 3 = `ovn-sbctl dump-flows CR | grep lr_out_snat | \\\n-wc -l`])\n+ovn-sbctl dump-flows DR > drflows5\n+AT_CAPTURE_FILE([drflows2])\n+ovn-sbctl dump-flows CR > crflows5\n+AT_CAPTURE_FILE([crflows2])\n \n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $allowed_range\" | wc -l], [0], [1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows5 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $allowed_range), action=(ip4.src=172.16.1.2; next;)\n ])\n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $allowed_range\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $allowed_range\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $allowed_range\" | wc -l], [0], [1\n+\n+AT_CHECK([grep -e \"lr_out_snat\" crflows5 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $allowed_range), action=(ip4.src=172.16.1.2; next;)\n ])\n \n # Stateful FIP with DISALLOWED_IPs\n@@ -1150,23 +1149,25 @@ ovn-nbctl --stateless lr-nat-add CR dnat_and_snat  172.16.1.2 50.0.0.11\n ovn-nbctl --is-exempted lr-nat-update-ext-ip DR dnat_and_snat 172.16.1.2 disallowed_range\n ovn-nbctl --is-exempted lr-nat-update-ext-ip CR dnat_and_snat 172.16.1.2 disallowed_range\n \n-ovn-nbctl show DR\n-ovn-sbctl dump-flows DR\n-ovn-nbctl show CR\n-ovn-sbctl dump-flows CR\n+ovn-nbctl --wait=sb sync\n \n-OVS_WAIT_UNTIL([test 4 = `ovn-sbctl dump-flows DR | grep lr_out_snat | \\\n-wc -l`])\n-OVS_WAIT_UNTIL([test 4 = `ovn-sbctl dump-flows CR | grep lr_out_snat | \\\n-wc -l`])\n+ovn-sbctl dump-flows DR > drflows6\n+AT_CAPTURE_FILE([drflows2])\n+ovn-sbctl dump-flows CR > crflows6\n+AT_CAPTURE_FILE([crflows2])\n \n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep \"priority=162\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows DR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $disallowed_range\" | grep \"priority=101\" | wc -l], [0], [1\n+AT_CHECK([grep -e \"lr_out_snat\" drflows6 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=161  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\")), action=(ip4.src=172.16.1.2; next;)\n+  table=??(lr_out_snat        ), priority=163  , match=(ip && ip4.src == 50.0.0.11 && outport == \"DR-S1\" && is_chassis_resident(\"cr-DR-S1\") && ip4.dst == $disallowed_range), action=(next;)\n ])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_out_snat | grep \"ip4.src == 50.0.0.11\" | grep \"ip4.dst == $disallowed_range\" | grep \"priority=34\" | wc -l], [0], [1\n-])\n-AT_CHECK([ovn-sbctl dump-flows CR | grep lr_in_dnat | grep \"ip4.dst == 172.16.1.2\" | grep \"ip4.src == $disallowed_range\" | grep \"priority=101\" | wc -l], [0], [1\n+\n+AT_CHECK([grep -e \"lr_out_snat\" crflows6 | sed 's/table=../table=??/' | sort], [0], [dnl\n+  table=??(lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=??(lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=??(lr_out_snat        ), priority=33   , match=(ip && ip4.src == 50.0.0.11), action=(ip4.src=172.16.1.2; next;)\n+  table=??(lr_out_snat        ), priority=35   , match=(ip && ip4.src == 50.0.0.11 && ip4.dst == $disallowed_range), action=(next;)\n ])\n \n AT_CLEANUP\n@@ -3475,14 +3476,14 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 10.0.0.100 && tcp && reg9[[16..31]] == 80), action=(ct_lb(backends=10.0.0.40:8080);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n check ovn-nbctl --wait=sb set logical_router lr0 options:lb_force_snat_ip=\"20.0.0.4 aef0::4\"\n@@ -3511,21 +3512,21 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 10.0.0.100 && tcp && reg9[[16..31]] == 80), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.40:8080);)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=100  , match=(flags.force_snat_for_lb == 1 && ip4), action=(ct_snat(20.0.0.4);)\n-  table=2 (lr_out_snat        ), priority=100  , match=(flags.force_snat_for_lb == 1 && ip6), action=(ct_snat(aef0::4);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=100  , match=(flags.force_snat_for_lb == 1 && ip4), action=(ct_snat(20.0.0.4);)\n+  table=? (lr_out_snat        ), priority=100  , match=(flags.force_snat_for_lb == 1 && ip6), action=(ct_snat(aef0::4);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n check ovn-nbctl --wait=sb set logical_router lr0 options:lb_force_snat_ip=\"router_ip\"\n@@ -3557,22 +3558,22 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 10.0.0.100 && tcp && reg9[[16..31]] == 80), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.40:8080);)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.100);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw1\"), action=(ct_snat(20.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.100);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw1\"), action=(ct_snat(20.0.0.1);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n check ovn-nbctl --wait=sb remove logical_router lr0 options chassis\n@@ -3584,9 +3585,9 @@ AT_CHECK([grep \"lr_in_unsnat\" lr0flows | sort], [0], [dnl\n   table=4 (lr_in_unsnat       ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n check ovn-nbctl set logical_router lr0 options:chassis=ch1\n@@ -3617,23 +3618,23 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 10.0.0.100 && tcp && reg9[[16..31]] == 80), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.40:8080);)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.100);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw1\"), action=(ct_snat(20.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-sw1\"), action=(ct_snat(bef0::1);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.100);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw1\"), action=(ct_snat(20.0.0.1);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-sw1\"), action=(ct_snat(bef0::1);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n check ovn-nbctl --wait=sb lb-add lb2 10.0.0.20:80 10.0.0.40:8080\n@@ -3661,18 +3662,18 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | grep skip_snat_for_lb | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 10.0.0.20 && tcp && reg9[[16..31]] == 80), action=(flags.skip_snat_for_lb = 1; ct_lb(backends=10.0.0.40:8080);)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | grep skip_snat_for_lb | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=120  , match=(flags.skip_snat_for_lb == 1 && ip), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | grep skip_snat_for_lb | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=120  , match=(flags.skip_snat_for_lb == 1 && ip), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n AT_CLEANUP\n@@ -4176,6 +4177,8 @@ check ovn-nbctl lsp-set-options lrp1-attachment router-port=lrp1\n check ovn-nbctl lr-nat-add lr0 dnat 42.42.42.42 192.168.0.2\n check ovn-nbctl --wait=sb sync\n \n+ovn-trace --minimal 'inport == \"sw1-port1\" && eth.src == 50:54:00:00:00:03 && eth.dst == 00:00:00:00:ff:02 && ip4.dst == 42.42.42.42 && ip4.src == 11.0.0.2 && ip.ttl == 64'\n+\n AT_CHECK([ovn-trace --minimal 'inport == \"sw1-port1\" && eth.src == 50:54:00:00:00:03 && eth.dst == 00:00:00:00:ff:02 && ip4.dst == 42.42.42.42 && ip4.src == 11.0.0.2 && ip.ttl == 64' | grep \"output(\\\"sw0-port1\\\")\"], [0], [ignore])\n \n dnl If we remove the DNAT entry we will be unable to trace to the DNAT address\n@@ -4761,17 +4764,17 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n # Create few dnat_and_snat entries\n@@ -4797,17 +4800,21 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+])\n+\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n ovn-sbctl chassis-add gw1 geneve 127.0.0.1\n@@ -4828,9 +4835,12 @@ AT_CAPTURE_FILE([lr0flows])\n \n AT_CHECK([grep \"lr_in_unsnat\" lr0flows | sort], [0], [dnl\n   table=4 (lr_in_unsnat       ), priority=0    , match=(1), action=(next;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n ])\n \n AT_CHECK([grep \"lr_in_defrag\" lr0flows | sort], [0], [dnl\n@@ -4839,26 +4849,34 @@ AT_CHECK([grep \"lr_in_defrag\" lr0flows | sort], [0], [dnl\n \n AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=0    , match=(1), action=(next;)\n-  table=6 (lr_in_dnat         ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat(10.0.0.3);)\n+  table=6 (lr_in_dnat         ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone(10.0.0.3);)\n+])\n+\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.10 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.20 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.30 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=100  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=100  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=153  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=153  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=154  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.20);)\n+  table=? (lr_out_snat        ), priority=162  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=162  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.20);)\n ])\n \n # Associate load balancer to lr0\n@@ -4879,9 +4897,12 @@ AT_CAPTURE_FILE([lr0flows])\n \n AT_CHECK([grep \"lr_in_unsnat\" lr0flows | sort], [0], [dnl\n   table=4 (lr_in_unsnat       ), priority=0    , match=(1), action=(next;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n-  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.10 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && flags.loopback == 0 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone;)\n+  table=4 (lr_in_unsnat       ), priority=100  , match=(ip && ip4.dst == 172.168.0.30 && inport == \"lr0-public\" && flags.loopback == 1 && flags.use_snat_zone == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat;)\n ])\n \n AT_CHECK([grep \"lr_in_defrag\" lr0flows | sort], [0], [dnl\n@@ -4894,7 +4915,7 @@ AT_CHECK([grep \"lr_in_defrag\" lr0flows | sort], [0], [dnl\n \n AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=0    , match=(1), action=(next;)\n-  table=6 (lr_in_dnat         ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat(10.0.0.3);)\n+  table=6 (lr_in_dnat         ), priority=100  , match=(ip && ip4.dst == 172.168.0.20 && inport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone(10.0.0.3);)\n   table=6 (lr_in_dnat         ), priority=110  , match=(ct.est && ip4 && reg0 == 172.168.0.200 && ct_label.natted == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(next;)\n   table=6 (lr_in_dnat         ), priority=110  , match=(ct.new && ip4 && reg0 == 172.168.0.200 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_lb(backends=10.0.0.80,10.0.0.81);)\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.est && ip4 && reg0 == 10.0.0.10 && tcp && reg9[[16..31]] == 80 && ct_label.natted == 1 && is_chassis_resident(\"cr-lr0-public\")), action=(next;)\n@@ -4905,27 +4926,35 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 172.168.0.210 && udp && reg9[[16..31]] == 60 && is_chassis_resident(\"cr-lr0-public\")), action=(ct_lb(backends=10.0.0.50:6062,10.0.0.60:6062);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=100  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.4 && tcp.src == 8080)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.50 && tcp.src == 82) || (ip4.src == 10.0.0.60 && tcp.src == 82)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.50 && udp.src == 6062) || (ip4.src == 10.0.0.60 && udp.src == 6062)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.80) || (ip4.src == 10.0.0.81)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.10 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.20 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n+  table=? (lr_out_chk_dnat_local), priority=50   , match=(ip && ip4.dst == 172.168.0.30 && is_chassis_resident(\"cr-lr0-public\")), action=(reg9[[4]] = 1; next;)\n+])\n+\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=100  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n+  table=? (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.4 && tcp.src == 8080)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n+  table=? (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.50 && tcp.src == 82) || (ip4.src == 10.0.0.60 && tcp.src == 82)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n+  table=? (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.50 && udp.src == 6062) || (ip4.src == 10.0.0.60 && udp.src == 6062)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n+  table=? (lr_out_undnat      ), priority=120  , match=(ip4 && ((ip4.src == 10.0.0.80) || (ip4.src == 10.0.0.81)) && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_dnat_in_czone;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=153  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=153  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=154  , match=(ip && ip4.src == 10.0.0.0/24 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=161  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\")), action=(ct_snat_in_czone(172.168.0.20);)\n+  table=? (lr_out_snat        ), priority=162  , match=(ip && ip4.src == 10.0.0.10 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=162  , match=(ip && ip4.src == 10.0.0.3 && outport == \"lr0-public\" && is_chassis_resident(\"cr-lr0-public\") && reg9[[4]] == 1), action=(reg9[[4]] = 0; ct_snat(172.168.0.20);)\n ])\n \n # Make the logical router as Gateway router\n@@ -4965,22 +4994,26 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 172.168.0.210 && udp && reg9[[16..31]] == 60), action=(ct_lb(backends=10.0.0.50:6062,10.0.0.60:6062);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+])\n+\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n ])\n \n # Set lb force snat logical router.\n@@ -5020,24 +5053,28 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 172.168.0.210 && udp && reg9[[16..31]] == 60), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.50:6062,10.0.0.60:6062);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n+])\n+\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n ])\n \n # Add a LB VIP same as router ip.\n@@ -5081,24 +5118,28 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 172.168.0.210 && udp && reg9[[16..31]] == 60), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.50:6062,10.0.0.60:6062);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+])\n+\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n ])\n \n # Add IPv6 router port and LB.\n@@ -5155,26 +5196,30 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip6 && xxreg0 == def0::2 && tcp && reg9[[16..31]] == 8000), action=(flags.force_snat_for_lb = 1; ct_lb(backends=[[aef0::2]]:80,[[aef0::3]]:80);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n+])\n+\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-public\"), action=(ct_snat(def0::10);)\n-  table=2 (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-sw0\"), action=(ct_snat(aef0::1);)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n-  table=2 (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n-  table=2 (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-public\"), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip4 && outport == \"lr0-sw0\"), action=(ct_snat(10.0.0.1);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-public\"), action=(ct_snat(def0::10);)\n+  table=? (lr_out_snat        ), priority=110  , match=(flags.force_snat_for_lb == 1 && ip6 && outport == \"lr0-sw0\"), action=(ct_snat(aef0::1);)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+  table=? (lr_out_snat        ), priority=25   , match=(ip && ip4.src == 10.0.0.0/24), action=(ct_snat(172.168.0.10);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.10), action=(ct_snat(172.168.0.30);)\n+  table=? (lr_out_snat        ), priority=33   , match=(ip && ip4.src == 10.0.0.3), action=(ct_snat(172.168.0.20);)\n ])\n \n check ovn-nbctl lrp-del lr0-sw0\n@@ -5209,19 +5254,23 @@ AT_CHECK([grep \"lr_in_dnat\" lr0flows | sort], [0], [dnl\n   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip4 && reg0 == 172.168.0.210 && udp && reg9[[16..31]] == 60), action=(flags.force_snat_for_lb = 1; ct_lb(backends=10.0.0.50:6062,10.0.0.60:6062);)\n ])\n \n-AT_CHECK([grep \"lr_out_undnat\" lr0flows | sort], [0], [dnl\n-  table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n-  table=0 (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n+AT_CHECK([grep \"lr_out_chk_dnat_local\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_chk_dnat_local), priority=0    , match=(1), action=(reg9[[4]] = 0; next;)\n+])\n+\n+AT_CHECK([grep \"lr_out_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_undnat      ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_undnat      ), priority=50   , match=(ip), action=(flags.loopback = 1; ct_dnat;)\n ])\n \n-AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sort], [0], [dnl\n-  table=1 (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n-  table=1 (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n+AT_CHECK([grep \"lr_out_post_undnat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_post_undnat ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_post_undnat ), priority=50   , match=(ip && ct.new), action=(ct_commit { } ; next; )\n ])\n \n-AT_CHECK([grep \"lr_out_snat\" lr0flows | sort], [0], [dnl\n-  table=2 (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n-  table=2 (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n+AT_CHECK([grep \"lr_out_snat\" lr0flows | sed 's/table=./table=?/' | sort], [0], [dnl\n+  table=? (lr_out_snat        ), priority=0    , match=(1), action=(next;)\n+  table=? (lr_out_snat        ), priority=120  , match=(nd_ns), action=(next;)\n ])\n \n AT_CLEANUP\ndiff --git a/tests/ovn.at b/tests/ovn.at\nindex 0d606b42f..ae5744407 100644\n--- a/tests/ovn.at\n+++ b/tests/ovn.at\n@@ -21604,7 +21604,7 @@ AT_CAPTURE_FILE([sbflows])\n AT_CHECK([for regex in ct_snat ct_dnat ip4.dst= ip4.src=; do\n   grep -c \"$regex\" sbflows;\n done], [0], [0\n-1\n+0\n 2\n 2\n ])\ndiff --git a/tests/system-ovn.at b/tests/system-ovn.at\nindex c9f5771c9..7f6cb32dc 100644\n--- a/tests/system-ovn.at\n+++ b/tests/system-ovn.at\n@@ -2224,7 +2224,7 @@ ovn-nbctl set load_balancer $uuid vips:'\"30.0.0.2:8000\"'='\"192.168.1.2:80,192.16\n \n ovn-nbctl list load_balancer\n ovn-sbctl dump-flows R2\n-OVS_WAIT_UNTIL([ovs-ofctl -O OpenFlow13 dump-flows br-int table=42 | \\\n+OVS_WAIT_UNTIL([ovs-ofctl -O OpenFlow13 dump-flows br-int table=43 | \\\n grep 'nat(src=20.0.0.2)'])\n \n dnl Test load-balancing that includes L4 ports in NAT.\n@@ -2262,7 +2262,7 @@ ovn-nbctl set load_balancer $uuid vips:'\"30.0.0.2:8000\"'='\"192.168.1.2:80,192.16\n \n ovn-nbctl list load_balancer\n ovn-sbctl dump-flows R2\n-OVS_WAIT_UNTIL([ovs-ofctl -O OpenFlow13 dump-flows br-int table=42 | \\\n+OVS_WAIT_UNTIL([ovs-ofctl -O OpenFlow13 dump-flows br-int table=43 | \\\n grep 'nat(src=20.0.0.2)'])\n \n rm -f wget*.log\n@@ -3711,17 +3711,24 @@ sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n icmpv6,orig=(src=fd20::2,dst=fd20::3,id=<cleared>,type=128,code=0),reply=(src=fd11::2,dst=fd20::2,id=<cleared>,type=129,code=0),zone=<cleared>\n ])\n \n+AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n+\n # South-North SNAT: 'foo2' pings 'alice1'. But 'alice1' receives traffic\n-# from 172.16.1.4\n+# from fd20::4\n NS_CHECK_EXEC([foo2], [ping6 -q -c 3 -i 0.3 -w 2 fd20::2 | FORMAT_PING], \\\n [0], [dnl\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that SNAT indeed happened via 'dump-conntrack' command.\n+ovs-appctl dpctl/dump-conntrack | grep icmpv6\n AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd11::3) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmpv6,orig=(src=fd11::3,dst=fd20::2,id=<cleared>,type=128,code=0),reply=(src=fd20::2,dst=fd11::3,id=<cleared>,type=129,code=0),zone=<cleared>\n+])\n+\n+# We verify that SNAT indeed happened via 'dump-conntrack' command.\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd20::4) | \\\n+sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n+icmpv6,orig=(src=fd11::3,dst=fd20::2,id=<cleared>,type=128,code=0),reply=(src=fd20::2,dst=fd20::4,id=<cleared>,type=129,code=0),zone=<cleared>\n ])\n \n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n@@ -3861,11 +3868,9 @@ NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 192.168.2.2 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(192.168.2.2) | \\\n+# We verify that the connection is not tracked.\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep icmp | FORMAT_CT(192.168.2.2) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmp,orig=(src=192.168.1.2,dst=192.168.2.2,id=<cleared>,type=8,code=0),reply=(src=192.168.2.2,dst=192.168.1.2,id=<cleared>,type=0,code=0),zone=<cleared>\n ])\n \n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n@@ -3875,11 +3880,9 @@ NS_CHECK_EXEC([foo2], [ping -q -c 3 -i 0.3 -w 2 192.168.2.2 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(192.168.2.2) | \\\n+# We verify that the connection is not tracked.\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep icmp | FORMAT_CT(192.168.2.2) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmp,orig=(src=192.168.1.3,dst=192.168.2.2,id=<cleared>,type=8,code=0),reply=(src=192.168.2.2,dst=192.168.1.3,id=<cleared>,type=0,code=0),zone=<cleared>\n ])\n \n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n@@ -3889,14 +3892,13 @@ NS_CHECK_EXEC([bar1], [ping -q -c 3 -i 0.3 -w 2 192.168.1.3 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(192.168.2.2) | \\\n+# We verify that the connection is not tracked.\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep icmp | FORMAT_CT(192.168.2.2) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmp,orig=(src=192.168.2.2,dst=192.168.1.3,id=<cleared>,type=8,code=0),reply=(src=192.168.1.3,dst=192.168.2.2,id=<cleared>,type=0,code=0),zone=<cleared>\n ])\n \n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n+\n # East-West NAT: 'foo1' pings 'bar1' using 172.16.1.4.\n NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 172.16.1.4 | FORMAT_PING], \\\n [0], [dnl\n@@ -3905,11 +3907,10 @@ NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 172.16.1.4 | FORMAT_PING], \\\n \n # Check conntrack entries.  First SNAT of 'foo1' address happens.\n # Then DNAT of 'bar1' address happens (listed first below).\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.1.4) | \\\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep icmp | FORMAT_CT(172.16.1.4) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n icmp,orig=(src=172.16.1.3,dst=172.16.1.4,id=<cleared>,type=8,code=0),reply=(src=192.168.2.2,dst=172.16.1.3,id=<cleared>,type=0,code=0),zone=<cleared>\n icmp,orig=(src=192.168.1.2,dst=172.16.1.4,id=<cleared>,type=8,code=0),reply=(src=172.16.1.4,dst=172.16.1.3,id=<cleared>,type=0,code=0),zone=<cleared>\n-icmp,orig=(src=192.168.1.2,dst=172.16.1.4,id=<cleared>,type=8,code=0),reply=(src=172.16.1.4,dst=192.168.1.2,id=<cleared>,type=0,code=0),zone=<cleared>\n ])\n \n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n@@ -3922,7 +3923,7 @@ NS_CHECK_EXEC([foo2], [ping -q -c 3 -i 0.3 -w 2 172.16.1.4 | FORMAT_PING], \\\n \n # Check conntrack entries.  First SNAT of 'foo2' address happens.\n # Then DNAT of 'bar1' address happens (listed first below).\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.1.1) | \\\n+AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep icmp | FORMAT_CT(172.16.1.1) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n icmp,orig=(src=172.16.1.1,dst=172.16.1.4,id=<cleared>,type=8,code=0),reply=(src=192.168.2.2,dst=172.16.1.1,id=<cleared>,type=0,code=0),zone=<cleared>\n icmp,orig=(src=192.168.1.3,dst=172.16.1.4,id=<cleared>,type=8,code=0),reply=(src=172.16.1.4,dst=172.16.1.1,id=<cleared>,type=0,code=0),zone=<cleared>\n@@ -4055,13 +4056,6 @@ NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 fd12::2 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd12::2) | \\\n-sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmpv6,orig=(src=fd11::2,dst=fd12::2,id=<cleared>,type=128,code=0),reply=(src=fd12::2,dst=fd11::2,id=<cleared>,type=129,code=0),zone=<cleared>\n-])\n-\n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n # East-West No NAT: 'foo2' pings 'bar1' using fd12::2.\n NS_CHECK_EXEC([foo2], [ping -q -c 3 -i 0.3 -w 2 fd12::2 | FORMAT_PING], \\\n@@ -4069,13 +4063,6 @@ NS_CHECK_EXEC([foo2], [ping -q -c 3 -i 0.3 -w 2 fd12::2 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd12::2) | \\\n-sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmpv6,orig=(src=fd11::3,dst=fd12::2,id=<cleared>,type=128,code=0),reply=(src=fd12::2,dst=fd11::3,id=<cleared>,type=129,code=0),zone=<cleared>\n-])\n-\n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n # East-West No NAT: 'bar1' pings 'foo2' using fd11::3.\n NS_CHECK_EXEC([bar1], [ping -q -c 3 -i 0.3 -w 2 fd11::3 | FORMAT_PING], \\\n@@ -4083,13 +4070,6 @@ NS_CHECK_EXEC([bar1], [ping -q -c 3 -i 0.3 -w 2 fd11::3 | FORMAT_PING], \\\n 3 packets transmitted, 3 received, 0% packet loss, time 0ms\n ])\n \n-# We verify that the connection is tracked but not NATted. This is due to the\n-# unDNAT table in the egress router pipeline\n-AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd12::2) | \\\n-sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmpv6,orig=(src=fd12::2,dst=fd11::3,id=<cleared>,type=128,code=0),reply=(src=fd11::3,dst=fd12::2,id=<cleared>,type=129,code=0),zone=<cleared>\n-])\n-\n AT_CHECK([ovs-appctl dpctl/flush-conntrack])\n # East-West NAT: 'foo1' pings 'bar1' using fd20::4.\n NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 fd20::4 | FORMAT_PING], \\\n@@ -4101,7 +4081,6 @@ NS_CHECK_EXEC([foo1], [ping -q -c 3 -i 0.3 -w 2 fd20::4 | FORMAT_PING], \\\n # Then DNAT of 'bar1' address happens (listed first below).\n AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd20::4) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n-icmpv6,orig=(src=fd11::2,dst=fd20::4,id=<cleared>,type=128,code=0),reply=(src=fd20::4,dst=fd11::2,id=<cleared>,type=129,code=0),zone=<cleared>\n icmpv6,orig=(src=fd11::2,dst=fd20::4,id=<cleared>,type=128,code=0),reply=(src=fd20::4,dst=fd20::3,id=<cleared>,type=129,code=0),zone=<cleared>\n icmpv6,orig=(src=fd20::3,dst=fd20::4,id=<cleared>,type=128,code=0),reply=(src=fd12::2,dst=fd20::3,id=<cleared>,type=129,code=0),zone=<cleared>\n ])\n@@ -6037,7 +6016,6 @@ NS_CHECK_EXEC([sw01-x], [ping -q -c 3 -i 0.3 -w 2 172.16.1.100 | FORMAT_PING], \\\n AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.1.100) | \\\n sed -e 's/zone=[[0-9]]*/zone=<cleared>/'], [0], [dnl\n icmp,orig=(src=192.168.1.2,dst=172.16.1.100,id=<cleared>,type=8,code=0),reply=(src=172.16.1.100,dst=172.16.1.20,id=<cleared>,type=0,code=0),zone=<cleared>\n-icmp,orig=(src=192.168.1.2,dst=172.16.1.100,id=<cleared>,type=8,code=0),reply=(src=172.16.1.100,dst=192.168.1.2,id=<cleared>,type=0,code=0),zone=<cleared>\n ])\n \n OVS_APP_EXIT_AND_WAIT([ovn-controller])\n",
    "prefixes": [
        "ovs-dev",
        "v2",
        "2/2"
    ]
}