Add tc filter example
Subsystems (3)
v4 cover Add tc filter example
The patch in this series introduces an example tool that creates, shows and deletes flower filter with two VLAN actions. The example inserts a dummy action at index 0 to work around the tc actions array oddity.
---
v4:
- Fix tc-filter-add return error codes.
v3: https://lore.kernel.org/netdev/[email protected]/
- Dropped the patch that ignored index zero for indexed arrays.
- Extended the example to work around tc action array indexing oddity.
- Move to the example CFLAGS to samples/Makefile.
- Enhanced attribute dumping.
v2: https://lore.kernel.org/netdev/[email protected]/
- extend the sampe tool to show and delete the filter
- drop fix for ynl_attr_put_str as already fixed by:
- make indexed-arrays to start from index 1.
v1: https://lore.kernel.org/netdev/[email protected]/
Zahari Doychev (1):
ynl: samples: add tc filter example
tools/net/ynl/samples/.gitignore | 1 + tools/net/ynl/samples/Makefile | 1 + tools/net/ynl/samples/tc-filter-add.c | 335 ++++++++++++++++++++++++++ 3 files changed, 337 insertions(+) create mode 100644 tools/net/ynl/samples/tc-filter-add.c
Signature · 1 line
2.51.2
PATCH v4 1/1 ynl: samples: add tc filter example
Add a sample tool demonstrating how to add, dump, and delete a flower filter with two VLAN push actions. The example can be invoked as:
# samples/tc-filter-add p2
flower pref 1 proto: 0x8100
flower:
vlan_id: 100
vlan_prio: 5
num_of_vlans: 3
action order: 1 vlan push id 200 protocol 0x8100 priority 0
action order: 2 vlan push id 300 protocol 0x8100 priority 0This verifies correct handling of tc action attributes for multiple VLAN push actions. The tc action indexed arrays start from index 1, and the index defines the action order. This behavior differs from the YNL specification, which expects arrays to be zero-based. To accommodate this, the example adds a dummy action at index 0, which is ignored by the kernel.
--- tools/net/ynl/samples/.gitignore | 1 + tools/net/ynl/samples/Makefile | 1 + tools/net/ynl/samples/tc-filter-add.c | 335 ++++++++++++++++++++++++++ 3 files changed, 337 insertions(+) create mode 100644 tools/net/ynl/samples/tc-filter-add.c
tools/net/ynl/samples/.gitignore +1 -0
@@ -7,3 +7,4 @@ rt-addr rt-link rt-route tc +tc-filter-add
tools/net/ynl/samples/Makefile +1 -0
@@ -19,6 +19,7 @@ include $(wildcard *.d) all: $(BINS) CFLAGS_page-pool=$(CFLAGS_netdev) +CFLAGS_tc-filter-add:=$(CFLAGS_tc) $(BINS): ../lib/ynl.a ../generated/protos.a $(SRCS) @echo -e '\tCC sample $@'
tools/net/ynl/samples/tc-filter-add.c new file +335 -0
335 lines not on this page · raw message
Signature · 1 line
2.51.2
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 19 Nov 2025 21:36:17 +0100 you wrote:
The patch in this series introduces an example tool that creates, shows and deletes flower filter with two VLAN actions. The example inserts a dummy action at index 0 to work around the tc actions array oddity.
---
v4:
- Fix tc-filter-add return error codes.[...]
Here is the summary with links:
- [v4,1/1] ynl: samples: add tc filter example
https://git.kernel.org/netdev/net-next/c/8b4e023d79b7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html