1 From 33710a648a805d96abf49d5adf6ca55b89f9c858 Mon Sep 17 00:00:00 2001
2 From: Chen Qi <Qi.Chen@windriver.com>
3 Date: Wed, 9 Nov 2022 16:33:18 +0800
4 Subject: [PATCH] 20-resolv.conf: improve the sitation of working with systemd
6 systemd's resolvconf implementation ignores the protocol part.
7 See https://github.com/systemd/systemd/issues/25032.
9 When using 'dhcp server + dns server + dhcpcd + systemd', we
10 get an integration issue, that is dhcpcd runs 'resolvconf -d eth0.ra',
11 yet systemd's resolvconf treats it as eth0. This will delete the
12 DNS information set by 'resolvconf -a eth0.dhcp'.
14 Fortunately, 20-resolv.conf has the ability to build the resolv.conf
15 file contents itself. We can just pass the generated contents to
16 systemd's resolvconf. This way, the DNS information is not incorrectly
17 deleted. Also, it does not cause behavior regression for dhcpcd
20 Upstream-Status: Inappropriate [OE Specific]
21 This patch has been rejected by dhcpcd upstream.
22 See details in https://github.com/NetworkConfiguration/dhcpcd/pull/152
24 Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
26 hooks/20-resolv.conf | 17 +++++++++++++----
27 1 file changed, 13 insertions(+), 4 deletions(-)
29 diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf
30 index 7c29e276..becc019f 100644
31 --- a/hooks/20-resolv.conf
32 +++ b/hooks/20-resolv.conf
33 @@ -11,8 +11,12 @@ nocarrier_roaming_dir="$state_dir/roaming"
36 : ${resolvconf:=resolvconf}
37 +resolvconf_from_systemd=false
38 if command -v "$resolvconf" >/dev/null 2>&1; then
40 + if [ $(basename $(readlink -f $(which $resolvconf))) = resolvectl ]; then
41 + resolvconf_from_systemd=true
46 @@ -69,8 +73,13 @@ build_resolv_conf()
48 echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
50 - if change_file /etc/resolv.conf "$cf"; then
51 - chmod 644 /etc/resolv.conf
52 + if $resolvconf_from_systemd; then
53 + [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
54 + "$resolvconf" -a "$ifname" <"$cf"
56 + if change_file /etc/resolv.conf "$cf"; then
57 + chmod 644 /etc/resolv.conf
62 @@ -170,7 +179,7 @@ add_resolv_conf()
63 for x in ${new_domain_name_servers}; do
64 conf="${conf}nameserver $x$NL"
66 - if $have_resolvconf; then
67 + if $have_resolvconf && ! $resolvconf_from_systemd; then
68 [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
69 printf %s "$conf" | "$resolvconf" -a "$ifname"
71 @@ -186,7 +195,7 @@ add_resolv_conf()
75 - if $have_resolvconf; then
76 + if $have_resolvconf && ($if_down || ! $resolvconf_from_systemd); then
77 "$resolvconf" -d "$ifname" -f
79 if [ -e "$resolv_conf_dir/$ifname" ]; then