Skip to contentSkip to conversation

RDMA/rxe: Disable ipv6 features when ipv6.disable in cmdline

PATCH In review Zhu Yanjun 4 participants 7 messages Apr 13, 2021 – Apr 15, 2021

Subsystems (2)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH v5 1/1 RDMA/rxe: Disable ipv6 features when ipv6.disable in cmdline

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +12 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-		pr_err("failed to create udp socket. err = %d\n", err);
+		/* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+		 * over ipv4 still works. This error message will not pop out.
+		 * If UDP tunnle over ipv4 fails or other errors with ipv6
+		 * tunnel, this error should pop out.
+		 */
+		if (!((err == -EAFNOSUPPORT) && (ipv6)))
+			pr_err("failed to create udp socket. err = %d\n", err);
 		return ERR_PTR(err);
 	}
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
 	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
 						htons(ROCE_V2_UDP_DPORT), true);
 	if (IS_ERR(recv_sockets.sk6)) {
+		/* Though IPv6 is not supported, IPv4 still needs to continue
+		 */
+		if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+			return 0;
+
 		recv_sockets.sk6 = NULL;
 		pr_err("Failed to create IPv6 UDP tunnel\n");
 		return -1;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 24 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +0 -0
index 01662727dca0..984c3ac449bd 100644

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

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +6 -1
@@ -208,7 +208,13 @@ 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) {
-		pr_err("failed to create udp socket. err = %d\n", err);
+		/* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+		 * over ipv4 still works. This error message will not pop out.
+		 * If UDP tunnle over ipv4 fails or other errors with ipv6
+		 * tunnel, this error should pop out.
+		 */
+		if (!((err == -EAFNOSUPPORT) && (ipv6)))

You have too much brackets.

if (err != -EAFNOSUPPORT || !ipv6)))

Quoted 19 lines
drivers/infiniband/sw/rxe/rxe_net.c +6 -0
+			pr_err("failed to create udp socket. err = %d\n", err);
 		return ERR_PTR(err);
 	}
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
 	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
 						htons(ROCE_V2_UDP_DPORT), true);
 	if (IS_ERR(recv_sockets.sk6)) {
+		/* Though IPv6 is not supported, IPv4 still needs to continue
+		 */
+		if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+			return 0;
+
 		recv_sockets.sk6 = NULL;
 		pr_err("Failed to create IPv6 UDP tunnel\n");
 		return -1;
Signature · 1 line
2.27.0
maintainer
#2 lore raw
Quoted 30 lines · Leon Romanovsky
Quoted 28 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +0 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-             pr_err("failed to create udp socket. err = %d\n", err);
Quoted 8 lines

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

Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_net.c +6 -0
+             /* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+              * over ipv4 still works. This error message will not pop out.
+              * If UDP tunnle over ipv4 fails or other errors with ipv6
+              * tunnel, this error should pop out.
+              */
+             if (!((err == -EAFNOSUPPORT) && (ipv6)))

You have too much brackets.

My code corresponds with the comments.

Zhu Yanjun

Quoted 22 lines

if (err != -EAFNOSUPPORT || !ipv6)))

Quoted 19 lines
drivers/infiniband/sw/rxe/rxe_net.c +6 -1
+                     pr_err("failed to create udp socket. err = %d\n", err);
              return ERR_PTR(err);
      }
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
      recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
                                              htons(ROCE_V2_UDP_DPORT), true);
      if (IS_ERR(recv_sockets.sk6)) {
+             /* Though IPv6 is not supported, IPv4 still needs to continue
+              */
+             if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+                     return 0;
+
              recv_sockets.sk6 = NULL;
              pr_err("Failed to create IPv6 UDP tunnel\n");
              return -1;
--

2.27.0

#3 lore raw
In reply to Zhu Yanjun
Quoted 41 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +7 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-		pr_err("failed to create udp socket. err = %d\n", err);
+		/* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+		 * over ipv4 still works. This error message will not pop out.
+		 * If UDP tunnle over ipv4 fails or other errors with ipv6
+		 * tunnel, this error should pop out.
+		 */
+		if (!((err == -EAFNOSUPPORT) && (ipv6)))
+			pr_err("failed to create udp socket. err = %d\n", err);
 		return ERR_PTR(err);
 	}
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
 	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 636

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
 						htons(ROCE_V2_UDP_DPORT), true);
 	if (IS_ERR(recv_sockets.sk6)) {
+		/* Though IPv6 is not supported, IPv4 still needs to continue
+		 */
+		if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+			return 0;
+
 		recv_sockets.sk6 = NULL;
 		pr_err("Failed to create IPv6 UDP tunnel\n");
 		return -1;

I think the following change is much simpler than changing the udp_sock_create() helper function?

(quoted diff) +0 -0

b/drivers/infiniband/sw/rxe/rxe_net.c
index 01662727dca0..b56d6f76ab31 100644

drivers/infiniband/sw/rxe/rxe_net.c +5 -0
@@ -621,6 +621,11 @@ static int rxe_net_ipv6_init(void)
                                                htons(ROCE_V2_UDP_DPORT), true);
        if (IS_ERR(recv_sockets.sk6)) {
                recv_sockets.sk6 = NULL;
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {
+                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
+                       return 0;
+               }
+
                pr_err("Failed to create IPv6 UDP tunnel\n");
                return -1;
        }
