netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
	Madhu Chittim <madhu.chittim@intel.com>,
	Sridhar Samudrala <sridhar.samudrala@intel.com>,
	Simon Horman <horms@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Sunil Kovvuri Goutham <sgoutham@marvell.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
	intel-wired-lan@lists.osuosl.org, edumazet@google.com
Subject: Re: [PATCH v5 net-next 02/12] net-shapers: implement NL get operation
Date: Fri, 30 Aug 2024 11:39:00 -0700	[thread overview]
Message-ID: <20240830113900.4c5c9b2a@kernel.org> (raw)
In-Reply-To: <57ef8eb8-9534-4061-ba6c-4dadaf790c45@redhat.com>

On Fri, 30 Aug 2024 12:55:05 +0200 Paolo Abeni wrote:
> On 8/30/24 03:20, Jakub Kicinski wrote:>> +/* Initialize the context 
> fetching the relevant device and
> >> + * acquiring a reference to it.
> >> + */
> >> +static int net_shaper_ctx_init(const struct genl_info *info, int type,
> >> +			       struct net_shaper_nl_ctx *ctx)
> >> +{
> >> +	struct net *ns = genl_info_net(info);
> >> +	struct net_device *dev;
> >> +	int ifindex;
> >> +
> >> +	memset(ctx, 0, sizeof(*ctx));
> >> +	if (GENL_REQ_ATTR_CHECK(info, type))
> >> +		return -EINVAL;
> >> +
> >> +	ifindex = nla_get_u32(info->attrs[type]);  
> > 
> > Let's limit the 'binding' thing to just driver call sites, we can
> > redo the rest easily later. This line and next pretends to take
> > "arbitrary" type but clearly wants a ifindex/netdev, right?  
> 
> There is a misunderstanding. This helper will be used in a following 
> patch (7/12) with a different 'type' argument: 
> NET_SHAPER_A_BINDING_IFINDEX. I've put a note in the commit message, but 
> was unintentionally dropped in one of the recent refactors. I'll add 
> that note back.

What I'm saying is that if you want to prep the ground for more
"binding" types you should also add:

	if (type != ...IFINDEX) {
		/* other binding types are TBD */
		return -EINVAL;
	}

> I hope you are ok with the struct net_shaper_binding * argument to most 
> helpers? does not add complexity, will help to support devlink objects 
> and swapping back and forth from/to struct net_device* can't be automated.

I am "okay" in the American sense of the word which AFAIU is "unhappy
but won't complain unless asked".

> > Maybe send a patch like this, to avoid having to allocate this space,
> > and special casing dump vs doit:
> > 
> > diff --git a/include/net/genetlink.h b/include/net/genetlink.h
> > index 9ab49bfeae78..7658f0885178 100644
> > --- a/include/net/genetlink.h
> > +++ b/include/net/genetlink.h
> > @@ -124,7 +124,8 @@ struct genl_family {
> >    * @genlhdr: generic netlink message header
> >    * @attrs: netlink attributes
> >    * @_net: network namespace
> > - * @user_ptr: user pointers
> > + * @ctx: storage space for the use by the family
> > + * @user_ptr: user pointers (deprecated, use ctx instead)
> >    * @extack: extended ACK report struct
> >    */
> >   struct genl_info {
> > @@ -135,7 +136,10 @@ struct genl_info {
> >   	struct genlmsghdr *	genlhdr;
> >   	struct nlattr **	attrs;
> >   	possible_net_t		_net;
> > -	void *			user_ptr[2];
> > +	union {
> > +		u8		ctx[48];
> > +		void *		user_ptr[2];
> > +	};
> >   	struct netlink_ext_ack *extack;
> >   };  
> 
> Makes sense. Plus likely:
> 
> #define NETLINK_CTX_SIZE 48
> 
> and use such define above and in linux/netlink.h

Aha, would be good to also have a checking macro. Maybe rename

NL_ASSERT_DUMP_CTX_FITS()

to apply more broadly? or add a new one? Weak preference for former.

  reply	other threads:[~2024-08-30 18:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29 15:16 [PATCH v5 net-next 00/12] net: introduce TX H/W shaping API Paolo Abeni
2024-08-29 15:16 ` [PATCH v5 net-next 01/12] netlink: spec: add shaper YAML spec Paolo Abeni
2024-08-29 15:16 ` [PATCH v5 net-next 02/12] net-shapers: implement NL get operation Paolo Abeni
2024-08-29 23:28   ` Jakub Kicinski
2024-08-30  1:20   ` Jakub Kicinski
2024-08-30 10:55     ` Paolo Abeni
2024-08-30 18:39       ` Jakub Kicinski [this message]
2024-08-30 23:42         ` Jakub Kicinski
2024-09-02 13:00         ` Paolo Abeni
2024-08-30 15:43     ` Paolo Abeni
2024-08-30 19:14       ` Jakub Kicinski
2024-09-02 10:10         ` Paolo Abeni
2024-09-03  0:37           ` Jakub Kicinski
2024-08-29 15:16 ` [PATCH v5 net-next 03/12] net-shapers: implement NL set and delete operations Paolo Abeni
2024-08-30  1:43   ` Jakub Kicinski
2024-08-29 15:16 ` [PATCH v5 net-next 04/12] net-shapers: implement NL group operation Paolo Abeni
2024-08-30  2:04   ` Jakub Kicinski
2024-08-30 16:48     ` Paolo Abeni
2024-08-30 18:48       ` Jakub Kicinski
2024-08-29 15:16 ` [PATCH v5 net-next 05/12] net-shapers: implement delete support for NODE scope shaper Paolo Abeni
2024-08-29 15:16 ` [PATCH v5 net-next 06/12] netlink: spec: add shaper introspection support Paolo Abeni
2024-08-29 15:17 ` [PATCH v5 net-next 07/12] net: shaper: implement " Paolo Abeni
2024-08-30  2:11   ` Jakub Kicinski
2024-08-29 15:17 ` [PATCH v5 net-next 08/12] testing: net-drv: add basic shaper test Paolo Abeni
2024-08-29 15:17 ` [PATCH v5 net-next 09/12] virtchnl: support queue rate limit and quanta size configuration Paolo Abeni
2024-08-29 15:17 ` [PATCH v5 net-next 10/12] ice: Support VF " Paolo Abeni
2024-08-29 15:17 ` [PATCH v5 net-next 11/12] iavf: Add net_shaper_ops support Paolo Abeni
2024-08-30  2:09   ` Jakub Kicinski
2024-08-29 15:17 ` [PATCH v5 net-next 12/12] iavf: add support to exchange qos capabilities Paolo Abeni

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=20240830113900.4c5c9b2a@kernel.org \
    --to=kuba@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=madhu.chittim@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sgoutham@marvell.com \
    --cc=sridhar.samudrala@intel.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;
as well as URLs for NNTP newsgroup(s).