Repository navigation
Allow exclusion of destination addresses from usage on KVM shared networks - #14607
Open
MitchDrage wants to merge 2 commits into
Open
MitchDrage wants to merge 2 commits into
MitchDrage wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Description
This PR applies
network.usage.exempt.cidrsto VMs on shared networks on KVM. It builds on #14583, which adds the setting for virtual routers, so this branch includes that commit until #14583 merges.On shared networks the host reports usage from libvirt, which reads each VM NIC's tap counters. Those count every byte, so the agent counts exempt traffic separately on the same tap and reports the libvirt total minus that.
How it works:
SetHostParamsCommand, on connect and whenever the setting is updated or reset.netdevtable with the exempt addresses in two sets (IPv4 and IPv6). Each user VM's tap gets two chains: the ingress hook counts what the VM sends to exempt addresses, and the egress hook counts what it receives from them. A sync every 10 seconds adds chains for new taps (VM start, NIC plug, migration in) and repairs the table if it's flushed.A few details keep the numbers safe to bill. These are in
UsageExemptBilling:/run, so it survives an agent restart and a reboot clears it along with the tap counters.Why nftables: hooking the tap counts both directions whatever bridge or switch it's plugged into, Linux bridge or OVS. iptables only sees bridged traffic with
br_netfilter, which changes filtering for every VM. ebtables only covers Linux bridges. tc would sit alongside the qdiscs libvirt already uses for rate limiting. This addsnftablesto the agent's package dependencies.The egress hook needs Linux 5.16 or later, or a backport:
On kernels without the hook, or without
nft, the agent logs one warning and reports usage as before.Other changes and limits:
configureHostParamsonly refreshes the reconcile command logs when the reconcile setting is sent, which only happens on connect. Before this, any setting pushed to a running agent (for examplemigrate.wait) marked commands still in progress as interrupted.Fixes: #14578
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
UsageExemptBillingTest(the arithmetic),UsageExemptCountersTest(the nftables side against a fakenft) andAgentManagerImplTest(sending the list to one zone or all zones).nftinstalled.How did you try to break this feature and the system with this change?
nft flush rulesetbetween stats collections. The sync rebuilt the table and the exempt bytes already counted stayed off.nftoutput. That collection kept the previous exempt counts and the stats request still succeeded.nftat all.