Skip to content

Commit c7a8701

Browse files
committed
nftables: cleanup service chain checks
A packet can traverse the service-xxxx chains by matching on either service-ips or service-nodeports verdict map. We masquerade off-cluster traffic to ClusterIP (when masqueradeAll = false) by adding a rule in service-xxxx which checks if destination IP is ClusterIP, port and protocol matches with service specs and source IP doesn't belong to PodCIDR and masquerade on match. If the packet reaches the service chain by match on service-ips map, then ClusterIP, port and protocol are already matching service specs. If it comes via external-xxxx chain then the destination IP will never be ClusterIP. Therefore, we can simplify the masquerade off-cluster traffic to ClusterIP check by simply matching on destination ip and source ip. Signed-off-by: Daman Arora <[email protected]>
1 parent 5290c24 commit c7a8701

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

pkg/proxy/nftables/proxier.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,6 @@ func (proxier *Proxier) syncProxyRules() {
15861586
Chain: internalTrafficChain,
15871587
Rule: knftables.Concat(
15881588
ipX, "daddr", svcInfo.ClusterIP(),
1589-
protocol, "dport", svcInfo.Port(),
15901589
"jump", markMasqChain,
15911590
),
15921591
})
@@ -1600,7 +1599,6 @@ func (proxier *Proxier) syncProxyRules() {
16001599
Chain: internalTrafficChain,
16011600
Rule: knftables.Concat(
16021601
ipX, "daddr", svcInfo.ClusterIP(),
1603-
protocol, "dport", svcInfo.Port(),
16041602
proxier.localDetector.IfNotLocalNFT(),
16051603
"jump", markMasqChain,
16061604
),

0 commit comments

Comments
 (0)