From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40E8F34107A for ; Fri, 10 Apr 2026 22:51:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775861488; cv=none; b=qHLBTtQ2zyFOMzvwNhCbCdr0MlqLZZmxwYIO8VWZR1KJl8PijFVNDDPycVnY5j7zAPkgHQL7+pYOavn3UJMyVFbKsZ8C50dN9mjenU4vh049Z2/MuNdilOpxkr6lGE8VwD+oYjk8Bvqe/UxRP3D81RmZccFyPf5Zhxof30bJjuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775861488; c=relaxed/simple; bh=g94ZvU6Eq6VpyU6gZKGEO5v6YDDlDdSD7Aa1Zvg13DE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nRRNsOzFRAuM3mNAKNfs2NDxN4E0ZImZhV/K7ka5tkialqsuwJr5H6owimrtzQOx6nj3QmpXnPS/Y7nLDxTJ6gpredXrEOyYIsW9OeccOUaKseBj/O2CDgeF7go0iqdJcehExX6INpaYtcSKzKnkXDHTzFqTj1pyp7g4TgG8DQ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=arW4m0QT; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="arW4m0QT" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4889e045bc6so27343195e9.2 for ; Fri, 10 Apr 2026 15:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775861486; x=1776466286; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hSRTjy6wm25VHK2uTpX6ZsxoXvGmhSlH5xYLbZJnuyM=; b=arW4m0QTOPPf05hrS5AjHRfG/+uUs/txJE8eYQKR2OF2YlIM6l9Y/aNMSat595hmtr 3/yQjWMmnHCaKz3L0F5xYbOKX1vOJipPjCziobAvhLbwmzzC2ncPxmkJ95hifT3CYCjb KErI+PBJRPF+JMh4BvsrYRJSdUWO3TFVUmqqKk/Nk/4svGJVqpD74qL6gYXPs++S5e6M SROks9h7fGqHzguzqfv55iNheOHJWwWDc4KwQ/ITR2cx7qumWYAtkNGi4vTaJpHGtC48 K50hxhQBzTss2V6BcScRZZo9YGhM8ps7AF+FWPpq5PIfC0rhhxCa+onhR04Ab+jJfAla +Www== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775861486; x=1776466286; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hSRTjy6wm25VHK2uTpX6ZsxoXvGmhSlH5xYLbZJnuyM=; b=hvGcJyFubVjkbV5SrRNK4oxb1vURLAMV6FrayoF5kfabnY2OgTEJbkRZhqqfS8Oq2/ H8TbaoCBzYrpnEr0oKIMYirieLIuQR8GyJyh3w9Pjq/eshVHREINOSA2/b3a8tOzX5t3 t4qJjmYJVUyELQzLMLzQJONb/cf2yD1MaGYLD1Nzg+41HUylm6SyJ8RDfxoTcFDXcUwo N9dviZjjrdeOfHq07nSpk+O4w2ZXljMAy9+Jzy3z6lzDhj//Vv4668w/pIIDDv9fHRTC yxAn9J7A7AyXv1tn+GiCBddryezYeZhFD5H28vCC93b22B76eF8jf0TyrlctrSBToQ2Q dEww== X-Forwarded-Encrypted: i=1; AJvYcCVgEDrKxtVFS7SmSkgmZY0NITtwlByVtB27FVX9dlDXxOIjcUQEcQkd2YMkLJU5dgip17MVa2ezDywg63g=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1srWW1TxG7rCxesXnP/twtLDuMVESZ2l0d7FtsigiwNe77h22 t0mWe3y4IKx/Nq1I18zxjp1cz29mxI8eaK3EyqVkf3hGhNIzMIBOmQn5 X-Gm-Gg: AeBDievI7epKVyr7yFYNd5brx8fYFSK2klRfDfWo+eh/3CgzgEhYM4xL9LEyzy/zel4 4OHz8fSmPt5mzvm0ZedjnuFw039rUKWgagI5emjHkdvrO5qPn6ipsogMxO47UxjDUtSSPraUqrB GksVsI4/rPYUfSshzbBfM595T7dOoS0ruEjfYLn9HsCNm6rHbBpxRSVXSk69ynVqP//Kn1CoSkq v8DaE8fqs2TojMBcMYL806hbasI6MoYL9bOKfN0QWWq7EKH23RY4ZXis45ymp2bpwE3I22AAERV DuCQdYFPtR8MLp7aYzMPG3+rvEJZBYqYC8T4Cn5ZmVjFLAzsnn8O0tXLij5q3ubYkZVeMwAkmux hbg9+zLyM9hGmJq8tPrmBshbP016MtxQ7U8Mzlsl8rHXkeaT/oabFZnu0664e9hK6R9EuZNnCW+ XVKhrggL1cHS9Hb3546QiK X-Received: by 2002:a05:600c:8585:b0:488:9bf8:7f17 with SMTP id 5b1f17b1804b1-488d684bcb0mr48381585e9.14.1775861485409; Fri, 10 Apr 2026 15:51:25 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:1c::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d5347ea5sm118712345e9.8.2026.04.10.15.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 15:51:24 -0700 (PDT) From: Mohsin Bashir 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 Message-ID: <20260410225123.2341672-1-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Mohsin Bashir --- 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