Conversation
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
WalkthroughThe nftables rule initialization logic in the Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
pkg/proxy/nft.go (1)
30-34: Remove unused struct fields.The struct fields
rawPrerouting,natOutput, andnatPreroutingare no longer used after the refactoring to a singleearly_snatchain but remain in the struct definition.// Chains. - rawPrerouting *nftables.Chain // Chain "raw_prerouting": for notrack rules. - natOutput *nftables.Chain // Chain "nat_output": for SNAT rule. - natPrerouting *nftables.Chain // Chain "nat_prerouting": for DNAT rule. + earlySNAT *nftables.Chain // Chain "early_snat": for SNAT and DNAT rules.
🧹 Nitpick comments (1)
pkg/proxy/nft.go (1)
322-322: Update outdated comment reference.The comment references
raw_preroutingchain which no longer exists after the refactoring.-// This ensures that the raw_prerouting chain no longer matches these IPs. +// This ensures that the early_snat chain no longer matches these IPs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/proxy/nft.go(3 hunks)
🔇 Additional comments (2)
pkg/proxy/nft.go (2)
133-194: LGTM: Rules correctly assigned to new chain.The SNAT and DNAT rules are properly assigned to the new
earlySNATchain, and the logging has been updated appropriately.
123-130: Verify the architectural impact of consolidating chains.The refactoring consolidates three separate chains into a single
early_snatchain in the raw table. This removes the previous notrack functionality that was applied to pod and service IPs.Please verify that removing the notrack rules doesn't break connection tracking behavior for the proxy functionality. The previous implementation had explicit notrack rules that are now absent.
#!/bin/bash # Search for any references to notrack functionality or connection tracking requirements rg -i "notrack|conntrack|connection.track" --type go
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/proxy/nft.go(4 hunks)
🔇 Additional comments (6)
pkg/proxy/nft.go (6)
102-132: SNAT rule implementation looks correct.The SNAT rule correctly:
- Reads the source IP from network header offset 12 (IPv4 source address)
- Performs map lookup in pod_svc map
- Writes the translated IP back to the source address field
- Updates checksums appropriately
133-162: DNAT rule implementation looks correct.The DNAT rule correctly:
- Reads the destination IP from network header offset 16 (IPv4 destination address)
- Performs map lookup in svc_pod map
- Writes the translated IP back to the destination address field
- Updates checksums appropriately
163-163: Logging message accurately reflects the consolidated approach.The updated log message correctly indicates that both SNAT and DNAT rules are now added to the single early_snat chain.
268-268: Comment correctly updated to reflect removed raw set management.The comment has been appropriately updated to remove references to the raw pod set that was eliminated in this refactoring.
310-310: Logging message correctly updated to reflect removed raw set management.The log message has been appropriately updated to remove references to raw set elements that are no longer managed.
96-98: Verify the implications of using raw priority for NAT operations.Using
ChainPriorityRawfor NAT operations means the address translation happens before connection tracking. This could have several implications:
- Connection tracking won't see the original addresses
- Applications expecting to see original addresses may break
- Stateful firewalling based on original addresses won't work
Ensure this early processing aligns with your networking requirements.
#!/bin/bash # Check if there are any existing iptables/nftables rules that might conflict # or depend on seeing original addresses before NAT echo "Checking for existing NAT rules..." nft list ruleset 2>/dev/null | grep -A5 -B5 "nat\|snat\|dnat" || echo "No existing NAT rules found" echo "Checking for connection tracking rules..." nft list ruleset 2>/dev/null | grep -A5 -B5 "ct\|conntrack" || echo "No connection tracking rules found"
This PR includes the following change cozystack/cozy-proxy#6 Which makes source-based-routing working with wholeIP services <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated Helm chart and Docker image versions for cozy-proxy to v0.2.0. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Use:
instead of
Summary by CodeRabbit