Skip to contentSkip to conversation

RDMA/rxe: prevent rxe creation on top of vlan interface

PATCH Applied Mohammad Heib 3 participants 5 messages Aug 11, 2020 – Aug 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/rxe: prevent rxe creation on top of vlan interface

Creating rxe device on top of vlan interface will create a non-functional device that has an empty gids table and can't be used for rdma cm communication.

This is caused by the logic in enum_all_gids_of_dev_cb()/is_eth_port_of_netdev(), which only considers networks connected to "upper devices" of the configured network device, resulting in an empty set of gids for a vlan interface, and attempts to connect via this rdma device fail in cm_init_av_for_response because no gids can be resolved.

apparently, this behavior was implemented to fit the HW-RoCE devices that create RoCE device per port, therefore RXE must behave the same like HW-RoCE devices and create rxe device per real device only.

In order to communicate via a vlan interface, the user must use the gid index of the vlan address instead of creating rxe over vlan.

---
 drivers/infiniband/sw/rxe/rxe.c       | 6 ++++++
 drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++++++
 2 files changed, 12 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +6 -0
index 5642eefb4ba1..d2076aa7a732 100644
@@ -310,6 +310,12 @@ static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)
 	struct rxe_dev *exists;
 	int err = 0;
 
+	if (is_vlan_dev(ndev)) {
+		pr_err("rxe creation allowed on top of a real device only\n");
+		err = -EPERM;
+		goto err;
+	}
+
 	exists = rxe_get_dev_from_net(ndev);
 	if (exists) {
 		ib_device_put(&exists->ib_dev);
drivers/infiniband/sw/rxe/rxe_sysfs.c +6 -0
index ccda5f5a3bc0..0a083c3d900a 100644
@@ -73,6 +73,12 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
 		return -EINVAL;
 	}
 
+	if (is_vlan_dev(ndev)) {
+		pr_err("rxe creation allowed on top of a real device only\n");
+		err = -EPERM;
+		goto err;
+	}
+
 	exists = rxe_get_dev_from_net(ndev);
 	if (exists) {
 		ib_device_put(&exists->ib_dev);
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 2 lines · Mohammad Heib

Creating rxe device on top of vlan interface will create a non-functional device that has an empty gids table and can't be used for rdma cm communication.

Can we fix this empty gids table?

So this gids table can be used for rdma cm communication.

Zhu Yanjun

Quoted 54 lines

This is caused by the logic in enum_all_gids_of_dev_cb()/is_eth_port_of_netdev(), which only considers networks connected to "upper devices" of the configured network device, resulting in an empty set of gids for a vlan interface, and attempts to connect via this rdma device fail in cm_init_av_for_response because no gids can be resolved.

apparently, this behavior was implemented to fit the HW-RoCE devices that create RoCE device per port, therefore RXE must behave the same like HW-RoCE devices and create rxe device per real device only.

In order to communicate via a vlan interface, the user must use the gid index of the vlan address instead of creating rxe over vlan.

---
  drivers/infiniband/sw/rxe/rxe.c       | 6 ++++++
  drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++++++
  2 files changed, 12 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +6 -0
index 5642eefb4ba1..d2076aa7a732 100644
@@ -310,6 +310,12 @@ static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)
  	struct rxe_dev *exists;
  	int err = 0;
 
+	if (is_vlan_dev(ndev)) {
+		pr_err("rxe creation allowed on top of a real device only\n");
+		err = -EPERM;
+		goto err;
+	}
+
  	exists = rxe_get_dev_from_net(ndev);
  	if (exists) {
  		ib_device_put(&exists->ib_dev);
drivers/infiniband/sw/rxe/rxe_sysfs.c +6 -0
index ccda5f5a3bc0..0a083c3d900a 100644
@@ -73,6 +73,12 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
  		return -EINVAL;
  	}
 
