diff mbox series

[for-rc] RDMA/rxe: Fix failure during driver load

Message ID 20210601055612.195653-1-kamalheib1@gmail.com (mailing list archive)
State Superseded
Delegated to: Jason Gunthorpe
Headers show
Series [for-rc] RDMA/rxe: Fix failure during driver load | expand

Commit Message

Kamal Heib June 1, 2021, 5:56 a.m. UTC
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")
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Zhu Yanjun June 1, 2021, 7:45 a.m. UTC | #1
On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
>
> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
also tries to solve ipv6 problem.

Zhu Yanjun

>
> Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> index 01662727dca0..f353fc18769f 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> @@ -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
>
Kamal Heib June 1, 2021, 7:56 a.m. UTC | #2
> On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> 
> On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
>> 
>> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> 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


>> 
>> Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
>> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
>> ---
>> drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
>> index 01662727dca0..f353fc18769f 100644
>> --- a/drivers/infiniband/sw/rxe/rxe_net.c
>> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
>> @@ -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
>>
Zhu Yanjun June 1, 2021, 8:11 a.m. UTC | #3
On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
>
>
>
> > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> >
> > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> >>
> >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > 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?

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

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c
b/drivers/infiniband/sw/rxe/rxe_net.c
index 0701bd1ffd1a..6ef092cb575e 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -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

>
> Thanks,
> Kamal
>
>
> >>
> >> Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
> >> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> >> ---
> >> drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
> >> 1 file changed, 8 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> >> index 01662727dca0..f353fc18769f 100644
> >> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> >> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> >> @@ -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
> >>
Kamal Heib June 1, 2021, 9:09 a.m. UTC | #4
On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
> On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
> >
> >
> >
> > > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> > >
> > > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > >>
> > >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > > 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?
> 
> 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

> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c
> b/drivers/infiniband/sw/rxe/rxe_net.c
> index 0701bd1ffd1a..6ef092cb575e 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> @@ -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
> 
> >
> > Thanks,
> > Kamal
> >
> >
> > >>
> > >> Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
> > >> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> > >> ---
> > >> drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
> > >> 1 file changed, 8 insertions(+), 6 deletions(-)
> > >>
> > >> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > >> index 01662727dca0..f353fc18769f 100644
> > >> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > >> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > >> @@ -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
> > >>
Zhu Yanjun June 1, 2021, 3:59 p.m. UTC | #5
On Tue, Jun 1, 2021 at 5:09 PM Kamal Heib <kamalheib1@gmail.com> wrote:
>
> On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
> > On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
> > >
> > >
> > >
> > > > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> > > >
> > > > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > > >>
> > > >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > > > 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/20210326012723.41769-1-yanjun.zhu@intel.com/T/
carefully.

Please pay attention to the comments from Jason Gunthorpe

Zhu Yanjun

> > >
> > > 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
>
> > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c
> > b/drivers/infiniband/sw/rxe/rxe_net.c
> > index 0701bd1ffd1a..6ef092cb575e 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > @@ -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
> >
> > >
> > > Thanks,
> > > Kamal
> > >
> > >
> > > >>
> > > >> Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel")
> > > >> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> > > >> ---
> > > >> drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------
> > > >> 1 file changed, 8 insertions(+), 6 deletions(-)
> > > >>
> > > >> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > > >> index 01662727dca0..f353fc18769f 100644
> > > >> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> > > >> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > > >> @@ -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
> > > >>
Jason Gunthorpe June 1, 2021, 5:01 p.m. UTC | #6
On Tue, Jun 01, 2021 at 11:59:44PM +0800, Zhu Yanjun wrote:
> On Tue, Jun 1, 2021 at 5:09 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> >
> > On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
> > > On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
> > > >
> > > >
> > > >
> > > > > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> > > > >
> > > > > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > > > >>
> > > > >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > > > > 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/20210326012723.41769-1-yanjun.zhu@intel.com/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
Zhu Yanjun June 2, 2021, 7:22 a.m. UTC | #7
On Wed, Jun 2, 2021 at 1:01 AM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Tue, Jun 01, 2021 at 11:59:44PM +0800, Zhu Yanjun wrote:
> > On Tue, Jun 1, 2021 at 5:09 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > >
> > > On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
> > > > On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
> > > > >
> > > > >
> > > > >
> > > > > > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> > > > > >
> > > > > > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > > > > >>
> > > > > >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > > > > > 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/20210326012723.41769-1-yanjun.zhu@intel.com/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

> errno down in the call chain and just ignore ipv6 support in this
> case.
>
> Jason
Kamal Heib June 2, 2021, 1:10 p.m. UTC | #8
On Tue, Jun 01, 2021 at 02:01:32PM -0300, Jason Gunthorpe wrote:
> On Tue, Jun 01, 2021 at 11:59:44PM +0800, Zhu Yanjun wrote:
> > On Tue, Jun 1, 2021 at 5:09 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > >
> > > On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
> > > > On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
> > > > >
> > > > >
> > > > >
> > > > > > On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
> > > > > >
> > > > > > On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
> > > > > >>
> > > > > >> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
> > > > > > 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/20210326012723.41769-1-yanjun.zhu@intel.com/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

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

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 01662727dca0..144d9e1c1c3d 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ 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;
+               }
+
                pr_err("failed to create udp socket. err = %d\n", err);
                return ERR_PTR(err);
        }


Thanks,
Kamal
Zhu Yanjun June 2, 2021, 2:04 p.m. UTC | #9
在 2021/6/2 21:10, Kamal Heib 写道:
> On Tue, Jun 01, 2021 at 02:01:32PM -0300, Jason Gunthorpe wrote:
>> On Tue, Jun 01, 2021 at 11:59:44PM +0800, Zhu Yanjun wrote:
>>> On Tue, Jun 1, 2021 at 5:09 PM Kamal Heib <kamalheib1@gmail.com> wrote:
>>>> On Tue, Jun 01, 2021 at 04:11:08PM +0800, Zhu Yanjun wrote:
>>>>> On Tue, Jun 1, 2021 at 3:56 PM kamal heib <kamalheib1@gmail.com> wrote:
>>>>>>
>>>>>>
>>>>>>> On 1 Jun 2021, at 10:45, Zhu Yanjun <zyjzyj2000@gmail.com> wrote:
>>>>>>>
>>>>>>> On Tue, Jun 1, 2021 at 1:58 PM Kamal Heib <kamalheib1@gmail.com> wrote:
>>>>>>>> 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/20210413234252.12209-1-yanjun.zhu@intel.com/
>>>>>>> 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/20210326012723.41769-1-yanjun.zhu@intel.com/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
> OK, Could you please tell me what do you think about the following:
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> index 01662727dca0..144d9e1c1c3d 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ 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;

The returned value is changed.

Zhu Yanjun

> +               }
> +
>                  pr_err("failed to create udp socket. err = %d\n", err);
>                  return ERR_PTR(err);
>          }
>
>
> Thanks,
> Kamal
Jason Gunthorpe June 2, 2021, 11:31 p.m. UTC | #10
On Wed, Jun 02, 2021 at 04:10:07PM +0300, Kamal Heib wrote:

> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> 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

>                 pr_err("failed to create udp socket. err = %d\n",
>                 err);

And delete some of this needless debugging

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 01662727dca0..f353fc18769f 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -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;