diff mbox series

[ovs-dev,v6,2/3] northd: make default drops explicit

Message ID 20221121161217.304094-3-amorenoz@redhat.com
State Accepted
Delegated to: Dumitru Ceara
Headers show
Series Add ovn drop debugging | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Adrián Moreno Nov. 21, 2022, 4:12 p.m. UTC
By default, traffic that doesn't match any configured flow will be dropped.
But having that behavior implicit makes those drops more difficult to
visualize.

Make default drops explicit both as default logical flows and as default
openflow flows (e.g: for physical tables). The only exceptions are
physical tables 68 and 70 that are used to implement chk_lb_hairpin and
ct_snat_to_vip actions and don't drop traffic.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 controller/physical.c   |  32 ++++++++
 northd/northd.c         |  34 +++++++-
 northd/ovn-northd.8.xml |  40 +++++++++-
 tests/ovn-northd.at     |  84 ++++++++++++++++++++
 tests/ovn.at            | 169 +++++++++++++++++++++++++++++++++++++++-
 5 files changed, 349 insertions(+), 10 deletions(-)

Comments

Numan Siddique Nov. 23, 2022, 3:30 p.m. UTC | #1
On Mon, Nov 21, 2022 at 11:13 AM Adrian Moreno <amorenoz@redhat.com> wrote:
>
> By default, traffic that doesn't match any configured flow will be dropped.
> But having that behavior implicit makes those drops more difficult to
> visualize.
>
> Make default drops explicit both as default logical flows and as default
> openflow flows (e.g: for physical tables). The only exceptions are
> physical tables 68 and 70 that are used to implement chk_lb_hairpin and
> ct_snat_to_vip actions and don't drop traffic.
>
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>

Acked-by: Numan Siddique <numans@ovn.org>

This patch series needs a rebase.  Can you please spin up  v7 ?

Numan

