A logical switch with at least one non-empty DNS record gets a datapath-wide "udp.dst == 53" flow that applies dns_lookup(). All its UDP DNS queries are then sent to ovn-controller, whatever DNS server they are addressed to and whether or not OVN knows the name.
The only way to turn this off is to leave the DNS records of the logical switch empty [0]. That is not possible when the CMS does not own all the records of the logical switch, or cannot stop the entity that writes them. OpenStack Neutron, for instance, writes the DNS records of a network again whenever one of its ports is updated, and can only be told to stop for the whole deployment [1]. A deployment that runs its own resolver for the workloads of such a logical switch has two problems. The queries for a name that is in the DNS records never reach that resolver: OVN answers them, over UDP only, with its own record types and TTL. All the other queries still go through ovn-controller, a cost that was measured in [1] and reported on ovs-discuss (Gavin McKee, 2024-10-04; Piotr Misiak, 2025-02-14). Add the logical switch option other_config:dns_lookup. When it is set to false, ovn-northd does not add to that logical switch the DNS lookup and response flows, nor the flow that lets the DNS replies built by ovn-controller skip the egress ACLs. The DNS records are not changed and are still synced to the Southbound database, so setting the option back restores the lookup at once. The default is true: nothing changes for a logical switch that does not set the option. A change of Logical_Switch.other_config already makes ovn-northd recompute, so there is no incremental processing change. Narrowing the lookup, instead of disabling it, was proposed in [2] (queries addressed to one IP) and in the patch "northd: Skip DNS lookup for packets entering through router ports." posted to ovs-dev on 2026-11-17. This change does not depend on them: it covers the case in which OVN must not answer any query of the logical switch. [0] https://bugzilla.redhat.com/show_bug.cgi?id=2104568#c1 [1] https://bugs.launchpad.net/neutron/+bug/2172741 [2] https://github.com/ovn-org/ovn/pull/307 Assisted-by: Claude Fable 5.2, Claude Code Signed-off-by: Bekei Park <[email protected]> --- This touches the function that "northd: Skip DNS lookup for packets entering through router ports." (2026-11-17) also changes. If that patch is applied first I will rebase this one and make its new router port flow follow the option as well. Documentation/ref/ovn-logical-flows.7.rst | 9 ++- NEWS | 4 ++ northd/northd.c | 19 ++++++- ovn-nb.xml | 18 +++++- tests/ovn-northd.at | 68 +++++++++++++++++++++++ 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/Documentation/ref/ovn-logical-flows.7.rst b/Documentation/ref/ovn-logical-flows.7.rst index 15e6e739b..105ced795 100644 --- a/Documentation/ref/ovn-logical-flows.7.rst +++ b/Documentation/ref/ovn-logical-flows.7.rst @@ -1391,7 +1391,8 @@ This table looks up and resolves the DNS names to the corresponding configured IP address(es). - 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 + configured with DNS records and ``other_config:dns_lookup`` is not set to + ``false``, which matches the IPv4 and IPv6 packets with ``udp.dst`` = 53 and applies the action ``dns_lookup`` and advances the packet to the next table. :: @@ -1411,7 +1412,8 @@ This table implements DNS responder for the DNS replies generated by the previous table. - 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 + configured with DNS records and ``other_config:dns_lookup`` is not set to + ``false``, which matches the IPv4 and IPv6 packets with ``udp.dst = 53 && reg0[4] == 1`` and responds back to the ``inport`` after applying these actions. If ``reg0[4]`` is set to 1, it means that the action ``dns_lookup`` was successful. :: @@ -1801,7 +1803,8 @@ In addition, the following flows are added. responses <ls-in-29>`. This is indicated by setting the allow bit. - A priority 34000 logical flow is added for each logical switch datapath - configured with DNS records with the match ``udp.dst = 53`` to allow the DNS + configured with DNS records, unless ``other_config:dns_lookup`` is set to + ``false``, with the match ``udp.dst = 53`` to allow the DNS reply packet from :ref:`Ingress Table 31: DNS responses <ls-in-31>`. This is indicated by setting the allow bit. diff --git a/NEWS b/NEWS index b2416f98b..c2288d42d 100644 --- a/NEWS +++ b/NEWS @@ -77,6 +77,10 @@ Post v26.09.0 the replies from the backends of its load balancers. The CMS must make sure that the replies re-enter the router on the chassis that load balanced the request. See ovn-nb(5). + - Added a new logical switch option "other_config:dns_lookup". If set to + false, ovn-northd does not add the DNS lookup and response flows to the + logical switch even if it has DNS records, so that its DNS queries are + not intercepted by OVN. OVN v26.09.0 - xxx xx xxxx -------------------------- diff --git a/northd/northd.c b/northd/northd.c index e4acb11ab..fca05859b 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -7136,6 +7136,18 @@ ls_has_dns_records(const struct nbrec_logical_switch *nbs) return false; } +/* + * Returns true if the DNS queries of the logical switch have to be looked up + * in its DNS records, i.e. the logical switch is configured with DNS records + * and the CMS did not disable the lookup with other_config:dns_lookup. + */ +static bool +ls_needs_dns_lookup(const struct nbrec_logical_switch *nbs) +{ + return smap_get_bool(&nbs->other_config, "dns_lookup", true) + && ls_has_dns_records(nbs); +} + static bool build_empty_lb_event_flow(struct ovn_lb_vip *lb_vip, const struct ovn_northd_lb *lb, @@ -8802,9 +8814,10 @@ build_acls(const struct ls_stateful_record *ls_stateful_rec, } /* Add a 34000 priority flow to advance the DNS reply from ovn-controller, - * if the CMS has configured DNS records for the datapath. + * if the CMS has configured DNS records for the datapath and did not + * disable the DNS lookup. */ - if (ls_has_dns_records(od->nbs)) { + if (ls_needs_dns_lookup(od->nbs)) { const char *dns_actions = has_stateful ? REGBIT_ACL_VERDICT_ALLOW" = 1; " "ct_commit; next;" @@ -11579,7 +11592,7 @@ build_lswitch_dns_lookup_and_response(struct ovn_datapath *od, struct lflow_ref *lflow_ref) { ovs_assert(od->nbs); - if (!ls_has_dns_records(od->nbs)) { + if (!ls_needs_dns_lookup(od->nbs)) { return; } ovn_lflow_add(lflows, od, S_SWITCH_IN_DNS_LOOKUP, 100, diff --git a/ovn-nb.xml b/ovn-nb.xml index 0d18010aa..23eaa25cd 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -811,7 +811,9 @@ <column name="dns_records"> This column defines the DNS records to be used for resolving internal DNS queries within the logical switch by the native DNS resolver. - Please see the <ref table="DNS"/> table. + Please see the <ref table="DNS"/> table. The native DNS resolver can + be disabled for the logical switch, without removing its DNS records, + with <ref column="other_config" key="dns_lookup"/>. </column> <column name="forwarding_groups"> @@ -1201,6 +1203,20 @@ forwarded to all routers and therefor the mac bindings of the routers are no longer updated. </column> + + <column name="other_config" key="dns_lookup" + type='{"type": "boolean"}'> + Determines whether the DNS queries of the logical switch are looked up + in its <ref column="dns_records"/> (default) or not. If set to + <code>false</code>, <code>ovn-northd</code> does not add the DNS + logical flows to the logical switch: its DNS queries are not sent to + <code>ovn-controller</code> and are forwarded to their destination + like any other traffic, including the ones for a name that is in the + <ref column="dns_records"/>. The <ref column="dns_records"/> are + not changed, so this option allows to turn the native DNS resolver + off, and back on, for a logical switch whose DNS records are written + by another entity. + </column> </group> <group title="Common Columns"> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index f1e88b4bd..37943578b 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -13161,6 +13161,74 @@ OVN_CLEANUP_NORTHD AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([Logical switch other_config:dns_lookup]) +ovn_start + +check ovn-nbctl ls-add sw0 +check ovn-nbctl ls-add sw1 +dns_uuid=$(ovn-nbctl create DNS records={}) +check ovn-nbctl set DNS $dns_uuid records:vm1.ovn.org="10.0.0.4" +check ovn-nbctl set Logical_Switch sw0 dns_records="$dns_uuid" +check ovn-nbctl set Logical_Switch sw1 dns_records="$dns_uuid" +check ovn-nbctl --wait=sb sync + +dns_flows() { + ovn-sbctl dump-flows $1 | grep -e ls_in_dns_lookup -e ls_in_dns_response \ + -e 'udp.src == 53' | ovn_strip_lflows +} + +check_dns_flows_present() { + AT_CHECK([dns_flows $1], [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_response ), priority=0 , match=(1), action=(next;) + table=??(ls_in_dns_response ), priority=100 , match=(udp.dst == 53 && reg0[[4]]), action=(eth.dst <-> eth.src; ip4.src <-> ip4.dst; udp.dst = udp.src; udp.src = 53; outport = inport; flags.loopback = 1; output;) + table=??(ls_in_dns_response ), priority=100 , match=(udp.dst == 53 && reg0[[4]]), action=(eth.dst <-> eth.src; ip6.src <-> ip6.dst; udp.dst = udp.src; udp.src = 53; outport = inport; flags.loopback = 1; output;) + table=??(ls_out_acl_eval ), priority=34000, match=(flags.from_ctrl && udp.src == 53), action=(reg8[[16]] = 1; next;) +]) +} + +check_dns_flows_absent() { + AT_CHECK([dns_flows $1], [0], [dnl + table=??(ls_in_dns_lookup ), priority=0 , match=(1), action=(next;) + table=??(ls_in_dns_response ), priority=0 , match=(1), action=(next;) +]) +} + +AS_BOX([By default a switch with DNS records looks up DNS queries]) +check_dns_flows_present sw0 +check_dns_flows_present sw1 + +AS_BOX([dns_lookup=false removes the DNS flows of that switch only]) +check ovn-nbctl --wait=sb set Logical_Switch sw0 other_config:dns_lookup=false +check_dns_flows_absent sw0 +check_dns_flows_present sw1 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +AS_BOX([The DNS records are still synced to the SB]) +sb_dns_uuid=$(fetch_column sb:DNS _uuid) +AT_CHECK([ovn-sbctl get DNS $sb_dns_uuid records:vm1.ovn.org], [0], [dnl +"10.0.0.4" +]) + +AS_BOX([dns_lookup=true restores the DNS flows]) +check ovn-nbctl --wait=sb set Logical_Switch sw0 other_config:dns_lookup=true +check_dns_flows_present sw0 +check_dns_flows_present sw1 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +AS_BOX([Removing the key restores the DNS flows]) +check ovn-nbctl --wait=sb set Logical_Switch sw0 other_config:dns_lookup=false +check_dns_flows_absent sw0 +check ovn-nbctl --wait=sb remove Logical_Switch sw0 other_config dns_lookup +check_dns_flows_present sw0 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +OVN_CLEANUP_NORTHD +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD_NO_HV([ AT_SETUP([ACL/Meter incremental processing - no northd recompute]) ovn_start -- 2.43.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
