Skip to content

l3cfg: fix DNS routes

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

Summary

The current approach is flawed. During a commit of the L3 configuration we do a RTM_GETROUTE to find the next-hop to the DNS server on the current interface, in order to create the DNS route to inject into the l3cd. However, we haven't added routes to kernel yet and so the result of the RTM_GETROUTE is going to be wrong.

In some cases, for example when IPv4 DAD is enabled, the bug can't be easily noticed because we perform multiple commits for the interface, and the regular routes are already set in kernel from the 2nd commit on.

To fix the problem, do the following: during a commit we first add addresses and routes to platform. Then, we create a list of DNS routes to configure, we collect the old DNS routes, and do a comparison. If they changed, we need to add the DNS routes to platform in a 2nd step.

Note that in the previous approach we tracked the routes in the committed-l3cd object of the l3cfg, and so they were applied to kernel automatically. Because of the 2-step requirement, that no longer works and we must apply the DNS routes manually.

Merge request reports

Loading