> ---
>  controller/physical.c   |  32 ++++++++
>  northd/northd.c         |  34 +++++++-
>  northd/ovn-northd.8.xml |  40 +++++++++-
>  tests/ovn-northd.at     |  84 ++++++++++++++++++++
>  tests/ovn.at            | 169 +++++++++++++++++++++++++++++++++++++++-
>  5 files changed, 349 insertions(+), 10 deletions(-)
>
> diff --git a/controller/physical.c b/controller/physical.c
> index 705146316..58c4e1f05 100644
> --- a/controller/physical.c
> +++ b/controller/physical.c
> @@ -833,6 +833,17 @@ put_zones_ofpacts(const struct zone_ids *zone_ids, struct ofpbuf *ofpacts_p)
>      }
>  }
>
> +static void
> +add_default_drop_flow(uint8_t table_id,
> +                      struct ovn_desired_flow_table *flow_table)
> +{
> +    struct match match = MATCH_CATCHALL_INITIALIZER;
> +    struct ofpbuf ofpacts;
> +    ofpbuf_init(&ofpacts, 0);
> +    ofctrl_add_flow(flow_table, table_id, 0, 0, &match,
> +                    &ofpacts, hc_uuid);
> +}
> +
>  static void
>  put_local_common_flows(uint32_t dp_key,
>                         const struct sbrec_port_binding *pb,
> @@ -2114,6 +2125,13 @@ physical_run(struct physical_ctx *p_ctx,
>          }
>      }
>
> +    /* Table 0, priority 0.
> +     * ======================
> +     *
> +     * Drop packets tha do not match any tunnel in_port.
> +     */
> +    add_default_drop_flow(OFTABLE_PHY_TO_LOG, flow_table);
> +
>      /* Table 37, priority 150.
>       * =======================
>       *
> @@ -2159,6 +2177,13 @@ physical_run(struct physical_ctx *p_ctx,
>      ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 0, 0, &match,
>                      &ofpacts, hc_uuid);
>
> +    /* Table 38, priority 0.
> +     * ======================
> +     *
> +     * Drop packets that do not match previous flows.
> +     */
> +    add_default_drop_flow(OFTABLE_LOCAL_OUTPUT, flow_table);
> +
>      /* Table 39, Priority 0.
>       * =======================
>       *
> @@ -2185,5 +2210,12 @@ physical_run(struct physical_ctx *p_ctx,
>      ofctrl_add_flow(flow_table, OFTABLE_SAVE_INPORT, 0, 0, &match,
>                      &ofpacts, hc_uuid);
>
> +    /* Table 65, priority 0.
> +     * ======================
> +     *
> +     * Drop packets that do not match previous flows.
> +     */
> +    add_default_drop_flow(OFTABLE_LOG_TO_PHY, flow_table);
> +
>      ofpbuf_uninit(&ofpacts);
>  }
> diff --git a/northd/northd.c b/northd/northd.c
> index e1f3bace8..1cccc33df 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -5155,6 +5155,16 @@ ovn_lflow_add_at(struct hmap *lflow_map, struct ovn_datapath *od,
>                                 io_port, ctrl_meter, stage_hint, where, hash);
>  }
>
> +static void
> +__ovn_lflow_add_default_drop(struct hmap *lflow_map,
> +                             struct ovn_datapath *od,
> +                             enum ovn_stage stage,
> +                             const char *where)
> +{
> +    ovn_lflow_add_at(lflow_map, od, stage, 0, "1", "drop;",
> +                         NULL, NULL, NULL, where );
> +}
> +
>  /* Adds a row with the specified contents to the Logical_Flow table. */
>  #define ovn_lflow_add_with_hint__(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, \
>                                    ACTIONS, IN_OUT_PORT, CTRL_METER, \
> @@ -5167,6 +5177,10 @@ ovn_lflow_add_at(struct hmap *lflow_map, struct ovn_datapath *od,
>      ovn_lflow_add_at(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
>                       NULL, NULL, STAGE_HINT, OVS_SOURCE_LOCATOR)
>
> +#define ovn_lflow_add_default_drop(LFLOW_MAP, OD, STAGE)                    \
> +    __ovn_lflow_add_default_drop(LFLOW_MAP, OD, STAGE, OVS_SOURCE_LOCATOR)
> +
> +
>  /* This macro is similar to ovn_lflow_add_with_hint, except that it requires
>   * the IN_OUT_PORT argument, which tells the lport name that appears in the
>   * MATCH, which helps ovn-controller to bypass lflows parsing when the lport is
> @@ -10975,6 +10989,9 @@ build_adm_ctrl_flows_for_lrouter(
>           * Broadcast/multicast source address is invalid. */
>          ovn_lflow_add(lflows, od, S_ROUTER_IN_ADMISSION, 100,
>                        "vlan.present || eth.src[40]", "drop;");
> +
> +        /* Default action for L2 security is to drop. */
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_ADMISSION);
>      }
>  }
>
> @@ -11216,6 +11233,8 @@ build_neigh_learning_flows_for_lrouter(
>                            "nd_ns", "put_nd(inport, ip6.src, nd.sll); next;",
>                            copp_meter_get(COPP_ND_NS, od->nbr->copp,
>                                           meter_groups));
> +
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_LEARN_NEIGHBOR);
>      }
>
>  }
> @@ -11492,6 +11511,8 @@ build_static_route_flows_for_lrouter(
>          const struct hmap *bfd_connections)
>  {
>      if (od->nbr) {
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP);
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING);
>          ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP, 150,
>                        REG_ECMP_GROUP_ID" == 0", "next;");
>
> @@ -11663,6 +11684,7 @@ build_ingress_policy_flows_for_lrouter(
>                        REG_ECMP_GROUP_ID" = 0; next;");
>          ovn_lflow_add(lflows, od, S_ROUTER_IN_POLICY_ECMP, 150,
>                        REG_ECMP_GROUP_ID" == 0", "next;");
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_POLICY_ECMP);
>
>          /* Convert routing policies to flows. */
>          uint16_t ecmp_group_id = 1;
> @@ -11695,11 +11717,13 @@ build_arp_resolve_flows_for_lrouter(
>          ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 500,
>                        "ip4.mcast || ip6.mcast", "next;");
>
> -        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 0, "ip4",
> +        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 1, "ip4",
>                        "get_arp(outport, " REG_NEXT_HOP_IPV4 "); next;");
>
> -        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 0, "ip6",
> +        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 1, "ip6",
>                        "get_nd(outport, " REG_NEXT_HOP_IPV6 "); next;");
> +
> +        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_ARP_RESOLVE);
>      }
>  }
>
> @@ -11825,9 +11849,9 @@ build_arp_resolve_flows_for_lrouter_port(
>           * in stage "lr_in_ip_input" but traffic that could have been unSNATed
>           * but didn't match any existing session might still end up here.
>           *
> -         * Priority 1.
> +         * Priority 2.
>           */
> -        build_lrouter_drop_own_dest(op, S_ROUTER_IN_ARP_RESOLVE, 1, true,
> +        build_lrouter_drop_own_dest(op, S_ROUTER_IN_ARP_RESOLVE, 2, true,
>                                      lflows);
>      } else if (op->od->n_router_ports && !lsp_is_router(op->nbsp)
>                 && strcmp(op->nbsp->type, "virtual")) {
> @@ -12429,6 +12453,8 @@ build_egress_delivery_flows_for_lrouter_port(
>          ds_put_format(match, "outport == %s", op->json_key);
>          ovn_lflow_add(lflows, op->od, S_ROUTER_OUT_DELIVERY, 100,
>                        ds_cstr(match), "output;");
> +
> +        ovn_lflow_add_default_drop(lflows, op->od, S_ROUTER_OUT_DELIVERY);
>      }
>
>  }
> diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml
> index 051f3dc6e..ab01add2f 100644
> --- a/northd/ovn-northd.8.xml
> +++ b/northd/ovn-northd.8.xml
> @@ -2151,6 +2151,11 @@ output;
>            the NAT rule resides.
>          </p>
>        </li>
> +
> +      <li>
> +        A priority-0 logical flow that matches all packets not already handled
> +        (match <code>1</code>) and drops them (action <code>drop;</code>).
> +      </li>
>      </ul>
>
>      <p>
> @@ -2358,6 +2363,11 @@ next;
>          applies the action
>          <code>put_nd(inport, ip6.src, nd.sll); next;</code>
>        </li>
> +
> +      <li>
> +        A priority-0 logical flow that matches all packets not already handled
> +        (match <code>1</code>) and drops them (action <code>drop;</code>).
> +      </li>
>      </ul>
>
>      <h3>Ingress Table 3: IP Input</h3>
> @@ -3739,6 +3749,11 @@ reg8[0..15] = <var>GID</var>;
>  select(reg8[16..31], <var>MID1</var>, <var>MID2</var>, ...);
>          </pre>
>        </li>
> +
> +      <li>
> +        A priority-0 logical flow that matches all packets not already handled
> +        (match <code>1</code>) and drops them (action <code>drop;</code>).
> +      </li>
>      </ul>
>
>      <h3>Ingress Table 12: IP_ROUTING_ECMP</h3>
> @@ -3791,6 +3806,11 @@ eth.src = <var>E</var>;
>  outport = <var>P</var>;
>          </pre>
>        </li>
> +
> +      <li>
> +        A priority-0 logical flow that matches all packets not already handled
> +        (match <code>1</code>) and drops them (action <code>drop;</code>).
> +      </li>
>      </ul>
>
>      <h3>Ingress Table 13: Router policies</h3>
> @@ -3907,6 +3927,11 @@ outport = <var>P</var>
>            which the <code>nexthop</code> is reachable.
>          </p>
>        </li>
> +
> +      <li>
> +        A priority-0 logical flow that matches all packets not already handled
> +        (match <code>1</code>) and drops them (action <code>drop;</code>).
> +      </li>
>      </ul>
>
>      <h3>Ingress Table 15: ARP/ND Resolution</h3>
> @@ -4082,16 +4107,22 @@ outport = <var>P</var>
>          </p>
>
>          <p>
> -          A priority-1 logical flow with match <code>ip4.dst = {..}</code>
> +          A priority-2 logical flow with match <code>ip4.dst = {..}</code>
>            matches on traffic destined to router owned IPv4 addresses which are
>            also SNAT IPs. This flow has action <code>drop;</code>.
>          </p>
>
>          <p>
> -          A priority-1 logical flow with match <code>ip6.dst = {..}</code>
> +          A priority-2 logical flow with match <code>ip6.dst = {..}</code>
>            matches on traffic destined to router owned IPv6 addresses which are
>            also SNAT IPs. This flow has action <code>drop;</code>.
>          </p>
> +
> +        <p>
> +          A priority-0 logical that flow matches all packets not already
> +          handled (match <code>1</code>) and drops them
> +          (action <code>drop;</code>).
> +        </p>
>        </li>
>
>        <li>
> @@ -4808,6 +4839,11 @@ clone {
>            Priority-100 logical flows that match packets on each enabled
>            logical router port, with action <code>output;</code>.
>          </li>
> +        <li>
> +          A priority-0 logical flow that matches all packets not already
> +          handled (match <code>1</code>) and drops them
> +          (action <code>drop;</code>).
> +        </li>
>        </ul>
>      </p>
>
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index e849afd85..778eb84c6 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -2850,6 +2850,7 @@ AT_CAPTURE_FILE([lr0flows3])
>  AT_CHECK([grep "lr_in_policy" lr0flows3 | sed 's/table=../table=??/' | sort], [0], [dnl
>    table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = 0; next;)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
> @@ -2865,6 +2866,7 @@ sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
>    table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2);)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
> @@ -2884,6 +2886,7 @@ sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2);)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
> @@ -2902,6 +2905,7 @@ sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
>    table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
>    table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 3), action=(reg0 = 172.168.0.103; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
> @@ -2917,6 +2921,7 @@ sed 's/reg8\[[0..15\]] = [[0-9]]*/reg8\[[0..15\]] = <cleared>/' | \
>  sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table=../table=??/' | sort], [0], [dnl
>    table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
>    table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == <cleared>), action=(next;)
>  ])
>
> @@ -2928,6 +2933,7 @@ AT_CHECK([grep "lr_in_policy" lr0flows3 |  \
>  sed 's/reg8\[[0..15\]] = [[0-9]]*/reg8\[[0..15\]] = <cleared>/' | \
>  sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table=../table=??/' | sort], [0], [dnl
>    table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
> +  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == <cleared>), action=(next;)
>  ])
>
> @@ -5762,6 +5768,7 @@ ovn-sbctl dump-flows lr0 > lr0flows
>  AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows |sort], [0], [dnl
>  ])
>  AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/table=../table=??/' |sort], [0], [dnl
> +  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
>  ])
>
> @@ -5772,6 +5779,7 @@ AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | sed 's/table=../table=??
>    table=??(lr_in_ip_routing   ), priority=97   , match=(reg7 == 0 && ip4.dst == 1.0.0.1/32), action=(ip.ttl--; flags.loopback = 1; reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
>  ])
>  AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/192\.168\.0\..0/192.168.0.??/' | sed 's/table=../table=??/' | sort], [0], [dnl
> +  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
>    table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
>    table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
> @@ -5815,6 +5823,7 @@ AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | sed 's/table=../table=??
>    table=??(lr_in_ip_routing   ), priority=97   , match=(reg7 == 0 && ip4.dst == 1.0.0.1/32), action=(ip.ttl--; flags.loopback = 1; reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
>  ])
>  AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/192\.168\.0\..0/192.168.0.??/' | sed 's/table=../table=??/' | sort], [0], [dnl
> +  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
>    table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
>    table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
>    table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
> @@ -6896,6 +6905,7 @@ AT_CHECK([cat lrflows | grep -e lr_in_lookup_neighbor -e lr_in_learn_neighbor |
>    table=1 (lr_in_lookup_neighbor), priority=100  , match=(arp.op == 2), action=(reg9[[2]] = lookup_arp(inport, arp.spa, arp.sha); next;)
>    table=1 (lr_in_lookup_neighbor), priority=100  , match=(nd_na), action=(reg9[[2]] = lookup_nd(inport, nd.target, nd.tll); next;)
>    table=1 (lr_in_lookup_neighbor), priority=100  , match=(nd_ns), action=(reg9[[2]] = lookup_nd(inport, ip6.src, nd.sll); next;)
> +  table=2 (lr_in_learn_neighbor), priority=0    , match=(1), action=(drop;)
>    table=2 (lr_in_learn_neighbor), priority=100  , match=(reg9[[2]] == 1), action=(next;)
>    table=2 (lr_in_learn_neighbor), priority=90   , match=(arp), action=(put_arp(inport, arp.spa, arp.sha); next;)
>    table=2 (lr_in_learn_neighbor), priority=90   , match=(nd_na), action=(put_nd(inport, nd.target, nd.tll); next;)
> @@ -7929,3 +7939,77 @@ AT_CHECK([grep "lr_in_arp_resolve" R1flows | grep priority=90 | sort], [0], [dnl
>
>  AT_CLEANUP
>  ])
> +
> +OVN_FOR_EACH_NORTHD([
> +AT_SETUP([Check default drop])
> +AT_KEYWORDS([drop])
> +
> +# Check that there is an explicit drop lflow in all tables.
> +check_default_lflow() {
> +    dps=$(ovn-sbctl --bare  --columns=_uuid list Datapath_Binding | xargs)
> +    for dp in $dps; do
> +        for pipeline in ingress egress; do
> +            for table in $(ovn-sbctl --bare --columns=table_id find Logical_Flow logical_datapath="$dp" pipeline="$pipeline" | xargs | sort | uniq); do
> +               echo "Checking if datapath $dp pipeline $pipeline table $table has a default action"
> +               AT_CHECK([ovn-sbctl --columns=_uuid find Logical_Flow logical_datapath="$dp" pipeline="$pipeline" table_id=$table match="1" priority">="0 | wc -l | tr -d "\n\r" ], [0], [1], [ignore],
> +               [echo "Datapath $dp pipeline $pipeline table $table does not have a default action"])
> +            done
> +        done
> +    done
> +}
> +
> +ovn_start
> +
> +# Create LS + LR
> +check ovn-nbctl --wait=sb \
> +                -- lr-add R1 \
> +                -- lrp-add R1 R1-S1 02:ac:10:01:00:01 172.16.1.1/24 \
> +                -- ls-add S1 \
> +                -- lsp-add S1 S1-R1 \
> +                -- lsp-set-type S1-R1 router \
> +                -- lsp-set-addresses S1-R1 02:ac:10:01:00:01 \
> +                -- lsp-set-options S1-R1 router-port=R1-S1 \
> +                -- lsp-add S1 p1 \
> +                -- lsp-set-addresses p1 "02:ac:10:01:00:0a 172.16.1.100"
> +
> +check_default_lflow
> +
> +# Add stateless ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add S1 from-lport 100 'inport=p1 && ip4' allow-stateless
> +
> +check_default_lflow
> +
> +check ovn-nbctl --wait=sb acl-del S1
> +
> +
> +# Add stateful ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add S1 from-lport 2 "udp" allow-related
> +
> +check_default_lflow
> +
> +check ovn-nbctl --wait=sb acl-del S1
> +
> +# Add LB
> +check ovn-nbctl --wait=sb \
> +    -- lb-add lb "10.0.0.1" "10.0.0.2" \
> +    -- ls-lb-add S1 lb
> +
> +check_default_lflow
> +
> +# Check LB + stateless ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add S1 from-lport 100 'inport=p1 && ip4' allow-stateless
> +check_default_lflow
> +
> +check ovn-nbctl --wait=sb acl-del S1
> +
> +# Check LB + statelful ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add S1 from-lport 2 "udp" allow-related
> +
> +check_default_lflow
> +
> +AT_CLEANUP
> +])
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 08d91e2e8..792655f99 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -12777,7 +12777,7 @@ for i in 1 2; do
>      done
>  done
>
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
> +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
>  10
>  11
>  ])
> @@ -12786,7 +12786,7 @@ AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 1
>  as hv1
>  check ovs-vsctl del-port vif01
>  check ovn-nbctl --wait=hv sync
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
> +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
>  11
>  ])
>
> @@ -12794,7 +12794,7 @@ as hv1
>  check ovs-vsctl add-port br-int vif01 \
>      -- set Interface vif01 external-ids:iface-id=lp01
>  check ovn-nbctl --wait=hv sync
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
> +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
>  2
>  11
>  ])
> @@ -27910,7 +27910,7 @@ AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep "actions=controller" | grep
>  ])
>
>  # The packet should've been dropped in the lr_in_arp_resolve stage.
> -AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep -E "table=23, n_packets=1,.* priority=1,ip,metadata=0x${sw_key},nw_dst=10.0.1.1 actions=drop" -c], [0], [dnl
> +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep -E "table=23, n_packets=1,.* priority=2,ip,metadata=0x${sw_key},nw_dst=10.0.1.1 actions=drop" -c], [0], [dnl
>  1
>  ])
>
> @@ -33081,3 +33081,164 @@ check ovn-nbctl --wait=hv sync
>  OVN_CLEANUP([hv1])
>  AT_CLEANUP
>  ])
> +
> +OVN_FOR_EACH_NORTHD([
> +AT_SETUP([Check default openflow flows])
> +ovn_start
> +
> +# Check that every table has a default (i.e: priority=0) flow.
> +# Technically a default flow would have no match but we allow the datapath
> +# match (metadata=0xXX) to be present.
> +check_default_flows() {
> +    ovs-ofctl dump-flows br-int > oflows
> +    AT_CAPTURE_FILE([oflows])
> +    for table in $(grep -oP "table=\K\d*, " oflows | tr -d ',' | sort -n | uniq); do
> +        # Tables 68 and 70 are part of the chk_lb_hairpin and ct_snat_to_vip actions
> +        # respectively and it's OK if they don't have a default action.
> +        if test ${table} -eq 68 -o ${table} -eq 70; then
> +            continue;
> +        fi
> +        AT_CHECK([grep -qe "table=$table.* priority=0\(,metadata=0x\w*\)\? actions" oflows], [0], [ignore], [ignore], [echo "Table $table does not contain a default action"])
> +    done
> +}
> +
> +# Logical network:
> +# Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
> +# network. R1 has a switchs ls1 (191.168.1.0/24) connected to it.
> +# R2 has ls2 (172.16.1.0/24) connected to it.
> +
> +ls1_lp1_mac="f0:00:00:01:02:03"
> +rp_ls1_mac="00:00:00:01:02:03"
> +rp_ls2_mac="00:00:00:01:02:04"
> +ls2_lp1_mac="f0:00:00:01:02:04"
> +
> +ls1_lp1_ip="192.168.1.2"
> +ls2_lp1_ip="172.16.1.2"
> +
> +ovn-nbctl lr-add R1
> +ovn-nbctl ls-add ls1
> +ovn-nbctl ls-add ls2
> +
> +# Connect ls1 to R1
> +ovn-nbctl lrp-add R1 ls1 $rp_ls1_mac 192.168.1.1/24
> +
> +ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
> +  options:router-port=ls1 addresses=\"$rp_ls1_mac\"
> +
> +# Connect ls2 to R1
> +ovn-nbctl lrp-add R1 ls2 $rp_ls2_mac 172.16.1.1/24
> +
> +ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
> +  options:router-port=ls2 addresses=\"$rp_ls2_mac\"
> +
> +# Create logical port ls1-lp1 in ls1
> +ovn-nbctl lsp-add ls1 ls1-lp1 \
> +-- lsp-set-addresses ls1-lp1 "$ls1_lp1_mac $ls1_lp1_ip"
> +
> +# Create logical port ls2-lp1 in ls2
> +ovn-nbctl lsp-add ls2 ls2-lp1 \
> +-- lsp-set-addresses ls2-lp1 "$ls2_lp1_mac $ls2_lp1_ip"
> +
> +# Create two hypervisor and create OVS ports corresponding to logical ports.
> +net_add n1
> +
> +sim_add hv1
> +as hv1
> +ovs-vsctl add-br br-phys
> +ovn_attach n1 br-phys 192.168.0.1
> +ovs-vsctl -- add-port br-int hv1-vif1 -- \
> +    set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \
> +    options:tx_pcap=hv1/vif1-tx.pcap \
> +    options:rxq_pcap=hv1/vif1-rx.pcap \
> +    ofport-request=1
> +
> +sim_add hv2
> +as hv2
> +ovs-vsctl add-br br-phys
> +ovn_attach n1 br-phys 192.168.0.2
> +ovs-vsctl -- add-port br-int hv2-vif1 -- \
> +    set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \
> +    options:tx_pcap=hv2/vif1-tx.pcap \
> +    options:rxq_pcap=hv2/vif1-rx.pcap \
> +    ofport-request=1
> +
> +
> +# Allow some time for ovn-northd and ovn-controller to catch up.
> +wait_for_ports_up
> +check ovn-nbctl --wait=hv sync
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +# Add stateless ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls1 from-lport 100 'ip4' allow-stateless
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls2 from-lport 100 'ip4' allow-stateless
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +check ovn-nbctl --wait=sb acl-del ls1
> +check ovn-nbctl --wait=sb acl-del ls2
> +
> +# Add stateful ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls1 from-lport 100 "udp" allow-related
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls2 from-lport 100 "udp" allow-related
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +check ovn-nbctl --wait=sb acl-del ls1
> +check ovn-nbctl --wait=sb acl-del ls2
> +
> +# Add LB
> +check ovn-nbctl --wait=sb \
> +    -- lb-add lb1 "10.0.0.1" "10.0.0.2" \
> +    -- ls-lb-add ls1 lb1
> +
> +check ovn-nbctl --wait=sb \
> +    -- lb-add lb2 "10.0.1.1" "10.0.1.2" \
> +    -- ls-lb-add ls2 lb2
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +# LB + stateless ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls1 from-lport 100 'ip4' allow-stateless
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls2 from-lport 100 'ip4' allow-stateless
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +check ovn-nbctl --wait=sb acl-del ls1
> +check ovn-nbctl --wait=sb acl-del ls2
> +
> +# LB + stateful ACL
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls1 from-lport 100 "udp" allow-related
> +check ovn-nbctl --wait=sb \
> +                -- acl-add ls2 from-lport 100 "udp" allow-related
> +
> +as hv1
> +check_default_flows
> +as hv2
> +check_default_flows
> +
> +OVN_CLEANUP([hv1],[hv2])
> +AT_CLEANUP
> +])
> --
> 2.38.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/controller/physical.c b/controller/physical.c
index 705146316..58c4e1f05 100644
--- a/controller/physical.c
+++ b/controller/physical.c
@@ -833,6 +833,17 @@  put_zones_ofpacts(const struct zone_ids *zone_ids, struct ofpbuf *ofpacts_p)
     }
 }
 
