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

Fix vl3 dns #1429

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/networkservice/chains/nsmgr/vl3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ func Test_NSC_ConnectsTo_vl3NSE(t *testing.T) {
ctx,
nseReg,
sandbox.GenerateTestToken,
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx,
dnsServerIPCh,
vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."),
vl3dns.WithDNSPort(40053)),
vl3.NewServer(ctx, serverPrefixCh),
)

resolver := net.Resolver{
Expand Down Expand Up @@ -163,7 +163,6 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) {
ctx,
nseReg,
sandbox.GenerateTestToken,
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx,
dnsServerIPCh,
vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."),
Expand All @@ -173,6 +172,7 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) {
vl3dns.WithConfigs(dnsConfigs),
vl3dns.WithDNSPort(40053),
),
vl3.NewServer(ctx, serverPrefixCh),
)

resolver := net.Resolver{
Expand Down Expand Up @@ -252,11 +252,11 @@ func Test_NSC_GetsVl3DnsAddressDelay(t *testing.T) {
ctx,
nseReg,
sandbox.GenerateTestToken,
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx,
dnsServerIPCh,
vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."),
vl3dns.WithDNSPort(40053)))
vl3dns.WithDNSPort(40053)),
vl3.NewServer(ctx, serverPrefixCh))

nsc := domain.Nodes[0].NewClient(ctx, sandbox.GenerateTestToken)

Expand Down Expand Up @@ -300,10 +300,10 @@ func Test_vl3NSE_ConnectsTo_Itself(t *testing.T) {
ctx,
nseReg,
sandbox.GenerateTestToken,
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx,
dnsServerIPCh,
vl3dns.WithDNSPort(40053)))
vl3dns.WithDNSPort(40053)),
vl3.NewServer(ctx, serverPrefixCh))

// Connection to itself. This allows us to assign a dns address to ourselves.
nsc := domain.Nodes[0].NewClient(ctx, sandbox.GenerateTestToken, client.WithName(nseReg.Name))
Expand Down
17 changes: 8 additions & 9 deletions pkg/networkservice/connectioncontext/dnscontext/vl3dns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,16 @@ func (n *vl3DNSServer) Request(ctx context.Context, request *networkservice.Netw
}
}

ips := getSrcIPs(request.GetConnection())
if len(ips) > 0 {
for _, recordName := range recordNames {
n.dnsServerRecords.Store(recordName, ips)
}

metadata.Map(ctx, false).Store(clientDNSNameKey{}, recordNames)
}

resp, err := next.Server(ctx).Request(ctx, request)
if err == nil {
ips := getSrcIPs(resp)
if len(ips) > 0 {
for _, recordName := range recordNames {
n.dnsServerRecords.Store(recordName, ips)
}

metadata.Map(ctx, false).Store(clientDNSNameKey{}, recordNames)
}
configs := make([]*networkservice.DNSConfig, 0)
if srcRoutes := resp.GetContext().GetIpContext().GetSrcRoutes(); len(srcRoutes) > 0 {
var lastPrefix = srcRoutes[len(srcRoutes)-1].Prefix
Expand Down