RDMA/ipoib: Set rtnl_link_ops for ipoib interfaces
PATCH v2 1/1 RDMA/ipoib: Set rtnl_link_ops for ipoib interfaces
To avoid inconsistent user experience for PKey interfaces that are created via netlink vs PKey interfaces that are created via sysfs and the base interface, make sure to set the rtnl_link_ops for all ipoib network devices, so the ipoib attributes will be reported/modified via iproute2 for all ipoib interfaces regardless of how they are created.
Also, after setting the rtnl_link_ops for the base interface, implement the dellink() callback to block users from trying to remove it.
---
v2: Update commit message.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +2 -0
@@ -2477,6 +2477,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy); + ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);if (result) { pr_warn("%s: couldn't register ipoib port %d; error %d\n",
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +11 -0
@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,return 0 ; } +static void ipoib_del_child_link (struct net_device *dev,struct list_head *head) +{ +struct ipoib_dev_priv *priv =ipoib_priv (dev); + +if (!priv->parent) +return ; + +unregister_netdevice_queue (dev, head); +} +static size_t ipoib_get_size (const struct net_device *dev) { return nla_total_size(2) + /* IFLA_IPOIB_PKEY */
@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2 -0
@@ -129,6 +129,8 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, goto out_early; } + ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdevice (ndev);if (result) {ipoib_warn (priv,"failed to initialize; error %i" , result);
Signature · 1 line
2.26.2
Jason Gunthorpe
maintainerQuoted 21 lines · Kamal Heib
To avoid inconsistent user experience for PKey interfaces that are created via netlink vs PKey interfaces that are created via sysfs and the base interface, make sure to set the
rtnl_link_opsfor all ipoib network devices, so the ipoib attributes will be reported/modified via iproute2 for all ipoib interfaces regardless of how they are created.Also, after setting the
rtnl_link_opsfor the base interface, implement thedellink()callback to block users from trying to remove it.Fixes 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")Signed-off-by Kamal Heib <[email protected]>v2: Update commit message.
drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_main.c static struct net_device *ipoib_add_port(const char *format, · line 2482
Quoted 6 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +2
-0@@ -2477,6 +2477,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy); + ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);
Why do we need this one? I understand fixing the sysfs but not this part.
Quoted 8 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +0
-0if (result) { pr_warn("%s: couldn't register ipoib port %d; error %d\n",drivers/infiniband/ulp/ipoib/ipoib_netlink.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,return 0 ; }
drivers/infiniband/ulp/ipoib/ipoib_netlink.c static int ipoib_new_child_link(struct net *src_net, struct net_device *dev, · line 155
Quoted 10 lines
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +9
-0+static void ipoib_del_child_link (struct net_device *dev,struct list_head *head) +{ +struct ipoib_dev_priv *priv =ipoib_priv (dev); + +if (!priv->parent) +return ; + +unregister_netdevice_queue (dev, head); +}
The above is why this hunk was added right?
Quoted 15 lines
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +1
-0static size_t ipoib_get_size (const struct net_device *dev) { return nla_total_size(2) + /* IFLA_IPOIB_PKEY */@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,drivers/infiniband/ulp/ipoib/ipoib_vlan.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
drivers/infiniband/ulp/ipoib/ipoib_vlan.c int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, · line 133
Quoted 5 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2
-0@@ -129,6 +129,8 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, goto out_early; } + ndev->rtnl_link_ops =ipoib_get_link_ops (); +
If this is only for the sysfs case why isn't it in ipoib_vlan_add() which is the sysfs only flow?
Jason
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Kamal Heib
To avoid inconsistent user experience for PKey interfaces that are created via netlink vs PKey interfaces that are created via sysfs and the base interface, make sure to set the
rtnl_link_opsfor all ipoib network devices, so the ipoib attributes will be reported/modified via iproute2 for all ipoib interfaces regardless of how they are created.Also, after setting the
rtnl_link_opsfor the base interface, implement thedellink()callback to block users from trying to remove it.Fixes 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")Signed-off-by Kamal Heib <[email protected]>v2: Update commit message.
drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c@@ -2477,6 +2477,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy);
Quoted 6 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c static struct net_device *ipoib_add_port(const char *format, · line 2482
Quoted 3 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);Why do we need this one? I understand fixing the sysfs but not this part.
We need this one to report/modify the ipoib attributes for the parent interface (please take a look at pkey, mode, and umcast after applying this patch):
$ ip -d link show dev mlx5_ib0
29: mlx5_ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2044 qdisc mq state UP mode DEFAULT group default qlen 256
link/infiniband 00:00:1f:e4:fe:80:00:00:00:00:00:00:24:8a:07:03:00:a3:19:64 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65520
ipoib pkey 0xffff mode datagram umcast 0000 addrgenmode none numtxqueues 256 numrxqueues 32 gso_max_size 65536 gso_max_segs 65535Quoted 9 lines
Quoted 9 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +0
-0if (result) { pr_warn("%s: couldn't register ipoib port %d; error %d\n",drivers/infiniband/ulp/ipoib/ipoib_netlink.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,return 0 ; }
Quoted 11 lines
drivers/infiniband/ulp/ipoib/ipoib_netlink.c static int ipoib_new_child_link(struct net *src_net, struct net_device *dev, · line 155
Quoted 9 lines
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +9
-0+static void ipoib_del_child_link (struct net_device *dev,struct list_head *head) +{ +struct ipoib_dev_priv *priv =ipoib_priv (dev); + +if (!priv->parent) +return ; + +unregister_netdevice_queue (dev, head); +}The above is why this hunk was added right?
This hunk was added to block users from trying to remove the parent interface.
Quoted 19 lines
Quoted 19 lines
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +1
-0static size_t ipoib_get_size (const struct net_device *dev) { return nla_total_size(2) + /* IFLA_IPOIB_PKEY */@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,drivers/infiniband/ulp/ipoib/ipoib_vlan.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c@@ -129,6 +129,8 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, goto out_early; }
Quoted 6 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, · line 133
Quoted 2 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); +If this is only for the sysfs case why isn't it in
ipoib_vlan_add()which is the sysfs only flow?
Basically, I was making sure set the rtnl_link_ops before calling register_netdevice(), but you are right this can be moved to the ipoib_vlan_add() as the setting of the rtnl_link_ops for pkey that is created via netlink is done before calling newlink callback, I'll send a v3 that move it to ipoib_vlan_add().
Thanks,
Kamal
Quoted 1 line
Jason
Jason Gunthorpe
maintainerQuoted 32 lines · Kamal Heib
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Kamal Heib
To avoid inconsistent user experience for PKey interfaces that are created via netlink vs PKey interfaces that are created via sysfs and the base interface, make sure to set the
rtnl_link_opsfor all ipoib network devices, so the ipoib attributes will be reported/modified via iproute2 for all ipoib interfaces regardless of how they are created.Also, after setting the
rtnl_link_opsfor the base interface, implement thedellink()callback to block users from trying to remove it.Fixes 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")Signed-off-by Kamal Heib <[email protected]>v2: Update commit message.
drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c@@ -2477,6 +2477,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy);Quoted 5 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c static struct net_device *ipoib_add_port(const char *format, · line 2482
Quoted 3 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);Why do we need this one? I understand fixing the sysfs but not this part.
Quoted 8 lines
We need this one to report/modify the ipoib attributes for the parent interface (please take a look at pkey, mode, and umcast after applying this patch):
$ ip -d link show dev mlx5_ib0 29: mlx5_ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2044 qdisc mq state UP mode DEFAULT group default qlen 256 link/infiniband 00:00:1f:e4:fe:80:00:00:00:00:00:00:24:8a:07:03:00:a3:19:64 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65520 ipoib pkey 0xffff mode datagram umcast 0000 addrgenmode none numtxqueues 256 numrxqueues 32 gso_max_size 65536 gso_max_segs 65535
So this is what you mean by "base interface" ? Hmm OK. Highlight this a bit more in the commit message since this is something everyone will see
Quoted 25 lines
Quoted 18 lines
Quoted 18 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +0
-0static size_t ipoib_get_size (const struct net_device *dev) {drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0return nla_total_size(2) + /* IFLA_IPOIB_PKEY */@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,drivers/infiniband/ulp/ipoib/ipoib_vlan.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c@@ -129,6 +129,8 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, goto out_early; }Quoted 6 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, · line 133
Quoted 2 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); +If this is only for the sysfs case why isn't it in
ipoib_vlan_add()which is the sysfs only flow?
Quoted 5 lines
Basically, I was making sure set the
rtnl_link_opsbefore callingregister_netdevice(), but you are right this can be moved to theipoib_vlan_add()as the setting of thertnl_link_opsfor pkey that is created via netlink is done before calling newlink callback, I'll send a v3 that move it toipoib_vlan_add().
Please
Jason
Quoted 37 lines · Jason Gunthorpe
Quoted 36 lines · Kamal Heib
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Kamal Heib
To avoid inconsistent user experience for PKey interfaces that are created via netlink vs PKey interfaces that are created via sysfs and the base interface, make sure to set the
rtnl_link_opsfor all ipoib network devices, so the ipoib attributes will be reported/modified via iproute2 for all ipoib interfaces regardless of how they are created.Also, after setting the
rtnl_link_opsfor the base interface, implement thedellink()callback to block users from trying to remove it.Fixes 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")Signed-off-by Kamal Heib <[email protected]>v2: Update commit message.
drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c@@ -2477,6 +2477,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy);Quoted 5 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c static struct net_device *ipoib_add_port(const char *format, · line 2482
Quoted 3 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);Why do we need this one? I understand fixing the sysfs but not this part.
We need this one to report/modify the ipoib attributes for the parent interface (please take a look at pkey, mode, and umcast after applying this patch):
Quoted 9 lines
Quoted 4 lines
$ ip -d link show dev mlx5_ib0 29: mlx5_ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2044 qdisc mq state UP mode DEFAULT group default qlen 256 link/infiniband 00:00:1f:e4:fe:80:00:00:00:00:00:00:24:8a:07:03:00:a3:19:64 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65520 ipoib pkey 0xffff mode datagram umcast 0000 addrgenmode none numtxqueues 256 numrxqueues 32 gso_max_size 65536 gso_max_segs 65535So this is what you mean by "base interface" ? Hmm OK. Highlight this a bit more in the commit message since this is something everyone will see
Yes, correct.
I'll update the commit message.
Thanks,
Kamal
Quoted 34 lines
Quoted 25 lines
Quoted 18 lines
Quoted 18 lines
drivers/infiniband/ulp/ipoib/ipoib_main.c +0
-0static size_t ipoib_get_size (const struct net_device *dev) {drivers/infiniband/ulp/ipoib/ipoib_main.c +1
-0return nla_total_size(2) + /* IFLA_IPOIB_PKEY */@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,drivers/infiniband/ulp/ipoib/ipoib_vlan.c +1
-0+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c@@ -129,6 +129,8 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, goto out_early; }Quoted 6 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, · line 133
Quoted 2 lines
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2
-0+ ndev->rtnl_link_ops =ipoib_get_link_ops (); +If this is only for the sysfs case why isn't it in
ipoib_vlan_add()which is the sysfs only flow?Quoted 5 lines
Basically, I was making sure set the
rtnl_link_opsbefore callingregister_netdevice(), but you are right this can be moved to theipoib_vlan_add()as the setting of thertnl_link_opsfor pkey that is created via netlink is done before calling newlink callback, I'll send a v3 that move it toipoib_vlan_add().Please
Jason