mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jang Ingyu <ingyujang25@korea.ac.kr>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] infiniband/core: Fix logic error in ib_get_gids_from_rdma_hdr()
Date: Mon, 5 Jan 2026 20:55:55 -0400	[thread overview]
Message-ID: <20260106005555.GL125261@ziepe.ca> (raw)
In-Reply-To: <20251221093038.GG13030@unreal>

On Sun, Dec 21, 2025 at 11:30:38AM +0200, Leon Romanovsky wrote:
> On Sun, Dec 21, 2025 at 11:24:18AM +0200, Leon Romanovsky wrote:
> > On Fri, Dec 19, 2025 at 01:15:08PM +0900, Jang Ingyu wrote:
> > > Fix missing comparison operator for RDMA_NETWORK_ROCE_V1 in the
> > > conditional statement. The constant was used directly instead of
> > > being compared with net_type, causing the condition to always
> > > evaluate to true.
> > 
> > In current code, it doesn't matter as network type can be one of four
> > possible values, and this "else if" will be always true anyway.
> > 
> > I changed your patch to this and added Fixes line:
> > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> > index ee390928511ae..256f81c5803ff 100644
> > --- a/drivers/infiniband/core/verbs.c
> > +++ b/drivers/infiniband/core/verbs.c
> > @@ -737,14 +737,11 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr,
> >                 ipv6_addr_set_v4mapped(dst_saddr,
> >                                        (struct in6_addr *)dgid);
> >                 return 0;
> > -       } else if (net_type == RDMA_NETWORK_IPV6 ||
> > -                  net_type == RDMA_NETWORK_IB || net_type == RDMA_NETWORK_ROCE_V1) {
> > -               *dgid = hdr->ibgrh.dgid;
> > -               *sgid = hdr->ibgrh.sgid;
> > -               return 0;
> > -       } else {
> > -               return -EINVAL;
> >         }
> > +
> > +       *dgid = hdr->ibgrh.dgid;
> > +       *sgid = hdr->ibgrh.sgid;
> > +       return 0;
> >  }
> >  EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr);
> 
> After some additional consideration, I'll keep your patch as is.
> 
> My change is technically correct, but it's risky since some drivers  
> use non‑conformant values.

I don't think it is that risky because it is what has been happening
all this time anyhow.

> > >  	} else if (net_type == RDMA_NETWORK_IPV6 ||
> > > -		   net_type == RDMA_NETWORK_IB || RDMA_NETWORK_ROCE_V1) {

That expression is always true

Conversely with the "correct" patch if we have a net type of
RDMA_NETWORK_IPV4 we now get an EINVAL that we didn't get before..

I guess we will see if this turns into a problem or not..

Jason

  reply	other threads:[~2026-01-06  0:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19  4:15 Jang Ingyu
2025-12-21  9:24 ` Leon Romanovsky
2025-12-21  9:30   ` Leon Romanovsky
2026-01-06  0:55     ` Jason Gunthorpe [this message]
2025-12-21  9:31 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260106005555.GL125261@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=ingyujang25@korea.ac.kr \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®