netshaper: Add netshaper command
Subsystems (3)
PATCH v4 1/1 netshaper: Add netshaper command
Add support for the netshaper Generic Netlink family to iproute2. Introduce a new command for configuring netshaper parameters directly from userspace.
This interface allows users to set shaping attributes which are passed to the kernel to perform the corresponding netshaper operation.
Example usage:
$netshaper { set | show | delete } dev DEV \
handle scope SCOPE [id ID] \
[ bw-max BW_MAX ]
Internally, this triggers a kernel call to apply the shaping configuration to the specified network device.
Currently, the tool supports the following functionalities:
- Setting bandwidth in Mbps, enabling bandwidth clamping for a network device that support netshaper operations.
- Deleting the current configuration.
- Querying the existing configuration.
Additional netshaper operations will be integrated into the tool as per requirement.
This change enables easy and scriptable configuration of bandwidth shaping for devices that use the netshaper Netlink family.
Corresponding net-next patches:
1) https://lore.kernel.org/all/[email protected]/
2) https://lore.kernel.org/lkml/[email protected]/
Install pkg-config and libmnl* packages to print kernel extack errors to stdout.
---
References and Documentation:
1) https://dri.freedesktop.org/docs/drm/networking/netlink_spec/net_shaper.html
2) https://github.com/VENNELA2132/netshaper_mana/blob/main/netshaper%20implementation
3) https://github.com/VENNELA2132/netshaper_mana/blob/main/userspace%20tool%20for%20netshaper%20operations
---
Changes in v4:
* Use netshaper as a standalone command.
* Add a man page and Makefile for netshaper command.
* Update commit message.
* Use rta_getattr_uint instead of rta_getattr_u32 for BW_MAX.
* Use "show" instead of "get" to query the shaper details.
* Add net_shaper_scope_names to map scope values to strings.
* Print scope for netshaper show command.
* Handle ID is optional, implement code accordingly.
* Add OPTIONS for Version, Color and Help.
* Change usage() function accordingly for the updated changes.
Changes in v3:
* Use strcmp instead of matches.
* Use get_rate64 instead get_unsigned for speed parameter.
* Remove speed_mbps in do_cmd() to reduce redundancy.
* Update the usage of speed parameter in the command.
Changes in v2:
* Use color coding for printing device name in stdout.
* Use clang-format to format the code inline.
* Use __u64 for speed_bps.
* Remove include/uapi/linux/netshaper.h file.
--- Makefile | 2 +- man/man8/netshaper.8 | 215 +++++++++++++++++++++++++++++++++ netshaper/Makefile | 18 +++ netshaper/netshaper.c | 270 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 504 insertions(+), 1 deletion(-) create mode 100644 man/man8/netshaper.8 create mode 100644 netshaper/Makefile create mode 100644 netshaper/netshaper.c
Makefile +1 -1
@@ -71,7 +71,7 @@ YACCFLAGS = -d -t -v SUBDIRS=lib ip tc bridge misc netem genl man ifeq ($(HAVE_MNL),y) -SUBDIRS += tipc devlink rdma dcb vdpa +SUBDIRS += tipc devlink rdma dcb vdpa netshaper endif LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
man/man8/netshaper.8 new file +215 -0
215 lines not on this page · raw message
netshaper/Makefile new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0 +include ../config.mk + +NSOBJ = netshaper.o +TARGETS += netshaper + +all: $(TARGETS) $(LIBS) + +netshaper: $(NSOBJ) + $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@ + +install: all + for i in $(TARGETS); \ + do install -m 0755 $$i $(DESTDIR)$(SBINDIR); \ + done + +clean: + rm -f $(NSOBJ) $(TARGETS)
netshaper/netshaper.c new file +270 -0
270 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 28 lines · Erni Sri Satya Vennela
Add support for the netshaper Generic Netlink family to iproute2. Introduce a new command for configuring netshaper parameters directly from userspace.
This interface allows users to set shaping attributes which are passed to the kernel to perform the corresponding netshaper operation.
Example usage:
$netshaper { set | show | delete } dev DEV \
handle scope SCOPE [id ID] \
[ bw-maxBW_MAX]Internally, this triggers a kernel call to apply the shaping configuration to the specified network device.
Currently, the tool supports the following functionalities:
- Setting bandwidth in Mbps, enabling bandwidth clamping for a network device that support netshaper operations.
- Deleting the current configuration.
- Querying the existing configuration.Additional netshaper operations will be integrated into the tool as per requirement.
This change enables easy and scriptable configuration of bandwidth shaping for devices that use the netshaper Netlink family.
Quoted 8 lines
Corresponding net-next patches:
1) https://lore.kernel.org/all/[email protected]/
2) https://lore.kernel.org/lkml/[email protected]/Install pkg-config and libmnl* packages to print kernel extack errors to stdout.
Signed-off-by Erni Sri Satya Vennela <[email protected]>
Hi,
Just following up on the patch I sent last week. I wanted to check if you have had a chance to look at it. Please let me know if any changes are needed or if I should resend it. I appreciate your time and feedback.
Thanks,
Vennela
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Hello:
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Quoted 9 lines · On Tue, 7 Oct 2025 04:06:14 -0700 you wrote:
Add support for the netshaper Generic Netlink family to iproute2. Introduce a new command for configuring netshaper parameters directly from userspace.
This interface allows users to set shaping attributes which are passed to the kernel to perform the corresponding netshaper operation.
[...]
Here is the summary with links:
- [iproute2-next,v4] netshaper: Add netshaper command
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=8f67f01cdad6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html