Skip to content

Commit 86470e3

Browse files
committed
iptables: Fix proxy port restoration for CEC/CCEC ports
CiliumEnvoyConfig ports do not have the "cilium-" prefix. Change the regex to not require it and also to capture more of the comment to not make it less robust. This fixes proxy port churn for CEC/CCEC ports on Cilium restarts and helps avoid churn on Envoy listener xDS updates as well. Tested locally with examples/kubernetes/servicemesh/envoy/envoy-helloworld-v1-90-v2-10.yaml applied. Before agent update: $ kubectl exec -it -n kube-system cilium-m9zzx -- iptables -t mangle -n -L CILIUM_PRE_mangle | grep -E "/\* cilium: TPROXY to host ([^ ]+) proxy \*/ TPROXY redirect (0.0.0.0|127.0.0.1|::|::1):([1-9][0-9]*) mark" TPROXY tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x59890200 /* cilium: TPROXY to host cilium-dns-egress proxy */ TPROXY redirect 127.0.0.1:35161 mark 0x200/0xffffffff TPROXY udp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x59890200 /* cilium: TPROXY to host cilium-dns-egress proxy */ TPROXY redirect 127.0.0.1:35161 mark 0x200/0xffffffff TPROXY tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0xfb440200 /* cilium: TPROXY to host default/envoy-lb-listener/envoy-lb-listener proxy */ TPROXY redirect 127.0.0.1:17659 mark 0x200/0xffffffff TPROXY udp -- 0.0.0.0/0 0.0.0.0/0 mark match 0xfb440200 /* cilium: TPROXY to host default/envoy-lb-listener/envoy-lb-listener proxy */ TPROXY redirect 127.0.0.1:17659 mark 0x200/0xffffffff After agent update: $ kubectl exec -it -n kube-system cilium-75dfv -- iptables -t mangle -n -L CILIUM_PRE_mangle | grep -E "/\* cilium: TPROXY to host ([^ ]+) proxy \*/ TPROXY redirect (0.0.0.0|127.0.0.1|::|::1):([1-9][0-9]*) mark" TPROXY tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x59890200 /* cilium: TPROXY to host cilium-dns-egress proxy */ TPROXY redirect 127.0.0.1:35161 mark 0x200/0xffffffff TPROXY udp -- 0.0.0.0/0 0.0.0.0/0 mark match 0x59890200 /* cilium: TPROXY to host cilium-dns-egress proxy */ TPROXY redirect 127.0.0.1:35161 mark 0x200/0xffffffff TPROXY tcp -- 0.0.0.0/0 0.0.0.0/0 mark match 0xfb440200 /* cilium: TPROXY to host default/envoy-lb-listener/envoy-lb-listener proxy */ TPROXY redirect 127.0.0.1:17659 mark 0x200/0xffffffff TPROXY udp -- 0.0.0.0/0 0.0.0.0/0 mark match 0xfb440200 /* cilium: TPROXY to host default/envoy-lb-listener/envoy-lb-listener proxy */ TPROXY redirect 127.0.0.1:17659 mark 0x200/0xffffffff Note that agent pod names are different (due to the update), but both the DNS and CEC proxy ports are the same (35161 and 17659, respectively). Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
1 parent 3823779 commit 86470e3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

pkg/datapath/iptables/iptables.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ func (m *Manager) iptProxyRule(rules string, prog runnable, l4proto, ip string,
637637
return nil
638638
}
639639

640+
// NOTE: Proxy port restoration depends on the comment string below, see doGetProxyPorts()
640641
rule := []string{
641642
"-t", "mangle",
642643
"-A", ciliumPreMangleChain,
@@ -1288,7 +1289,7 @@ func (m *Manager) doGetProxyPorts(prog iptablesInterface) map[string]uint16 {
12881289
}
12891290

12901291
re := regexp.MustCompile(
1291-
"(cilium-[^ ]*) proxy.*TPROXY redirect " +
1292+
"/\\* cilium: TPROXY to host ([^ ]+) proxy \\*/ TPROXY redirect " +
12921293
"(0.0.0.0|" + ipfamily.IPv4().Localhost +
12931294
"|::|" + ipfamily.IPv6().Localhost + ")" +
12941295
":([1-9][0-9]*) mark",

0 commit comments

Comments
 (0)