public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia•com>
To: Daniel Machon <daniel.machon@microchip•com>
Cc: <netdev@vger•kernel.org>, <davem@davemloft•net>,
	<edumazet@google•com>, <kuba@kernel•org>, <pabeni@redhat•com>,
	<lars.povlsen@microchip•com>, <Steen.Hegelund@microchip•com>,
	<UNGLinuxDriver@microchip•com>, <joe@perches•com>,
	<error27@gmail•com>, <horatiu.vultur@microchip•com>,
	<Julia.Lawall@inria•fr>, <petrm@nvidia•com>,
	<vladimir.oltean@nxp•com>, <maxime.chevallier@bootlin•com>,
	<linux-arm-kernel@lists•infradead.org>,
	<linux-kernel@vger•kernel.org>
Subject: Re: [PATCH net-next v2 3/6] net: dcb: add new rewrite table
Date: Wed, 18 Jan 2023 11:54:23 +0100	[thread overview]
Message-ID: <87lem0w1k3.fsf@nvidia.com> (raw)
In-Reply-To: <20230116144853.2446315-4-daniel.machon@microchip.com>


Daniel Machon <daniel.machon@microchip•com> writes:

> diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
> index cb5319c6afe6..54af3ee03491 100644
> --- a/net/dcb/dcbnl.c
> +++ b/net/dcb/dcbnl.c
> @@ -178,6 +178,7 @@ static const struct nla_policy dcbnl_featcfg_nest[DCB_FEATCFG_ATTR_MAX + 1] = {
>  };
>  
>  static LIST_HEAD(dcb_app_list);
> +static LIST_HEAD(dcb_rewr_list);
>  static DEFINE_SPINLOCK(dcb_lock);
>  
>  static enum ieee_attrs_app dcbnl_app_attr_type_get(u8 selector)
> @@ -1138,7 +1139,7 @@ static int dcbnl_app_table_setdel(struct nlattr *attr,
>  static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
>  {
>  	const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
> -	struct nlattr *ieee, *app;
> +	struct nlattr *ieee, *app, *rewr;
>  	struct dcb_app_type *itr;
>  	int dcbx;
>  	int err;
> @@ -1241,6 +1242,26 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
>  	spin_unlock_bh(&dcb_lock);
>  	nla_nest_end(skb, app);
>  
> +	rewr = nla_nest_start_noflag(skb, DCB_ATTR_DCB_REWR_TABLE);
> +	if (!rewr)
> +		return -EMSGSIZE;

This being new code, don't use _noflag please.

> +
> +	spin_lock_bh(&dcb_lock);
> +	list_for_each_entry(itr, &dcb_rewr_list, list) {
> +		if (itr->ifindex == netdev->ifindex) {
> +			enum ieee_attrs_app type =
> +				dcbnl_app_attr_type_get(itr->app.selector);
> +			err = nla_put(skb, type, sizeof(itr->app), &itr->app);
> +			if (err) {
> +				spin_unlock_bh(&dcb_lock);

This should cancel the nest started above.

I wonder if it would be cleaner in a separate function, so that there
can be a dedicated clean-up block to goto.

> +				return -EMSGSIZE;
> +			}
> +		}
> +	}
> +
> +	spin_unlock_bh(&dcb_lock);
> +	nla_nest_end(skb, rewr);
> +
>  	if (ops->dcbnl_getapptrust) {
>  		err = dcbnl_getapptrust(netdev, skb);
>  		if (err)

  reply	other threads:[~2023-01-18 11:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 14:48 [PATCH net-next v2 0/6] Introduce new DCB rewrite table Daniel Machon
2023-01-16 14:48 ` [PATCH net-next v2 1/6] net: dcb: modify dcb_app_add to take list_head ptr as parameter Daniel Machon
2023-01-18 11:02   ` Petr Machata
2023-01-16 14:48 ` [PATCH net-next v2 2/6] net: dcb: add new common function for set/del of app/rewr entries Daniel Machon
2023-01-18 10:26   ` Petr Machata
2023-01-18 11:03     ` Petr Machata
2023-01-18 13:56       ` Daniel.Machon
2023-01-18 15:42         ` Petr Machata
2023-01-16 14:48 ` [PATCH net-next v2 3/6] net: dcb: add new rewrite table Daniel Machon
2023-01-18 10:54   ` Petr Machata [this message]
2023-01-18 13:47     ` Daniel.Machon
2023-01-18 15:20       ` Petr Machata
2023-01-18 15:07     ` Dan Carpenter
2023-01-18 15:11       ` Dan Carpenter
2023-01-19  9:38       ` Petr Machata
2023-01-16 14:48 ` [PATCH net-next v2 4/6] net: dcb: add helper functions to retrieve PCP and DSCP rewrite maps Daniel Machon
2023-01-18 11:01   ` Petr Machata
2023-01-16 14:48 ` [PATCH net-next v2 5/6] net: microchip: sparx5: add support for PCP rewrite Daniel Machon
2023-01-16 14:48 ` [PATCH net-next v2 6/6] net: microchip: sparx5: add support for DSCP rewrite Daniel Machon
2023-01-18 11:00 ` [PATCH net-next v2 0/6] Introduce new DCB rewrite table Simon Horman

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=87lem0w1k3.fsf@nvidia.com \
    --to=petrm@nvidia$(echo .)com \
    --cc=Julia.Lawall@inria$(echo .)fr \
    --cc=Steen.Hegelund@microchip$(echo .)com \
    --cc=UNGLinuxDriver@microchip$(echo .)com \
    --cc=daniel.machon@microchip$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=error27@gmail$(echo .)com \
    --cc=horatiu.vultur@microchip$(echo .)com \
    --cc=joe@perches$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=lars.povlsen@microchip$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=maxime.chevallier@bootlin$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=vladimir.oltean@nxp$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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