+static void
+add_default_drop_flow(uint8_t table_id,
+                      struct ovn_desired_flow_table *flow_table)
+{
+    struct match match = MATCH_CATCHALL_INITIALIZER;
+    struct ofpbuf ofpacts;
+    ofpbuf_init(&ofpacts, 0);
+    ofctrl_add_flow(flow_table, table_id, 0, 0, &match,
+                    &ofpacts, hc_uuid);
+}
+
 static void
 put_local_common_flows(uint32_t dp_key,
                        const struct sbrec_port_binding *pb,
@@ -2114,6 +2125,13 @@  physical_run(struct physical_ctx *p_ctx,
         }
     }
 
+    /* Table 0, priority 0.
+     * ======================
+     *
+     * Drop packets tha do not match any tunnel in_port.
+     */
+    add_default_drop_flow(OFTABLE_PHY_TO_LOG, flow_table);
+
     /* Table 37, priority 150.
      * =======================
      *
@@ -2159,6 +2177,13 @@  physical_run(struct physical_ctx *p_ctx,
     ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 0, 0, &match,
                     &ofpacts, hc_uuid);
 
+    /* Table 38, priority 0.
+     * ======================
+     *
+     * Drop packets that do not match previous flows.
+     */
+    add_default_drop_flow(OFTABLE_LOCAL_OUTPUT, flow_table);
+
     /* Table 39, Priority 0.
      * =======================
      *
@@ -2185,5 +2210,12 @@  physical_run(struct physical_ctx *p_ctx,
     ofctrl_add_flow(flow_table, OFTABLE_SAVE_INPORT, 0, 0, &match,
                     &ofpacts, hc_uuid);
 
+    /* Table 65, priority 0.
+     * ======================
+     *
+     * Drop packets that do not match previous flows.
+     */
+    add_default_drop_flow(OFTABLE_LOG_TO_PHY, flow_table);
+
     ofpbuf_uninit(&ofpacts);
 }
