Skip to content

Commit

Permalink
go.mod, vendor: use github.com/cilium/dns fork directly
Browse files Browse the repository at this point in the history
We have been maintaining and using that fork for a long time and it
looks like the custom changes won't make it upstream any time soon.

There are no other vendored dependencies using miekg/dns, so switching
to the cilium/dns fork shouldn't have any side effects. The fork's
module name was changed to match its import path in
cilium/dns#4.

Let's replace the github.com/miekg/dns import path by
github.com/cilium/dns to get rid of another replace directive in go.mod
and thus make life a tiny bit easier for downstream packages importing
github.com/cilium/cilium.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
  • Loading branch information
tklauser committed Aug 18, 2023
1 parent 182edfe commit db13dd4
Show file tree
Hide file tree
Showing 69 changed files with 46 additions and 39 deletions.
2 changes: 1 addition & 1 deletion daemon/cmd/fqdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"sync"
"time"

"github.com/cilium/dns"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/miekg/dns"
"github.com/sirupsen/logrus"

"github.com/cilium/cilium/api/v1/models"
Expand Down
22 changes: 11 additions & 11 deletions daemon/cmd/fqdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

. "github.com/cilium/checkmate"
miekgdns "github.com/miekg/dns"
ciliumdns "github.com/cilium/dns"

