bpf: Introduce wildcard service entries to drop traffic towards unknown protocol/port combinations#40684
Merged
borkmann merged 8 commits intocilium:mainfrom Aug 27, 2025
Merged
Conversation
bd5a7e7 to
f5a6f60
Compare
joamaki
requested changes
Jul 29, 2025
fb75646 to
adf633a
Compare
joamaki
reviewed
Jul 30, 2025
adf633a to
c391c35
Compare
joamaki
reviewed
Jul 31, 2025
8b5e388 to
f408d79
Compare
dylandreimerink
requested changes
Aug 1, 2025
Member
dylandreimerink
left a comment
There was a problem hiding this comment.
This looks great overall. One point of feedback though.
f408d79 to
6b2266c
Compare
Member
Author
|
/ci-e2e-upgrade |
Member
Author
|
/ci-ginkgo |
…ice(). Previously, if the lookup of a service derived from ingress 5-tuple results in no match, we undertake an additional lookup with IPPROTO_ANY. This was necessary to maintain backwards compatibility with earlier versions of Cilium that did not support protocol differentiation when programming the data path. Cilium 1.18 introduced logic to migrate IPPROTO_ANY service/backend BPF map entries to an appropriate protocol automatically, such that the additional lookups are no longer required. Appropriate tests updated to include explicit lookups for IPPROTO_TCP, IPPROTO_UDP, and mismatched protocol checks. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
This change modifies the behaviour of lbXX_lookup_service() such that if an external service lookup does not find an entry, we undertake an additional lookup with DPort=0 and Protocol=0. This will facilitate a wildcard lookup that, when programmed with a suitable wildcard entry by the control plane, will trigger the data path to drop unmatched ingress traffic. This change modifies the semantics of said routines such that they no longer propagate changes to the key protocol field, unless a wildcard service entry was found in the external scope, and returned. In this case, the dport and protocol field will be zero. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com> Signed-off-by: Mikael Knutsson <mikael.knutsson@gmail.com>
…paths. Previously, lbX_lookup_service() would zeroise the key protocol field, such that callers would need to reinstate the key protocol field if their logic re-used the key. Following the previous commit, the lbX_lookup_service() routines will now only zeroise the key protocol (and dport) fields if an external wild-card entry is returned. Thus, the restoration of key values can be removed. This commit also removes lbX_key_set_protocol() helpers as they became broadly unnecessary. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
This set of tests verifies that if we receive a packet towards a VIP on either an unknown destination port, or unknown protocol, the data plane will correctly drop if a wildcard entry is present in the service map. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
This change extends the nodePortAddrKey structure to include the L4 Protocol number of an address, such that addresses with differing addresses will be better distributed in the nodePortAddrByPort map. This required the introduction of a helper routine to translate the L4Addr protocol field into the real IANA number. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Introduce logic in bpf_reconciler to map frontend service entries to wildcard service entries, and program them in the data path, for LoadBalancer and ClusterIP frontends of external scope. This will ensure the data path drops traffic towards unknown destination ports and/or protocols. Wildcard state is tracked as a map (indexed by IP Address) that contains a slice of Frontend ServiceIDs. The first entry that requires a wildcard will trigger programming of the data path entry. The last entry that depends on a wildcard entry to be removed will trigger removal of the wildcard entry. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com> Signed-off-by: Mikael Knutsson <mikael.knutsson@gmail.com>
Update the unit tests for loadbalancer and ciliumenvoyconfig to include wildcard entries. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
Remove lb_v4_add_mixed_proto_service_with_flags() as it no longer makes sense. Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
fe966e5 to
abf0fec
Compare
Member
Author
|
/test |
Member
Author
|
ci-ginkgo failures is likely a flake - happens across different tests on main, eg: |
12 tasks
Closed
3 tasks
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.
PR to resolve a forwarding bug in data path.
This work is derived from work undertaken by Mikael Knutsson mikael.knutsson@gmail.com so has been credited in the relevant commit logs.
Summary of issue
Given a configured LoadBalancer or Cluster IP on a specific L4 destination port and protocol, ingress traffic towards the IP on an alternate destination port or protocol will not match eBPF service map lookup, so traffic be punted back to the network. Where the upstream network re-delivers the traffic back to Cilium, a packet loop is formed.
Summary of Changes
Release Notes: