5 Commits

Author SHA1 Message Date
Stephen Hemminger
2a82227f98 netshaper: ignore build result
If netshaper is built locally, ignore the result.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2025-11-08 10:24:39 -08:00
Stephen Hemminger
9282ff21af netshaper: remove unused variable
Clang complains that the variable 'n' used for nlmsghdr is passed
uninitiailized. Remove it because it is never used.

Fixes: 6f7779ad4ef6 ("netshaper: Add netshaper command")
Cc: ernis@linux.microsoft.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2025-11-08 09:33:29 -08:00
Andrea Claudi
ca756f36a0 netshaper: fix build failure
netshaper fails to build from sources with this error:

$ make
netshaper
    CC       netshaper.o
    LINK     netshaper
/usr/bin/ld: ../lib/libutil.a(utils_math.o): in function `get_rate':
utils_math.c:(.text+0x97): undefined reference to `floor'
/usr/bin/ld: ../lib/libutil.a(utils_math.o): in function `get_size64':
utils_math.c:(.text+0x2a8): undefined reference to `floor'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:10: netshaper] Error 1
make: *** [Makefile:81: all] Error 2

Fix this simply linking against the math C library, similarly to what we
already did with commit 1a22ad2721fb ("build: Fix link errors on some
systems").

Fixes: 6f7779ad4ef6 ("netshaper: Add netshaper command")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2025-10-29 17:02:54 -07:00
Stephen Hemminger
54921a4bf2 netshaper: update include files
Use iwyu to make sure all includes are listed.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2025-10-21 15:06:11 -07:00
Erni Sri Satya Vennela
6f7779ad4e 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/cover.1728460186.git.pabeni@redhat.com/
2) https://lore.kernel.org/lkml/1750144656-2021-1-git-send-email-ernis@linux.microsoft.com/

Install pkg-config and libmnl* packages to print kernel extack
errors to stdout.

Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2025-10-21 15:06:05 -07:00