Signature · 5 lines
2.26.3


Thanks,
Kamal
#4 lore raw
Quoted 65 lines · Kamal Heib
Quoted 41 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +7 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-		pr_err("failed to create udp socket. err = %d\n", err);
+		/* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+		 * over ipv4 still works. This error message will not pop out.
+		 * If UDP tunnle over ipv4 fails or other errors with ipv6
+		 * tunnel, this error should pop out.
+		 */
+		if (!((err == -EAFNOSUPPORT) && (ipv6)))
+			pr_err("failed to create udp socket. err = %d\n", err);
 		return ERR_PTR(err);
 	}
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
 	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 636

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
 						htons(ROCE_V2_UDP_DPORT), true);
 	if (IS_ERR(recv_sockets.sk6)) {
+		/* Though IPv6 is not supported, IPv4 still needs to continue
+		 */
+		if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+			return 0;
+
 		recv_sockets.sk6 = NULL;
 		pr_err("Failed to create IPv6 UDP tunnel\n");
 		return -1;

I think the following change is much simpler than changing the udp_sock_create() helper function?

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

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 624

Quoted 4 lines
drivers/infiniband/sw/rxe/rxe_net.c +1 -0
@@ -621,6 +621,11 @@ static int rxe_net_ipv6_init(void)
                                                htons(ROCE_V2_UDP_DPORT), true);
        if (IS_ERR(recv_sockets.sk6)) {
                recv_sockets.sk6 = NULL;
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {

You have "recv_sockets.sk6 = NULL;" in the line above.

Quoted 14 lines
drivers/infiniband/sw/rxe/rxe_net.c +4 -0
+                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
+                       return 0;
+               }
+
                pr_err("Failed to create IPv6 UDP tunnel\n");
                return -1;
        }
Signature · 5 lines
2.26.3


Thanks,
Kamal
#5 lore raw
Quoted 60 lines · Leon Romanovsky
Quoted 59 lines · Kamal Heib
Quoted 41 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +7 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-		pr_err("failed to create udp socket. err = %d\n", err);
+		/* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+		 * over ipv4 still works. This error message will not pop out.
+		 * If UDP tunnle over ipv4 fails or other errors with ipv6
+		 * tunnel, this error should pop out.
+		 */
+		if (!((err == -EAFNOSUPPORT) && (ipv6)))
+			pr_err("failed to create udp socket. err = %d\n", err);
 		return ERR_PTR(err);
 	}
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
 	recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 636

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
 						htons(ROCE_V2_UDP_DPORT), true);
 	if (IS_ERR(recv_sockets.sk6)) {
+		/* Though IPv6 is not supported, IPv4 still needs to continue
+		 */
+		if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+			return 0;
+
 		recv_sockets.sk6 = NULL;
 		pr_err("Failed to create IPv6 UDP tunnel\n");
 		return -1;

I think the following change is much simpler than changing the udp_sock_create() helper function?

Quoted 13 lines

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 624

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +1 -0
index 01662727dca0..b56d6f76ab31 100644
@@ -621,6 +621,11 @@ static int rxe_net_ipv6_init(void)
                                                htons(ROCE_V2_UDP_DPORT), true);
        if (IS_ERR(recv_sockets.sk6)) {
                recv_sockets.sk6 = NULL;
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {

You have "recv_sockets.sk6 = NULL;" in the line above.

Sorry, my bad...

The idea is to handle this issue in the error path of rxe_net_ipv6_init() instead of changing the udp_sock_create(), also to make sure that "recv_sockets.sk6" is set to NULL.

(quoted diff) +0 -0

b/drivers/infiniband/sw/rxe/rxe_net.c
index 01662727dca0..445a47f82f42 100644

drivers/infiniband/sw/rxe/rxe_net.c +11 -3
@@ -615,17 +615,25 @@ static int rxe_net_ipv4_init(void)
 
 static int rxe_net_ipv6_init(void)
 {
+       int err = 0;
 #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)) {
+
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {
+                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
+                       err = 0;
+               } else {
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       err = -1;
+               }
+
                recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
        }
 #endif
-       return 0;
+       return err;
 }
 
Quoted 15 lines
Quoted 14 lines
drivers/infiniband/sw/rxe/rxe_net.c +4 -0
+                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
+                       return 0;
+               }
+
                pr_err("Failed to create IPv6 UDP tunnel\n");
                return -1;
        }
