lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e5c2178-22e2-409e-8cbd-9aaa66594fdc@redhat.com>
Date: Fri, 23 Aug 2024 10:52:04 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, Jiri Pirko <jiri@...nulli.us>,
 Madhu Chittim <madhu.chittim@...el.com>,
 Sridhar Samudrala <sridhar.samudrala@...el.com>,
 Simon Horman <horms@...nel.org>, John Fastabend <john.fastabend@...il.com>,
 Sunil Kovvuri Goutham <sgoutham@...vell.com>,
 Jamal Hadi Salim <jhs@...atatu.com>, Donald Hunter <donald.hunter@...il.com>
Subject: Re: [PATCH v4 net-next 03/12] net-shapers: implement NL get operation

On 8/23/24 04:10, Jakub Kicinski wrote:
> On Tue, 20 Aug 2024 17:12:24 +0200 Paolo Abeni wrote:
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -81,6 +81,8 @@ struct xdp_frame;
>>   struct xdp_metadata_ops;
>>   struct xdp_md;
>>   struct ethtool_netdev_state;
>> +struct net_shaper_ops;
>> +struct net_shaper_data;
> 
> no need, forward declarations are only needed for function declarations
> 
>> + * struct net_shaper_ops - Operations on device H/W shapers
>> + *
>> + * The initial shaping configuration at device initialization is empty:
>> + * does not constraint the rate in any way.
>> + * The network core keeps track of the applied user-configuration in
>> + * the net_device structure.
>> + * The operations are serialized via a per network device lock.
>> + *
>> + * Each shaper is uniquely identified within the device with an 'handle'
> 
> a handle
> 
>> + * comprising the shaper scope and a scope-specific id.
>> + */
>> +struct net_shaper_ops {
>> +	/**
>> +	 * @group: create the specified shapers scheduling group
>> +	 *
>> +	 * Nest the @leaves shapers identified by @leaves_handles under the
>> +	 * @root shaper identified by @root_handle. All the shapers belong
>> +	 * to the network device @dev. The @leaves and @leaves_handles shaper
>> +	 * arrays size is specified by @leaves_count.
>> +	 * Create either the @leaves and the @root shaper; or if they already
>> +	 * exists, links them together in the desired way.
>> +	 * @leaves scope must be NET_SHAPER_SCOPE_QUEUE.
> 
> Or SCOPE_NODE, no?

I had a few back-and-forth between the two options, enforcing only QUEUE 
leaves or allowing even NODE.

I think the first option is general enough - can create arbitrary 
topologies with the same amount of operations - and leads to slightly 
simpler code, but no objections for allow both.

> 
>> +	 * Returns 0 on group successfully created, otherwise an negative
>> +	 * error value and set @extack to describe the failure's reason.
> 
> the return and extack lines are pretty obvious, you can drop
> 
>> +	 */
>> +	int (*group)(struct net_device *dev, int leaves_count,
>> +		     const struct net_shaper_handle *leaves_handles,
>> +		     const struct net_shaper_info *leaves,
>> +		     const struct net_shaper_handle *root_handle,
>> +		     const struct net_shaper_info *root,
>> +		     struct netlink_ext_ack *extack);
> 
>> +#endif
>> +
> 
> ooh, here's one of the trailing whitespace git was mentioning :)
> 
>>   #include <linux/kernel.h>
>> +#include <linux/bits.h>
>> +#include <linux/bitfield.h>
>> +#include <linux/idr.h>
>> +#include <linux/netdevice.h>
>> +#include <linux/netlink.h>
>>   #include <linux/skbuff.h>
>> +#include <linux/xarray.h>
>> +#include <net/net_shaper.h>
> 
> kernel.h between idr.h and netdevice.h
> 
>> +static int net_shaper_fill_handle(struct sk_buff *msg,
>> +				  const struct net_shaper_handle *handle,
>> +				  u32 type, const struct genl_info *info)
>> +{
>> +	struct nlattr *handle_attr;
>> +
>> +	if (handle->scope == NET_SHAPER_SCOPE_UNSPEC)
>> +		return 0;
> 
> In what context can we try to fill handle with scope unspec?

Uhmm... should happen only in buggy situation. What about adding adding 
WARN_ON_ONCE() ?

>> +	handle_attr = nla_nest_start_noflag(msg, type);
>> +	if (!handle_attr)
>> +		return -EMSGSIZE;
>> +
>> +	if (nla_put_u32(msg, NET_SHAPER_A_SCOPE, handle->scope) ||
>> +	    (handle->scope >= NET_SHAPER_SCOPE_QUEUE &&
>> +	     nla_put_u32(msg, NET_SHAPER_A_ID, handle->id)))
>> +		goto handle_nest_cancel;
> 
> So netdev root has no id and no scope?

I don't understand the question.

The root handle has scope NETDEV and id 0, the id will not printed out 
as redundant: there is only a scope NETDEV shaper per struct net_device.

Thanks,

Paolo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