]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: add skb_load_bytes_relative helper
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 3 May 2018 23:08:15 +0000 (01:08 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 May 2018 23:49:19 +0000 (16:49 -0700)
commit235c75c54bfef6a39d52625af665ef747d3c1efb
treec7bc363b064ec1d5a3917de49d90696c8794e361
parent84d9b76c63c2358c6b711658445afbfcda49f951
bpf: add skb_load_bytes_relative helper

This adds a small BPF helper similar to bpf_skb_load_bytes() that
is able to load relative to mac/net header offset from the skb's
linear data. Compared to bpf_skb_load_bytes(), it takes a fifth
argument namely start_header, which is either BPF_HDR_START_MAC
or BPF_HDR_START_NET. This allows for a more flexible alternative
compared to LD_ABS/LD_IND with negative offset. It's enabled for
tc BPF programs as well as sock filter program types where it's
mainly useful in reuseport programs to ease access to lower header
data.

Reference: https://lists.iovisor.org/pipermail/iovisor-dev/2017-March/000698.html
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
net/core/filter.c