+	if (is_vlan_dev(ndev)) {
+		pr_err("rxe creation allowed on top of a real device only\n");
+		err = -EPERM;
+		goto err;
+	}
+
  	exists = rxe_get_dev_from_net(ndev);
  	if (exists) {
  		ib_device_put(&exists->ib_dev);
author
#2 lore raw
Quoted 5 lines · Zhu Yanjun
Quoted 2 lines · Mohammad Heib

Creating rxe device on top of vlan interface will create a non-functional device that has an empty gids table and can't be used for rdma cm communication.

Can we fix this empty gids table?

I'm not sure if that can be done in the rxe only, since the IP's of the netdev enrolls into

the gids table by the ibcore in the device registration stage(gid_table_setup_one) and that requires making changes in the ibcore.

we can enroll those IP's into the device gids table after the rxe device registration but still

we have to expose some ibcore functions (add_netdev_ips) and track the address change events of the

vlan interface and update the gids table accordingly to those IP's changes.

Quoted 61 lines

So this gids table can be used for rdma cm communication.

Zhu Yanjun

Quoted 54 lines

This is caused by the logic in enum_all_gids_of_dev_cb()/is_eth_port_of_netdev(), which only considers networks connected to "upper devices" of the configured network device, resulting in an empty set of gids for a vlan interface, and attempts to connect via this rdma device fail in cm_init_av_for_response because no gids can be resolved.

apparently, this behavior was implemented to fit the HW-RoCE devices that create RoCE device per port, therefore RXE must behave the same like HW-RoCE devices and create rxe device per real device only.

In order to communicate via a vlan interface, the user must use the gid index of the vlan address instead of creating rxe over vlan.

---
  drivers/infiniband/sw/rxe/rxe.c       | 6 ++++++ drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++++++

  2 files changed, 12 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +5 -0
index 5642eefb4ba1..d2076aa7a732 100644
@@ -310,6 +310,12 @@ static int rxe_newlink(const char *ibdev_name, 
 struct net_device *ndev)
       struct rxe_dev *exists;
       int err = 0;
   +    if (is_vlan_dev(ndev)) {
+        pr_err("rxe creation allowed on top of a real device only\n");
+        err = -EPERM;
+        goto err;
+    }
+
       exists = rxe_get_dev_from_net(ndev);
       if (exists) {

          ib_device_put(&exists->ib_dev);

drivers/infiniband/sw/rxe/rxe_sysfs.c +5 -0
index ccda5f5a3bc0..0a083c3d900a 100644
@@ -73,6 +73,12 @@ static int rxe_param_set_add(const char *val, 
 const struct kernel_param *kp)
           return -EINVAL;
       }
   +    if (is_vlan_dev(ndev)) {
+        pr_err("rxe creation allowed on top of a real device only\n");
+        err = -EPERM;
+        goto err;
+    }
+
       exists = rxe_get_dev_from_net(ndev);
       if (exists) {

          ib_device_put(&exists->ib_dev);

maintainer
#3 lore raw
Quoted 10 lines · mohammad
Quoted 5 lines · Zhu Yanjun
Quoted 2 lines · Mohammad Heib

Creating rxe device on top of vlan interface will create a non-functional device that has an empty gids table and can't be used for rdma cm communication.

Can we fix this empty gids table?

I'm not sure if that can be done in the rxe only, since the IP's of the netdev enrolls into

Quoted 8 lines

the gids table by the ibcore in the device registration stage(gid_table_setup_one) and that requires making changes in the ibcore.

we can enroll those IP's into the device gids table after the rxe device registration but still

we have to expose some ibcore functions (add_netdev_ips) and track the address change events of the

vlan interface and update the gids table accordingly to those IP's changes.

Thanks a lot for your explanations.

Not sure if a patch containing the above is better than just preventing rxe creation on top of vlan interface.

Zhu Yanjun

Quoted 62 lines
Quoted 62 lines

So this gids table can be used for rdma cm communication.

Zhu Yanjun

Quoted 54 lines

This is caused by the logic in enum_all_gids_of_dev_cb()/is_eth_port_of_netdev(), which only considers networks connected to "upper devices" of the configured network device, resulting in an empty set of gids for a vlan interface, and attempts to connect via this rdma device fail in cm_init_av_for_response because no gids can be resolved.

apparently, this behavior was implemented to fit the HW-RoCE devices that create RoCE device per port, therefore RXE must behave the same like HW-RoCE devices and create rxe device per real device only.

In order to communicate via a vlan interface, the user must use the gid index of the vlan address instead of creating rxe over vlan.

---
  drivers/infiniband/sw/rxe/rxe.c       | 6 ++++++ drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++++++

  2 files changed, 12 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +5 -0
index 5642eefb4ba1..d2076aa7a732 100644
@@ -310,6 +310,12 @@ static int rxe_newlink(const char *ibdev_name, 
 struct net_device *ndev)
       struct rxe_dev *exists;
       int err = 0;
   +    if (is_vlan_dev(ndev)) {
+        pr_err("rxe creation allowed on top of a real device only\n");
+        err = -EPERM;
+        goto err;
+    }
+
       exists = rxe_get_dev_from_net(ndev);
       if (exists) {

          ib_device_put(&exists->ib_dev);

drivers/infiniband/sw/rxe/rxe_sysfs.c +5 -0
index ccda5f5a3bc0..0a083c3d900a 100644
@@ -73,6 +73,12 @@ static int rxe_param_set_add(const char *val, 
 const struct kernel_param *kp)
           return -EINVAL;
       }
   +    if (is_vlan_dev(ndev)) {
+        pr_err("rxe creation allowed on top of a real device only\n");
+        err = -EPERM;
+        goto err;
+    }
+
       exists = rxe_get_dev_from_net(ndev);
       if (exists) {

          ib_device_put(&exists->ib_dev);

maintainer Applied
#4 lore raw
In reply to Mohammad Heib
Quoted 13 lines · Mohammad Heib

Creating rxe device on top of vlan interface will create a non-functional device that has an empty gids table and can't be used for rdma cm communication.

This is caused by the logic in enum_all_gids_of_dev_cb()/is_eth_port_of_netdev(), which only considers networks connected to "upper devices" of the configured network device, resulting in an empty set of gids for a vlan interface, and attempts to connect via this rdma device fail in cm_init_av_for_response because no gids can be resolved.

apparently, this behavior was implemented to fit the HW-RoCE devices that create RoCE device per port, therefore RXE must behave the same like HW-RoCE devices and create rxe device per real device only.

Quoted 8 lines

In order to communicate via a vlan interface, the user must use the gid index of the vlan address instead of creating rxe over vlan.

---
 drivers/infiniband/sw/rxe/rxe.c       | 6 ++++++
 drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++++++
 2 files changed, 12 insertions(+)

It would be better to somehow fix things so the gid table was properly populated, but until that is done, blocking it is a reasonable thing to do.

Applied to for-next, thanks

Jason