summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-1.20/0010-net-Fix-issue-with-DNS-not-being-updated.patch
blob: 6ead5188434176b3337a1ab7835430365e80c8de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 20176b390e28daa86b4552965cb7bd9181983c4d Mon Sep 17 00:00:00 2001
From: Chaitanya Vadrevu <chaitanya.vadrevu@ni.com>
Date: Mon, 6 Nov 2023 20:11:19 -0600
Subject: [PATCH] net: Fix issue with DNS not being updated

When dns requests are made, go's native DNS resolver only reads
/etc/resolv.conf if the previous request is older than 5 seconds.

On first network call, an initialization code runs that is
supposed to initialize DNS data and set lastChecked time. There is a bug
in this code that causes /etc/resolv.conf to not be read during
initialization and the DNS data from program startup ends up being used
until the next 5 seconds. This means that if /etc/resolv.conf changed
between program startup and the first network call, old DNS data is
still used until the next 5 seconds.

This causes "docker pull" to fail the first time if docker daemon is
started before networking is up.

Upstream commit d52883f443e1d564b0300acdd382af1769bf0477 made lot of
improvements to DNS resolver to fix some issues which also fixes this
issue.
This patch picks the relevant changes from it to fix this particular
issue.

Upstream-Status: Backport [https://github.com/golang/go/commit/d52883f443e1d564b0300acdd382af1769bf0477]

Signed-off-by: Chaitanya Vadrevu <chaitanya.vadrevu@ni.com>
---
 src/net/dnsclient_unix.go | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index 6dfd4af..520ffe6 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -337,10 +337,7 @@ var resolvConf resolverConfig
 func (conf *resolverConfig) init() {
 	// Set dnsConfig and lastChecked so we don't parse
 	// resolv.conf twice the first time.
-	conf.dnsConfig = systemConf().resolv
-	if conf.dnsConfig == nil {
-		conf.dnsConfig = dnsReadConfig("/etc/resolv.conf")
-	}
+	conf.dnsConfig = dnsReadConfig("/etc/resolv.conf")
 	conf.lastChecked = time.Now()
 
 	// Prepare ch so that only one update of resolverConfig may
-- 
2.34.1