[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260106005555.GL125261@ziepe.ca>
Date: Mon, 5 Jan 2026 20:55:55 -0400
From: Jason Gunthorpe <jgg@...pe.ca>
To: Leon Romanovsky <leon@...nel.org>
Cc: Jang Ingyu <ingyujang25@...ea.ac.kr>, linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] infiniband/core: Fix logic error in
ib_get_gids_from_rdma_hdr()
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
Powered by blists - more mailing lists