diff options
author | Peter Oskolkov <posk@google.com> | 2019-02-13 11:53:36 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-02-13 18:27:55 -0800 |
commit | 52f278774e796a553be0c869dcaaee6f259ca795 (patch) | |
tree | b4a404b2199dddbf9e622587dca9047b73300fcb /include/net/lwtunnel.h | |
parent | 3e0bd37ce0e4a574df6d87a901e13bcb46e10301 (diff) | |
download | linux-52f278774e796a553be0c869dcaaee6f259ca795.tar.gz linux-52f278774e796a553be0c869dcaaee6f259ca795.tar.bz2 linux-52f278774e796a553be0c869dcaaee6f259ca795.zip |
bpf: implement BPF_LWT_ENCAP_IP mode in bpf_lwt_push_encap
Implement BPF_LWT_ENCAP_IP mode in bpf_lwt_push_encap BPF helper.
It enables BPF programs (specifically, BPF_PROG_TYPE_LWT_IN and
BPF_PROG_TYPE_LWT_XMIT prog types) to add IP encapsulation headers
to packets (e.g. IP/GRE, GUE, IPIP).
This is useful when thousands of different short-lived flows should be
encapped, each with different and dynamically determined destination.
Although lwtunnels can be used in some of these scenarios, the ability
to dynamically generate encap headers adds more flexibility, e.g.
when routing depends on the state of the host (reflected in global bpf
maps).
v7 changes:
- added a call skb_clear_hash();
- removed calls to skb_set_transport_header();
- refuse to encap GSO-enabled packets.
v8 changes:
- fix build errors when LWT is not enabled.
Note: the next patch in the patchset with deal with GSO-enabled packets,
which are currently rejected at encapping attempt.
Signed-off-by: Peter Oskolkov <posk@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/net/lwtunnel.h')
-rw-r--r-- | include/net/lwtunnel.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h index 33fd9ba7e0e5..671113bcb2cc 100644 --- a/include/net/lwtunnel.h +++ b/include/net/lwtunnel.h @@ -126,6 +126,8 @@ int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b); int lwtunnel_output(struct net *net, struct sock *sk, struct sk_buff *skb); int lwtunnel_input(struct sk_buff *skb); int lwtunnel_xmit(struct sk_buff *skb); +int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, + bool ingress); static inline void lwtunnel_set_redirect(struct dst_entry *dst) { |