mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@gmail.com>
To: Matthieu Baerts <matthieu.baerts@tessares.net>
Cc: mptcp@lists.linux.dev, mptcp <mptcp@lists.01.org>
Subject: Re: [PATCH mptcp-next 1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options"
Date: Tue, 23 Mar 2021 12:00:54 +0800	[thread overview]
Message-ID: <CA+WQbwsLSnoVm_L-34DmEqgBLNkZpVQSX3tkiSLSiFnNL1_9mw@mail.gmail.com> (raw)
In-Reply-To: <20210322162132.2471823-1-matthieu.baerts@tessares.net>

Hi Matt,

Please update the commit log too:

---
Since the port number became as a big-endian order now, use ntohs to
convert it before printing it out.
---

 ->

---
Since the port number became big-endian now, use ntohs to convert it
before sending it out with the ADD_ADDR suboption. Also convert it
when passing it to add_addr_generate_hmac or printing it out.
---

Thanks.

-Geliang

Matthieu Baerts <matthieu.baerts@tessares.net> 于2021年3月23日周二 上午12:21写道:
>
> Fix issues reported by sparse because we were doing non explicit casting
> from __be16 to u16.
>
>   net/mptcp/options.c:662:72: warning: incorrect type in argument 5 (different base types)
>   net/mptcp/options.c:662:72:    expected unsigned short [usertype] port
>   net/mptcp/options.c:662:72:    got restricted __be16 [usertype] port
>   net/mptcp/options.c:673:73: warning: incorrect type in argument 5 (different base types)
>   net/mptcp/options.c:673:73:    expected unsigned short [usertype] port
>   net/mptcp/options.c:673:73:    got restricted __be16 [usertype] port
>   net/mptcp/options.c:1244:62: warning: incorrect type in argument 1 (different base types)
>   net/mptcp/options.c:1244:62:    expected unsigned short [usertype] val
>   net/mptcp/options.c:1244:62:    got restricted __be16 [usertype] port
>   net/mptcp/options.c:1253:62: warning: restricted __be16 degrades to integer
>
> Before the mentioned commit, we were using port in u16 in
> mptcp_out_options, everything was OK.
>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
>  net/mptcp/options.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> index 7e01f44ed885..03019a6d5059 100644
> --- a/net/mptcp/options.c
> +++ b/net/mptcp/options.c
> @@ -659,7 +659,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
>                                                              msk->remote_key,
>                                                              opts->addr.id,
>                                                              &opts->addr.addr,
> -                                                            opts->addr.port);
> +                                                            be16_to_cpu(opts->addr.port));
>                 }
>         }
>  #if IS_ENABLED(CONFIG_MPTCP_IPV6)
> @@ -670,7 +670,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
>                                                               msk->remote_key,
>                                                               opts->addr.id,
>                                                               &opts->addr.addr6,
> -                                                             opts->addr.port);
> +                                                             be16_to_cpu(opts->addr.port));
>                 }
>         }
>  #endif
> @@ -1238,10 +1238,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
>                                 ptr += 2;
>                         }
>                 } else {
> +                       u16 port = be16_to_cpu(opts->addr.port);
> +
>                         if (opts->ahmac) {
>                                 u8 *bptr = (u8 *)ptr;
>
> -                               put_unaligned_be16(opts->addr.port, bptr);
> +                               put_unaligned_be16(port, bptr);
>                                 bptr += 2;
>                                 put_unaligned_be64(opts->ahmac, bptr);
>                                 bptr += 8;
> @@ -1250,7 +1252,7 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
>
>                                 ptr += 3;
>                         } else {
> -                               put_unaligned_be32(opts->addr.port << 16 |
> +                               put_unaligned_be32(port << 16 |
>                                                    TCPOPT_NOP << 8 |
>                                                    TCPOPT_NOP, ptr);
>                                 ptr += 1;
> --
> 2.30.2
>

      parent reply	other threads:[~2021-03-23  4:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 16:21 [PATCH mptcp-next 1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options" Matthieu Baerts
2021-03-22 16:21 ` [PATCH mptcp-next 2/3] Squash to "mptcp: use mptcp_addr_info in mptcp_options_received" Matthieu Baerts
2021-03-23  4:02   ` Geliang Tang
2021-03-22 16:21 ` [PATCH mptcp-next 3/3] Squash to "mptcp: drop MPTCP_ADDR_IPVERSION_4/6" Matthieu Baerts
2021-03-22 21:56   ` Mat Martineau
2021-03-23  3:06     ` Geliang Tang
2021-03-23  7:59       ` Matthieu Baerts
2021-03-23  8:09         ` Geliang Tang
2021-03-23 10:19           ` Matthieu Baerts
2021-03-23  4:00 ` Geliang Tang [this message]

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=CA+WQbwsLSnoVm_L-34DmEqgBLNkZpVQSX3tkiSLSiFnNL1_9mw@mail.gmail.com \
    --to=geliangtang@gmail.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.01.org \
    --cc=mptcp@lists.linux.dev \
    /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).