Skip to content

fix: use iifname for input interface name matches#134024

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
jack4it:jack4it/iifname
Sep 16, 2025
Merged

fix: use iifname for input interface name matches#134024
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
jack4it:jack4it/iifname

Conversation

@jack4it
Copy link
Copy Markdown
Contributor

@jack4it jack4it commented Sep 11, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes a bug in the nftables support of kube-proxy. An example error without this fix. Notice that iif was mistakenly used instead of iifname in that.

I0911 16:35:49.542259       1 proxier.go:1840] "Reloading service nftables data" ipFamily="IPv4" numServices=5 numEndpoints=8
E0911 16:35:49.547707       1 proxier.go:1851] "nftables sync failed" err=<
	/dev/stdin:72:109-112: Error: Interface does not exist
	add rule ip kube-proxy service-2QRHZV4L-default/kubernetes/tcp/https ip daddr 10.0.0.1 tcp dport 443 iif != azv* jump mark-for-masquerade
	                                                                                                            ^^^^
	/dev/stdin:84:109-112: Error: Interface does not exist
	add rule ip kube-proxy service-FY5PMXPG-kube-system/kube-dns/udp/dns ip daddr 10.0.0.10 udp dport 53 iif != azv* jump mark-for-masquerade
	                                                                                                            ^^^^
	/dev/stdin:97:113-116: Error: Interface does not exist
	add rule ip kube-proxy service-NWBZK7IH-kube-system/kube-dns/tcp/dns-tcp ip daddr 10.0.0.10 tcp dport 53 iif != azv* jump mark-for-masquerade
	                                                                                                                ^^^^
	/dev/stdin:111:129-132: Error: Interface does not exist
	add rule ip kube-proxy service-EZ4UY2LR-calico-system/calico-typha/tcp/calico-typha ip daddr 10.0.172.152 tcp dport 5473 iif != azv* jump mark-for-masquerade
	                                                                                                                                ^^^^
 > ipFamily="IPv4"
I0911 16:35:49.547728       1 proxier.go:1204] "Sync failed" ipFamily="IPv4" retryingTime="30s"

Which issue(s) this PR is related to:

KEP: https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/3866-nftables-proxy/README.md

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixed a bug in kube-proxy nftables mode (GA as of 1.33) that fails to determine if traffic originates from a local source on the node. The issue was caused by using the wrong meta `iif` instead of `iifname` for name based matches.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 11, 2025
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Sep 11, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jack4it / name: Jack Ma (b81e87c)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 11, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @jack4it!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 11, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @jack4it. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added area/kube-proxy sig/network Categorizes an issue or PR as relevant to SIG Network. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 11, 2025
@jack4it jack4it marked this pull request as ready for review September 11, 2025 20:44
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 11, 2025
@aojea
Copy link
Copy Markdown
Member

aojea commented Sep 11, 2025

/assign @danwinship @aroradaman

based on https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_metainformation it looks correct, iif is the index and iifname is the name

/ok-to-test
/lgtm
/kind bug

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 11, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 11, 2025
@jack4it
Copy link
Copy Markdown
Contributor Author

jack4it commented Sep 12, 2025

/retest-required

@adrianmoisey
Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 12, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 84ba230a77262661c9c66504219dad03c576b6d2

@aojea
Copy link
Copy Markdown
Member

aojea commented Sep 12, 2025

@jack4it one final request sorry, do you mind to squash the commits? so we backport the fix and the unit test altogether in one commit

add tests to cover nftables; also fix NewDetectLocalByBridgeInterface
@jack4it
Copy link
Copy Markdown
Contributor Author

jack4it commented Sep 12, 2025

@jack4it one final request sorry, do you mind to squash the commits? so we backport the fix and the unit test altogether in one commit

absolutely, squashed. thx @aojea for the review

@aojea
Copy link
Copy Markdown
Member

aojea commented Sep 12, 2025

/lgtm
/approve

Thanks, @jack4it since we do not seem to have CI on this mode and you find it, I assume you already validated this works fine, right?

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2025
@jack4it
Copy link
Copy Markdown
Contributor Author

jack4it commented Sep 12, 2025

/lgtm /approve

Thanks, @jack4it since we do not seem to have CI on this mode and you find it, I assume you already validated this works fine, right?

before i merge, i'll make sure it's verified in my setup. thx @aojea. will circle back

@aojea
Copy link
Copy Markdown
Member

aojea commented Sep 12, 2025

before i merge, i'll make sure it's verified in my setup. thx @aojea. will circle back

ok, then I put it on hold and you just do /hold cancel once you validated it

/hold

the PR is already approved and it will marge if no changes are done

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 12, 2025
Copy link
Copy Markdown
Member

@aroradaman aroradaman left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, aroradaman, jack4it

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@aroradaman
Copy link
Copy Markdown
Member

Once verified we should back port this to v1.33 as well.

@aojea
Copy link
Copy Markdown
Member

aojea commented Sep 16, 2025

kindly ping @jack4it 😄

@jack4it
Copy link
Copy Markdown
Contributor Author

jack4it commented Sep 16, 2025

circling back. had a successful integration test

│     Command:                                                                                                                                                                                                                                 │
│       kube-proxy                                                                                                                                                                                                                             │
│       --conntrack-max-per-core=0                                                                                                                                                                                                             │
│       --metrics-bind-address=0.0.0.0:10249                                                                                                                                                                                                   │
│       --cluster-cidr=10.244.0.0/16                                                                                                                                                                                                           │
│       --detect-local-mode=InterfaceNamePrefix                                                                                                                                                                                                │
│       --pod-interface-name-prefix=azv                                                                                                                                                                                                        │
│       --v=3                                                                                                                                                                                                                                  │
│       --proxy-mode=nftables                                                                                                                                                                                                                  │
│     State:          Running                                                                                                                                                                                                                  │
│       Started:      Tue, 16 Sep 2025 13:39:12 -0700                                                                                                                                                                                          │
│     Ready:          True                                                                                                                                                                                                                     │
│ I0916 20:41:08.768503       1 proxier.go:1199] "Syncing nftables rules" ipFamily="IPv4" fullSync=false                                                                                                                                       │
│ I0916 20:41:08.780704       1 proxier.go:1840] "Reloading service nftables data" ipFamily="IPv4" numServices=5 numEndpoints=9                                                                                                                │
│ I0916 20:41:08.808435       1 proxier.go:1193] "SyncProxyRules complete" ipFamily="IPv4" elapsed="40.038299ms"                                                                                                                               │
│ I0916 20:41:08.808464       1 bounded_frequency_runner.go:296] sync-runner: ran, next possible in 1s, periodic in 1h0m0s                                                                                                                     │

@aojea

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 16, 2025
@k8s-ci-robot k8s-ci-robot merged commit 053267a into kubernetes:master Sep 16, 2025
13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.35 milestone Sep 16, 2025
k8s-ci-robot added a commit that referenced this pull request Sep 19, 2025
…024-upstream-release-1.33

Automated cherry pick of #134024: fix: use iifname for input interface name matches
k8s-ci-robot added a commit that referenced this pull request Sep 19, 2025
…024-upstream-release-1.34

Automated cherry pick of #134024: fix: use iifname for input interface name matches
k8s-ci-robot added a commit that referenced this pull request Sep 26, 2025
…134024-upstream-release-1.33

Automated cherry pick of #134024: fix: use iifname for input interface name matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kube-proxy cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants