[rds-devel] [PATCH net] rds: Fix endian annotations across various assignments
Al Viro
viro at zeniv.linux.org.uk
Sun Aug 10 18:38:55 UTC 2025
On Sun, Aug 10, 2025 at 06:47:05PM +0100, Al Viro wrote:
> > diff --git a/net/rds/connection.c b/net/rds/connection.c
> > index d62f486ab29f..0047b76c3c0b 100644
> > --- a/net/rds/connection.c
> > +++ b/net/rds/connection.c
> > @@ -62,13 +62,13 @@ static struct hlist_head *rds_conn_bucket(const struct in6_addr *laddr,
> > net_get_random_once(&rds_hash_secret, sizeof(rds_hash_secret));
> > net_get_random_once(&rds6_hash_secret, sizeof(rds6_hash_secret));
> >
> > - lhash = (__force u32)laddr->s6_addr32[3];
> > + lhash = (__force __u32)laddr->s6_addr32[3];
> > #if IS_ENABLED(CONFIG_IPV6)
> > fhash = __ipv6_addr_jhash(faddr, rds6_hash_secret);
> > #else
> > - fhash = (__force u32)faddr->s6_addr32[3];
> > + fhash = (__force __u32)(faddr->s6_addr32[3]);
> > #endif
> > - hash = __inet_ehashfn(lhash, 0, fhash, 0, rds_hash_secret);
> > + hash = __inet_ehashfn((__force __be32)lhash, 0, (__force __be32)fhash, 0, rds_hash_secret);
>
> what the... You have lhash and fhash set to __be32 values, then
> feed them to function that expects __be32 argument. Just turn
> these two variables into __be32 and lose the pointless casts.
FWIW, here you do have a missing cast -
fhash = __ipv6_addr_jhash(faddr, rds6_hash_secret);
should be
fhash = (__force __be32)__ipv6_addr_jhash(faddr, rds6_hash_secret);
With both fhash and lhash declared as __be32.
More information about the rds-devel
mailing list