From: Parav Pandit <parav@nvidia.com>
To: <kuba@kernel.org>, <davem@davemloft.net>,
<netdev@vger.kernel.org>, <jiri@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Subject: [PATCH net 2/2] devlink: Make sure devlink instance and port are in same net namespace
Date: Sun, 22 Nov 2020 08:12:57 +0200 [thread overview]
Message-ID: <20201122061257.60425-3-parav@nvidia.com> (raw)
In-Reply-To: <20201122061257.60425-1-parav@nvidia.com>
When devlink reload operation is not used, netdev of an Ethernet port
may be present in different net namespace than the net namespace of the
devlink instance.
Ensure that both the devlink instance and devlink port netdev are
located in same net namespace.
Fixes: 070c63f20f6c ("net: devlink: allow to change namespaces during reload")
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
net/core/devlink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 6135ef5972ce..2e1b0e82a102 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -778,12 +778,15 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por
static int devlink_nl_port_netdev_fill(struct sk_buff *msg, struct devlink_port *devlink_port)
{
struct net_device *netdev = devlink_port->type_dev;
- int err;
+ int err = 0;
ASSERT_RTNL();
if (!netdev)
return 0;
+ if (!net_eq(devlink_net(devlink_port->devlink), dev_net(netdev)))
+ goto done;
+
err = nla_put_u32(msg, DEVLINK_ATTR_PORT_NETDEV_IFINDEX, netdev->ifindex);
if (err)
goto done;
--
2.26.2
next prev parent reply other threads:[~2020-11-22 6:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-22 6:12 [PATCH net 0/2] devlink port attribute fixes Parav Pandit
2020-11-22 6:12 ` [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes Parav Pandit
2020-11-24 22:29 ` Jakub Kicinski
2020-11-25 7:13 ` Parav Pandit
2020-11-25 16:30 ` Jakub Kicinski
2020-11-25 17:21 ` Parav Pandit
2020-11-25 17:41 ` Jakub Kicinski
2020-11-25 18:17 ` Parav Pandit
2020-11-22 6:12 ` Parav Pandit [this message]
2020-11-25 9:16 ` [PATCH net v2 0/2] devlink port attribute fixes Parav Pandit
2020-11-25 9:16 ` [PATCH net v2 1/2] devlink: Hold rtnl lock while reading netdev attributes Parav Pandit
2020-11-25 9:16 ` [PATCH net v2 2/2] devlink: Make sure devlink instance and port are in same net namespace Parav Pandit
2020-11-26 1:40 ` [PATCH net v2 0/2] devlink port attribute fixes patchwork-bot+netdevbpf
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=20201122061257.60425-3-parav@nvidia.com \
--to=parav@nvidia.com \
--cc=davem@davemloft.net \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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).