"github.com/cilium/cilium/pkg/allocator"
"github.com/cilium/cilium/pkg/checker"
Expand Down Expand Up @@ -234,28 +234,28 @@ func (ds *DaemonFQDNSuite) Benchmark_notifyOnDNSMsg(c *C) {
// parameter is only used in logging. Not using the endpoint's IP
// so we don't spend any time in the benchmark on converting from
// net.IP to string.
c.Assert(ds.d.notifyOnDNSMsg(time.Now(), ep, "10.96.64.8:12345", 0, "10.96.64.1:53", &miekgdns.Msg{
MsgHdr: miekgdns.MsgHdr{
c.Assert(ds.d.notifyOnDNSMsg(time.Now(), ep, "10.96.64.8:12345", 0, "10.96.64.1:53", &ciliumdns.Msg{
MsgHdr: ciliumdns.MsgHdr{
Response: true,
},
Question: []miekgdns.Question{{
Question: []ciliumdns.Question{{
Name: dns.FQDN("cilium.io"),
}},
Answer: []miekgdns.RR{&miekgdns.A{
Hdr: miekgdns.RR_Header{Name: dns.FQDN("cilium.io")},
Answer: []ciliumdns.RR{&ciliumdns.A{
Hdr: ciliumdns.RR_Header{Name: dns.FQDN("cilium.io")},
A: ciliumDNSRecord[dns.FQDN("cilium.io")].IPs[0],
}}}, "udp", true, &dnsproxy.ProxyRequestContext{}), IsNil)

c.Assert(ds.d.notifyOnDNSMsg(time.Now(), ep, "10.96.64.4:54321", 0, "10.96.64.1:53", &miekgdns.Msg{
MsgHdr: miekgdns.MsgHdr{
c.Assert(ds.d.notifyOnDNSMsg(time.Now(), ep, "10.96.64.4:54321", 0, "10.96.64.1:53", &ciliumdns.Msg{
MsgHdr: ciliumdns.MsgHdr{
Response: true,
},
Compress: false,
Question: []miekgdns.Question{{
Question: []ciliumdns.Question{{
Name: dns.FQDN("ebpf.io"),
}},
Answer: []miekgdns.RR{&miekgdns.A{
Hdr: miekgdns.RR_Header{Name: dns.FQDN("ebpf.io")},
Answer: []ciliumdns.RR{&ciliumdns.A{
Hdr: ciliumdns.RR_Header{Name: dns.FQDN("ebpf.io")},
A: ebpfDNSRecord[dns.FQDN("ebpf.io")].IPs[0],
}}}, "udp", true, &dnsproxy.ProxyRequestContext{}), IsNil)
}(endpoints[i%len(endpoints)])
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/cilium/checkmate v1.0.3
github.com/cilium/coverbee v0.3.2
github.com/cilium/deepequal-gen v0.0.0-20230330134849-754271daeec2
github.com/cilium/dns v1.1.51-0.20230303133941-d3bcb3008ed2
github.com/cilium/ebpf v0.11.0
github.com/cilium/fake v0.5.0
github.com/cilium/linters v0.0.0-20230808123256-d08e43b7cebd
Expand Down Expand Up @@ -60,7 +61,6 @@ require (
github.com/mattn/go-shellwords v1.0.12
github.com/mdlayher/arp v0.0.0-20220221190821-c37aaafac7f9
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118
github.com/miekg/dns v1.1.43
github.com/mitchellh/mapstructure v1.5.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.7
Expand Down Expand Up @@ -259,8 +259,6 @@ require (
)

replace (
github.com/miekg/dns => github.com/cilium/dns v1.1.51-0.20220729113855-5b94b11b46fc

go.universe.tf/metallb => github.com/cilium/metallb v0.1.1-0.20220829170633-5d7dfb1129f7

// Using private fork of controller-tools. See commit msg for more context
Expand Down
26 changes: 18 additions & 8 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/fqdn/dnsproxy/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"net"

"github.com/miekg/dns"
"github.com/cilium/dns"
)

// lookupTargetDNSServer finds the intended DNS target server for a specific
Expand Down
6 changes: 3 additions & 3 deletions pkg/fqdn/dnsproxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"syscall"
"time"

"github.com/miekg/dns"
"github.com/cilium/dns"
"github.com/sirupsen/logrus"
"golang.org/x/sync/semaphore"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -87,7 +87,7 @@ type DNSProxy struct {
// design now.
NotifyOnDNSMsg NotifyOnDNSMsgFunc

// DNSServers are the miekg/dns server instances.
// DNSServers are the cilium/dns server instances.
// Depending on the configuration, these might be
// TCPv4, UDPv4, TCPv6 and/or UDPv4.
// They handle DNS parsing etc. for us.
Expand Down Expand Up @@ -1157,7 +1157,7 @@ func evaluateAddress(address string, port uint16, bindPort uint16, ipFamily ipFa
// for a given request.
// Originally, DNS was limited to 512 byte responses. EDNS0 allows for larger
// sizes. In either case, responses can apply DNS compression, and the original
// RFCs require clients to accept this. In miekg/dns there is a comment that BIND
// RFCs require clients to accept this. In cilium/dns there is a comment that BIND
// does not support compression, so we retain the ability to suppress this.
func shouldCompressResponse(request, response *dns.Msg) bool {
ednsOptions := request.IsEdns0()
Expand Down
2 changes: 1 addition & 1 deletion pkg/fqdn/dnsproxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"

. "github.com/cilium/checkmate"
"github.com/miekg/dns"
"github.com/cilium/dns"
"golang.org/x/exp/maps"
"sigs.k8s.io/yaml"

Expand Down
2 changes: 1 addition & 1 deletion pkg/fqdn/dnsproxy/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"syscall"
"unsafe"

"github.com/miekg/dns"
"github.com/cilium/dns"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"golang.org/x/sys/unix"
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/logrecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"strings"

"github.com/miekg/dns"
"github.com/cilium/dns"

"github.com/cilium/cilium/pkg/proxy/accesslog"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/proxy/accesslog/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,17 @@ type LogRecordDNS struct {

// RCode is the response code
// defined as per https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
// Use github.com/miekg/dns.RcodeToString map to retrieve string representation
// Use github.com/cilium/dns.RcodeToString map to retrieve string representation
RCode int `json:"RCode,omitempty"`

// QTypes are question types in DNS message
// https://www.ietf.org/rfc/rfc1035.txt
// Use github.com/miekg/dns.TypeToString map to retrieve string representation
// Use github.com/cilium/dns.TypeToString map to retrieve string representation
QTypes []uint16 `json:"QTypes,omitempty"`

// AnswerTypes are record types in the answer section
// https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4
// Use github.com/miekg/dns.TypeToString map to retrieve string representation
// Use github.com/cilium/dns.TypeToString map to retrieve string representation
AnswerTypes []uint16 `json:"AnswerTypes,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"sync"
"testing"

"github.com/cilium/dns"

"github.com/cilium/cilium/pkg/hive"
"github.com/cilium/cilium/pkg/hive/cell"
"github.com/cilium/cilium/pkg/maps/eventsmap"
Expand All @@ -22,8 +24,6 @@ import (
"github.com/cilium/cilium/pkg/node"
"github.com/cilium/cilium/pkg/proxy/accesslog"
"github.com/cilium/cilium/pkg/u8proto"

"github.com/miekg/dns"
)

// mockLogRecord is a log entry similar to the one used in fqdn.go for
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit db13dd4

Please sign in to comment.