]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
4f687b0292e2a616b06a2fc29ff9f824e8fd69dc
[thirdparty/openembedded/openembedded-core-contrib.git] /
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
5
6 systemd's resolvconf implementation ignores the protocol part.
7 See https://github.com/systemd/systemd/issues/25032.
8
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'.
13
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
18 in other cases.
19
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
23
24 Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
25 ---
26 hooks/20-resolv.conf | 17 +++++++++++++----
27 1 file changed, 13 insertions(+), 4 deletions(-)
28
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"
34 NL="
35 "
36 : ${resolvconf:=resolvconf}
37 +resolvconf_from_systemd=false
38 if command -v "$resolvconf" >/dev/null 2>&1; then
39 have_resolvconf=true
40 + if [ $(basename $(readlink -f $(which $resolvconf))) = resolvectl ]; then
41 + resolvconf_from_systemd=true
42 + fi
43 else
44 have_resolvconf=false
45 fi
46 @@ -69,8 +73,13 @@ build_resolv_conf()
47 else
48 echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
49 fi
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"
55 + else
56 + if change_file /etc/resolv.conf "$cf"; then
57 + chmod 644 /etc/resolv.conf
58 + fi
59 fi
60 rm -f "$cf"
61 }
62 @@ -170,7 +179,7 @@ add_resolv_conf()
63 for x in ${new_domain_name_servers}; do
64 conf="${conf}nameserver $x$NL"
65 done
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"
70 return $?
71 @@ -186,7 +195,7 @@ add_resolv_conf()
72
73 remove_resolv_conf()
74 {
75 - if $have_resolvconf; then
76 + if $have_resolvconf && ($if_down || ! $resolvconf_from_systemd); then
77 "$resolvconf" -d "$ifname" -f
78 else
79 if [ -e "$resolv_conf_dir/$ifname" ]; then