Skip to content

Commit 5012abf

Browse files
ygao-gbowei
authored andcommitted
atenet: bind the Envoy sockets and Services dual-stack
The router and egress manifests bind the IPv4 wildcard on every Envoy socket, and neither gateway's Service asks for a second IP family. On a dual-stack cluster the router answers on its IPv4 ClusterIP and on nothing at all for IPv6; on an IPv6-primary cluster the kubelet cannot probe the pod on its only address, so atenet-egress crashloops while Envoy itself starts fine. Both gateways now bind `::` as well and ask for PreferDualStack. That makes them accept IPv6, not reach it: the egress dns_lookup_family, the DNS AAAA path, and atunnel's original-destination lookup stay IPv4. The experimental sdsmint egress variant is untouched.
1 parent 61f8f90 commit 5012abf

4 files changed

Lines changed: 70 additions & 20 deletions

File tree

‎cmd/atenet/internal/router/xds.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,27 @@ func (x *XdsServer) buildTracing() *hcmv3.HttpConnectionManager_Tracing {
11081108
}
11091109
}
11101110

1111+
// dualStackAdditionalAddresses returns the IPv6 half of a dual-stack ingress
1112+
// listener, to pair with a primary 0.0.0.0 socket on the same port. Ipv4Compat
1113+
// stays false: clearing IPV6_V6ONLY would collide with that primary.
1114+
func dualStackAdditionalAddresses(port int) []*listenerv3.AdditionalAddress {
1115+
return []*listenerv3.AdditionalAddress{
1116+
{
1117+
Address: &corev3.Address{
1118+
Address: &corev3.Address_SocketAddress{
1119+
SocketAddress: &corev3.SocketAddress{
1120+
Address: "::",
1121+
Ipv4Compat: false,
1122+
PortSpecifier: &corev3.SocketAddress_PortValue{
1123+
PortValue: uint32(port),
1124+
},
1125+
},
1126+
},
1127+
},
1128+
},
1129+
}
1130+
}
1131+
11111132
func (x *XdsServer) buildListener() *listenerv3.Listener {
11121133
hcm := x.buildHcm("ingress_http", true)
11131134

@@ -1123,6 +1144,7 @@ func (x *XdsServer) buildListener() *listenerv3.Listener {
11231144
},
11241145
},
11251146
},
1147+
AdditionalAddresses: dualStackAdditionalAddresses(x.ingressPort),
11261148
FilterChains: []*listenerv3.FilterChain{
11271149
{
11281150
Filters: []*listenerv3.Filter{
@@ -1182,6 +1204,7 @@ func (x *XdsServer) buildHttpsListener() *listenerv3.Listener {
11821204
},
11831205
},
11841206
},
1207+
AdditionalAddresses: dualStackAdditionalAddresses(x.httpsPort),
11851208
FilterChains: []*listenerv3.FilterChain{
11861209
{
11871210
Filters: []*listenerv3.Filter{
@@ -1213,6 +1236,7 @@ func (x *XdsServer) buildConnectTerminateListener() *listenerv3.Listener {
12131236
},
12141237
},
12151238
},
1239+
AdditionalAddresses: dualStackAdditionalAddresses(x.connectPlainTextPort),
12161240
FilterChains: []*listenerv3.FilterChain{
12171241
{
12181242
Filters: []*listenerv3.Filter{
@@ -1246,6 +1270,7 @@ func (x *XdsServer) buildConnectTerminateTLSListener() *listenerv3.Listener {
12461270
},
12471271
},
12481272
},
1273+
AdditionalAddresses: dualStackAdditionalAddresses(x.connectTLSPort),
12491274
FilterChains: []*listenerv3.FilterChain{
12501275
{
12511276
Filters: []*listenerv3.Filter{

‎cmd/atenet/internal/router/xds_test.go‎

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@ import (
4848
"github.com/agent-substrate/substrate/internal/atunnel"
4949
)
5050

51+
// assertDualStackIngress checks an ingress listener keeps its 0.0.0.0 primary
52+
// and gains exactly one "::" socket on the same port.
53+
func assertDualStackIngress(t *testing.T, l *listenerv3.Listener, wantPort uint32) {
54+
t.Helper()
55+
56+
sa := l.GetAddress().GetSocketAddress()
57+
if sa.GetAddress() != "0.0.0.0" {
58+
t.Errorf("Expected address '0.0.0.0', got %s", sa.GetAddress())
59+
}
60+
if sa.GetPortValue() != wantPort {
61+
t.Errorf("Expected port %d, got %d", wantPort, sa.GetPortValue())
62+
}
63+
64+
addrs := l.GetAdditionalAddresses()
65+
if len(addrs) != 1 {
66+
t.Fatalf("Expected 1 additional address on %s, got %d", l.GetName(), len(addrs))
67+
}
68+
69+
asa := addrs[0].GetAddress().GetSocketAddress()
70+
if asa.GetAddress() != "::" {
71+
t.Errorf("Expected additional address '::', got %s", asa.GetAddress())
72+
}
73+
if asa.GetIpv4Compat() {
74+
t.Error("Expected additional address Ipv4Compat to be false")
75+
}
76+
if asa.GetPortValue() != wantPort {
77+
t.Errorf("Expected additional port %d, got %d", wantPort, asa.GetPortValue())
78+
}
79+
}
80+
5181
func TestXdsServer_UpdateSnapshot(t *testing.T) {
5282
server := NewXdsServer(18000)
5383
server.SetConfig(8081, 50052, "10.0.0.1")
@@ -150,14 +180,7 @@ func TestXdsServer_UpdateSnapshot(t *testing.T) {
150180
if raw, exists := listenersMap[IngressHTTPListener]; !exists {
151181
t.Errorf("Listener name '%s' is missing from snapshot listeners", IngressHTTPListener)
152182
} else {
153-
l := raw.(*listenerv3.Listener)
154-
sa := l.GetAddress().GetSocketAddress()
155-
if sa.GetPortValue() != 8081 {
156-
t.Errorf("Expected port 8081, got %d", sa.GetPortValue())
157-
}
158-
if sa.GetAddress() != "0.0.0.0" {
159-
t.Errorf("Expected address '0.0.0.0', got %s", sa.GetAddress())
160-
}
183+
assertDualStackIngress(t, raw.(*listenerv3.Listener), 8081)
161184
}
162185
}
163186

@@ -192,10 +215,7 @@ func TestXdsServer_UpdateSnapshot_WithHttps(t *testing.T) {
192215
t.Errorf("Listener name '%s' is missing from snapshot listeners", IngressHTTPSListener)
193216
} else {
194217
l := raw.(*listenerv3.Listener)
195-
sa := l.GetAddress().GetSocketAddress()
196-
if sa.GetPortValue() != 8443 {
197-
t.Errorf("Expected port 8443, got %d", sa.GetPortValue())
198-
}
218+
assertDualStackIngress(t, l, 8443)
199219

200220
// Verify the TLS config references the serving cert via SDS rather
201221
// than embedding it: inline filename DataSources are read only once
@@ -354,16 +374,14 @@ func TestXdsServer_UpdateSnapshot_WithConnect(t *testing.T) {
354374
}
355375
if raw, exists := listenersMap["connect_terminate"]; !exists {
356376
t.Error("connect_terminate listener missing")
357-
} else if sa := raw.(*listenerv3.Listener).GetAddress().GetSocketAddress(); sa.GetPortValue() != 8081 {
358-
t.Errorf("Expected connect_terminate port 8081, got %d", sa.GetPortValue())
377+
} else {
378+
assertDualStackIngress(t, raw.(*listenerv3.Listener), 8081)
359379
}
360380
if raw, exists := listenersMap["connect_terminate_tls"]; !exists {
361381
t.Error("connect_terminate_tls listener missing")
362382
} else {
363383
l := raw.(*listenerv3.Listener)
364-
if sa := l.GetAddress().GetSocketAddress(); sa.GetPortValue() != 8444 {
365-
t.Errorf("Expected connect_terminate_tls port 8444, got %d", sa.GetPortValue())
366-
}
384+
assertDualStackIngress(t, l, 8444)
367385
ts := l.GetFilterChains()[0].GetTransportSocket()
368386
if ts.GetName() != "envoy.transport_sockets.tls" {
369387
t.Errorf("Expected connect_terminate_tls to be TLS-wrapped, got transport socket %q", ts.GetName())

‎manifests/ate-install/atenet-egress.yaml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ data:
3737
envoy.yaml: |
3838
admin:
3939
address:
40-
socket_address: { address: 0.0.0.0, port_value: 15000 }
40+
# ipv4_compat is load-bearing: see --envoy-admin-address below.
41+
socket_address: { address: "::", ipv4_compat: true, port_value: 15000 }
4142
static_resources:
4243
listeners:
4344
- name: egress
4445
address:
45-
socket_address: { address: 0.0.0.0, port_value: 443 }
46+
# ipv4_compat rather than a second socket: IPv4 peers arrive as
47+
# ::ffff: and nothing here reads the peer -- identity is the cert.
48+
socket_address: { address: "::", ipv4_compat: true, port_value: 443 }
4649
filter_chains:
4750
# Named so ext_proc can read it back as xds.filter_chain_name. Must
4851
# match EgressFilterChainName in
@@ -379,6 +382,7 @@ metadata:
379382
namespace: ate-system
380383
spec:
381384
type: ClusterIP
385+
ipFamilyPolicy: PreferDualStack
382386
selector:
383387
app: atenet-egress
384388
ports:

‎manifests/ate-install/atenet-router.yaml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ data:
8686
admin:
8787
address:
8888
socket_address:
89-
address: 0.0.0.0
89+
# ipv4_compat is load-bearing: dataplane.go probes /ready over IPv4 loopback.
90+
address: "::"
91+
ipv4_compat: true
9092
port_value: 9901
9193
9294
node:
@@ -354,6 +356,7 @@ metadata:
354356
namespace: ate-system
355357
spec:
356358
type: ClusterIP
359+
ipFamilyPolicy: PreferDualStack
357360
selector:
358361
app: atenet-router
359362
ports:

0 commit comments

Comments
 (0)