diff --git a/northd/northd.c b/northd/northd.c
index e1f3bace8..1cccc33df 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -5155,6 +5155,16 @@  ovn_lflow_add_at(struct hmap *lflow_map, struct ovn_datapath *od,
                                io_port, ctrl_meter, stage_hint, where, hash);
 }
 
+static void
+__ovn_lflow_add_default_drop(struct hmap *lflow_map,
+                             struct ovn_datapath *od,
+                             enum ovn_stage stage,
+                             const char *where)
+{
+    ovn_lflow_add_at(lflow_map, od, stage, 0, "1", "drop;",
+                         NULL, NULL, NULL, where );
+}
+
 /* Adds a row with the specified contents to the Logical_Flow table. */
 #define ovn_lflow_add_with_hint__(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, \
                                   ACTIONS, IN_OUT_PORT, CTRL_METER, \
@@ -5167,6 +5177,10 @@  ovn_lflow_add_at(struct hmap *lflow_map, struct ovn_datapath *od,
     ovn_lflow_add_at(LFLOW_MAP, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
                      NULL, NULL, STAGE_HINT, OVS_SOURCE_LOCATOR)
 
+#define ovn_lflow_add_default_drop(LFLOW_MAP, OD, STAGE)                    \
+    __ovn_lflow_add_default_drop(LFLOW_MAP, OD, STAGE, OVS_SOURCE_LOCATOR)
+
+
 /* This macro is similar to ovn_lflow_add_with_hint, except that it requires
  * the IN_OUT_PORT argument, which tells the lport name that appears in the
  * MATCH, which helps ovn-controller to bypass lflows parsing when the lport is
@@ -10975,6 +10989,9 @@  build_adm_ctrl_flows_for_lrouter(
          * Broadcast/multicast source address is invalid. */
         ovn_lflow_add(lflows, od, S_ROUTER_IN_ADMISSION, 100,
                       "vlan.present || eth.src[40]", "drop;");
+
+        /* Default action for L2 security is to drop. */
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_ADMISSION);
     }
 }
 
