On 11/13/26 11:16 AM, Ales Musil via dev wrote:
> Flooded ARP replies and neighbor advertisements reenter router ingress
> with a remote logical inport.  Their destination MAC can belong to a
> different router port, so per-port Ethernet admission is insufficient.
> 
> Admit only tunneled replies on transit routers below the Ethernet
> security drops.  Explicitly reject disabled inports before the shared
> exception so replies cannot create or overwrite their MAC bindings.
> Keep neighbor learning, including the NA-without-TLL fallback, without
> requiring the ingress port MAC register.
> 
> Fixes: 7c3f7f415f1d ("northd, controller: Flood ARP and NA packet on transit 
> router.")
> Assisted-by: GPT-6.1 Sol, OpenCode
> Signed-off-by: Ales Musil <[email protected]>
> ---

Hi Ales,

Thanks for the fix!

>  Documentation/ref/ovn-logical-flows.7.rst |  7 ++
>  northd/northd.c                           | 19 ++++-
>  tests/ovn-northd.at                       | 54 +++++++++++++
>  tests/system-ovn.at                       | 93 +++++++++++++++++++++++
>  4 files changed, 171 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/ref/ovn-logical-flows.7.rst 
> b/Documentation/ref/ovn-logical-flows.7.rst
> index 913ebbc83..c3cc08fc9 100644
> --- a/Documentation/ref/ovn-logical-flows.7.rst
> +++ b/Documentation/ref/ovn-logical-flows.7.rst
> @@ -2071,6 +2071,13 @@ Ethernet headers.  It contains the following flows:
>  - Priority-100 flows to drop packets with VLAN tags or multicast Ethernet 
> source
>    addresses.
>  
> +- On transit routers, a priority-40 flow admits ARP replies and IPv6 neighbor
> +  advertisements received from a tunnel, regardless of their destination MAC
> +  address.  These packets reenter ingress to learn remote neighbor bindings;
> +  the IP input table then drops them.  The higher-priority Ethernet security
> +  drops still apply.  A priority-60 flow drops packets from each disabled
> +  router port, overriding the shared admission rule.
> +
>  - For each enabled router port *P* with Ethernet address *E*, a priority-50 
> flow
>    that matches ``inport == P && (eth.mcast || eth.dst == E``), stores the 
> router
>    port ethernet address and advances to next table, with action
> diff --git a/northd/northd.c b/northd/northd.c
> index 750dd4d29..50b0b7d5f 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -15044,6 +15044,14 @@ build_adm_ctrl_flows_for_lrouter(
>                    "vlan.present || eth.src[40]", debug_drop_action(),
>                    lflow_ref);
>  
> +    if (od->is_transit_router) {
> +        /* Flooded replies reenter ingress with a remote inport to learn
> +         * neighbor bindings.  They need not target that port's MAC. */
> +        ovn_lflow_add(lflows, od, S_ROUTER_IN_ADMISSION, 40,
> +                      "flags.tunnel_rx == 1 && (arp.op == 2 || nd_na)",
> +                      "next;", lflow_ref);
> +    }
> +
>      /* Default action for L2 security is to drop. */
>      ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_ADMISSION,
>                                 lflow_ref);
> @@ -15157,8 +15165,15 @@ build_adm_ctrl_flows_for_lrouter_port(
>      ovs_assert(op->nbrp);
>  
>      if (!lrport_is_enabled(op->nbrp)) {
> -        /* Drop packets from disabled logical ports (since logical flow
> -         * tables are default-drop). */
> +        /* Override shared reply admission on transit routers.  Other
> +         * routers reject disabled inports through the default drop. */
> +        if (op->od->is_transit_router) {
> +            ds_clear(match);
> +            ds_put_format(match, "inport == %s", op->json_key);
> +            ovn_lflow_add(lflows, op->od, S_ROUTER_IN_ADMISSION, 60,
> +                          ds_cstr(match), debug_drop_action(), lflow_ref,
> +                          WITH_HINT(&op->nbrp->header_));
> +        }
>          return;
>      }
>  
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index d42ea34ae..01d3c93f1 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -17135,6 +17135,60 @@ OVN_CLEANUP_NORTHD
>  AT_CLEANUP
>  ])
>  
> +OVN_FOR_EACH_NORTHD_NO_HV([
> +AT_SETUP([Transit router - reply admission])
> +ovn_start
> +
> +check ovn-sbctl chassis-add remote geneve 192.0.2.2 \
> +    -- set chassis remote other_config:is-remote=true
> +check ovn-nbctl lr-add tr \
> +    -- lrp-add tr local 00:00:00:00:01:01 10.0.1.1/24 fd00:1::1/64 \
> +    -- lrp-add tr remote 00:00:00:00:02:01 10.0.2.1/24 fd00:2::1/64 \
> +    -- set Logical_Router_Port remote options:requested-chassis=remote
> +check ovn-nbctl --wait=sb sync
> +
> +AT_CHECK([ovn-sbctl lflow-list tr | grep lr_in_admission | grep 
> 'priority=40' | ovn_strip_lflows], [0], [dnl
> +  table=??(lr_in_admission    ), priority=40   , match=(flags.tunnel_rx == 1 
> && (arp.op == 2 || nd_na)), action=(next;)
> +])
> +
> +dnl The reply destination need not be the remote LRP's own MAC address.
> +for learn in true false; do
> +    check ovn-nbctl --wait=sb set Logical_Router tr \
> +        options:always_learn_from_arp_request=$learn
> +    arp='inport == "remote" && eth.src == 00:00:00:00:02:02 && eth.dst == 
> 00:00:00:00:03:01 && arp.op == 2 && arp.spa == 10.0.2.2 && arp.tpa == 
> 10.0.3.1 && arp.sha == 00:00:00:00:02:02 && arp.tha == 00:00:00:00:03:01'
> +    AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $arp" > arp.trace])
> +    AT_CAPTURE_FILE([arp.trace])
> +    AT_CHECK([grep -q 'put_arp(inport, arp.spa, arp.sha)' arp.trace])
> +    for tll in 00:00:00:00:02:02 00:00:00:00:00:00; do
> +        na="inport == \"remote\" && eth.src == 00:00:00:00:02:02 && eth.dst 
> == 00:00:00:00:03:01 && ip6.src == fd00:2::2 && ip6.dst == fd00:3::1 && 
> ip.ttl == 255 && nd_na && nd.target == fd00:2::2 && nd.tll == $tll"
> +        AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $na" | grep -q 
> put_nd])
> +    done
> +    dnl No non-tunnel or VLAN-tagged reply may use the exception.
> +    AT_CHECK([ovn-trace tr "$arp" | grep -q put_arp], [1])
> +    AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && vlan.tci == 0x1001 && 
> $arp" | grep -q put_arp], [1])
> +    AT_CHECK([ovn-trace tr 'flags.tunnel_rx == 1 && inport == "remote" && 
> eth.src == 01:00:00:00:02:02 && eth.dst == 00:00:00:00:03:01 && arp.op == 2' 
> | grep -q put_arp], [1])
> +    AT_CHECK([ovn-trace tr 'flags.tunnel_rx == 1 && inport == "remote" && 
> eth.src == 00:00:00:00:02:02 && eth.dst == 00:00:00:00:03:01 && arp.op == 1' 
> | grep -q put_arp], [1])
> +done
> +CHECK_NO_CHANGE_AFTER_RECOMPUTE
> +
> +dnl Disabling the port must override the shared reply exception.
> +check ovn-nbctl --wait=sb set Logical_Router_Port remote enabled=false
> +AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $arp" | grep -q put_arp], 
> [1])
> +AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $na" | grep -q put_nd], [1])
> +CHECK_NO_CHANGE_AFTER_RECOMPUTE
> +check ovn-nbctl --wait=sb set Logical_Router_Port remote enabled=true
> +AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $arp" | grep -q put_arp])
> +AT_CHECK([ovn-trace tr "flags.tunnel_rx == 1 && $na" | grep -q put_nd])
> +
> +dnl Removing the last remote binding withdraws the exception.
> +check ovn-nbctl --wait=sb lrp-del remote
> +AT_CHECK([ovn-sbctl lflow-list tr | grep lr_in_admission | grep -q 
> 'priority=40'], [1])
> +CHECK_NO_CHANGE_AFTER_RECOMPUTE
> +
> +OVN_CLEANUP_NORTHD
> +AT_CLEANUP
> +])
> +
>  OVN_FOR_EACH_NORTHD_NO_HV([
>  AT_SETUP([Transit router - remote ports])
>  ovn_start
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 035229486..c8bbe8081 100644
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -1,5 +1,98 @@
>  AT_BANNER([system-ovn])
>  
> +OVN_FOR_EACH_NORTHD([
> +AT_SETUP([Transit router - tunneled neighbor admission])

This test is a bit cluttered.

I added some empty lines to separate the logical parts and then pushed
the patch to main, 26.09 and 26.03.

> +CHECK_SCAPY
> +ovn_start
> +OVS_TRAFFIC_VSWITCHD_START()
> +ADD_BR([br-int])
> +ADD_BR([br-phys])
> +check ovs-ofctl add-flow br-phys actions=normal
> +check ip addr add 192.0.2.1/24 dev br-phys
> +check ip link set br-phys up
> +check ovs-vsctl set Open_vSwitch . external_ids:system-id=hv1 \
> +    external_ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \
> +    external_ids:ovn-encap-type=geneve external_ids:ovn-encap-ip=192.0.2.1 \
> +    external_ids:ovn-is-interconn=true \
> +    -- set Bridge br-int fail-mode=secure other_config:disable-in-band=true
> +start_daemon ovn-controller
> +check ovn-sbctl chassis-add hv2 geneve 192.0.2.2 \
> +    -- set Chassis hv2 other_config:is-remote=true
> +check ovn-nbctl lr-add tr \
> +    -- lrp-add tr local 00:00:00:00:01:01 10.0.1.1/24 fd00:1::1/64 \
> +    -- lrp-add tr remote 00:00:00:00:02:01 10.0.2.1/24 fd00:2::1/64 \
> +    -- set Logical_Router_Port remote options:requested-chassis=hv2 \
> +    -- ls-add ls -- lsp-add-router-port ls ls-tr local \
> +    -- lsp-add ls workload -- lsp-set-addresses workload '00:00:00:00:01:02 
> 10.0.1.2'
> +ADD_NAMESPACES(workload, underlay)
> +ADD_VETH(workload, workload, br-int, "10.0.1.2/24", "00:00:00:00:01:02")
> +ADD_VETH(underlay, underlay, br-phys, "192.0.2.2/24", "00:00:00:00:ff:02")
> +wait_for_ports_up
> +check ovn-nbctl --wait=hv sync
> +
> +dp_key=$(fetch_column Datapath_Binding tunnel_key external_ids:name=tr)
> +port_key=$(fetch_column Port_Binding tunnel_key logical_port=remote)
> +underlay_mac=$(ovs-vsctl get Interface br-phys mac_in_use | tr -d '\"')
> +cat > send-replies.py <<'EOF'
> +import argparse
> +from scapy.all import Ether, IP, IPv6, UDP, ARP, sendp
> +from scapy.all import ICMPv6ND_NA, ICMPv6NDOptDstLLAddr
> +from scapy.contrib.geneve import GENEVE, GeneveOptions
> +
> +parser = argparse.ArgumentParser()
> +for name in ("datapath", "port", "host", "network"):
> +    parser.add_argument(name, type=int)
> +parser.add_argument("mac")
> +parser.add_argument("underlay_mac")
> +args = parser.parse_args()
> +outer = (Ether(src="00:00:00:00:ff:02", dst=args.underlay_mac) /
> +         IP(src="192.0.2.2", dst="192.0.2.1") / UDP(dport=6081) /
> +         GENEVE(vni=args.datapath, options=GeneveOptions(
> +             classid=0x102, type=0x80, data=(args.port << 16).to_bytes(4, 
> "big"))))
> +inner = Ether(src=args.mac, dst="00:00:00:00:03:01")
> +ip4 = f"10.0.{args.network}.{args.host}"
> +ip6 = f"fd00:{args.network}::{args.host}"
> +sendp(outer / inner / ARP(op=2, hwsrc=args.mac, psrc=ip4, pdst="10.0.3.1"),
> +      iface="underlay", verbose=False)
> +sendp(outer / inner / IPv6(src=ip6, dst="fd00:3::1", hlim=255) /
> +      ICMPv6ND_NA(tgt=ip6, S=1) / ICMPv6NDOptDstLLAddr(lladdr=args.mac),
> +      iface="underlay", verbose=False)
> +EOF
> +
> +send_replies() {
> +    NS_CHECK_EXEC([underlay], [$PYTHON send-replies.py "$dp_key" "$port_key" 
> "$1" "$2" "$3" "$underlay_mac"], [0], [], [ignore])
> +}
> +send_replies 2 2 00:00:00:00:02:02
> +wait_column '00:00:00:00:02:02' MAC_Binding mac logical_port=remote 
> ip=10.0.2.2
> +wait_column '00:00:00:00:02:02' MAC_Binding mac logical_port=remote 
> ip='"fd00:2::2"'
> +
> +check ovn-nbctl --wait=hv set Logical_Router_Port remote enabled=false
> +send_replies 2 2 00:00:00:00:02:99
> +send_replies 99 2 00:00:00:00:02:99
> +remote_key=$port_key
> +port_key=$(fetch_column Port_Binding tunnel_key logical_port=local)
> +send_replies 99 1 00:00:00:00:01:99
> +wait_column '00:00:00:00:01:99' MAC_Binding mac logical_port=local 
> ip='"fd00:1::99"'
> +port_key=$remote_key
> +check_row_count MAC_Binding 0 logical_port=remote ip=10.0.2.99
> +check_row_count MAC_Binding 0 logical_port=remote ip='"fd00:2::99"'
> +check_column '00:00:00:00:02:02' MAC_Binding mac logical_port=remote 
> ip=10.0.2.2
> +check_column '00:00:00:00:02:02' MAC_Binding mac logical_port=remote 
> ip='"fd00:2::2"'
> +check ovn-nbctl --wait=hv set Logical_Router_Port remote enabled=true
> +send_replies 99 2 00:00:00:00:02:99
> +wait_column '00:00:00:00:02:99' MAC_Binding mac logical_port=remote 
> ip=10.0.2.99
> +wait_column '00:00:00:00:02:99' MAC_Binding mac logical_port=remote 
> ip='"fd00:2::99"'
> +
> +dnl Discard cached tunnel flows before controller cleanup removes the tunnel.
> +check ovs-appctl revalidator/purge
> +OVN_CLEANUP_CONTROLLER([hv1])
> +OVN_CLEANUP_NORTHD
> +as
> +OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d
> +/connection dropped.*/d"])
> +AT_CLEANUP
> +])
> +

Regards,
Dumitru

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to