Commit b62b29e6 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Paolo Abeni
Browse files

net: shaper: enforce singleton NETDEV scope with id 0



The NETDEV scope represents a singleton root shaper in the per-device
hierarchy.  All code assumes NETDEV shapers have id 0:
net_shaper_default_parent() hardcodes parent->id = 0 when returning
the NETDEV parent for QUEUE/NODE children, and the UAPI documentation
describes NETDEV scope as "the main shaper" (singular, not plural).

Make sure we reject non-0 IDs.

Fixes: 4b623f9f ("net-shapers: implement NL get operation")
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260510192904.3987113-10-kuba@kernel.org


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 8d5806c6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -482,6 +482,12 @@ static int net_shaper_parse_handle(const struct nlattr *attr,
	else if (handle->scope == NET_SHAPER_SCOPE_NODE)
		id = NET_SHAPER_ID_UNSPEC;

	if (id && handle->scope == NET_SHAPER_SCOPE_NETDEV) {
		NL_SET_ERR_MSG_ATTR(info->extack, id_attr,
				    "Netdev scope is a singleton, must use ID 0");
		return -EINVAL;
	}

	handle->id = id;
	return 0;
}