* [PATCH] docs: bpf: Added more extension example
@ 2021-07-07 17:40 UjjaL Roy
2021-07-07 22:22 ` Song Liu
0 siblings, 1 reply; 2+ messages in thread
From: UjjaL Roy @ 2021-07-07 17:40 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, David S . Miller, Jakub Kicinski, Jonathan Corbet,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Nathan Chancellor,
Nick Desaulniers
Cc: netdev, bpf, linux-doc, linux-kernel, linux-riscv, clang-built-linux
From: "Roy, UjjaL" <royujjal@gmail.com>
After reading this document observed that for new users it is
hard to find an example of "extension" easily.
So, added a new heading for extensions for better readability.
Now, the new readers can easily identify "extension" examples.
Also, added one more example of filtering interface index.
Signed-off-by: Roy, UjjaL <royujjal@gmail.com>
---
Documentation/networking/filter.rst | 23 ++++++++++++++++-------
1 file 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
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] docs: bpf: Added more extension example
2021-07-07 17:40 [PATCH] docs: bpf: Added more extension example UjjaL Roy
@ 2021-07-07 22:22 ` Song Liu
0 siblings, 0 replies; 2+ messages in thread
From: Song Liu @ 2021-07-07 22:22 UTC (permalink / raw)
To: UjjaL Roy
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, David S . Miller, Jakub Kicinski, Jonathan Corbet,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Nathan Chancellor,
Nick Desaulniers, Networking, bpf, Linux Doc Mailing List,
open list, linux-riscv, clang-built-linux
On Wed, Jul 7, 2021 at 10:50 AM UjjaL Roy <royujjal@gmail.com> wrote:
>
> From: "Roy, UjjaL" <royujjal@gmail.com>
>
> After reading this document observed that for new users it is
> hard to find an example of "extension" easily.
>
> So, added a new heading for extensions for better readability.
> Now, the new readers can easily identify "extension" examples.
> Also, added one more example of filtering interface index.
>
> Signed-off-by: Roy, UjjaL <royujjal@gmail.com>
Please prefix the subject with the target tree. In this case, the subject should
say [PATCH bpf-next] xxx. Also, please revise the commit log as suggested in
Documentation/process/submitting-patches.rst:
Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
to do frotz", as if you are giving orders to the codebase to change
its behaviour.
Otherwise, this change looks good to me. You can add my Acked-by
tag in v2. (prefix v2 with [PATCH v2 bpf-next].
Thanks,
Song
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> Documentation/networking/filter.rst | 23 ++++++++++++++++-------
> 1 file 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
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-07 22:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 17:40 [PATCH] docs: bpf: Added more extension example UjjaL Roy
2021-07-07 22:22 ` Song Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).