Skip to content

Helper function bpf_set_retval

v5.18

Definition

Copyright (c) 2015 The Libbpf Authors. All rights reserved.

Set the BPF program's return value that will be returned to the upper layers.

This helper is currently supported by cgroup programs and only by the hooks where BPF program's return value is returned to the userspace via errno.

Note that there is the following corner case where the program exports an error via bpf_set_retval but signals success via 'return 1':

    bpf_set_retval(-EPERM); return 1;

In this case, the BPF program's return value will use helper's -EPERM. This still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case.

Returns

0 on success, or a negative error in case of failure.

static int (* const bpf_set_retval)(int retval) = (void *) 187;

Usage

Docs could be improved

This part of the docs is incomplete, contributions are very welcome

Program types

This helper call can be used in the following program types:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome