diff options
author | Roy, UjjaL <royujjal@gmail.com> | 2021-07-16 22:04:41 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-07-16 22:08:17 +0200 |
commit | 8886534747c2e56d9d3b978c99e92dc479cd9426 (patch) | |
tree | 1468de456a9d96735b4a5a2b26cb6c8f9075e53b /Documentation/networking | |
parent | c7603cfa04e7c3a435b31d065f7cbdc829428f6e (diff) | |
download | linux-8886534747c2e56d9d3b978c99e92dc479cd9426.tar.gz linux-8886534747c2e56d9d3b978c99e92dc479cd9426.tar.bz2 linux-8886534747c2e56d9d3b978c99e92dc479cd9426.zip |
bpf, doc: Add heading and example for extensions in cbpf
Add new heading for extensions to make it more readable. Also, add one
more example of filtering interface index for better understanding.
Signed-off-by: Roy, UjjaL <royujjal@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/CAADnVQJ=DoRDcVkaXmY3EmNdLoO7gq1mkJOn5G=00wKH8qUtZQ@mail.gmail.com
Diffstat (limited to 'Documentation/networking')
-rw-r--r-- | Documentation/networking/filter.rst | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst index 3e2221f4abe4..5f13905b12e0 100644 --- a/Documentation/networking/filter.rst +++ b/Documentation/networking/filter.rst @@ -320,13 +320,6 @@ Examples for low-level BPF: ret #-1 drop: ret #0 -**(Accelerated) VLAN w/ id 10**:: - - ld vlan_tci - jneq #10, drop - ret #-1 - drop: ret #0 - **icmp random packet sampling, 1 in 4**:: ldh [12] @@ -358,6 +351,22 @@ Examples for low-level BPF: bad: ret #0 /* SECCOMP_RET_KILL_THREAD */ good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */ +Examples for low-level BPF extension: + +**Packet for interface index 13**:: + + ld ifidx + jneq #13, drop + ret #-1 + drop: ret #0 + +**(Accelerated) VLAN w/ id 10**:: + + ld vlan_tci + jneq #10, drop + ret #-1 + drop: ret #0 + The above example code can be placed into a file (here called "foo"), and then be passed to the bpf_asm tool for generating opcodes, output that xt_bpf and cls_bpf understands and can directly be loaded with. Example with above |