Signature · 5 lines
2.26.3


Thanks,
Kamal
maintainer
#6 lore raw
Quoted 78 lines · Kamal Heib
Quoted 60 lines · Leon Romanovsky
Quoted 59 lines · Kamal Heib
Quoted 41 lines · Zhu Yanjun

From: Zhu Yanjun <[email protected]>

When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled in the stack. As such, the operations of ipv6 in RXE will fail. So ipv6 features in RXE should also be disabled in RXE.

---
V4->V5: Clean up signature block and remove error message V3->V4: Check the returned value instead of ipv6 module V2->V3: Remove print message
V1->V2: Modify the pr_info messages

---
 drivers/infiniband/sw/rxe/rxe_net.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +7 -1
index 01662727dca0..984c3ac449bd 100644
@@ -208,7 +208,13 @@ 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) {
-           pr_err("failed to create udp socket. err = %d\n", err);
+           /* If UDP tunnel over ipv6 fails with -EAFNOSUPPORT, the tunnel
+            * over ipv4 still works. This error message will not pop out.
+            * If UDP tunnle over ipv4 fails or other errors with ipv6
+            * tunnel, this error should pop out.
+            */
+           if (!((err == -EAFNOSUPPORT) && (ipv6)))
+                   pr_err("failed to create udp socket. err = %d\n", err);
            return ERR_PTR(err);
    }
 
@@ -620,6 +626,11 @@ static int rxe_net_ipv6_init(void)
    recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 636

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +5 -0
                                            htons(ROCE_V2_UDP_DPORT), true);
    if (IS_ERR(recv_sockets.sk6)) {
+           /* Though IPv6 is not supported, IPv4 still needs to continue
+            */
+           if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT)
+                   return 0;
+
            recv_sockets.sk6 = NULL;
            pr_err("Failed to create IPv6 UDP tunnel\n");
            return -1;

I think the following change is much simpler than changing the udp_sock_create() helper function?

Quoted 13 lines

drivers/infiniband/sw/rxe/rxe_net.c static int rxe_net_ipv6_init(void) · line 624

Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_net.c +1 -0
index 01662727dca0..b56d6f76ab31 100644
@@ -621,6 +621,11 @@ static int rxe_net_ipv6_init(void)
                                                htons(ROCE_V2_UDP_DPORT), true);
        if (IS_ERR(recv_sockets.sk6)) {
                recv_sockets.sk6 = NULL;
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {

You have "recv_sockets.sk6 = NULL;" in the line above.

Quoted 4 lines

Sorry, my bad...

The idea is to handle this issue in the error path of rxe_net_ipv6_init() instead of changing the udp_sock_create(), also to make sure that

We do not change udp_sock_create.

Quoted 1 line

"recv_sockets.sk6" is set to NULL.

Is it necessary to set recv_sockets_sk6 to NULL?

Zhu Yanjun

Quoted 50 lines
drivers/infiniband/sw/rxe/rxe_net.c +11 -3
index 01662727dca0..445a47f82f42 100644
@@ -615,17 +615,25 @@ static int rxe_net_ipv4_init(void)
 
 static int rxe_net_ipv6_init(void)
 {
+       int err = 0;
 #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)) {
+
+               if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {
+                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
+                       err = 0;
+               } else {
+                       pr_err("Failed to create IPv6 UDP tunnel\n");
+                       err = -1;
+               }
+
                recv_sockets.sk6 = NULL;
-               pr_err("Failed to create IPv6 UDP tunnel\n");
-               return -1;
        }
 #endif
-       return 0;
+       return err;
 }
 
 >> +                       pr_warn("Create IPv6 UDP tunnel is not supported\n");
Quoted 14 lines
Quoted 13 lines
drivers/infiniband/sw/rxe/rxe_net.c +3 -1
+                       return 0;
+               }
+
                pr_err("Failed to create IPv6 UDP tunnel\n");
                return -1;
        }
--

2.26.3

Thanks,
Kamal