• Alexei Starovoitov's avatar
    bpf: add helpers to access tunnel metadata · d3aa45ce
    Alexei Starovoitov authored
    Introduce helpers to let eBPF programs attached to TC manipulate tunnel metadata:
    bpf_skb_[gs]et_tunnel_key(skb, key, size, flags)
    skb: pointer to skb
    key: pointer to 'struct bpf_tunnel_key'
    size: size of 'struct bpf_tunnel_key'
    flags: room for future extensions
    
    First eBPF program that uses these helpers will allocate per_cpu
    metadata_dst structures that will be used on TX.
    On RX metadata_dst is allocated by tunnel driver.
    
    Typical usage for TX:
    struct bpf_tunnel_key tkey;
    ... populate tkey ...
    bpf_skb_set_tunnel_key(skb, &tkey, sizeof(tkey), 0);
    bpf_clone_redirect(skb, vxlan_dev_ifindex, 0);
    
    RX:
    struct bpf_tunnel_key tkey = {};
    bpf_skb_get_tunnel_key(skb, &tkey, sizeof(tkey), 0);
    ... lookup or redirect based on tkey ...
    
    'struct bpf_tunnel_key' will be extended in the future by adding
    elements to the end and the 'size' argument will indicate which fields
    are populated, thereby keeping backwards compatibility.
    The 'flags' argument may be used as well when the 'size' is not enough or
    to indicate completely different layout of bpf_tunnel_key.
    Signed-off-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
    Acked-by: default avatarThomas Graf <tgraf@suug.ch>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d3aa45ce
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt/kvm Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...
REPORTING-BUGS Loading commit data...