Skip to content

Commit

Permalink
fix vl3 dns (#1429)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
  • Loading branch information
wazsone authored Feb 27, 2023
1 parent bcd1eb0 commit 9a7d5a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
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

0 comments on commit 9a7d5a4

Please sign in to comment.