@@ -11216,6 +11233,8 @@  build_neigh_learning_flows_for_lrouter(
                           "nd_ns", "put_nd(inport, ip6.src, nd.sll); next;",
                           copp_meter_get(COPP_ND_NS, od->nbr->copp,
                                          meter_groups));
+
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_LEARN_NEIGHBOR);
     }
 
 }
@@ -11492,6 +11511,8 @@  build_static_route_flows_for_lrouter(
         const struct hmap *bfd_connections)
 {
     if (od->nbr) {
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP);
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING);
         ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP, 150,
                       REG_ECMP_GROUP_ID" == 0", "next;");
 
@@ -11663,6 +11684,7 @@  build_ingress_policy_flows_for_lrouter(
                       REG_ECMP_GROUP_ID" = 0; next;");
         ovn_lflow_add(lflows, od, S_ROUTER_IN_POLICY_ECMP, 150,
                       REG_ECMP_GROUP_ID" == 0", "next;");
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_POLICY_ECMP);
 
         /* Convert routing policies to flows. */
         uint16_t ecmp_group_id = 1;
@@ -11695,11 +11717,13 @@  build_arp_resolve_flows_for_lrouter(
         ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 500,
                       "ip4.mcast || ip6.mcast", "next;");
 
-        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 0, "ip4",
+        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 1, "ip4",
                       "get_arp(outport, " REG_NEXT_HOP_IPV4 "); next;");
 
-        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 0, "ip6",
+        ovn_lflow_add(lflows, od, S_ROUTER_IN_ARP_RESOLVE, 1, "ip6",
                       "get_nd(outport, " REG_NEXT_HOP_IPV6 "); next;");
+
+        ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_ARP_RESOLVE);
     }
 }
 
