Skip to content

Commit

Permalink
iptables: preserve encrypt mark for egress proxy forward traffic
Browse files Browse the repository at this point in the history
[ upstream commit f018b20 ]

Once forward traffic for an egress proxy connection has traversed through
cilium_host / cilium_net, we expect IPsec-marked packets to get handled
by xfrm. But this currently conflicts with an iptables rule for the
proxy's transparent socket, which then over-writes the mark:

    -A CILIUM_PRE_mangle -m socket --transparent -m comment --comment "cilium: any->pod redirect proxied traffic to host proxy" -j MARK --set-xmark 0x200/0xffffffff

We can avoid this by adding an extra filter to this rule, so that it
doesn't match IPsec-marked packets.

Signed-off-by: Zhichuan Liang<gray.liang@isovalent.com>
Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
  • Loading branch information
jschwinger233 authored and julianwiedmann committed Mar 7, 2024
1 parent c22e2fb commit 298fa33
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/datapath/iptables/iptables.go
Expand Up @@ -433,10 +433,12 @@ func (m *IptablesManager) inboundProxyRedirectRule(cmd string) []string {
// 2. route original direction traffic that would otherwise be intercepted
// by ip_early_demux
toProxyMark := fmt.Sprintf("%#08x", linux_defaults.MagicMarkIsToProxy)
matchFromIPSecEncrypt := fmt.Sprintf("%#08x/%#08x", linux_defaults.RouteMarkEncrypt, linux_defaults.RouteMarkMask)
return []string{
"-t", "mangle",
cmd, ciliumPreMangleChain,
"-m", "socket", "--transparent",
"-m", "mark", "!", "--mark", matchFromIPSecEncrypt,
"-m", "comment", "--comment", "cilium: any->pod redirect proxied traffic to host proxy",
"-j", "MARK",
"--set-mark", toProxyMark}
Expand Down

0 comments on commit 298fa33

Please sign in to comment.