Skip to contentSkip to conversation

RDMA/rxe: Fix failure during driver load

PATCH In review Kamal Heib 4 participants 11 messages Jun 1, 2021 – Jun 2, 2021

Subsystems (2)
lore
Share & tools
lore

Kamal Heib

author
#0 lore raw

PATCH 1/1 RDMA/rxe: Fix failure during driver load

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
---
 drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -6
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-						htons(ROCE_V2_UDP_DPORT), true);
-	if (IS_ERR(recv_sockets.sk6)) {
-		recv_sockets.sk6 = NULL;
-		pr_err("Failed to create IPv6 UDP tunnel\n");
-		return -1;
+	if (ipv6_mod_enabled()) {
+		recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+					htons(ROCE_V2_UDP_DPORT), true);
+		if (IS_ERR(recv_sockets.sk6)) {
+			recv_sockets.sk6 = NULL;
+			pr_err("Failed to create IPv6 UDP tunnel\n");
+			return -1;
+		}
 	}
 #endif
 	return 0;
Signature · 1 line
2.26.3
maintainer
#1 lore raw
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Quoted 35 lines
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
---
 drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -7
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-       recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-                                               htons(ROCE_V2_UDP_DPORT), true);
-       if (IS_ERR(recv_sockets.sk6)) {
-               recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
+       if (ipv6_mod_enabled()) {
+               recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+                                       htons(ROCE_V2_UDP_DPORT), true);
+               if (IS_ERR(recv_sockets.sk6)) {
+                       recv_sockets.sk6 = NULL;
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       return -1;
+               }
        }
 #endif
        return 0;
--

2.26.3

author
#2 lore raw
Quoted 10 lines · Zhu Yanjun
Quoted 5 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

Quoted 9 lines
Quoted 2 lines
$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Could you please review and ACK this patch?

Thanks,
Kamal

Quoted 35 lines
Quoted 35 lines
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")

---
drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------

1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -7
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-       recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-                                               htons(ROCE_V2_UDP_DPORT), true);
-       if (IS_ERR(recv_sockets.sk6)) {
-               recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
+       if (ipv6_mod_enabled()) {
+               recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+                                       htons(ROCE_V2_UDP_DPORT), true);
+               if (IS_ERR(recv_sockets.sk6)) {
+                       recv_sockets.sk6 = NULL;
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       return -1;
+               }
       }
 #endif
       return 0;
--

2.26.3

maintainer
#3 lore raw
Quoted 18 lines · kamal heib
Quoted 18 lines · Zhu Yanjun
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Quoted 6 lines
Quoted 2 lines

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Could you please review and ACK this patch?

https://www.spinics.net/lists/linux-rdma/msg100274.html
Compared with the above commit, are the following also needed?

(quoted diff) +0 -0

b/drivers/infiniband/sw/rxe/rxe_net.c
index 0701bd1ffd1a..6ef092cb575e 100644

drivers/infiniband/sw/rxe/rxe_net.c +0 -0
@@ -72,6 +72,11 @@ static struct dst_entry *rxe_find_route6(struct

net_device *ndev,

        struct dst_entry *ndst;
        struct flowi6 fl6 = { { 0 } };

+ if (!ipv6_mod_enabled()) {
+ pr_info("IPv6 is disabled by ipv6.disable=1 in cmdline");
+ return NULL;
+ }
+

        memset(&fl6, 0, sizeof(fl6));
        fl6.flowi6_oif = ndev->ifindex;
        memcpy(&fl6.saddr, saddr, sizeof(*saddr));

Zhu Yanjun

Quoted 40 lines

Thanks,
Kamal

Quoted 35 lines
Quoted 35 lines
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")

---
drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------

1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -7
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-       recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-                                               htons(ROCE_V2_UDP_DPORT), true);
-       if (IS_ERR(recv_sockets.sk6)) {
-               recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
+       if (ipv6_mod_enabled()) {
+               recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+                                       htons(ROCE_V2_UDP_DPORT), true);
+               if (IS_ERR(recv_sockets.sk6)) {
+                       recv_sockets.sk6 = NULL;
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       return -1;
+               }
       }
 #endif
       return 0;
--

2.26.3

author
#4 lore raw
Quoted 22 lines · Zhu Yanjun
Quoted 21 lines · kamal heib
Quoted 20 lines · Zhu Yanjun
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Quoted 7 lines
Quoted 3 lines

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Could you please review and ACK this patch?

https://www.spinics.net/lists/linux-rdma/msg100274.html
Compared with the above commit, are the following also needed?

I don't think so, because we aren't going to reach this function.

Do you know about a real bug that fails in this function?!

Thanks,
Kamal

Quoted 61 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
index 0701bd1ffd1a..6ef092cb575e 100644
@@ -72,6 +72,11 @@ static struct dst_entry *rxe_find_route6(struct
 net_device *ndev,
        struct dst_entry *ndst;
        struct flowi6 fl6 = { { 0 } };
 
+       if (!ipv6_mod_enabled()) {
+               pr_info("IPv6 is disabled by ipv6.disable=1 in cmdline");
+               return NULL;
+       }
+
        memset(&fl6, 0, sizeof(fl6));
        fl6.flowi6_oif = ndev->ifindex;
        memcpy(&fl6.saddr, saddr, sizeof(*saddr));

Zhu Yanjun

Quoted 40 lines

Thanks,
Kamal

Quoted 35 lines
Quoted 35 lines
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")

---
drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------

1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -7
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-       recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-                                               htons(ROCE_V2_UDP_DPORT), true);
-       if (IS_ERR(recv_sockets.sk6)) {
-               recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
+       if (ipv6_mod_enabled()) {
+               recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+                                       htons(ROCE_V2_UDP_DPORT), true);
+               if (IS_ERR(recv_sockets.sk6)) {
+                       recv_sockets.sk6 = NULL;
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       return -1;
+               }
       }
 #endif
       return 0;
--

2.26.3

maintainer
#5 lore raw
Quoted 17 lines · Kamal Heib
Quoted 15 lines · Zhu Yanjun
Quoted 14 lines · kamal heib
Quoted 14 lines · Zhu Yanjun
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Please check this link
https://lore.kernel.org/linux-rdma/[email protected]/T/
carefully.

Please pay attention to the comments from Jason Gunthorpe

Zhu Yanjun

Quoted 75 lines
Quoted 6 lines
Quoted 2 lines

Could you please review and ACK this patch?

https://www.spinics.net/lists/linux-rdma/msg100274.html
Compared with the above commit, are the following also needed?

I don't think so, because we aren't going to reach this function.

Do you know about a real bug that fails in this function?!

Thanks,
Kamal

Quoted 61 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
index 0701bd1ffd1a..6ef092cb575e 100644
@@ -72,6 +72,11 @@ static struct dst_entry *rxe_find_route6(struct
 net_device *ndev,
        struct dst_entry *ndst;
        struct flowi6 fl6 = { { 0 } };
 
+       if (!ipv6_mod_enabled()) {
+               pr_info("IPv6 is disabled by ipv6.disable=1 in cmdline");
+               return NULL;
+       }
+
        memset(&fl6, 0, sizeof(fl6));
        fl6.flowi6_oif = ndev->ifindex;
        memcpy(&fl6.saddr, saddr, sizeof(*saddr));

Zhu Yanjun

Quoted 40 lines

Thanks,
Kamal

Quoted 35 lines
Quoted 35 lines
Fixes dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")

---
drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------

1 file changed, 8 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_net.c +8 -7
index 01662727dca0..f353fc18769f 100644
@@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void)
 {
 #if IS_ENABLED(CONFIG_IPV6)
 
-       recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
-                                               htons(ROCE_V2_UDP_DPORT), true);
-       if (IS_ERR(recv_sockets.sk6)) {
-               recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
+       if (ipv6_mod_enabled()) {
+               recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
+                                       htons(ROCE_V2_UDP_DPORT), true);
+               if (IS_ERR(recv_sockets.sk6)) {
+                       recv_sockets.sk6 = NULL;
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       return -1;
+               }
       }
 #endif
       return 0;
--

2.26.3

#6 lore raw
Quoted 25 lines · Zhu Yanjun
Quoted 24 lines · Kamal Heib
Quoted 22 lines · Zhu Yanjun
Quoted 21 lines · kamal heib
Quoted 20 lines · Zhu Yanjun
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Please check this link
https://lore.kernel.org/linux-rdma/[email protected]/T/
carefully.

Please pay attention to the comments from Jason Gunthorpe

I think the comment still holds, the correct fix is to detect the -97 errno down in the call chain and just ignore ipv6 support in this case.

Jason

maintainer
#7 lore raw
Quoted 29 lines · Jason Gunthorpe
Quoted 27 lines · Zhu Yanjun
Quoted 25 lines · Kamal Heib
Quoted 23 lines · Zhu Yanjun
Quoted 22 lines · kamal heib
Quoted 11 lines · Zhu Yanjun
Quoted 5 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

Quoted 9 lines
Quoted 2 lines
$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Quoted 7 lines
Quoted 5 lines

Please check this link
https://lore.kernel.org/linux-rdma/[email protected]/T/
carefully.

Please pay attention to the comments from Jason Gunthorpe

I think the comment still holds, the correct fix is to detect the -97

Great! Thanks

Zhu Yanjun

Quoted 4 lines

errno down in the call chain and just ignore ipv6 support in this case.

Jason

author
#8 lore raw
In reply to Jason Gunthorpe
Quoted 32 lines · Jason Gunthorpe
Quoted 31 lines · Zhu Yanjun
Quoted 17 lines · Kamal Heib
Quoted 15 lines · Zhu Yanjun
Quoted 14 lines · kamal heib
Quoted 14 lines · Zhu Yanjun
Quoted 7 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Please check this link
https://lore.kernel.org/linux-rdma/[email protected]/T/
carefully.

Quoted 7 lines
Quoted 1 line

Please pay attention to the comments from Jason Gunthorpe

I think the comment still holds, the correct fix is to detect the -97 errno down in the call chain and just ignore ipv6 support in this case.

Jason

OK, Could you please tell me what do you think about the following:

drivers/infiniband/sw/rxe/rxe_net.c +5 -0
index 01662727dca0..144d9e1c1c3d 100644
@@ -208,6 +208,11 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port,
        /* Create UDP socket */
        err = udp_sock_create(net, &udp_cfg, &sock);
        if (err < 0) {
+               if (ipv6 && (err == -EAFNOSUPPORT)) {
+                       pr_warn("IPv6 is not supported can not create UDP socket\n");
+                       return NULL;
+               }
+
                pr_err("failed to create udp socket. err = %d\n", err);
                return ERR_PTR(err);
        }

Thanks,
Kamal

#9 lore raw
Quoted 40 lines · Kamal Heib
Quoted 26 lines · Jason Gunthorpe
Quoted 25 lines · Zhu Yanjun
Quoted 13 lines · Kamal Heib
Quoted 12 lines · Zhu Yanjun
Quoted 11 lines · kamal heib
Quoted 11 lines · Zhu Yanjun
Quoted 6 lines · Kamal Heib

To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel.

$ modprobe rdma_rxe
modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

About this problem, this link:
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
also tries to solve ipv6 problem.

Zhu Yanjun

Yes, but this patch is fixing the problem more cleanly and I’ve tested it.

Please check this link
https://lore.kernel.org/linux-rdma/[email protected]/T/
carefully.

Quoted 6 lines
Quoted 1 line

Please pay attention to the comments from Jason Gunthorpe

I think the comment still holds, the correct fix is to detect the -97 errno down in the call chain and just ignore ipv6 support in this case.

Jason

OK, Could you please tell me what do you think about the following:

drivers/infiniband/sw/rxe/rxe_net.c +0 -0
index 01662727dca0..144d9e1c1c3d 100644

drivers/infiniband/sw/rxe/rxe_net.c static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, · line 213

Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_net.c +3 -0
@@ -208,6 +208,11 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port,
         /* Create UDP socket */
         err = udp_sock_create(net, &udp_cfg, &sock);
         if (err < 0) {
+               if (ipv6 && (err == -EAFNOSUPPORT)) {
+                       pr_warn("IPv6 is not supported can not create UDP socket\n");
+                       return NULL;

The returned value is changed.

Zhu Yanjun

Quoted 9 lines
drivers/infiniband/sw/rxe/rxe_net.c +2 -0
+               }
+
                 pr_err("failed to create udp socket. err = %d\n", err);
                 return ERR_PTR(err);
         }

Thanks,
Kamal

#10 lore raw
In reply to Kamal Heib

drivers/infiniband/sw/rxe/rxe_net.c static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, · line 215

Quoted 12 lines · Kamal Heib
drivers/infiniband/sw/rxe/rxe_net.c +6 -0
index 01662727dca0..144d9e1c1c3d 100644
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -208,6 +208,11 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port,
        /* Create UDP socket */
        err = udp_sock_create(net, &udp_cfg, &sock);
        if (err < 0) {
+               if (ipv6 && (err == -EAFNOSUPPORT)) {
+                       pr_warn("IPv6 is not supported can not create UDP socket\n");
+                       return NULL;
+               }
+

I would put this test in rxe_net_ipv6_init. returning errptr, null or a valid pointer is a bit too ugly

drivers/infiniband/sw/rxe/rxe_net.c static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port, · line 217

Quoted 2 lines
drivers/infiniband/sw/rxe/rxe_net.c +0 -0
                pr_err("failed to create udp socket. err = %d\n",
                err);

And delete some of this needless debugging

Jason