Skip to content

Helper function bpf_redirect_map

v4.14

Definition

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

Redirect the packet to the endpoint referenced by map at index key. Depending on its type, this map can contain references to net devices (for forwarding packets through other ports), or to CPUs (for redirecting XDP frames to another CPU; but this is only implemented for native XDP (with driver support) as of this writing).

The lower two bits of flags are used as the return code if the map lookup fails. This is so that the return value can be one of the XDP program return codes up to XDP_TX, as chosen by the caller. The higher bits of flags can be set to BPF_F_BROADCAST or BPF_F_EXCLUDE_INGRESS as defined below.

With BPF_F_BROADCAST the packet will be broadcasted to all the interfaces in the map, with BPF_F_EXCLUDE_INGRESS the ingress interface will be excluded when do broadcasting.

See also bpf_redirect(), which only supports redirecting to an ifindex, but doesn't require a map to do so.

Returns

XDP_REDIRECT on success, or the value of the two lower bits of the flags argument on error.

static long (* const bpf_redirect_map)(void *map, __u64 key, __u64 flags) = (void *) 51;

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