Skip to contentSkip to conversation

Documentation/bpf: Add heading and example for extensions in filter.rst

PATCH In review Roy, UjjaL 4 participants 4 messages Jul 12, 2021 – Jul 16, 2021

Subsystems (5)
lore
Share & tools
lore

Roy, UjjaL

author
#0 lore raw

PATCH v2 1/1 Documentation/bpf: Add heading and example for extensions in filter.rst

[1] https://www.kernel.org/doc/html/latest/bpf/

Add new heading for extensions to make it more readable. Also, add one more example of filtering interface index for better understanding.

---
 Documentation/networking/filter.rst | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
Documentation/networking/filter.rst +16 -7
index 3e2221f4abe4..5f13905b12e0 100644
@@ -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
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · UjjaL

[1] https://www.kernel.org/doc/html/latest/bpf/

Add new heading for extensions to make it more readable. Also, add one more example of filtering interface index for better understanding.

Looks OK to me. I thought the original was readable without the header, but if it helps someone seems easy enough to do.

#2 lore raw
Quoted 7 lines · John Fastabend
Quoted 5 lines · UjjaL

[1] https://www.kernel.org/doc/html/latest/bpf/

Add new heading for extensions to make it more readable. Also, add one more example of filtering interface index for better understanding.

Quoted 7 lines
Quoted 2 lines

Looks OK to me. I thought the original was readable without the header, but if it helps someone seems easy enough to do.

I cannot figure out how to apply this patch, because I see:
Applying: Documentation/bpf: Add heading and example for extensions in filter.rst
fatal: empty ident name (for <>) not allowed

Any idea?

maintainer
#3 lore raw
Quoted 14 lines · Alexei Starovoitov
Quoted 13 lines · John Fastabend
Quoted 7 lines · UjjaL

[1] https://www.kernel.org/doc/html/latest/bpf/

Add new heading for extensions to make it more readable. Also, add one more example of filtering interface index for better understanding.

Looks OK to me. I thought the original was readable without the header, but if it helps someone seems easy enough to do.

Quoted 8 lines
Quoted 1 line

I cannot figure out how to apply this patch, because I see:
Applying: Documentation/bpf: Add heading and example for extensions in filter.rst
fatal: empty ident name (for <>) not allowed

Any idea?

Same happened on my side. Maybe not sent via git-send-email(1)? Anyway, I've applied manually meanwhile.