@@ -11825,9 +11849,9 @@  build_arp_resolve_flows_for_lrouter_port(
          * in stage "lr_in_ip_input" but traffic that could have been unSNATed
          * but didn't match any existing session might still end up here.
          *
-         * Priority 1.
+         * Priority 2.
          */
-        build_lrouter_drop_own_dest(op, S_ROUTER_IN_ARP_RESOLVE, 1, true,
+        build_lrouter_drop_own_dest(op, S_ROUTER_IN_ARP_RESOLVE, 2, true,
                                     lflows);
     } else if (op->od->n_router_ports && !lsp_is_router(op->nbsp)
                && strcmp(op->nbsp->type, "virtual")) {
@@ -12429,6 +12453,8 @@  build_egress_delivery_flows_for_lrouter_port(
         ds_put_format(match, "outport == %s", op->json_key);
         ovn_lflow_add(lflows, op->od, S_ROUTER_OUT_DELIVERY, 100,
                       ds_cstr(match), "output;");
+
+        ovn_lflow_add_default_drop(lflows, op->od, S_ROUTER_OUT_DELIVERY);
     }
 
 }
diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml
index 051f3dc6e..ab01add2f 100644
--- a/northd/ovn-northd.8.xml
+++ b/northd/ovn-northd.8.xml
@@ -2151,6 +2151,11 @@  output;
           the NAT rule resides.
         </p>
       </li>
+
+      <li>
+        A priority-0 logical flow that matches all packets not already handled
+        (match <code>1</code>) and drops them (action <code>drop;</code>).
+      </li>
     </ul>
 
     <p>
@@ -2358,6 +2363,11 @@  next;
         applies the action
         <code>put_nd(inport, ip6.src, nd.sll); next;</code>
       </li>
+
+      <li>
+        A priority-0 logical flow that matches all packets not already handled
+        (match <code>1</code>) and drops them (action <code>drop;</code>).
+      </li>
     </ul>
 
     <h3>Ingress Table 3: IP Input</h3>
@@ -3739,6 +3749,11 @@  reg8[0..15] = <var>GID</var>;
 select(reg8[16..31], <var>MID1</var>, <var>MID2</var>, ...);
         </pre>
       </li>
+
+      <li>
+        A priority-0 logical flow that matches all packets not already handled
+        (match <code>1</code>) and drops them (action <code>drop;</code>).
+      </li>
     </ul>
 
     <h3>Ingress Table 12: IP_ROUTING_ECMP</h3>
@@ -3791,6 +3806,11 @@  eth.src = <var>E</var>;
 outport = <var>P</var>;
         </pre>
       </li>
+
+      <li>
+        A priority-0 logical flow that matches all packets not already handled
+        (match <code>1</code>) and drops them (action <code>drop;</code>).
+      </li>
     </ul>
 
     <h3>Ingress Table 13: Router policies</h3>
@@ -3907,6 +3927,11 @@  outport = <var>P</var>
           which the <code>nexthop</code> is reachable.
         </p>
       </li>
+
+      <li>
+        A priority-0 logical flow that matches all packets not already handled
+        (match <code>1</code>) and drops them (action <code>drop;</code>).
+      </li>
     </ul>
 
     <h3>Ingress Table 15: ARP/ND Resolution</h3>
@@ -4082,16 +4107,22 @@  outport = <var>P</var>
         </p>
 
         <p>
-          A priority-1 logical flow with match <code>ip4.dst = {..}</code>
+          A priority-2 logical flow with match <code>ip4.dst = {..}</code>
           matches on traffic destined to router owned IPv4 addresses which are
           also SNAT IPs. This flow has action <code>drop;</code>.
         </p>
 
         <p>
-          A priority-1 logical flow with match <code>ip6.dst = {..}</code>
+          A priority-2 logical flow with match <code>ip6.dst = {..}</code>
           matches on traffic destined to router owned IPv6 addresses which are
           also SNAT IPs. This flow has action <code>drop;</code>.
         </p>
+
+        <p>
+          A priority-0 logical that flow matches all packets not already
+          handled (match <code>1</code>) and drops them
+          (action <code>drop;</code>).
+        </p>
       </li>
 
       <li>
@@ -4808,6 +4839,11 @@  clone {
           Priority-100 logical flows that match packets on each enabled
           logical router port, with action <code>output;</code>.
         </li>
+        <li>
+          A priority-0 logical flow that matches all packets not already
+          handled (match <code>1</code>) and drops them
+          (action <code>drop;</code>).
+        </li>
       </ul>
     </p>
 
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index e849afd85..778eb84c6 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -2850,6 +2850,7 @@  AT_CAPTURE_FILE([lr0flows3])
 AT_CHECK([grep "lr_in_policy" lr0flows3 | sed 's/table=../table=??/' | sort], [0], [dnl
   table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = 0; next;)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
@@ -2865,6 +2866,7 @@  sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
   table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2);)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
@@ -2884,6 +2886,7 @@  sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.3), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2);)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
@@ -2902,6 +2905,7 @@  sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table
   table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.4), action=(reg8[[0..15]] = <cleared>; reg8[[16..31]] = select(1, 2, 3);)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 1), action=(reg0 = 172.168.0.101; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 2), action=(reg0 = 172.168.0.102; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
   table=??(lr_in_policy_ecmp  ), priority=100  , match=(reg8[[0..15]] == <cleared> && reg8[[16..31]] == 3), action=(reg0 = 172.168.0.103; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; next;)
@@ -2917,6 +2921,7 @@  sed 's/reg8\[[0..15\]] = [[0-9]]*/reg8\[[0..15\]] = <cleared>/' | \
 sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table=../table=??/' | sort], [0], [dnl
   table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
   table=??(lr_in_policy       ), priority=10   , match=(ip4.src == 10.0.0.5), action=(reg0 = 172.168.0.110; reg1 = 172.168.0.100; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; flags.loopback = 1; reg8[[0..15]] = <cleared>; next;)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == <cleared>), action=(next;)
 ])
 
@@ -2928,6 +2933,7 @@  AT_CHECK([grep "lr_in_policy" lr0flows3 |  \
 sed 's/reg8\[[0..15\]] = [[0-9]]*/reg8\[[0..15\]] = <cleared>/' | \
 sed 's/reg8\[[0..15\]] == [[0-9]]*/reg8\[[0..15\]] == <cleared>/' | sed 's/table=../table=??/' | sort], [0], [dnl
   table=??(lr_in_policy       ), priority=0    , match=(1), action=(reg8[[0..15]] = <cleared>; next;)
+  table=??(lr_in_policy_ecmp  ), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_policy_ecmp  ), priority=150  , match=(reg8[[0..15]] == <cleared>), action=(next;)
 ])
 
