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

Add BPF test facility to test skb->cb #24181

Merged

Conversation

YutaroHayakawa
Copy link
Member

@YutaroHayakawa YutaroHayakawa commented Mar 6, 2023

Please see commit message for more details. I piggybacked one small bug fix (node_config.h include guard).

Add BPF test facility to test skb->cb

When we write BPF unit test, sometimes we want to overwrite the macro
value in node_config.h by undef it and define it again. A typical code
for that looks like below.

```
 /* Include node_config.h before including bpf_overlay.h */
 #include "node_config.h"

 /* Overwrite some config */
 #undef NODEPORT_PORT_MIN
 #define NODEPORT_PORT_MIN 65000

 /* Include bpf_overlay.h (includes node_config.h internally)
  * and use above overwritten value.
  */
 #include "bpf_overlay.h"
```

However, currently node_config.h misses the include guard. Because of
that, when we include bpf_overlay.h, we redefine the same macro again.

Introduce a proper include guard to node_config.h to prevent that.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Mar 6, 2023
@YutaroHayakawa YutaroHayakawa added the release-note/misc This PR makes changes that have no direct user impact. label Mar 6, 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 Mar 6, 2023
@YutaroHayakawa YutaroHayakawa added dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Mar 6, 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 Mar 6, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.13.1 Mar 6, 2023
@YutaroHayakawa YutaroHayakawa force-pushed the yutaro/oss/bpf-test-metadata branch 5 times, most recently from 94c95dc to 182aeb8 Compare March 6, 2023 11:16
Add common facility to mock out skb metadata. Users can include
mock_skb_metadata.h then it automatically changes ctx_store_meta and
ctx_load_meta call to mock functions that read/write data to map. The
userspace program is aware of the map and clears the value after each
test. So that the value won't be leaked among tests. This commit also
adds a new test case to test above behavior.

I considered writing this feature using ctx_in attribute of the
BPF_PROG_TEST_RUN, but I didn't do that since it only works after 5.2
and currently, Cilium supports 4.19 or later.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
@YutaroHayakawa YutaroHayakawa added the sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. label Mar 6, 2023
@YutaroHayakawa YutaroHayakawa marked this pull request as ready for review March 6, 2023 11:56
@YutaroHayakawa YutaroHayakawa requested a review from a team as a code owner March 6, 2023 11:56
Copy link
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

Seem like a nice addition

@YutaroHayakawa
Copy link
Member Author

/test

@YutaroHayakawa
Copy link
Member Author

ConformanceIngress shouldn't be related to this change. Let me make this ready-to-merge.

@YutaroHayakawa YutaroHayakawa added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 7, 2023
@YutaroHayakawa YutaroHayakawa merged commit 10b7059 into cilium:master Mar 7, 2023
@nebril nebril added this to Needs backport from master in 1.13.2 Mar 15, 2023
@nebril nebril removed this from Needs backport from master in 1.13.1 Mar 15, 2023
@YutaroHayakawa YutaroHayakawa removed the needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch label Mar 18, 2023
@gentoo-root gentoo-root added this to Needs backport from master in 1.13.3 Apr 14, 2023
@gentoo-root gentoo-root removed this from Needs backport from master in 1.13.2 Apr 14, 2023
@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
@thorn3r thorn3r removed this from Needs backport from main in 1.13.4 May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants