From: Allison Henderson <allison.henderson@oracle.com>
To: "horms@kernel.org" <horms@kernel.org>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"rds-devel@oss.oracle.com" <rds-devel@oss.oracle.com>,
"edumazet@google.com" <edumazet@google.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next 1/2] rds: Correct endian annotation of port and addr assignments
Date: Fri, 20 Jun 2025 23:15:11 +0000 [thread overview]
Message-ID: <9a18d6ef5bf2c47cae42ec2ef96f3cc96a5507b9.camel@oracle.com> (raw)
In-Reply-To: <20250619-rds-minor-v1-1-86d2ee3a98b9@kernel.org>
On Thu, 2025-06-19 at 14:58 +0100, Simon Horman wrote:
> Correct the endianness annotation of port assignments:
>
> A host byte order value (RDS_TCP_PORT) is correctly converted to
> network byte order (big endian) using htons. But it is then cast back to
> host byte order before assigning to a variable that expects a big endian
> value. Address this by dropping the cast.
>
> This is not a bug because, while the endian annotation is changed by
> this patch, the assigned value is unchanged.
>
> Also correct the endianness of address assignment.
>
> A host byte order value (INADDR_ANY) is incorrectly assigned as-is to
> a variable that expects a big endian value. Address this by converting
> the value to network byte order (big endian).
>
> This is not a bug because INADDR_ANY is 0, which is isomorphic
> with regards to endian conversions. IOW, while the endian annotation
> is changed by this patch, the assigned value is unchanged.
>
> Incorrect endian annotations appear to date back to IPv4-only code added
> by commit 70041088e3b9 ("RDS: Add TCP transport to RDS").
>
> Flagged by Sparse.
>
> Signed-off-by: Simon Horman <horms@kernel.org>
These changes look fine to me. Thanks for the catch!
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
> ---
> net/rds/tcp_listen.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
> index d89bd8d0c354..b5c801c629a4 100644
> --- a/net/rds/tcp_listen.c
> +++ b/net/rds/tcp_listen.c
> @@ -298,15 +298,15 @@ struct socket *rds_tcp_listen_init(struct net *net, bool isv6)
> sin6 = (struct sockaddr_in6 *)&ss;
> sin6->sin6_family = PF_INET6;
> sin6->sin6_addr = in6addr_any;
> - sin6->sin6_port = (__force u16)htons(RDS_TCP_PORT);
> + sin6->sin6_port = htons(RDS_TCP_PORT);
> sin6->sin6_scope_id = 0;
> sin6->sin6_flowinfo = 0;
> addr_len = sizeof(*sin6);
> } else {
> sin = (struct sockaddr_in *)&ss;
> sin->sin_family = PF_INET;
> - sin->sin_addr.s_addr = INADDR_ANY;
> - sin->sin_port = (__force u16)htons(RDS_TCP_PORT);
> + sin->sin_addr.s_addr = htonl(INADDR_ANY);
> + sin->sin_port = htons(RDS_TCP_PORT);
> addr_len = sizeof(*sin);
> }
>
>
next prev parent reply other threads:[~2025-06-20 23:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 13:58 [PATCH net-next 0/2] rds: Minor updates for spelling and endian Simon Horman
2025-06-19 13:58 ` [PATCH net-next 1/2] rds: Correct endian annotation of port and addr assignments Simon Horman
2025-06-20 23:15 ` Allison Henderson [this message]
2025-06-19 13:58 ` [PATCH net-next 2/2] rds: Correct spelling Simon Horman
2025-06-20 23:16 ` Allison Henderson
2025-06-21 15:00 ` [PATCH net-next 0/2] rds: Minor updates for spelling and endian patchwork-bot+netdevbpf
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=9a18d6ef5bf2c47cae42ec2ef96f3cc96a5507b9.camel@oracle.com \
--to=allison.henderson@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rds-devel@oss.oracle.com \
/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;
as well as URLs for NNTP newsgroup(s).