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

Various improvements #28

Merged
merged 6 commits into from
Nov 14, 2023
Merged

Conversation

qdeslandes
Copy link
Contributor

Multiple improvements to the codebase derived from nftables support:

  • Add bf_dump_hex() to perform hexdump of a buffer.
  • Refactor bf_list_empty().
  • Add bf_response_new_raw().
  • Add XDP support.
  • Add option to disable iptables front.

bf_dump_hex() will read the content of a raw data buffer and print it as
hexadecimal values, 8 values in a row.

Signed-off-by: Quentin Deslandes <[email protected]>
@qdeslandes qdeslandes marked this pull request as ready for review November 14, 2023 20:53
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Attention: 96 lines in your changes are missing coverage. Please review.

Comparison is base (7c88a61) 13.49% compared to head (ba82129) 13.02%.

Files Patch % Lines
src/generator/xdp.c 0.00% 40 Missing ⚠️
src/core/bpf.c 0.00% 11 Missing ⚠️
src/generator/stub.c 0.00% 11 Missing ⚠️
src/xlate/ipt/ipt.c 0.00% 11 Missing ⚠️
src/core/dump.c 0.00% 10 Missing ⚠️
shared/src/response.c 0.00% 7 Missing ⚠️
src/opts.c 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
- Coverage   13.49%   13.02%   -0.47%     
==========================================
  Files          33       34       +1     
  Lines        2283     2364      +81     
==========================================
  Hits          308      308              
- Misses       1975     2056      +81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Rename bf_list_empty() to bf_list_is_empty() and make the parameter
const.

Signed-off-by: Quentin Deslandes <[email protected]>
bf_response_new_raw() allocates a new response with reserved space for
payload, but doesn't copy anything into the data field. The response
type is set to BF_RES_SUCCESS.

Signed-off-by: Quentin Deslandes <[email protected]>
Add support for XDP programs generation.

Packet data is manipulated in the BPF program through a dynamic pointer,
and programs are attached to the kernel using a BPF link.

This commit is the first step towards full support of XDP BPF programs,
with the following limitations:
- Only IPv4 packets are processed. Non-IPv4 packets are passed-through
  to the network stack.
- Only XDP_PASS and XDP_DROP actions are supported.
- Program replacement is not atomic: the previous program is dettached
  before the new one is attached.

Add a new function to ease dynamic pointer creation for XDP and
SKB-based programs: bf_stub_make_ctx_xdp_dynptr() and
bf_stub_make_ctx_skb_dynptr().

Introduce bf_bpf_xdp_link_create() to attach XDP programs.

Signed-off-by: Quentin Deslandes <[email protected]>
Add --no-iptables command line options to prevent iptables front from
running: ipt requests will be returned an error, and no cache will be
restored.

This change involved refactoring how fronts are serialised: every front
(even the ones disabled) have they marsh function called with an
allocated bf_marsh child. Disabled fronts won't have anything to add to
the marsh and will just return. This simplify serialised front
management as every front will be represented by a marsh object, so they
can be restored sequentially.

Signed-off-by: Quentin Deslandes <[email protected]>
@qdeslandes qdeslandes merged commit f48643b into facebook:main Nov 14, 2023
5 of 7 checks passed
@qdeslandes qdeslandes deleted the various_improvements branch November 14, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants