From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: ast@fiberby.net, chuck.lever@oracle.com, davem@davemloft.net,
donald.hunter@gmail.com, edumazet@google.com, horms@kernel.org,
kuba@kernel.org, linux-kernel@vger.kernel.org,
matttbe@kernel.org, pabeni@redhat.com, mohsin.bashr@gmail.com
Subject: [PATCH net-next] net: shaper: Reject zero weight in shaper config
Date: Fri, 10 Apr 2026 15:51:23 -0700 [thread overview]
Message-ID: <20260410225123.2341672-1-mohsin.bashr@gmail.com> (raw)
A zero weight is meaningless for DWRR scheduling and can cause
starvation of the affected node. Add a min-value constraint to
the weight attribute in the net_shaper netlink spec so that zero
is rejected at the netlink policy level.
Found while prototyping a new driver, existing drivers are not
affected.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
Documentation/netlink/specs/net_shaper.yaml | 2 ++
net/shaper/shaper_nl_gen.c | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Documentation/netlink/specs/net_shaper.yaml b/Documentation/netlink/specs/net_shaper.yaml
index 3f2ad772b64b..7216568fcfc5 100644
--- a/Documentation/netlink/specs/net_shaper.yaml
+++ b/Documentation/netlink/specs/net_shaper.yaml
@@ -106,6 +106,8 @@ attribute-sets:
-
name: weight
type: u32
+ checks:
+ min: 1
doc: |
Relative weight for round robin scheduling of the
given shaper.
diff --git a/net/shaper/shaper_nl_gen.c b/net/shaper/shaper_nl_gen.c
index 9b29be3ef19a..0cad1a355350 100644
--- a/net/shaper/shaper_nl_gen.c
+++ b/net/shaper/shaper_nl_gen.c
@@ -20,7 +20,7 @@ const struct nla_policy net_shaper_handle_nl_policy[NET_SHAPER_A_HANDLE_ID + 1]
const struct nla_policy net_shaper_leaf_info_nl_policy[NET_SHAPER_A_WEIGHT + 1] = {
[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
- [NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
+ [NET_SHAPER_A_WEIGHT] = NLA_POLICY_MIN(NLA_U32, 1),
};
/* NET_SHAPER_CMD_GET - do */
@@ -43,7 +43,7 @@ static const struct nla_policy net_shaper_set_nl_policy[NET_SHAPER_A_IFINDEX + 1
[NET_SHAPER_A_BW_MAX] = { .type = NLA_UINT, },
[NET_SHAPER_A_BURST] = { .type = NLA_UINT, },
[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
- [NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
+ [NET_SHAPER_A_WEIGHT] = NLA_POLICY_MIN(NLA_U32, 1),
};
/* NET_SHAPER_CMD_DELETE - do */
@@ -62,7 +62,7 @@ static const struct nla_policy net_shaper_group_nl_policy[NET_SHAPER_A_LEAVES +
[NET_SHAPER_A_BW_MAX] = { .type = NLA_UINT, },
[NET_SHAPER_A_BURST] = { .type = NLA_UINT, },
[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
- [NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
+ [NET_SHAPER_A_WEIGHT] = NLA_POLICY_MIN(NLA_U32, 1),
[NET_SHAPER_A_LEAVES] = NLA_POLICY_NESTED(net_shaper_leaf_info_nl_policy),
};
--
2.52.0
reply other threads:[~2026-04-10 22:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260410225123.2341672-1-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=ast@fiberby.net \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox