Skip to content

Commit 4721023

Browse files
Backport of Addition of missing IPv6 listeners and envoy dns ipv4 only resolution change into release/1.22.x (#22937)
backport of commit e285476 Co-authored-by: P Ajay Rao <pajay.rao@hashicorp.com>
1 parent 6567ee1 commit 4721023

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

agent/envoyextensions/builtin/aws-lambda/aws_lambda.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/go-viper/mapstructure/v2"
2121
pstruct "google.golang.org/protobuf/types/known/structpb"
2222

23+
"github.com/hashicorp/consul/agent/netutil"
2324
"github.com/hashicorp/consul/api"
2425
"github.com/hashicorp/consul/envoyextensions/extensioncommon"
2526
"github.com/hashicorp/go-multierror"
@@ -125,12 +126,16 @@ func (a *awsLambda) PatchCluster(p extensioncommon.ClusterPayload) (*envoy_clust
125126
if err != nil {
126127
return c, false, err
127128
}
128-
129+
dlf := envoy_cluster_v3.Cluster_V4_ONLY
130+
ds, _ := netutil.IsDualStack(nil, true)
131+
if ds {
132+
dlf = envoy_cluster_v3.Cluster_ALL
133+
}
129134
cluster := &envoy_cluster_v3.Cluster{
130135
Name: c.Name,
131136
ConnectTimeout: c.ConnectTimeout,
132137
ClusterDiscoveryType: &envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_LOGICAL_DNS},
133-
DnsLookupFamily: envoy_cluster_v3.Cluster_V4_ONLY,
138+
DnsLookupFamily: dlf,
134139
LbPolicy: envoy_cluster_v3.Cluster_ROUND_ROBIN,
135140
Metadata: &envoy_core_v3.Metadata{
136141
FilterMetadata: map[string]*pstruct.Struct{

agent/xds/clusters.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,10 @@ func configureClusterWithHostnames(
18421842
rate := 10 * time.Second
18431843
cluster.DnsRefreshRate = durationpb.New(rate)
18441844
cluster.DnsLookupFamily = envoy_cluster_v3.Cluster_V4_ONLY
1845+
ds, _ := netutil.IsDualStack(nil, true)
1846+
if ds {
1847+
cluster.DnsLookupFamily = envoy_cluster_v3.Cluster_ALL
1848+
}
18451849

18461850
envoyMaxEndpoints := 1
18471851
discoveryType := envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_LOGICAL_DNS}
@@ -1945,15 +1949,19 @@ func (s *ResourceGenerator) makeExternalIPCluster(snap *proxycfg.ConfigSnapshot,
19451949
func (s *ResourceGenerator) makeExternalHostnameCluster(snap *proxycfg.ConfigSnapshot, opts clusterOpts, discoveryType envoy_cluster_v3.Cluster_DiscoveryType) *envoy_cluster_v3.Cluster {
19461950
cfg := snap.GetGatewayConfig(s.Logger)
19471951
opts.connectTimeout = time.Duration(cfg.ConnectTimeoutMs) * time.Millisecond
1948-
1952+
dlf := envoy_cluster_v3.Cluster_V4_ONLY
1953+
ds, _ := netutil.IsDualStack(nil, true)
1954+
if ds {
1955+
dlf = envoy_cluster_v3.Cluster_ALL
1956+
}
19491957
cluster := &envoy_cluster_v3.Cluster{
19501958
Name: opts.name,
19511959
ConnectTimeout: durationpb.New(opts.connectTimeout),
19521960

19531961
// Having an empty config enables outlier detection with default config.
19541962
OutlierDetection: &envoy_cluster_v3.OutlierDetection{},
19551963
ClusterDiscoveryType: &envoy_cluster_v3.Cluster_Type{Type: discoveryType},
1956-
DnsLookupFamily: envoy_cluster_v3.Cluster_V4_ONLY,
1964+
DnsLookupFamily: dlf,
19571965
}
19581966

19591967
rate := 10 * time.Second

agent/xds/listeners.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,13 @@ func makeListener(opts makeListenerOpts) *envoy_listener_v3.Listener {
949949
func makeListenerWithDefault(opts makeListenerOpts) *envoy_listener_v3.Listener {
950950
if opts.addr == "" {
951951
opts.addr = "127.0.0.1"
952+
ds, err := netutil.IsDualStack(nil, true)
953+
if err != nil {
954+
return nil
955+
}
956+
if ds {
957+
opts.addr = "::1"
958+
}
952959
}
953960
accessLog, err := accesslogs.MakeAccessLogs(&opts.accessLogs, true)
954961
if err != nil && opts.logger != nil {
@@ -1342,6 +1349,13 @@ func (s *ResourceGenerator) makeInboundListener(cfgSnap *proxycfg.ConfigSnapshot
13421349
addr := cfgSnap.Address
13431350
if addr == "" {
13441351
addr = "0.0.0.0"
1352+
ds, err := netutil.IsDualStack(nil, true)
1353+
if err != nil {
1354+
return nil, err
1355+
}
1356+
if ds {
1357+
addr = "::"
1358+
}
13451359
}
13461360
if cfg.BindAddress != "" {
13471361
addr = cfg.BindAddress
@@ -1565,6 +1579,13 @@ func (s *ResourceGenerator) makeExposedCheckListener(cfgSnap *proxycfg.ConfigSna
15651579
addr = cfg.BindAddress
15661580
} else if addr == "" {
15671581
addr = "0.0.0.0"
1582+
ds, err := netutil.IsDualStack(nil, true)
1583+
if err != nil {
1584+
return nil, err
1585+
}
1586+
if ds {
1587+
addr = "::"
1588+
}
15681589
}
15691590

15701591
// Strip any special characters from path to make a valid and hopefully unique name

command/connect/envoy/envoy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,13 @@ func (c *cmd) proxyRegistration(svcForSidecar *api.AgentService) (*api.AgentServ
528528
// fallback to localhost as the gateway has to reside in the same network namespace
529529
// as the agent
530530
tcpCheckAddr = "127.0.0.1"
531+
ds, err := netutil.IsDualStack(nil, false)
532+
if err == nil {
533+
return nil, err
534+
}
535+
if ds {
536+
tcpCheckAddr = "::1"
537+
}
531538
}
532539

533540
var proxyConf *api.AgentServiceConnectProxyConfig

0 commit comments

Comments
 (0)