Skip to content

Keep conntrack counters current for offloaded flows - #13496

Merged
caseydavenport merged 13 commits into
projectcalico:masterfrom
caseydavenport:casey-flowtable-ct-counters
Sep 7, 2026
Merged

caseydavenport merged 13 commits into
projectcalico:masterfrom
caseydavenport:casey-flowtable-ct-counters

Conversation

@caseydavenport

@caseydavenport caseydavenport commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Flow logs take their packet and byte counts from the conntrack entry, but the software flowtable fast path bypasses the conntrack hook, so those counts freeze the moment a flow is offloaded. Setting the flowtable's counter flag keeps the kernel updating them, and Felix probes for the flag at startup since it needs kernel 5.13 or later, warning rather than failing when the kernel won't take it.

Depends on kubernetes-sigs/knftables#47. Until that merges, go.mod points at the projectcalico fork.

Related: CORE-13614

Fix flow log packet and byte counts freezing for connections offloaded to the nftables software flowtable.

Flow log packet and byte counts come off the conntrack entry, which the flowtable fast path never updates.
@caseydavenport caseydavenport added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Aug 11, 2026
@marvin-tigera marvin-tigera added this to the Calico v3.33.0 milestone Aug 11, 2026
Conntrack accounting stays up to date for offloaded flows, so flow logs report their real packet and byte counts.
…counters

# Conflicts:
#	app-policy/deps.txt
#	cmd/deps.txt
#	cni-plugin/deps.txt
#	felix/deps.txt
#	felix/fv/flowtable_test.go
#	go.mod
#	go.sum
#	kube-controllers/deps.txt
#	node/deps.txt
Counter is a *bool on the fork now, matching Set.AutoMerge.
@caseydavenport
caseydavenport marked this pull request as ready for review August 31, 2026 18:57
@caseydavenport
caseydavenport requested review from a team as code owners August 31, 2026 18:57
@caseydavenport caseydavenport changed the title Add FV showing conntrack counters freeze on offloaded flows Keep conntrack counters current for offloaded flows Aug 31, 2026
Comment thread felix/nftables/flowoffload_detect.go
Comment thread app-policy/deps.txt
A leftover probe flowtable turns the next probe's add into an update, and old kernels don't check flags on the update path.
Imports use the original module path, so a path-changing replace dropped the module from deps.txt entirely.
Copilot AI lite review requested due to automatic review settings September 2, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes Felix’s nftables dataplane behavior with kernel-version-dependent probing and introduces a temporary forked dependency, which warrants final human review despite test coverage.

Pull request overview

This PR fixes flow log packet/byte counts freezing when connections are offloaded to the nftables software flowtable by enabling the flowtable “counter” flag when supported, while probing for kernel support at Felix startup and warning (not failing) when counters aren’t available.

Changes:

  • Add startup probing for flowtable counter-flag support and plumb the result into nftables table programming.
  • Program the flowtable with the counter flag (when supported) and add unit/FV coverage for counter behavior.
  • Temporarily replace upstream sigs.k8s.io/knftables with the Project Calico fork revision that exposes the needed flowtable counter support, and adjust deps reporting to account for module replacements.
File summaries
File Description
node/deps.txt Record forked knftables module in generated deps output.
kube-controllers/deps.txt Record forked knftables module in generated deps output.
hack/cmd/deps/deps.go Update deps generator to match imports by original module path but report replaced module/version.
go.sum Add checksums for the forked knftables version; remove upstream knftables sums.
go.mod Add replace to use github.com/projectcalico/knftables until upstream release includes counter support.
felix/nftables/table.go Add FlowtableCounter option and program flowtable Counter flag during apply.
felix/nftables/table_test.go Unit test coverage for flowtable counter flag off/on programming.
felix/nftables/flowoffload_detect.go Extend probing to detect both flowtable support and counter-flag support (kernel version gating).
felix/nftables/flowoffload_detect_test.go Unit tests for supported/unsupported/counter-unsupported scenarios, including leftover-probe behavior.
felix/fv/flowtable_test.go FV test to ensure conntrack counters continue increasing for offloaded flows.
felix/deps.txt Record forked knftables module in generated deps output.
felix/dataplane/linux/int_dataplane.go Wire probe results into Felix startup: disable offload if unsupported; warn if counters unsupported; pass counter support into nftables table options.
cni-plugin/deps.txt Record forked knftables module in generated deps output.
cmd/deps.txt Record forked knftables module in generated deps output.
app-policy/deps.txt Record forked knftables module in generated deps output.
Review details
  • Files reviewed: 14/15 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Flowtable counter support is in knftables master, so the projectcalico fork replace is no longer needed.
@fasaxc

fasaxc commented Sep 7, 2026

Copy link
Copy Markdown
Member

LGTM

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

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact skip-bot-cherry-pick

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants