feat: add fib daddr type local return to nft prerouting and output chains#82
Merged
florentianayuwono merged 8 commits intoApr 28, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/e2adeac0-1971-4dd0-a7f4-fcf6045f2a2f Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Enhance automatic exclusion of local host traffic from prerouting DNAT
Add fib daddr type local return to nft prerouting chain
Apr 27, 2026
florentianayuwono
requested changes
Apr 27, 2026
Collaborator
florentianayuwono
left a comment
There was a problem hiding this comment.
@copilot please address the review and make sure to fix the failing linting workflow. can you please also test if this will work with Ubuntu 20.04?
…ration matrix Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/1b816434-1389-4807-ba7b-81d50c29451d Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Contributor
Author
Both addressed in cb4a288:
|
…l traffic exclusion Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/cb7beb88-ccba-4b3f-9f44-7f24a66a3668 Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
…rted base for any-charm Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/f4afe957-b5ef-4f28-9b77-c6033a7189a1 Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Collaborator
|
@copilot can you fix the lint |
Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/6a5395fa-26d1-4f71-8b64-04c907f473a9 Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Contributor
Author
florentianayuwono
approved these changes
Apr 28, 2026
Contributor
|
@copilot can you add |
Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/741bb379-3962-4de7-8709-e1f00bf82d3e Co-authored-by: weiiwang01 <18743205+weiiwang01@users.noreply.github.com>
Contributor
Author
Copilot
AI
changed the title
feat: add fib daddr type local return to nft prerouting chain
feat: add fib daddr type local return to nft prerouting and output chains
Apr 28, 2026
weiiwang01
approved these changes
Apr 28, 2026
Collaborator
|
@copilot fix the failing lint test please |
Agent-Logs-Url: https://github.com/canonical/aproxy-operator/sessions/27920951-7c9e-4358-800f-781ded56aef8 Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds
fib daddr type local returnas the first rule in both the nftablespreroutingandoutputchains, dynamically bypassing DNAT for any traffic destined to a local interface address.Also extends the integration test matrix to include Ubuntu 20.04, confirming compatibility (
fib daddr type localis supported since nftables 0.7.0 / Linux kernel 4.10, which predates Ubuntu 20.04's nftables 0.9.3 and kernel 5.4).Why we need it
The FIB check is kernel-driven and interface-aware — it covers all local IPs automatically without the operator needing to enumerate them. Applying it to both chains eliminates a footgun when deploying aproxy on hosts that also serve inbound traffic, and ensures locally-originated traffic to local addresses is also handled correctly.
Checklist
docs/changelog.mdwith user-relevant changes(e.g., in
.github/workflows/integration_tests.yaml, ensure themoduleslist is correct)terraform fmtpasses andtflintreports no errorsTest plan:
Integration test (
test_local_service_accessible_when_port_intercepted): Behavioral end-to-end test that configures aproxy to intercept port 8081, starts an HTTP server on that port inside the ubuntu unit, then curls the unit's own non-loopback IP and asserts a 200 response. Withoutfib daddr type local return, inbound traffic on the intercepted port would be DNAT'd to the proxy and the local service would be unreachable.Ubuntu 20.04 has been added to the integration test matrix for end-to-end verification across all supported bases. Because
any-charm(used to deploy the upstream tinyproxy) does not publish aubuntu@20.04build onlatest/edge, the tinyproxy deployment falls back toubuntu@22.04for that base — the proxy server's host OS is irrelevant to what is being tested; aproxy and the ubuntu principal still run on 20.04.Review focus: The rule is inserted as the first rule in both the
preroutingchain (inbound interception) and theoutputchain (locally-originated traffic), ensuring local-destined traffic bypasses DNAT in both directions.