]> asedeno.scripts.mit.edu Git - linux.git/commit
bpf: add helper for getting xfrm states
authorEyal Birger <eyal.birger@gmail.com>
Tue, 24 Apr 2018 14:50:29 +0000 (17:50 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 24 Apr 2018 20:26:58 +0000 (22:26 +0200)
commit12bed760a78da6e12ac8252fec64d019a9eac523
tree8cc73ba606e4af8871318a5c1e0ff64cffcd43b3
parentfbcf93ebcaef7d09881ee308b52cd84f5e43c622
bpf: add helper for getting xfrm states

This commit introduces a helper which allows fetching xfrm state
parameters by eBPF programs attached to TC.

Prototype:
bpf_skb_get_xfrm_state(skb, index, xfrm_state, size, flags)

skb: pointer to skb
index: the index in the skb xfrm_state secpath array
xfrm_state: pointer to 'struct bpf_xfrm_state'
size: size of 'struct bpf_xfrm_state'
flags: reserved for future extensions

The helper returns 0 on success. Non zero if no xfrm state at the index
is found - or non exists at all.

struct bpf_xfrm_state currently includes the SPI, peer IPv4/IPv6
address and the reqid; it can be further extended by adding elements to
its end - indicating the populated fields by the 'size' argument -
keeping backwards compatibility.

Typical usage:

struct bpf_xfrm_state x = {};
bpf_skb_get_xfrm_state(skb, 0, &x, sizeof(x), 0);
...

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/uapi/linux/bpf.h
net/core/filter.c