netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, mlxsw@mellanox.com, idosch@mellanox.com,
	jakub.kicinski@netronome.com, f.fainelli@gmail.com,
	andrew@lunn.ch, vivien.didelot@gmail.com
Subject: [patch net-next v3 10/15] net: devlink: disallow port_attrs_set() to be called before register
Date: Sun, 24 Mar 2019 11:14:33 +0100	[thread overview]
Message-ID: <20190324101438.6376-11-jiri@resnulli.us> (raw)
In-Reply-To: <20190324101438.6376-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox.com>

Since the port attributes are static and cannot change during the port
lifetime, WARN_ON if some driver calls it after registration. Also, no
need to call notifications as it is noop anyway due to check of
devlink_port->registered there.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/core/devlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 35ae9980ce86..f4dbd404688f 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5430,12 +5430,13 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
 {
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
 
+	if (WARN_ON(devlink_port->registered))
+		return;
 	attrs->set = true;
 	attrs->flavour = flavour;
 	attrs->port_number = port_number;
 	attrs->split = split;
 	attrs->split_subport_number = split_subport_number;
-	devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
 }
 EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
 
-- 
2.17.2


  parent reply	other threads:[~2019-03-24 10:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-24 10:14 [patch net-next v3 00/15] devlink: small spring cleanup Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 01/15] net: devlink: add couple of missing mutex_destroy() calls Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 02/15] bnxt: add missing net/devlink.h include Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 03/15] dsa: " Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 04/15] bnxt: set devlink port attrs properly Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 05/15] bnxt: call devlink_port_type_eth_set() before port register Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 06/15] net: devlink: don't take devlink_mutex for devlink_compat_* Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 07/15] net: devlink: don't pass return value of __devlink_port_type_set() Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 08/15] mlxsw: Move devlink_port_attrs_set() call before register Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 09/15] dsa: move " Jiri Pirko
2019-03-24 10:14 ` Jiri Pirko [this message]
2019-03-24 10:14 ` [patch net-next v3 11/15] nfp: move devlink port type set after netdev registration Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 12/15] bnxt: set devlink port type after registration Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 13/15] net: devlink: warn on setting type on unregistered port Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 14/15] net: devlink: add port type spinlock Jiri Pirko
2019-03-24 10:14 ` [patch net-next v3 15/15] net: devlink: select NET_DEVLINK from drivers Jiri Pirko
2019-03-24 19:04 ` [patch net-next v3 00/15] devlink: small spring cleanup David Miller

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=20190324101438.6376-11-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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).