@@ -5762,6 +5768,7 @@  ovn-sbctl dump-flows lr0 > lr0flows
 AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows |sort], [0], [dnl
 ])
 AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/table=../table=??/' |sort], [0], [dnl
+  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
 ])
 
@@ -5772,6 +5779,7 @@  AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | sed 's/table=../table=??
   table=??(lr_in_ip_routing   ), priority=97   , match=(reg7 == 0 && ip4.dst == 1.0.0.1/32), action=(ip.ttl--; flags.loopback = 1; reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
 ])
 AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/192\.168\.0\..0/192.168.0.??/' | sed 's/table=../table=??/' | sort], [0], [dnl
+  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
   table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
   table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
@@ -5815,6 +5823,7 @@  AT_CHECK([grep -e "lr_in_ip_routing.*select" lr0flows | sed 's/table=../table=??
   table=??(lr_in_ip_routing   ), priority=97   , match=(reg7 == 0 && ip4.dst == 1.0.0.1/32), action=(ip.ttl--; flags.loopback = 1; reg8[[0..15]] = 1; reg8[[16..31]] = select(1, 2);)
 ])
 AT_CHECK([grep -e "lr_in_ip_routing_ecmp" lr0flows | sed 's/192\.168\.0\..0/192.168.0.??/' | sed 's/table=../table=??/' | sort], [0], [dnl
+  table=??(lr_in_ip_routing_ecmp), priority=0    , match=(1), action=(drop;)
   table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 1), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
   table=??(lr_in_ip_routing_ecmp), priority=100  , match=(reg8[[0..15]] == 1 && reg8[[16..31]] == 2), action=(reg0 = 192.168.0.??; reg1 = 192.168.0.1; eth.src = 00:00:20:20:12:13; outport = "lr0-public"; next;)
   table=??(lr_in_ip_routing_ecmp), priority=150  , match=(reg8[[0..15]] == 0), action=(next;)
@@ -6896,6 +6905,7 @@  AT_CHECK([cat lrflows | grep -e lr_in_lookup_neighbor -e lr_in_learn_neighbor |
   table=1 (lr_in_lookup_neighbor), priority=100  , match=(arp.op == 2), action=(reg9[[2]] = lookup_arp(inport, arp.spa, arp.sha); next;)
   table=1 (lr_in_lookup_neighbor), priority=100  , match=(nd_na), action=(reg9[[2]] = lookup_nd(inport, nd.target, nd.tll); next;)
   table=1 (lr_in_lookup_neighbor), priority=100  , match=(nd_ns), action=(reg9[[2]] = lookup_nd(inport, ip6.src, nd.sll); next;)
+  table=2 (lr_in_learn_neighbor), priority=0    , match=(1), action=(drop;)
   table=2 (lr_in_learn_neighbor), priority=100  , match=(reg9[[2]] == 1), action=(next;)
   table=2 (lr_in_learn_neighbor), priority=90   , match=(arp), action=(put_arp(inport, arp.spa, arp.sha); next;)
   table=2 (lr_in_learn_neighbor), priority=90   , match=(nd_na), action=(put_nd(inport, nd.target, nd.tll); next;)
@@ -7929,3 +7939,77 @@  AT_CHECK([grep "lr_in_arp_resolve" R1flows | grep priority=90 | sort], [0], [dnl
 
 AT_CLEANUP
 ])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([Check default drop])
+AT_KEYWORDS([drop])
+
+# Check that there is an explicit drop lflow in all tables.
+check_default_lflow() {
+    dps=$(ovn-sbctl --bare  --columns=_uuid list Datapath_Binding | xargs)
+    for dp in $dps; do
+        for pipeline in ingress egress; do
+            for table in $(ovn-sbctl --bare --columns=table_id find Logical_Flow logical_datapath="$dp" pipeline="$pipeline" | xargs | sort | uniq); do
+               echo "Checking if datapath $dp pipeline $pipeline table $table has a default action"
+               AT_CHECK([ovn-sbctl --columns=_uuid find Logical_Flow logical_datapath="$dp" pipeline="$pipeline" table_id=$table match="1" priority">="0 | wc -l | tr -d "\n\r" ], [0], [1], [ignore],
+               [echo "Datapath $dp pipeline $pipeline table $table does not have a default action"])
+            done
+        done
+    done
+}
+
+ovn_start
+
+# Create LS + LR
+check ovn-nbctl --wait=sb \
+                -- lr-add R1 \
+                -- lrp-add R1 R1-S1 02:ac:10:01:00:01 172.16.1.1/24 \
+                -- ls-add S1 \
+                -- lsp-add S1 S1-R1 \
+                -- lsp-set-type S1-R1 router \
+                -- lsp-set-addresses S1-R1 02:ac:10:01:00:01 \
+                -- lsp-set-options S1-R1 router-port=R1-S1 \
+                -- lsp-add S1 p1 \
+                -- lsp-set-addresses p1 "02:ac:10:01:00:0a 172.16.1.100"
+
+check_default_lflow
+
+# Add stateless ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add S1 from-lport 100 'inport=p1 && ip4' allow-stateless
+
+check_default_lflow
+
+check ovn-nbctl --wait=sb acl-del S1
+
+
+# Add stateful ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add S1 from-lport 2 "udp" allow-related
+
+check_default_lflow
+
+check ovn-nbctl --wait=sb acl-del S1
+
+# Add LB
+check ovn-nbctl --wait=sb \
+    -- lb-add lb "10.0.0.1" "10.0.0.2" \
+    -- ls-lb-add S1 lb
+
+check_default_lflow
+
+# Check LB + stateless ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add S1 from-lport 100 'inport=p1 && ip4' allow-stateless
+check_default_lflow
+
+check ovn-nbctl --wait=sb acl-del S1
+
+# Check LB + statelful ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add S1 from-lport 2 "udp" allow-related
+
+check_default_lflow
+
+AT_CLEANUP
+])
diff --git a/tests/ovn.at b/tests/ovn.at
index 08d91e2e8..792655f99 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -12777,7 +12777,7 @@  for i in 1 2; do
     done
 done
 
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
+AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
 10
 11
 ])
@@ -12786,7 +12786,7 @@  AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 1
 as hv1
 check ovs-vsctl del-port vif01
 check ovn-nbctl --wait=hv sync
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
+AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
 11
 ])
 
