Skip to content

Allow exclusion of chosen addresses from virtual router usage counters - #14583

Open
MitchDrage wants to merge 1 commit into
apache:mainfrom
MitchDrage:usage-exempt-router
Open

MitchDrage wants to merge 1 commit into
apache:mainfrom
MitchDrage:usage-exempt-router

Conversation

@MitchDrage

@MitchDrage MitchDrage commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds a network.usage.exempt.cidrs setting so operators can leave chosen addresses out of virtual router network usage. A typical use is a provider's own S3 or backup endpoint, where VM traffic shouldn't be billed as egress.

  • The setting is global and zone-scoped. It takes comma-separated IPv4 addresses or CIDRs.
  • Traffic between guest networks and these addresses isn't counted, in either direction.
  • The router sends forwarded traffic through a new <chain>_EXEMPT chain. This chain skips the counters for exempt sources and destinations. The counting chains are unchanged, so existing usage collection reads them as before.
  • Invalid entries and /0 are rejected when the setting is saved.
  • A router picks up the value when it starts, so existing routers need a restart.
  • With the setting empty, routers get exactly the same rules as today.
  • Private gateway interfaces also get the exempt chain. Their counters are never read, since private gateway networks aren't billed, so this is harmless.
  • IPv4 and IPv6 entries are accepted. Virtual routers only count IPv4 traffic in network usage today, so they ignore IPv6 entries. IPv6 counting on routers would separate feature request. Shared networks will use IPv6 entries once they get exemptions.

This covers isolated networks and VPCs. Shared networks will follow in a separate PR as it's entirely different code.

Part of #14578

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

How Has This Been Tested?

  • Unit tests for the setting parser, save-time validation and router rule generation (VirtualNetworkApplianceManagerImplTest, ConfigurationManagerImplTest, TestCsConfig, TestCsAddress).
  • Router scripts from 4.22.1.1 with this change applied, run in a Debian 12 container with network namespaces for the guest and public sides. This was done for both an isolated router and a VPC router.
    • Traffic to and from an exempt address left the counters at zero.
    • Other traffic was counted as normal, read through netusage.sh and vpc_netusage.sh.
  • The management server change on 4.22.1.1 with the simulator.
    • A zone value reached the boot args of isolated and VPC routers, normalised.
    • A global value applied when the zone value was cleared.
    • An empty setting added no boot arg.

How did you try to break this feature and the system with this change?

  • Saved invalid entries (bogus, 192.0.2.300, 2001:db8::/129), 0.0.0.0/0 and ::/0. Each was rejected with an error naming the entry. Valid IPv6 entries were accepted and passed to the router, which ignores them for now as they don't support IPv6.
  • Re-ran the router configuration repeatedly. The rule set stayed the same.
  • Added and cleared exempt CIDRs on a running router. The rules followed each change.
  • With the setting empty, compared the router rules against stock 4.22.1.1. They were identical.
  • Applied, changed and removed VPC network ACLs with an exempt CIDR set.
    • The usage rules stayed untouched.
    • ACLs still allowed and blocked traffic as configured.
    • An ACL deny on an exempt address still blocked it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant