Skip to content

Commit

Permalink
linux/helper-function: Update helper function signatures
Browse files Browse the repository at this point in the history
A few helper functions have been updated with a new `__bpf_fastcall`
attribute. This commit updates the helper function signatures to reflect
this change in the libbpf headers.

Signed-off-by: Dylan Reimerink <[email protected]>
  • Loading branch information
dylandreimerink committed Oct 15, 2024
1 parent 86291c3 commit bc0bc07
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/linux/helper-function/bpf_get_smp_processor_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Get the SMP (symmetric multiprocessing) processor id. Note that all programs run

The SMP id of the processor running the program.

`#!c static __u32 (* const bpf_get_smp_processor_id)(void) = (void *) 8;`
`#!c static __bpf_fastcall __u32 (* const bpf_get_smp_processor_id)(void) = (void *) 8;`
<!-- [/HELPER_FUNC_DEF] -->

## Usage
Expand Down
4 changes: 2 additions & 2 deletions docs/linux/helper-function/bpf_kptr_xchg.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ description: "This page documents the 'bpf_kptr_xchg' eBPF helper function, incl

<!-- [HELPER_FUNC_DEF] -->
Exchange kptr at pointer _map_value_ with _ptr_, and return the old value. _ptr_ can be NULL, otherwise it must be a referenced pointer which will be released when this helper is called.
Exchange kptr at pointer _dst_ with _ptr_, and return the old value. _dst_ can be map value or local kptr. _ptr_ can be NULL, otherwise it must be a referenced pointer which will be released when this helper is called.

### Returns

The old value of kptr (which can be NULL). The returned pointer if not NULL, is a reference which must be released using its corresponding release function, or moved into a BPF map before program exit.

`#!c static void *(* const bpf_kptr_xchg)(void *map_value, void *ptr) = (void *) 194;`
`#!c static void *(* const bpf_kptr_xchg)(void *dst, void *ptr) = (void *) 194;`
<!-- [/HELPER_FUNC_DEF] -->

## Usage
Expand Down
2 changes: 1 addition & 1 deletion docs/linux/helper-function/bpf_loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description: "This page documents the 'bpf_loop' eBPF helper function, including
<!-- [HELPER_FUNC_DEF] -->
For **nr_loops**, call **callback_fn** function with **callback_ctx** as the context parameter. The **callback_fn** should be a static function and the **callback_ctx** should be a pointer to the stack. The **flags** is used to control certain aspects of the helper. Currently, the **flags** must be 0. Currently, nr_loops is limited to 1 << 23 (~8 million) loops.

long (\_callback_fn)(u32 index, void \_ctx);
long (\_callback_fn)(u64 index, void \_ctx);

where **index** is the current index in the loop. The index is zero-indexed.

Expand Down
2 changes: 0 additions & 2 deletions docs/linux/helper-function/bpf_override_return.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ This helper works by setting the PC (program counter) to an override function wh

This helper has security implications, and thus is subject to restrictions. It is only available if the kernel was compiled with the **CONFIG_BPF_KPROBE_OVERRIDE** configuration option, and in this case it only works on functions tagged with **ALLOW_ERROR_INJECTION** in the kernel code.

Also, the helper is only available for the architectures having the CONFIG_FUNCTION_ERROR_INJECTION option. As of this writing, x86 architecture is the only one to support this feature.

### Returns

0
Expand Down
2 changes: 1 addition & 1 deletion docs/linux/helper-function/bpf_setsockopt.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This helper actually implements a subset of **setsockopt()**. It supports the fo

* **SOL_SOCKET**, which supports the following _optname_s:
**SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**, **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**, **SO_BINDTODEVICE**, **SO_KEEPALIVE**, **SO_REUSEADDR**, **SO_REUSEPORT**, **SO_BINDTOIFINDEX**, **SO_TXREHASH**. * **IPPROTO_TCP**, which supports the following _optname_s:
**TCP_CONGESTION**, **TCP_BPF_IW**, **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**, **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**, **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**, **TCP_BPF_RTO_MIN**. * **IPPROTO_IP**, which supports _optname_ **IP_TOS**.
**TCP_CONGESTION**, **TCP_BPF_IW**, **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**, **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**, **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**, **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**, **TCP_BPF_RTO_MIN**, **TCP_BPF_SOCK_OPS_CB_FLAGS**. * **IPPROTO_IP**, which supports _optname_ **IP_TOS**.
* **IPPROTO_IPV6**, which supports the following _optname_s:
**IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**.

Expand Down

0 comments on commit bc0bc07

Please sign in to comment.