Skip to content

Commit e5064dd

Browse files
committed
Merge pull request #1048 from sanimej/fixes
On network disconnect clear the cached connections to external nameservers
2 parents 1252c14 + 17c1b13 commit e5064dd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

endpoint.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ func (ep *endpoint) Leave(sbox Sandbox, options ...EndpointOption) error {
547547
sb.joinLeaveStart()
548548
defer sb.joinLeaveEnd()
549549

550+
if sb.resolver != nil {
551+
sb.resolver.FlushExtServers()
552+
}
553+
550554
return ep.sbLeave(sb, false, options...)
551555
}
552556

resolver.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ type Resolver interface {
2828
// NameServer() returns the IP of the DNS resolver for the
2929
// containers.
3030
NameServer() string
31-
// To configure external name servers the resolver should use
31+
// SetExtServers configures the external nameservers the resolver
32+
// should use to forward queries
3233
SetExtServers([]string)
34+
// FlushExtServers clears the cached UDP connections to external
35+
// nameservers
36+
FlushExtServers()
3337
// ResolverOptions returns resolv.conf options that should be set
3438
ResolverOptions() []string
3539
}
@@ -139,11 +143,15 @@ func (r *resolver) Start() error {
139143
return nil
140144
}
141145

142-
func (r *resolver) Stop() {
146+
func (r *resolver) FlushExtServers() {
143147
for i := 0; i < maxExtDNS; i++ {
144148
r.extDNSList[i].extConn = nil
145149
r.extDNSList[i].extOnce = sync.Once{}
146150
}
151+
}
152+
153+
func (r *resolver) Stop() {
154+
r.FlushExtServers()
147155

148156
if r.server != nil {
149157
r.server.Shutdown()

0 commit comments

Comments
 (0)