@@ -12794,7 +12794,7 @@  as hv1
 check ovs-vsctl add-port br-int vif01 \
     -- set Interface vif01 external-ids:iface-id=lp01
 check ovn-nbctl --wait=hv sync
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
+AT_CHECK([as hv1 ovs-ofctl dump-flows br-int |awk '/table=65/ && !/actions=drop/{print substr($8, 16, length($8))}' |sort -n], [0], [dnl
 2
 11
 ])
@@ -27910,7 +27910,7 @@  AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep "actions=controller" | grep
 ])
 
 # The packet should've been dropped in the lr_in_arp_resolve stage.
-AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep -E "table=23, n_packets=1,.* priority=1,ip,metadata=0x${sw_key},nw_dst=10.0.1.1 actions=drop" -c], [0], [dnl
+AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep -E "table=23, n_packets=1,.* priority=2,ip,metadata=0x${sw_key},nw_dst=10.0.1.1 actions=drop" -c], [0], [dnl
 1
 ])
 
@@ -33081,3 +33081,164 @@  check ovn-nbctl --wait=hv sync
 OVN_CLEANUP([hv1])
 AT_CLEANUP
 ])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([Check default openflow flows])
+ovn_start
+
+# Check that every table has a default (i.e: priority=0) flow.
+# Technically a default flow would have no match but we allow the datapath
+# match (metadata=0xXX) to be present.
+check_default_flows() {
+    ovs-ofctl dump-flows br-int > oflows
+    AT_CAPTURE_FILE([oflows])
+    for table in $(grep -oP "table=\K\d*, " oflows | tr -d ',' | sort -n | uniq); do
+        # Tables 68 and 70 are part of the chk_lb_hairpin and ct_snat_to_vip actions
+        # respectively and it's OK if they don't have a default action.
+        if test ${table} -eq 68 -o ${table} -eq 70; then
+            continue;
+        fi
+        AT_CHECK([grep -qe "table=$table.* priority=0\(,metadata=0x\w*\)\? actions" oflows], [0], [ignore], [ignore], [echo "Table $table does not contain a default action"])
+    done
+}
+
+# Logical network:
+# Two LRs - R1 and R2 that are connected to each other as peers in 20.0.0.0/24
+# network. R1 has a switchs ls1 (191.168.1.0/24) connected to it.
+# R2 has ls2 (172.16.1.0/24) connected to it.
+
+ls1_lp1_mac="f0:00:00:01:02:03"
+rp_ls1_mac="00:00:00:01:02:03"
+rp_ls2_mac="00:00:00:01:02:04"
+ls2_lp1_mac="f0:00:00:01:02:04"
+
+ls1_lp1_ip="192.168.1.2"
+ls2_lp1_ip="172.16.1.2"
+
+ovn-nbctl lr-add R1
+ovn-nbctl ls-add ls1
+ovn-nbctl ls-add ls2
+
+# Connect ls1 to R1
+ovn-nbctl lrp-add R1 ls1 $rp_ls1_mac 192.168.1.1/24
+
+ovn-nbctl lsp-add ls1 rp-ls1 -- set Logical_Switch_Port rp-ls1 type=router \
+  options:router-port=ls1 addresses=\"$rp_ls1_mac\"
+
+# Connect ls2 to R1
+ovn-nbctl lrp-add R1 ls2 $rp_ls2_mac 172.16.1.1/24
+
+ovn-nbctl lsp-add ls2 rp-ls2 -- set Logical_Switch_Port rp-ls2 type=router \
+  options:router-port=ls2 addresses=\"$rp_ls2_mac\"
+
+# Create logical port ls1-lp1 in ls1
+ovn-nbctl lsp-add ls1 ls1-lp1 \
+-- lsp-set-addresses ls1-lp1 "$ls1_lp1_mac $ls1_lp1_ip"
+
+# Create logical port ls2-lp1 in ls2
+ovn-nbctl lsp-add ls2 ls2-lp1 \
+-- lsp-set-addresses ls2-lp1 "$ls2_lp1_mac $ls2_lp1_ip"
+
+# Create two hypervisor and create OVS ports corresponding to logical ports.
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.1
+ovs-vsctl -- add-port br-int hv1-vif1 -- \
+    set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \
+    options:tx_pcap=hv1/vif1-tx.pcap \
+    options:rxq_pcap=hv1/vif1-rx.pcap \
+    ofport-request=1
+
+sim_add hv2
+as hv2
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.2
+ovs-vsctl -- add-port br-int hv2-vif1 -- \
+    set interface hv2-vif1 external-ids:iface-id=ls2-lp1 \
+    options:tx_pcap=hv2/vif1-tx.pcap \
+    options:rxq_pcap=hv2/vif1-rx.pcap \
+    ofport-request=1
+
+
+# Allow some time for ovn-northd and ovn-controller to catch up.
+wait_for_ports_up
+check ovn-nbctl --wait=hv sync
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+# Add stateless ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add ls1 from-lport 100 'ip4' allow-stateless
+check ovn-nbctl --wait=sb \
+                -- acl-add ls2 from-lport 100 'ip4' allow-stateless
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+check ovn-nbctl --wait=sb acl-del ls1
+check ovn-nbctl --wait=sb acl-del ls2
+
+# Add stateful ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add ls1 from-lport 100 "udp" allow-related
+check ovn-nbctl --wait=sb \
+                -- acl-add ls2 from-lport 100 "udp" allow-related
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+check ovn-nbctl --wait=sb acl-del ls1
+check ovn-nbctl --wait=sb acl-del ls2
+
+# Add LB
+check ovn-nbctl --wait=sb \
+    -- lb-add lb1 "10.0.0.1" "10.0.0.2" \
+    -- ls-lb-add ls1 lb1
+
+check ovn-nbctl --wait=sb \
+    -- lb-add lb2 "10.0.1.1" "10.0.1.2" \
+    -- ls-lb-add ls2 lb2
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+# LB + stateless ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add ls1 from-lport 100 'ip4' allow-stateless
+check ovn-nbctl --wait=sb \
+                -- acl-add ls2 from-lport 100 'ip4' allow-stateless
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+check ovn-nbctl --wait=sb acl-del ls1
+check ovn-nbctl --wait=sb acl-del ls2
+
+# LB + stateful ACL
+check ovn-nbctl --wait=sb \
+                -- acl-add ls1 from-lport 100 "udp" allow-related
+check ovn-nbctl --wait=sb \
+                -- acl-add ls2 from-lport 100 "udp" allow-related
+
+as hv1
+check_default_flows
+as hv2
+check_default_flows
+
+OVN_CLEANUP([hv1],[hv2])
+AT_CLEANUP
+])