Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain V6 DNS server in resolv.conf; use only V4 servers for fallback #886

Merged
merged 1 commit into from
Jan 22, 2016

Conversation

sanimej
Copy link

@sanimej sanimej commented Jan 20, 2016

Fixes #885

Signed-off-by: Santhosh Manohar santhosh@docker.com

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
)

type extDNSEntry struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need this ?
You will convert the configured address from string form to net.IP, then when you need to program you will convert it again back to string form just to store the IPv6 flag.
Are you using anywhere extDNEntry.IP as a net.IP ? Otherwise this seem unnecessary.

I would just check in NameServer() with isIPv6 := net.ParseIP().to4() == nil in the loop.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to do the parsing once and set the v6 flag when the extDNS is populated rather than doing it on each DNS query handling which could be 100s of times.

I would just check in NameServer() with isIPv6 := net.ParseIP().to4() == nil in the loop.

Are you referring to ServeDNS() function ? That is the one handling the query where the v6 flag is checked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, also I misread the code, you actually keep the IP as string, so never mind.
Got confused by the IP parsing. I, in fact, would just look for a signature since it seems the addresses are already validated, something like:

r.extDNS[i].ip = dns[i]
r.extDNS[i].isIPv6 = strings.Contains(dns[i], ":")

but this is minor, up to you.

@sanimej sanimej changed the title Handle external v6 DNS servers and queries over v6 transport Retain V6 DNS server in resolv.conf; use only V4 servers for fallback Jan 21, 2016
@sanimej
Copy link
Author

sanimej commented Jan 21, 2016

@mrjana Updated changes keep the v6 behavior same as 1.9 and embedded server will use only the v4 DNS servers to forward the requests. PTAL.

@mrjana
Copy link
Contributor

mrjana commented Jan 21, 2016

LGTM

nameservers := []string{}
for _, line := range getLines(resolvConf, []byte("#")) {
var ns = nsRegexp.FindSubmatch(line)
var ns [][]byte
if kind == netutils.IP {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using a switch here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if, else is just fine for small number of cases..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we have been using switch for 3 else, but I see some places in the code where we have kept 3 else.
Anyway this is minor.

@aboch
Copy link
Contributor

aboch commented Jan 22, 2016

LGTM

aboch added a commit that referenced this pull request Jan 22, 2016
Retain V6 DNS server in resolv.conf; use only V4 servers for fallback
@aboch aboch merged commit 3c449b5 into moby:master Jan 22, 2016
@sanimej sanimej deleted the v6 branch September 7, 2016 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants