Skip to content

dns: fix tracking of best ip config

Beniamino Galvani requested to merge bg/dns-fix-best into main

Summary

Fix tracking of best DNS IP config

Purpose

This fixes a regression introduced in 1.32. See:

#1331 (closed)

https://lists.freedesktop.org/archives/networkmanager/2023-June/000123.html

When a IP configuration has type "best", it is the configuration with the best (lowest) metric default route for the specific address family. Therefore, there can be only one best configuration for address family.

When a new configuration is added as best, make sure it is the only one for the address family.

Reproducer

nmcli connection add type dummy con-name dummy-dummy1 ifname dummy1 ip4 172.25.1.1/24 gw4 172.25.1.254 ipv4.dns 172.25.1.53 autoconnect no ipv4.route-metric 100 ipv6.method disabled
nmcli connection add type dummy con-name dummy-dummy2 ifname dummy2 ip4 172.25.2.1/24 gw4 172.25.2.254 ipv4.dns 172.25.2.53 autoconnect no ipv4.route-metric 200 ipv6.method disabled

nmcli connection up dummy-dummy1
nmcli connection up dummy-dummy2

# now dummy1 is best

nmcli connection down dummy-dummy1

# now dummy2 is best

nmcli connection up dummy-dummy1

# due to the bug, now both dummy1 and dummy2 are best

cat /etc/resolv.conf

# with the bug, 172.25.2.53 is the first name server

Checklist

  • the subject for all commits is concise and explicative
  • the message for all commits explains the reason for the change
  • the source is properly formatted
  • any relevant documentation is up to date
  • you have added unit tests if applicable

Merge request reports