devlink port attribute fixes
Subsystems (2)
cover devlink port attribute fixes
This patchset contains 2 small fixes for devlink port attributes.
Patch summary:
Patch-1 synchronize the devlink port attribute reader
with net namespace change operation
Patch-2 Ensure to return devlink port's netdevice attributes
when netdev and devlink instance belong to same net namespace
Parav Pandit (2):
devlink: Hold rtnl lock while reading netdev attributes
devlink: Make sure devlink instance and port are in same net namespace
net/core/devlink.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 devlink: Hold rtnl lock while reading netdev attributes
A netdevice of a devlink port can be moved to different net namespace than its parent devlink instance. This scenario occurs when devlink reload is not used for maintaining backward compatibility.
When netdevice is undergoing migration to net namespace, its ifindex and name may change.
In such use case, devlink port query may read stale netdev attributes.
Fix it by reading them under rtnl lock.
--- net/core/devlink.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
net/core/devlink.c +24 -6
@@ -775,6 +775,23 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *porreturn err; } +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; + +ASSERT_RTNL (); +if (!netdev) +return 0 ; + + err =nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , netdev->ifindex); +if (err) + goto done; + err =nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , netdev->name); +done: +return err; +} + static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_port *devlink_port, enum devlink_command cmd, u32 portid,
@@ -792,6 +809,8 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,if (nla_put_u32 (msg,DEVLINK_ATTR_PORT_INDEX , devlink_port->index)) goto nla_put_failure; +/* Hold rtnl lock while accessing port's netdev attributes. */ +rtnl_lock ();spin_lock_bh (&devlink_port->type_lock);if (nla_put_u16 (msg,DEVLINK_ATTR_PORT_TYPE , devlink_port->type)) goto nla_put_failure_type_locked;
@@ -800,13 +819,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_device *netdev = devlink_port->type_dev; +int err; -if (netdev && - (nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , - netdev->ifindex) || -nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , - netdev->name))) + err =devlink_nl_port_netdev_fill (msg, devlink_port); +if (err) goto nla_put_failure_type_locked; }if (devlink_port->type ==DEVLINK_PORT_TYPE_IB ) {
@@ -818,6 +834,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, goto nla_put_failure_type_locked; }spin_unlock_bh (&devlink_port->type_lock); +rtnl_unlock ();if (devlink_nl_port_attrs_put (msg, devlink_port)) goto nla_put_failure;if (devlink_nl_port_function_attrs_put (msg, devlink_port, extack))
@@ -828,6 +845,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, nla_put_failure_type_locked:spin_unlock_bh (&devlink_port->type_lock); +rtnl_unlock (); nla_put_failure:genlmsg_cancel (msg, hdr);return -EMSGSIZE ;
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerRe: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 27 lines · On Sun, 22 Nov 2020 08:12:56 +0200 Parav Pandit wrote:
A netdevice of a devlink port can be moved to different net namespace than its parent devlink instance. This scenario occurs when devlink reload is not used for maintaining backward compatibility.
When netdevice is undergoing migration to net namespace, its ifindex and name may change.
In such use case, devlink port query may read stale netdev attributes.
Fix it by reading them under rtnl lock.
Fixes bfcd3a466172 ("Introduce devlink infrastructure")Signed-off-by Parav Pandit <[email protected]>--- net/core/devlink.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)net/core/devlink.c +0
-0@@ -775,6 +775,23 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *porreturn err; }
net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por · line 787
Quoted 10 lines
net/core/devlink.c +10
-0+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; + +ASSERT_RTNL (); +if (!netdev) +return 0 ; + + err =nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , netdev->ifindex);
The line wrapping was correct, please keep in under 80. Please tell your colleges at Mellanox.
net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por · line 789
Quoted 2 lines
net/core/devlink.c +2
-0+if (err) + goto done;
return err;
net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por · line 790
Quoted 1 line
net/core/devlink.c +1
-0+ err =nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , netdev->name);
return nla_put_...
Quoted 17 lines
net/core/devlink.c +6
-0+done: +return err; +} + static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_port *devlink_port, enum devlink_command cmd, u32 portid,@@ -792,6 +809,8 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,if (nla_put_u32 (msg,DEVLINK_ATTR_PORT_INDEX , devlink_port->index)) goto nla_put_failure; +/* Hold rtnl lock while accessing port's netdev attributes. */ +rtnl_lock ();spin_lock_bh (&devlink_port->type_lock);if (nla_put_u16 (msg,DEVLINK_ATTR_PORT_TYPE , devlink_port->type)) goto nla_put_failure_type_locked;
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 822
Quoted 5 lines
net/core/devlink.c +1
-1@@ -800,13 +819,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_device *netdev = devlink_port->type_dev; +int err;
What's the point of this local variable?
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 825
Quoted 7 lines
net/core/devlink.c +2
-5-if (netdev && - (nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , - netdev->ifindex) || -nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , - netdev->name))) + err =devlink_nl_port_netdev_fill (msg, devlink_port); +if (err)
just put the call in the if ()
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 828
Quoted 3 lines
net/core/devlink.c +0
-0goto nla_put_failure_type_locked; }if (devlink_port->type ==DEVLINK_PORT_TYPE_IB ) {
Honestly this patch is doing too much for a fix.
All you need is the RTNL lock and then add:
+ struct net *net = devlink_net(devlink_port->devlink);
struct net_device *netdev = devlink_port->type_dev;
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,You can do refactoring later in net-next. Maybe even add a check that drivers which support reload set namespace local on their netdevs.
RE: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 78 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, November 25, 2020 3:59 AMnet/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff
Quoted 23 lines · On Sun, 22 Nov 2020 08:12:56 +0200 Parav Pandit wrote:
A netdevice of a devlink port can be moved to different net namespace than its parent devlink instance.
This scenario occurs when devlink reload is not used for maintaining backward compatibility.When netdevice is undergoing migration to net namespace, its ifindex and name may change.
In such use case, devlink port query may read stale netdev attributes.
Fix it by reading them under rtnl lock.
Fixes bfcd3a466172 ("Introduce devlink infrastructure")Signed-off-by Parav Pandit <[email protected]>--- net/core/devlink.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)net/core/devlink.c index renamed from net/core/devlink.c +0
-0
acc29d5157f4..6135ef5972ce100644net/core/devlink.c +0
-0@@ -775,6 +775,23 @@ devlink_nl_port_function_attrs_put(struct sk_buff*msg, struct
devlink_port*porQuoted 4 lines
net/core/devlink.c +1
-0return err; } +static int devlink_nl_port_netdev_fill(struct sk_buff *msg, structnet/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por
Quoted 10 lines
net/core/devlink.c +10
-0+devlink_port *devlink_port) { +struct net_device *netdev = devlink_port->type_dev; +int err; + +ASSERT_RTNL (); +if (!netdev) +return 0 ; + + err =nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , +netdev->ifindex);The line wrapping was correct, please keep in under 80. Please tell your colleges at Mellanox.
net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por · line 789
Quoted 2 lines
net/core/devlink.c +2
-0+if (err) + goto done;return err;net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff · line 792
Quoted 2 lines
net/core/devlink.c +2
-0+ err =nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , +netdev->name);return nla_put_...net/core/devlink.c devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *por
Quoted 7 lines
net/core/devlink.c +4
-0+done: +return err; +} + static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_port *devlink_port, enum devlink_command cmd, u32 portid, @@ -792,6 +809,8 @@ static
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg,
Quoted 11 lines
int devlink_nl_port_fill(struct
sk_buff*msg, struct devlink *devlink,
if (nla_put_u32(msg,DEVLINK_ATTR_PORT_INDEX, devlink_port-
index))net/core/devlink.c +2
-0goto nla_put_failure; +/* Hold rtnl lock while accessing port's netdev attributes. */ +rtnl_lock ();spin_lock_bh (&devlink_port->type_lock);if (nla_put_u16 (msg,DEVLINK_ATTR_PORT_TYPE , devlink_port->type)) goto nla_put_failure_type_locked;@@ -800,13 +819,10 @@ static int devlink_nl_port_fill(struct sk_buff *msg,struct devlink *devlink,
Quoted 8 lines
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 822
Quoted 5 lines
net/core/devlink.c +1
-1devlink_port->desired_type)) goto nla_put_failure_type_locked;if (devlink_port->type ==DEVLINK_PORT_TYPE_ETH ) { -struct net_device *netdev = devlink_port->type_dev; +int err;What's the point of this local variable?
I will avoid refactor for now, so above comment doesn't need to be addressed.
Quoted 9 lines
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 825
Quoted 7 lines
net/core/devlink.c +2
-5-if (netdev && - (nla_put_u32 (msg,DEVLINK_ATTR_PORT_NETDEV_IFINDEX , - netdev->ifindex) || -nla_put_string (msg,DEVLINK_ATTR_PORT_NETDEV_NAME , - netdev->name))) + err =devlink_nl_port_netdev_fill (msg, devlink_port); +if (err)just put the call in the if ()
Ok.
Quoted 10 lines
net/core/devlink.c static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, · line 828
Quoted 4 lines
net/core/devlink.c +0
-0goto nla_put_failure_type_locked; }if (devlink_port->type ==DEVLINK_PORT_TYPE_IB ) {Honestly this patch is doing too much for a fix.
All you need is the RTNL lock and then add:
Ok. I will differ the refactor to later point.
Quoted 10 lines
(quoted diff) +2
-0+ struct net *net = devlink_net(devlink_port->devlink); struct net_device *netdev = devlink_port->type_dev; 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,
Quoted 2 lines
You can do refactoring later in net-next. Maybe even add a check that drivers which support reload set namespace local on their netdevs.
This will break the backward compatibility as orchestration for VFs are not using devlink reload, which is supported very recently.
But yes, for SF who doesn't have backward compatibility issue, as soon as initial series is merged, I will mark it as local, so that orchestration doesn't start on wrong foot.
Jakub Kicinski
maintainerRe: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 7 lines · On Wed, 25 Nov 2020 07:13:40 +0000 Parav Pandit wrote:
Quoted 2 lines
Maybe even add a check that drivers
which support reload set namespace local on their netdevs.This will break the backward compatibility as orchestration for VFs are not using devlink reload, which is supported very recently. But yes, for SF who doesn't have backward compatibility issue, as soon as initial series is merged, I will mark it as local, so that orchestration doesn't start on wrong foot.
Ah, right, that will not work because of the shenanigans you guys play with the uplink port. If all reprs are NETNS_LOCAL it'd not be an issue.
RE: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 8 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, November 25, 2020 10:00 PMQuoted 2 lines · On Wed, 25 Nov 2020 07:13:40 +0000 Parav Pandit wrote:
Quoted 2 lines
Maybe even add a check that drivers
which support reload set namespace local on their netdevs.
Quoted 8 lines
Quoted 5 lines
This will break the backward compatibility as orchestration for VFs are not using devlink reload, which is supported very recently. But yes, for SF who doesn't have backward compatibility issue, as soon as initial series is merged, I will mark it as local, so that orchestration doesn't start on wrong foot.
Ah, right, that will not work because of the shenanigans you guys play with the uplink port. If all reprs are
NETNS_LOCALit'd not be an issue.
I am not sure what secret are you talking about with uplink.
I am taking about the SF netdevice to have the NETNS_LOCAL not the SF rep. SF rep anyway has NETNS_LOCAL set.
I do not follow your comment - 'that will not work'. Can you please explain?
Do you mean I should take care for SF's netdevice to have NETNS_LOCAL in first patchset or you mean setting NETNS_LOCAL for VF's Netdev will not work? If its later, sure it will break the backward compatibility, so will not do as default.
But yes, SF I want to subsequently.
Jakub Kicinski
maintainerRe: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 12 lines · On Wed, 25 Nov 2020 17:21:41 +0000 Parav Pandit wrote:
Quoted 12 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, November 25, 2020 10:00 PMQuoted 7 lines · On Wed, 25 Nov 2020 07:13:40 +0000 Parav Pandit wrote:
Quoted 2 lines
Maybe even add a check that drivers
which support reload set namespace local on their netdevs.This will break the backward compatibility as orchestration for VFs are not using devlink reload, which is supported very recently. But yes, for SF who doesn't have backward compatibility issue, as soon as initial series is merged, I will mark it as local, so that orchestration doesn't start on wrong foot.
Quoted 3 lines
Quoted 2 lines
Ah, right, that will not work because of the shenanigans you guys play with the uplink port. If all reprs are
NETNS_LOCALit'd not be an issue.I am not sure what secret are you talking about with uplink.
I'm referring to Mellanox conflating PF with uplink. It's not a secret, we argued about it in the past.
Quoted 2 lines
I am taking about the SF netdevice to have the
NETNS_LOCALnot the SF rep. SF rep anyway hasNETNS_LOCALset.
All reps build by mlx5e_build_rep_netdev() have NETNS_LOCAL.
Quoted 1 line
I do not follow your comment - 'that will not work'. Can you please explain?
My half-baked suggestion was to basically add a:
WARN_ON(ops->reload_down && ops->reload_up && !(netdev->priv & NETIF_F_NETNS_LOCAL));
to devlink_port_type_netdev_checks(). Given if device has a reload callback devlink is the way to change netns. But yeah, we can't break existing behavior so your uplink has to be movable and can't have NETNS_LOCAL. IOW adding the WARN_ON() won't work.
Hope this is crystal clear now.
Quoted 2 lines
Do you mean I should take care for SF's netdevice to have
NETNS_LOCALin first patchset or you mean settingNETNS_LOCALfor VF's Netdev will not work? If its later, sure it will break the backward compatibility, so will not do as default.
RE: [PATCH net 1/2] devlink: Hold rtnl lock while reading netdev attributes
Quoted 18 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, November 25, 2020 11:12 PMQuoted 12 lines · On Wed, 25 Nov 2020 17:21:41 +0000 Parav Pandit wrote:
Quoted 12 lines
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, November 25, 2020 10:00 PMQuoted 7 lines · On Wed, 25 Nov 2020 07:13:40 +0000 Parav Pandit wrote:
Quoted 2 lines
Maybe even add a check that drivers which support reload set namespace local on their netdevs.
This will break the backward compatibility as orchestration for VFs are not using devlink reload, which is supported very recently. But yes, for SF who doesn't have backward compatibility issue, as soon as initial series is merged, I will mark it as local, so that orchestration doesn't start on wrong foot.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Ah, right, that will not work because of the shenanigans you guys play with the uplink port. If all reprs are
NETNS_LOCALit'd not be anissue.
Quoted 1 line
I am not sure what secret are you talking about with uplink.
I'm referring to Mellanox conflating PF with uplink. It's not a secret,
Ok.
Quoted 8 lines
we argued about it in the past.
Quoted 1 line
I am taking about the SF netdevice to have the
NETNS_LOCALnot the SFrep.
Quoted 1 line
SF rep anyway has
NETNS_LOCALset.All reps build by
mlx5e_build_rep_netdev()haveNETNS_LOCAL.
Yes. this is clear to me and we are good here. 😊
Quoted 4 lines
Quoted 1 line
I do not follow your comment - 'that will not work'. Can you please explain?
My half-baked suggestion was to basically add a:
Quoted 8 lines
WARN_ON(ops->reload_down && ops->reload_up && !(netdev->priv & NETIF_F_NETNS_LOCAL));to
devlink_port_type_netdev_checks(). Given if device has a reload callback devlink is the way to change netns. But yeah, we can't break existing behavior so your uplink has to be movable and can't haveNETNS_LOCAL. IOW adding theWARN_ON()won't work.
Right.
Quoted 1 line
Hope this is crystal clear now.
Yes, its clear. Thanks.
I addressed your comments and cut down both the fixes to merely 7 lines change. Sent v2.
PATCH 2/2 devlink: Make sure devlink instance and port are in same net namespace
In reply to Parav PanditWhen 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.
--- net/core/devlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/devlink.c +4 -1
@@ -778,12 +778,15 @@ devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *porstatic 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;
Signature · 1 line
2.26.2
v2 cover devlink port attribute fixes
This patchset contains 2 small fixes for devlink port attributes.
Patch summary:
Patch-1 synchronize the devlink port attribute reader
with net namespace change operation
Patch-2 Ensure to return devlink port's netdevice attributes
when netdev and devlink instance belong to same net namespace
---
Changelog:v1->v2:
- avoided refactoring the port fill attribute routine
Parav Pandit (2):
devlink: Hold rtnl lock while reading netdev attributes
devlink: Make sure devlink instance and port are in same net namespace
net/core/devlink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
PATCH v2 1/2 devlink: Hold rtnl lock while reading netdev attributes
A netdevice of a devlink port can be moved to different net namespace than its parent devlink instance.
This scenario occurs when devlink reload is not used.
When netdevice is undergoing migration to net namespace, its ifindex and name may change.
In such use case, devlink port query may read stale netdev attributes.
Fix it by reading them under rtnl lock.
---
Changelog:v1->v2:
- avoided refactoring the code
- updated commit log
--- net/core/devlink.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/devlink.c +4 -0
@@ -792,6 +792,8 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,if (nla_put_u32 (msg,DEVLINK_ATTR_PORT_INDEX , devlink_port->index)) goto nla_put_failure; +/* Hold rtnl lock while accessing port's netdev attributes. */ +rtnl_lock ();spin_lock_bh (&devlink_port->type_lock);if (nla_put_u16 (msg,DEVLINK_ATTR_PORT_TYPE , devlink_port->type)) goto nla_put_failure_type_locked;
@@ -818,6 +820,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, goto nla_put_failure_type_locked; }spin_unlock_bh (&devlink_port->type_lock); +rtnl_unlock ();if (devlink_nl_port_attrs_put (msg, devlink_port)) goto nla_put_failure;if (devlink_nl_port_function_attrs_put (msg, devlink_port, extack))
@@ -828,6 +831,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, nla_put_failure_type_locked:spin_unlock_bh (&devlink_port->type_lock); +rtnl_unlock (); nla_put_failure:genlmsg_cancel (msg, hdr);return -EMSGSIZE ;
Signature · 1 line
2.26.2
PATCH v2 2/2 devlink: Make sure devlink instance and port are in same net namespace
In reply to Parav PanditWhen 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.
---
Changelog:v1->v2:
- avoided refactor code from previous patch
--- net/core/devlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/devlink.c +2 -1
@@ -802,9 +802,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,
Signature · 1 line
2.26.2
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 9 lines · On Wed, 25 Nov 2020 11:16:18 +0200 you wrote:
This patchset contains 2 small fixes for devlink port attributes.
Patch summary:
Patch-1 synchronize the devlink port attribute reader
with net namespace change operation
Patch-2 Ensure to return devlink port's netdevice attributes
when netdev and devlink instance belong to same net namespace[...]
Here is the summary with links:
- [net,v2,1/2] devlink: Hold rtnl lock while reading netdev attributes
https://git.kernel.org/netdev/net/c/b187c9b4178b - [net,v2,2/2] devlink: Make sure devlink instance and port are in same net namespace https://git.kernel.org/netdev/net/c/a7b43649507d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html