From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, stephen@networkplumber.org,
pabeni@redhat.com, kuba@kernel.org, ernis@linux.microsoft.com,
mohsin.bashr@gmail.com
Subject: [PATCH iproute2-next 2/5] netshaper: Add bw-min and weight parameter support
Date: Thu, 30 Apr 2026 18:16:08 -0700 [thread overview]
Message-ID: <20260501011611.3533573-3-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20260501011611.3533573-1-mohsin.bashr@gmail.com>
Add bw-min and weight parameters to the set command. Previously
only bw-max was supported. Update the set validation to accept
any of bw-max, bw-min, or weight. Update usage text to reflect
the new parameters.
Before:
./netshaper set dev eth2 handle scope queue id 0 bw-min 100kbit
What is "bw-min"
Usage: netshaper [ OPTIONS ] { COMMAND | help }
OPTIONS := { -V[ersion] | -c[olor] | -help }
COMMAND := { set | get | delete } dev DEVNAME
handle scope HANDLE_SCOPE [id HANDLE_ID]
[bw-max BW_MAX]
Where: DEVNAME := STRING
HANDLE_SCOPE := { netdev | queue | node }
HANDLE_ID := UINT (required for queue/node, optional for netdev)
BW_MAX := UINT{ kbit | mbit | gbit }
After:
./netshaper set dev eth2 handle scope queue id 0 bw-min 100kbit
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
---
netshaper/netshaper.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/netshaper/netshaper.c b/netshaper/netshaper.c
index 1603e6e5..4ee30525 100644
--- a/netshaper/netshaper.c
+++ b/netshaper/netshaper.c
@@ -33,11 +33,12 @@ static void usage(void)
"OPTIONS := { -V[ersion] | -c[olor] | -help }\n"
"COMMAND := { set | get | delete } dev DEVNAME\n"
" handle scope HANDLE_SCOPE [id HANDLE_ID]\n"
- " [bw-max BW_MAX]\n"
+ " [bw-max BW_MAX] [bw-min BW_MIN] [weight WEIGHT]\n"
"Where: DEVNAME := STRING\n"
" HANDLE_SCOPE := { netdev | queue | node }\n"
" HANDLE_ID := UINT (required for queue/node, optional for netdev)\n"
- " BW_MAX := UINT{ kbit | mbit | gbit }\n");
+ " BW_MAX/BW_MIN := UINT{ kbit | mbit | gbit }\n"
+ " WEIGHT := UINT\n");
}
static const char *net_shaper_scope_names[NET_SHAPER_SCOPE_MAX + 1] = {
@@ -125,13 +126,13 @@ static int do_cmd(int argc, char **argv, int cmd)
GENL_REQUEST(req, 1024, genl_family, 0, NET_SHAPER_FAMILY_VERSION, cmd,
NLM_F_REQUEST | NLM_F_ACK);
- struct nlmsghdr *answer;
- __u64 bw_max_bps = 0;
- int ifindex = -1;
+ bool has_bw_max = false, has_bw_min = false, has_weight = false;
int handle_scope = NET_SHAPER_SCOPE_UNSPEC;
- __u32 handle_id = 0;
+ __u64 bw_max_bps = 0, bw_min_bps = 0;
+ __u32 handle_id = 0, weight = 0;
bool handle_present = false;
- int err;
+ struct nlmsghdr *answer;
+ int err, ifindex = -1;
while (argc > 0) {
if (strcmp(*argv, "dev") == 0) {
@@ -141,6 +142,19 @@ static int do_cmd(int argc, char **argv, int cmd)
NEXT_ARG();
if (parse_rate(*argv, &bw_max_bps))
return -1;
+ has_bw_max = true;
+ } else if (strcmp(*argv, "bw-min") == 0) {
+ NEXT_ARG();
+ if (parse_rate(*argv, &bw_min_bps))
+ return -1;
+ has_bw_min = true;
+ } else if (strcmp(*argv, "weight") == 0) {
+ NEXT_ARG();
+ if (get_unsigned(&weight, *argv, 10)) {
+ fprintf(stderr, "Invalid weight value\n");
+ return -1;
+ }
+ has_weight = true;
} else if (strcmp(*argv, "handle") == 0) {
handle_present = true;
NEXT_ARG();
@@ -197,8 +211,8 @@ static int do_cmd(int argc, char **argv, int cmd)
if (!handle_present)
missarg("handle");
- if (cmd == NET_SHAPER_CMD_SET && bw_max_bps == 0)
- missarg("bw-max");
+ if (cmd == NET_SHAPER_CMD_SET && !has_bw_max && !has_bw_min && !has_weight)
+ missarg("bw-max, bw-min, or weight");
addattr32(&req.n, sizeof(req), NET_SHAPER_A_IFINDEX, ifindex);
@@ -208,8 +222,12 @@ static int do_cmd(int argc, char **argv, int cmd)
addattr32(&req.n, sizeof(req), NET_SHAPER_A_HANDLE_ID, handle_id);
addattr_nest_end(&req.n, handle);
- if (cmd == NET_SHAPER_CMD_SET)
+ if (has_bw_max)
addattr64(&req.n, sizeof(req), NET_SHAPER_A_BW_MAX, bw_max_bps);
+ if (has_bw_min)
+ addattr64(&req.n, sizeof(req), NET_SHAPER_A_BW_MIN, bw_min_bps);
+ if (has_weight)
+ addattr32(&req.n, sizeof(req), NET_SHAPER_A_WEIGHT, weight);
err = rtnl_talk(&gen_rth, &req.n, &answer);
if (err < 0) {
--
2.52.0
next prev parent reply other threads:[~2026-05-01 1:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 1:16 [PATCH iproute2-next 0/5] netshaper: Extend netshaper support Mohsin Bashir
2026-05-01 1:16 ` [PATCH iproute2-next 1/5] netshaper: Extract parse_scope() and parse_rate() helpers Mohsin Bashir
2026-05-01 17:47 ` David Ahern
2026-05-01 1:16 ` Mohsin Bashir [this message]
2026-05-01 17:50 ` [PATCH iproute2-next 2/5] netshaper: Add bw-min and weight parameter support David Ahern
2026-05-01 1:16 ` [PATCH iproute2-next 3/5] netshaper: Extend show output with parent, bw-min and weight Mohsin Bashir
2026-05-01 1:16 ` [PATCH iproute2-next 4/5] netshaper: Make handle id optional for node scope Mohsin Bashir
2026-05-01 1:16 ` [PATCH iproute2-next 5/5] netshaper: Add group command for creating scheduling hierarchies Mohsin Bashir
2026-05-01 15:17 ` [PATCH iproute2-next 0/5] netshaper: Extend netshaper support Stephen Hemminger
2026-05-01 21:13 ` Mohsin Bashir
2026-05-01 17:52 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260501011611.3533573-3-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=dsahern@kernel.org \
--cc=ernis@linux.microsoft.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.