Skip to content

bpf, nodeport: source port ranges converted to runtime config#43680

Merged
ti-mo merged 4 commits intomainfrom
pr/vk/bpf/nodeport/cfg
Feb 5, 2026
Merged

bpf, nodeport: source port ranges converted to runtime config#43680
ti-mo merged 4 commits intomainfrom
pr/vk/bpf/nodeport/cfg

Conversation

@viktor-kurchenko
Copy link
Copy Markdown
Contributor

This commit moves NodePort and NodePort NAT port ranges into the node configuration, so BPF programs consume CONFIG(nodeport_port_*) values rather than fixed macros.
The Go datapath now populates these fields from the LB config when KPR or BPF masquerade is enabled, and the old headerfile defines in the Linux config writer are dropped.

Updates included:

  • BPF datapath and NAT logic switched to CONFIG(nodeport_port_min/max/min_nat/max_nat), with defaults and overrides in bpf/include/bpf/config/node.h.
  • Tests adjusted to use config-driven ranges (including deterministic overrides) and refreshed wildcard lookup helpers.
  • NodePortMaxNAT constant moved to pkg/datapath/config, and NAT stats import updated accordingly.

Related: #38370

@viktor-kurchenko viktor-kurchenko added area/loader Impacts the loading of BPF programs into the kernel. area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/misc This PR makes changes that have no direct user impact. labels Jan 11, 2026
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko viktor-kurchenko added the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jan 12, 2026
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko viktor-kurchenko marked this pull request as ready for review January 12, 2026 10:49
@viktor-kurchenko viktor-kurchenko requested review from a team as code owners January 12, 2026 10:49
@ti-mo ti-mo added this to the clang-free milestone Jan 12, 2026
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@aanm aanm removed the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jan 14, 2026
@rgo3
Copy link
Copy Markdown
Contributor

rgo3 commented Jan 16, 2026

Given Timo is already reviewing this, I'm taking myself of the reviewers list.

@rgo3 rgo3 removed their request for review January 16, 2026 13:30
Copy link
Copy Markdown
Contributor

@jrife jrife left a comment

Choose a reason for hiding this comment

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

LGTM for datapath. Let's just figure out the answer to how to reuse the same default port values across test files.

@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko viktor-kurchenko force-pushed the pr/vk/bpf/nodeport/cfg branch 2 times, most recently from 4067771 to 9e0588c Compare January 25, 2026 12:49
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko viktor-kurchenko force-pushed the pr/vk/bpf/nodeport/cfg branch 2 times, most recently from 665f6f1 to 1a7d57a Compare February 4, 2026 09:34
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

This commit moves NodePort and NodePort NAT port ranges into the node
configuration, so BPF programs consume CONFIG(nodeport_port_*) values
rather than fixed macros.
The Go datapath now populates these fields from the LB config when KPR
or BPF masquerade is enabled, and the old headerfile defines in the
Linux config writer are dropped.

Updates included:

- BPF datapath and NAT logic switched to
  CONFIG(nodeport_port_min/max/min_nat/max_nat), with defaults and
  overrides in bpf/include/bpf/config/node.h.
- Tests adjusted to use config-driven ranges (including deterministic
  overrides) and refreshed wildcard lookup helpers.
- NodePortMaxNAT constant moved to pkg/datapath/config, and NAT stats
  import updated accordingly.

Signed-off-by: viktor-kurchenko <viktor.kurchenko@isovalent.com>
This change removes hardcoded NodePort port default assignments from
bpf/include/bpf/config/node.h and moves test-only defaults into a shared
helper used by BPF tests.
The Go datapath node config now initializes port range fields to zero,
letting runtime config supply values.

Updates included:

- New bpf/tests/test_helpers.h with ASSIGN_NODEPORT_DEFAULTS() to set
  NodePort/NAT port ranges for deterministic source port selection.
- BPF tests now include test_helpers.h and call the helper instead of
  relying on node.h defaults or per-test overrides.

Signed-off-by: viktor-kurchenko <viktor.kurchenko@isovalent.com>
It removes the guard that only populated node.NodeportPortMin/Max and
the NAT NodePort range when kube-proxy replacement or BPF masquerade was
enabled.
Now those fields are always set from lnc.LBConfig, ensuring
consistent initialization regardless of KPR or masquerade settings.

Signed-off-by: viktor-kurchenko <viktor.kurchenko@isovalent.com>
The commit replaces nodeport_port_min_nat/max_nat config fields with BPF
macros and updates all NAT target uses in BPF programs/tests to use
NODEPORT_PORT_*_NAT macros.
Test defaults simplified.

Signed-off-by: viktor-kurchenko <viktor.kurchenko@isovalent.com>
@viktor-kurchenko
Copy link
Copy Markdown
Contributor Author

/test

Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks!

@ti-mo ti-mo enabled auto-merge February 4, 2026 16:50
Copy link
Copy Markdown
Member

@ysksuzuki ysksuzuki left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 5, 2026
@ti-mo ti-mo added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit 1200b35 Feb 5, 2026
467 of 470 checks passed
@ti-mo ti-mo deleted the pr/vk/bpf/nodeport/cfg branch February 5, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. area/loader Impacts the loading of BPF programs into the kernel. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants