Skip to content

Commit

Permalink
devlink: Make sure devlink instance and port are in same net namespace
Browse files Browse the repository at this point in the history
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: 070c63f ("net: devlink: allow to change namespaces during reload")
Signed-off-by: Parav Pandit <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
paravmellanox authored and kuba-moo committed Nov 26, 2020
1 parent b187c9b commit a7b4364
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/core/devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,10 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
devlink_port->desired_type))
goto nla_put_failure_type_locked;
if (devlink_port->type == DEVLINK_PORT_TYPE_ETH) {
struct net *net = devlink_net(devlink_port->devlink);
struct net_device *netdev = devlink_port->type_dev;

if (netdev &&
if (netdev && net_eq(net, dev_net(netdev)) &&
(nla_put_u32(msg, DEVLINK_ATTR_PORT_NETDEV_IFINDEX,
netdev->ifindex) ||
nla_put_string(msg, DEVLINK_ATTR_PORT_NETDEV_NAME,
Expand Down

0 comments on commit a7b4364

Please sign in to comment.