diff mbox series

[1/1] RDMA/addr: Disable ipv6 features when ipv6.disable set in cmdline

Message ID 20210326024405.3870-1-yanjun.zhu@intel.com (mailing list archive)
State Superseded
Headers show
Series [1/1] RDMA/addr: Disable ipv6 features when ipv6.disable set in cmdline | expand

Commit Message

Zhu Yanjun March 26, 2021, 2:44 a.m. UTC
From: Zhu Yanjun <zyjzyj2000@gmail.com>

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

Fixes: caf1e3ae9fa6 ("RDMA/core Introduce and use rdma_find_ndev_for_src_ip_rcu")
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
---
 drivers/infiniband/core/addr.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Zhu Yanjun March 31, 2021, 3:04 a.m. UTC | #1
On Thu, Mar 25, 2021 at 6:19 PM Zhu Yanjun <yanjun.zhu@intel.com> wrote:
>
> From: Zhu Yanjun <zyjzyj2000@gmail.com>
>
> When ipv6.disable=1 is set in cmdline, ipv6 is actually disabled
> in the stack. As such, the operations of ipv6 will fail.
> So ipv6 features in addr should also be disabled.
>
> Fixes: caf1e3ae9fa6 ("RDMA/core Introduce and use rdma_find_ndev_for_src_ip_rcu")
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>

Hi, Jason

Gently ping

> Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
> ---
>  drivers/infiniband/core/addr.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> index 0abce004a959..6fa57b83c4b1 100644
> --- a/drivers/infiniband/core/addr.c
> +++ b/drivers/infiniband/core/addr.c
> @@ -257,6 +257,9 @@ rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)
>                 break;
>  #if IS_ENABLED(CONFIG_IPV6)
>         case AF_INET6:
> +               if (!ipv6_mod_enabled())
> +                       return ERR_PTR(-EPFNOSUPPORT);
> +
>                 for_each_netdev_rcu(net, dev) {
>                         if (ipv6_chk_addr(net,
>                                           &((const struct sockaddr_in6 *)src_in)->sin6_addr,
> @@ -424,6 +427,9 @@ static int addr6_resolve(struct sockaddr *src_sock,
>         struct flowi6 fl6;
>         struct dst_entry *dst;
>
> +       if (!ipv6_mod_enabled())
> +               return -EADDRNOTAVAIL;
> +
>         memset(&fl6, 0, sizeof fl6);
>         fl6.daddr = dst_in->sin6_addr;
>         fl6.saddr = src_in->sin6_addr;
> --
> 2.27.0
>
diff mbox series

Patch

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 0abce004a959..6fa57b83c4b1 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -257,6 +257,9 @@  rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)
 		break;
 #if IS_ENABLED(CONFIG_IPV6)
 	case AF_INET6:
+		if (!ipv6_mod_enabled())
+			return ERR_PTR(-EPFNOSUPPORT);
+
 		for_each_netdev_rcu(net, dev) {
 			if (ipv6_chk_addr(net,
 					  &((const struct sockaddr_in6 *)src_in)->sin6_addr,
@@ -424,6 +427,9 @@  static int addr6_resolve(struct sockaddr *src_sock,
 	struct flowi6 fl6;
 	struct dst_entry *dst;
 
+	if (!ipv6_mod_enabled())
+		return -EADDRNOTAVAIL;
+
 	memset(&fl6, 0, sizeof fl6);
 	fl6.daddr = dst_in->sin6_addr;
 	fl6.saddr = src_in->sin6_addr;