Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
f9c03c2e
Commit
f9c03c2e
authored
Jan 23, 2018
by
Francois Tur
Committed by
Miek Gieben
Jan 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix computation of reverse zone based on Ipv6 CIDRs (#1415)
parent
9575789c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
core/dnsserver/address_test.go
core/dnsserver/address_test.go
+4
-3
plugin/kubernetes/reverse_test.go
plugin/kubernetes/reverse_test.go
+25
-1
plugin/kubernetes/setup_reverse_test.go
plugin/kubernetes/setup_reverse_test.go
+1
-0
plugin/normalize.go
plugin/normalize.go
+7
-2
No files found.
core/dnsserver/address_test.go
View file @
f9c03c2e
...
@@ -34,9 +34,9 @@ func TestNormalizeZoneReverse(t *testing.T) {
...
@@ -34,9 +34,9 @@ func TestNormalizeZoneReverse(t *testing.T) {
expected
string
expected
string
shouldErr
bool
shouldErr
bool
}{
}{
{
"2003::1/64"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.
0.0.0.0.0.0.0.0.
3.0.0.2.ip6.arpa.:53"
,
false
},
{
"2003::1/64"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53"
,
false
},
{
"2003::1/64."
,
"dns://2003::1/64.:53"
,
false
},
// OK, with closing dot the parse will fail.
{
"2003::1/64."
,
"dns://2003::1/64.:53"
,
false
},
// OK, with closing dot the parse will fail.
{
"2003::1/64:53"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.
0.0.0.0.0.0.0.0.
3.0.0.2.ip6.arpa.:53"
,
false
},
{
"2003::1/64:53"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53"
,
false
},
{
"2003::1/64.:53"
,
"dns://2003::1/64.:53"
,
false
},
{
"2003::1/64.:53"
,
"dns://2003::1/64.:53"
,
false
},
{
"10.0.0.0/24"
,
"dns://0.0.10.in-addr.arpa.:53"
,
false
},
{
"10.0.0.0/24"
,
"dns://0.0.10.in-addr.arpa.:53"
,
false
},
...
@@ -45,9 +45,10 @@ func TestNormalizeZoneReverse(t *testing.T) {
...
@@ -45,9 +45,10 @@ func TestNormalizeZoneReverse(t *testing.T) {
{
"10.0.0.0/24.:53"
,
"dns://10.0.0.0/24.:53"
,
false
},
{
"10.0.0.0/24.:53"
,
"dns://10.0.0.0/24.:53"
,
false
},
// non %8==0 netmasks
// non %8==0 netmasks
{
"2003::53/67"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.0.
0.0.0.0.0.0.0.
3.0.0.2.ip6.arpa.:53"
,
false
},
{
"2003::53/67"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53"
,
false
},
{
"10.0.0.0/25."
,
"dns://10.0.0.0/25.:53"
,
false
},
// has dot
{
"10.0.0.0/25."
,
"dns://10.0.0.0/25.:53"
,
false
},
// has dot
{
"10.0.0.0/25"
,
"dns://0.0.10.in-addr.arpa.:53"
,
false
},
{
"10.0.0.0/25"
,
"dns://0.0.10.in-addr.arpa.:53"
,
false
},
{
"fd00:77:30::0/110"
,
"dns://0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.:53"
,
false
},
}
{
}
{
addr
,
err
:=
normalizeZone
(
test
.
input
)
addr
,
err
:=
normalizeZone
(
test
.
input
)
actual
:=
addr
.
String
()
actual
:=
addr
.
String
()
...
...
plugin/kubernetes/reverse_test.go
View file @
f9c03c2e
...
@@ -50,6 +50,8 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
...
@@ -50,6 +50,8 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
switch
ip
{
switch
ip
{
case
"10.0.0.100"
:
case
"10.0.0.100"
:
case
"1234:abcd::1"
:
case
"1234:abcd::1"
:
case
"fd00:77:30::a"
:
case
"fd00:77:30::2:9ba6"
:
default
:
default
:
return
nil
return
nil
}
}
...
@@ -66,6 +68,14 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
...
@@ -66,6 +68,14 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
IP
:
"1234:abcd::1"
,
IP
:
"1234:abcd::1"
,
Hostname
:
"ep1b"
,
Hostname
:
"ep1b"
,
},
},
{
IP
:
"fd00:77:30::a"
,
Hostname
:
"ip6svc1ex"
,
},
{
IP
:
"fd00:77:30::2:9ba6"
,
Hostname
:
"ip6svc1in"
,
},
},
},
Ports
:
[]
api
.
EndpointPort
{
Ports
:
[]
api
.
EndpointPort
{
{
{
...
@@ -103,7 +113,7 @@ func (APIConnReverseTest) GetNamespaceByName(name string) (*api.Namespace, error
...
@@ -103,7 +113,7 @@ func (APIConnReverseTest) GetNamespaceByName(name string) (*api.Namespace, error
func
TestReverse
(
t
*
testing
.
T
)
{
func
TestReverse
(
t
*
testing
.
T
)
{
k
:=
New
([]
string
{
"cluster.local."
,
"0.10.in-addr.arpa."
,
"168.192.in-addr.arpa."
,
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa."
})
k
:=
New
([]
string
{
"cluster.local."
,
"0.10.in-addr.arpa."
,
"168.192.in-addr.arpa."
,
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa."
,
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."
})
k
.
APIConn
=
&
APIConnReverseTest
{}
k
.
APIConn
=
&
APIConnReverseTest
{}
tests
:=
[]
test
.
Case
{
tests
:=
[]
test
.
Case
{
...
@@ -128,6 +138,20 @@ func TestReverse(t *testing.T) {
...
@@ -128,6 +138,20 @@ func TestReverse(t *testing.T) {
test
.
PTR
(
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa. 5 IN PTR ep1b.svc1.testns.svc.cluster.local."
),
test
.
PTR
(
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa. 5 IN PTR ep1b.svc1.testns.svc.cluster.local."
),
},
},
},
},
{
// A PTR record query for an existing ipv6 endpoint should return a record
Qname
:
"a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."
,
Qtype
:
dns
.
TypePTR
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
PTR
(
"a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1ex.svc1.testns.svc.cluster.local."
),
},
},
{
// A PTR record query for an existing ipv6 endpoint should return a record
Qname
:
"6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."
,
Qtype
:
dns
.
TypePTR
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
PTR
(
"6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1in.svc1.testns.svc.cluster.local."
),
},
},
{
{
Qname
:
"101.0.0.10.in-addr.arpa."
,
Qtype
:
dns
.
TypePTR
,
Qname
:
"101.0.0.10.in-addr.arpa."
,
Qtype
:
dns
.
TypePTR
,
Rcode
:
dns
.
RcodeSuccess
,
Rcode
:
dns
.
RcodeSuccess
,
...
...
plugin/kubernetes/setup_reverse_test.go
View file @
f9c03c2e
...
@@ -13,6 +13,7 @@ func TestKubernetesParseReverseZone(t *testing.T) {
...
@@ -13,6 +13,7 @@ func TestKubernetesParseReverseZone(t *testing.T) {
}{
}{
{
`kubernetes coredns.local 10.0.0.0/16`
,
[]
string
{
"coredns.local."
,
"0.10.in-addr.arpa."
}},
{
`kubernetes coredns.local 10.0.0.0/16`
,
[]
string
{
"coredns.local."
,
"0.10.in-addr.arpa."
}},
{
`kubernetes coredns.local 10.0.0.0/17`
,
[]
string
{
"coredns.local."
,
"0.10.in-addr.arpa."
}},
{
`kubernetes coredns.local 10.0.0.0/17`
,
[]
string
{
"coredns.local."
,
"0.10.in-addr.arpa."
}},
{
`kubernetes coredns.local fd00:77:30::0/110`
,
[]
string
{
"coredns.local."
,
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."
}},
}
}
for
i
,
tc
:=
range
tests
{
for
i
,
tc
:=
range
tests
{
...
...
plugin/normalize.go
View file @
f9c03c2e
...
@@ -115,11 +115,16 @@ func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error) {
...
@@ -115,11 +115,16 @@ func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error) {
if
err
==
nil
{
if
err
==
nil
{
if
rev
,
e
:=
dns
.
ReverseAddr
(
ip
.
String
());
e
==
nil
{
if
rev
,
e
:=
dns
.
ReverseAddr
(
ip
.
String
());
e
==
nil
{
ones
,
bits
=
n
.
Mask
.
Size
()
ones
,
bits
=
n
.
Mask
.
Size
()
// get the size, in bits, of each portion of hostname defined in the reverse address. (8 for IPv4, 4 for IPv6)
sizeDigit
:=
8
if
len
(
n
.
IP
)
==
net
.
IPv6len
{
sizeDigit
=
4
}
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
mod
:=
(
bits
-
ones
)
%
8
mod
:=
(
bits
-
ones
)
%
sizeDigit
nearest
:=
(
bits
-
ones
)
+
mod
nearest
:=
(
bits
-
ones
)
+
mod
offset
,
end
:=
0
,
false
offset
,
end
:=
0
,
false
for
i
:=
0
;
i
<
nearest
/
8
;
i
++
{
for
i
:=
0
;
i
<
nearest
/
sizeDigit
;
i
++
{
offset
,
end
=
dns
.
NextLabel
(
rev
,
offset
)
offset
,
end
=
dns
.
NextLabel
(
rev
,
offset
)
if
end
{
if
end
{
break
break
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment