On 11/21/26 4:09 AM, Numan Siddique wrote:
> On Wed, Nov 18, 2026 at 10:52 PM Numan Siddique <[email protected]> wrote:
>>
>> On Wed, Nov 18, 2026 at 5:45 PM Brian Haley <[email protected]> wrote:
>>>
>>> Thanks for the change. Just an FYI someone reported the same issue
>>> against Neutron just a few days ago at [0], I had barely looked into it
>>> when I saw this.
>>>
>>> [0] https://bugs.launchpad.net/neutron/+bug/2174452
>>>
>>> -Brian
>>>
>>> On 11/17/26 9:51 AM, Numan via dev wrote:
>>>> From: Loke Berne <[email protected]>
>>>>
>>>> A logical switch with DNS records gets a datapath-wide flow in the
>>>> ls_in_dns_lookup stage matching "udp.dst == 53" and applying the
>>>> dns_lookup() action.  Any UDP packet to port 53 entering the logical
>>>> switch, including unsolicited ones coming from the outside through a
>>>> router port (e.g. from the internet to a NAT'ed address), is thus
>>>> handed to ovn-controller, where it is parsed, before any ACL is
>>>> evaluated.  An ACL can't stop this traffic, and a flood of such packets
>>>> can saturate ovn-controller and ovs-vswitchd on the chassis hosting the
>>>> targeted logical port.
>>>>
>>>> Add a priority 200 logical flow for each router port of a logical switch
>>>> with DNS records, matching on "inport" and advancing the packet to the
>>>> next stage without any lookup.  The priority 100 lookup flow is
>>>> unchanged, so the packets entering through any other port are handled
>>>> as before, and the number of added logical flows only depends on the
>>>> number of router ports of the logical switch, not on its number of
>>>> ports.
>>>>
>>>> Signed-off-by: Loke Berne <[email protected]>
>>
>> Thanks Loke for the patch and Brian for pointing to the neutron bug.
>>
>> Just FYI I'm not the author of this patch.
>>

Hi Loke, Numan,

Sorry for the delayed reply.

>> The intention of the native DNS feature when it was added was to provide the
>> native DNS resolution for the DNS requests originating from the VIF
>> logical ports of
>> a switch.  I think when a DNS request packet is destined to a VIF
>> logical port and
>> enters from outside of the switch (via a router port), it should not
>> be handled by
>> the OVN native dns resolver.
>>

We do potentially break scenarios in which an intermediate logical
router is placed between the VIF's logical switch and the logical switch
where DNS is configured.

However, I think such topologies are not realistic and kind of weird.

>> I agree with the approach used in this patch.
>>

I'm fine with it too.

>> I've a few small nit comments in the test code of this patch.
>> It would be good to address this:
>>
>> Even otherwise it's fine with me.
>>
>> Acked-by: Numan Siddique <[email protected]>
>>
>> I'll wait for any concerns from other maintainers before applying.
>>
> 
> Thanks Loke.
> 
> I went ahead and applied the patch to main and backported to
> branch-26.09 and branch-26.03.
> 

Thanks, Numan, for taking care of this!

Regards,
Dumitru

> Before applying I did the below changes.
> 
> ---------------------
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index b0c2c22df5..813d9e365e 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -13198,7 +13198,10 @@ for i in 2 3 4; do
>      check ovn-nbctl lsp-set-addresses sw0-vm$i "00:00:00:00:00:1$i 
> 10.0.0.1$i"
>  done
>  check ovn-nbctl --wait=sb sync
> -AT_CHECK([dns_lookup_flows | wc -l], [0], [3
> +AT_CHECK([dns_lookup_flows], [0], [dnl
> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
> +  table=??(ls_in_dns_lookup   ), priority=100  , match=(udp.dst ==
> 53), action=(reg0[[4]] = dns_lookup(); next;)
> +  table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
> "sw0-lr0"), action=(next;)
>  ])
> 
>  # A second router port gets its own skip flow, and loses it when removed.
> @@ -13207,11 +13210,19 @@ check ovn-nbctl lsp-set-type sw0-lr1 router
>  check ovn-nbctl lsp-set-addresses sw0-lr1 router
>  check ovn-nbctl lsp-set-options sw0-lr1 router-port=lrp1
>  check ovn-nbctl --wait=sb sync
> -AT_CHECK([dns_lookup_flows | grep -c 'priority=200'], [0], [2
> +AT_CHECK([dns_lookup_flows], [0], [dnl
> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
> +  table=??(ls_in_dns_lookup   ), priority=100  , match=(udp.dst ==
> 53), action=(reg0[[4]] = dns_lookup(); next;)
> +  table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
> "sw0-lr0"), action=(next;)
> +  table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
> "sw0-lr1"), action=(next;)
>  ])
> +
>  check ovn-nbctl lsp-del sw0-lr1
>  check ovn-nbctl --wait=sb sync
> -AT_CHECK([dns_lookup_flows | grep -c 'priority=200'], [0], [1
> +AT_CHECK([dns_lookup_flows], [0], [dnl
> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
> +  table=??(ls_in_dns_lookup   ), priority=100  , match=(udp.dst ==
> 53), action=(reg0[[4]] = dns_lookup(); next;)
> +  table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
> "sw0-lr0"), action=(next;)
>  ])
> 
>  # The DNS response flows are unchanged.
> diff --git a/northd/northd.c b/northd/northd.c
> index f4cb9999b0..fa85ae6175 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -11571,11 +11571,7 @@ build_lswitch_dhcp_and_dns_defaults(struct
> ovn_datapath *od,
> 
>  /* Logical switch ingress table 22 and 23: DNS lookup and response
>  * priority 100 flows.
> -*
> -* Packets entering the logical switch through a router port come from
> -* outside of the switch (e.g. from the internet through a NAT'ed address) and
> -* must not be handed to ovn-controller: see
> -* build_lswitch_dns_lookup_skip_router_port(). */
> +*/
>  static void
>  build_lswitch_dns_lookup_and_response(struct ovn_datapath *od,
>                                        struct lflow_table *lflows,
> -----------------------
> 
> Thanks
> Numan
> 
>> Thanks
>> Numan
>>
>>>> ---
>>>>   Documentation/ref/ovn-logical-flows.7.rst |  7 +++
>>>>   northd/northd.c                           | 26 +++++++-
>>>>   tests/ovn-northd.at                       | 77 +++++++++++++++++++++++
>>>>   3 files changed, 109 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/ref/ovn-logical-flows.7.rst 
>>>> b/Documentation/ref/ovn-logical-flows.7.rst
>>>> index 913ebbc83..4692c17cc 100644
>>>> --- a/Documentation/ref/ovn-logical-flows.7.rst
>>>> +++ b/Documentation/ref/ovn-logical-flows.7.rst
>>>> @@ -1390,6 +1390,13 @@ Ingress Table 30 DNS Lookup
>>>>   This table looks up and resolves the DNS names to the corresponding 
>>>> configured
>>>>   IP address(es).
>>>>
>>>> +- For each logical switch port ``P`` of type ``router`` of a logical 
>>>> switch
>>>> +  that is configured with DNS records, a priority-200 logical flow which
>>>> +  matches packets with ``inport`` == ``P`` and advances them to the next 
>>>> table
>>>> +  without any DNS lookup. Packets coming from the routed side of the 
>>>> logical
>>>> +  switch, e.g. from the internet, are thus never handed to 
>>>> ``ovn-controller``
>>>> +  and are subject to the ACLs like any other UDP traffic.
>>>> +
>>>>   - A priority-100 logical flow for each logical switch datapath if it is
>>>>     configured with DNS records, which matches the IPv4 and IPv6 packets 
>>>> with
>>>>     ``udp.dst`` = 53 and applies the action ``dns_lookup`` and advances 
>>>> the packet
>>>> diff --git a/northd/northd.c b/northd/northd.c
>>>> index 7585767c9..a858a313c 100644
>>>> --- a/northd/northd.c
>>>> +++ b/northd/northd.c
>>>> @@ -11568,7 +11568,11 @@ build_lswitch_dhcp_and_dns_defaults(struct 
>>>> ovn_datapath *od,
>>>>
>>>>   /* Logical switch ingress table 22 and 23: DNS lookup and response
>>>>   * priority 100 flows.
>>>> -*/
>>>> +*
>>>> +* Packets entering the logical switch through a router port come from
>>>> +* outside of the switch (e.g. from the internet through a NAT'ed address) 
>>>> and
>>>> +* must not be handed to ovn-controller: see
>>>> +* build_lswitch_dns_lookup_skip_router_port(). */
>>>>   static void
>>>>   build_lswitch_dns_lookup_and_response(struct ovn_datapath *od,
>>>>                                         struct lflow_table *lflows,
>>>> @@ -11598,6 +11602,25 @@ build_lswitch_dns_lookup_and_response(struct 
>>>> ovn_datapath *od,
>>>>                     dns_match, dns_action, lflow_ref);
>>>>   }
>>>>
>>>> +/* Table 22: DNS lookup, priority 200 flow that skips the lookup for the
>>>> + * packets entering the logical switch through a router port, so that
>>>> + * unsolicited DNS traffic coming from the routed side never reaches
>>>> + * ovn-controller, and is subject to the ACLs like any other UDP traffic. 
>>>> */
>>>> +static void
>>>> +build_lswitch_dns_lookup_skip_router_port(struct ovn_port *op,
>>>> +                                          struct lflow_table *lflows,
>>>> +                                          struct ds *match)
>>>> +{
>>>> +    ovs_assert(op->nbsp);
>>>> +    if (!lsp_is_router(op->nbsp) || !ls_has_dns_records(op->od->nbs)) {
>>>> +        return;
>>>> +    }
>>>> +    ds_clear(match);
>>>> +    ds_put_format(match, "inport == %s", op->json_key);
>>>> +    ovn_lflow_add(lflows, op->od, S_SWITCH_IN_DNS_LOOKUP, 200,
>>>> +                  ds_cstr(match), "next;", op->lflow_ref);
>>>> +}
>>>> +
>>>>   /* Table 24: External port. Drop ARP request for router ips from
>>>>    * external ports  on chassis not binding those ports.
>>>>    * This makes the router pipeline to be run only on the chassis
>>>> @@ -20772,6 +20795,7 @@ build_lswitch_and_lrouter_iterate_by_lsp(struct 
>>>> ovn_port *op,
>>>>       build_lswitch_arp_nd_responder_known_ips(op, lflows, ls_ports,
>>>>                                                meter_groups, actions, 
>>>> match);
>>>>       build_lswitch_dhcp_options_and_response(op, lflows, meter_groups);
>>>> +    build_lswitch_dns_lookup_skip_router_port(op, lflows, match);
>>>>       build_lswitch_external_port(op, lflows);
>>>>       build_lswitch_icmp_packet_toobig_admin_flows(op, lflows, match, 
>>>> actions);
>>>>       build_lswitch_ip_unicast_lookup(op, lflows, actions,
>>>> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
>>>> index e2b8424d2..de5241841 100644
>>>> --- a/tests/ovn-northd.at
>>>> +++ b/tests/ovn-northd.at
>>>> @@ -13101,6 +13101,83 @@ check ovn-nbctl clear Logical_Switch sw0 
>>>> dns_records
>>>>   check ovn-nbctl --wait=sb sync
>>>>   wait_row_count sb:DNS 0
>>>>
>>>> +OVN_CLEANUP_NORTHD
>>>> +AT_CLEANUP
>>>> +])
>>>> +
>>>> +OVN_FOR_EACH_NORTHD_NO_HV([
>>>> +AT_SETUP([DNS lookup skipped for packets entering through router ports])
>>>> +ovn_start
>>>> +
>>>> +check ovn-nbctl lr-add lr0
>>>> +check ovn-nbctl lrp-add lr0 lrp0 00:00:00:00:00:01 10.0.0.1/24
>>>> +check ovn-nbctl lrp-add lr0 lrp1 00:00:00:00:00:02 10.0.0.2/24
>>>> +
>>>> +check ovn-nbctl ls-add sw0
>>>> +check ovn-nbctl lsp-add sw0 sw0-vm1
>>>> +check ovn-nbctl lsp-set-addresses sw0-vm1 "00:00:00:00:00:11 10.0.0.11"
>>>> +check ovn-nbctl lsp-add sw0 sw0-lr0
>>>> +check ovn-nbctl lsp-set-type sw0-lr0 router
>>>> +check ovn-nbctl lsp-set-addresses sw0-lr0 router
>>>> +check ovn-nbctl lsp-set-options sw0-lr0 router-port=lrp0
>>>> +
>>>> +dns_uuid=$(ovn-nbctl create DNS records={})
>>>> +check ovn-nbctl set DNS $dns_uuid records:vm1.ovn.org="10.0.0.11"
>>>> +
>>>> +dns_lookup_flows() {
>>>> +    ovn-sbctl dump-flows sw0 | grep -w "ls_in_dns_lookup" | 
>>>> ovn_strip_lflows | sort
>>>> +}
>>>> +
>>>> +# Without DNS records, there is no lookup flow.
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows], [0], [dnl
>>>> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
>>>> +])
>>>> +
>>>> +# With DNS records, packets entering through the router port skip the 
>>>> lookup,
>>>> +# all the others are looked up, whatever the number of ports.
>>>> +check ovn-nbctl set Logical_Switch sw0 dns_records="$dns_uuid"
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows], [0], [dnl
>>>> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
>>>> +  table=??(ls_in_dns_lookup   ), priority=100  , match=(udp.dst == 53), 
>>>> action=(reg0[[4]] = dns_lookup(); next;)
>>>> +  table=??(ls_in_dns_lookup   ), priority=200  , match=(inport == 
>>>> "sw0-lr0"), action=(next;)
>>>> +])
>>>> +
>>>> +# Adding VIF ports does not add lookup flows.
>>>> +for i in 2 3 4; do
>>>> +    check ovn-nbctl lsp-add sw0 sw0-vm$i
>>>> +    check ovn-nbctl lsp-set-addresses sw0-vm$i "00:00:00:00:00:1$i 
>>>> 10.0.0.1$i"
>>>> +done
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows | wc -l], [0], [3
>>>> +])
>>>> +
>>>> +# A second router port gets its own skip flow, and loses it when removed.
>>>> +check ovn-nbctl lsp-add sw0 sw0-lr1
>>>> +check ovn-nbctl lsp-set-type sw0-lr1 router
>>>> +check ovn-nbctl lsp-set-addresses sw0-lr1 router
>>>> +check ovn-nbctl lsp-set-options sw0-lr1 router-port=lrp1
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows | grep -c 'priority=200'], [0], [2
>>>> +])
>>
>> Instead of grepping here with "-c" option I'd prefer you just do
>> something like below
>>
>> AT_CHECK([dns_lookup_flows], [0], [dnl
>>   table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
>>   table=??(ls_in_dns_lookup   ), priority=100  , match=(udp.dst ==
>> 53), action=(reg0[[4]] = dns_lookup(); next;)
>>   table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
>> "sw0-lr0"), action=(next;)
>>   table=??(ls_in_dns_lookup   ), priority=200  , match=(inport ==
>> "sw0-lr1"), action=(next;)
>> ])
>>
>> Same for below.
>>
>> Thanks
>> Numan
>>
>>
>>>> +check ovn-nbctl lsp-del sw0-lr1
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows | grep -c 'priority=200'], [0], [1
>>>> +])
>>>> +
>>>> +# The DNS response flows are unchanged.
>>>> +AT_CHECK([ovn-sbctl dump-flows sw0 | grep -w "ls_in_dns_response" | grep 
>>>> -c "udp.dst == 53"], [0], [2
>>>> +])
>>>> +
>>>> +# Clearing the DNS records removes every lookup flow again.
>>>> +check ovn-nbctl clear Logical_Switch sw0 dns_records
>>>> +check ovn-nbctl --wait=sb sync
>>>> +AT_CHECK([dns_lookup_flows], [0], [dnl
>>>> +  table=??(ls_in_dns_lookup   ), priority=0    , match=(1), action=(next;)
>>>> +])
>>>> +
>>>> +OVN_CLEANUP_NORTHD
>>>>   AT_CLEANUP
>>>>   ])
>>>>
>>>
> 

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

Reply via email to