Helper function bpf_skb_load_bytes_relative
Definition
Copyright (c) 2015 The Libbpf Authors. All rights reserved.
This helper is similar to bpf_skb_load_bytes() in that it provides an easy way to load len bytes from offset from the packet associated to skb, into the buffer pointed by to. The difference to bpf_skb_load_bytes() is that a fifth argument start_header exists in order to select a base offset to start from. start_header can be one of:
BPF_HDR_START_MAC
Base offset to load data from is skb's mac header.
BPF_HDR_START_NET
Base offset to load data from is skb's network header.
In general, "direct packet access" is the preferred method to access packet data, however, this helper is in particular useful in socket filters where skb->data does not always point to the start of the mac header and where "direct packet access" is not available.
Returns
0 on success, or a negative error in case of failure.
static long (* const bpf_skb_load_bytes_relative)(const void *skb, __u32 offset, void *to, __u32 len, __u32 start_header) = (void *) 68;
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:
BPF_PROG_TYPE_CGROUP_SKB
BPF_PROG_TYPE_SCHED_ACT
BPF_PROG_TYPE_SCHED_CLS
BPF_PROG_TYPE_SK_REUSEPORT
BPF_PROG_TYPE_SOCKET_FILTER
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome