Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf: improve handling for short packets #25159

Merged
merged 3 commits into from
May 12, 2023

Conversation

julianwiedmann
Copy link
Member

@julianwiedmann julianwiedmann commented Apr 27, 2023

Align the different packet paths in how they handle traffic where the IP header is not in the skb's linear data.

Avoid dropping short packets (that don't have their L3 header in linear data) in the to-netdev and from-host paths.

@julianwiedmann julianwiedmann added kind/bug This is a bug in the Cilium logic. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Apr 27, 2023
@julianwiedmann julianwiedmann requested a review from a team as a code owner April 27, 2023 09:00
@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Apr 27, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.13.3 Apr 27, 2023
@julianwiedmann julianwiedmann added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Apr 27, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 27, 2023
@julianwiedmann
Copy link
Member Author

julianwiedmann commented Apr 27, 2023

/test

Job 'Cilium-PR-K8s-1.26-kernel-net-next' hit: #24697 (89.50% similarity)

@julianwiedmann
Copy link
Member Author

As mlh noted, net-next flaked in the HostFW tests.

@julianwiedmann
Copy link
Member Author

julianwiedmann commented Apr 28, 2023

/test-1.26-net-next

Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed:

Click to show.

Test Name

K8sDatapathServicesTest Checks N/S loadbalancing with L7 policy Tests NodePort with L7 Policy from outside

Failure Output

FAIL: Can not connect to service "http://[fd04::12]:30496" from outside cluster (1/10)

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.26-kernel-net-next/1990/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.26-kernel-net-next so I can create one.

Then please upload the Jenkins artifacts to that issue.

Copy link
Contributor

@ldelossa ldelossa left a comment

Choose a reason for hiding this comment

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

Changes look good, commit structure is maybe a bit weird? Seems like large portions of your second commit could be discarded/squashed.

bpf/bpf_host.c Outdated
@@ -828,7 +821,16 @@ do_netdev(struct __ctx_buff *ctx, __u16 proto, const bool from_host)
#endif
#ifdef ENABLE_IPV4
case bpf_htons(ETH_P_IP):
identity = resolve_srcid_ipv4(ctx, identity, &ipcache_srcid,
/* This is the first time revalidate_data() is going to be called in
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you potentially drop this chunk all together? Looks like you nullify it in the next commit anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean like shuffling the second and third patch around? Yeah let's try 🤔.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, looks like you add this chunk, but then delete it in the third commit anyway.

Anyway, its a nit, is just to make the history a bit cleaner.

af_packet can craft packets without linear data. So make sure that we pull
the IPv4 header, as resolve_srcid_ipv4() won't do it for us (we call it
with from_host = true). Also update the comment to match current behaviour.

This aligns the IPv4 path with handle_to_netdev_ipv6().

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Don't trust that host traffic arrives with the IP header in the skb's
linear space. So have resolve_srcid_ipv*() always pull the necessary data,
without differentiating between from-netdev and from-host traffic.

This means that for to-netdev traffic we now have two places that can
handle the traffic. This is just temporary, and will go away with the next
patch.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
resolve_srcid_ipv*() is meant to return an __u32, that represents the
srcid. But it currently also validates the IP header, and returns
DROP_INVALID from that. We use this value without further checks.

Fix things up by performing the IP header validation & error handling
outside the helper.

Note that the to-netdev path already contains a revalidate_data_pull()
call, so it's safe to lose this additional one inside resolve_srcid_ipv*().

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann
Copy link
Member Author

/test

@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 May 12, 2023
@julianwiedmann julianwiedmann merged commit e1f24b6 into cilium:main May 12, 2023
58 checks passed
@julianwiedmann julianwiedmann deleted the 1.14-bpf-resolve_srcid branch May 12, 2023 11:17
@gentoo-root gentoo-root mentioned this pull request May 12, 2023
3 tasks
@julianwiedmann julianwiedmann added the backport/author The backport will be carried out by the author of the PR. label May 16, 2023
@jibi jibi mentioned this pull request May 17, 2023
7 tasks
@thorn3r thorn3r added this to Needs backport from main in 1.13.4 May 17, 2023
@thorn3r thorn3r removed this from Needs backport from main in 1.13.3 May 17, 2023
@julianwiedmann julianwiedmann added the backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. label May 29, 2023
@qmonnet qmonnet added this to Backport pending to v1.13 in 1.13.5 Jun 9, 2023
@qmonnet qmonnet removed this from Needs backport from main in 1.13.4 Jun 9, 2023
@julianwiedmann julianwiedmann added backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. and removed backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Jun 17, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Backport done to v1.13 in 1.13.3 Jun 17, 2023
@gentoo-root gentoo-root moved this from Backport pending to v1.13 to Backport done to v1.13 in 1.13.5 Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/author The backport will be carried out by the author of the PR. backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
No open projects
1.13.3
Backport done to v1.13
1.13.5
Backport done to v1.13
Development

Successfully merging this pull request may close these issues.

None yet

2 participants