mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Matthieu Baerts <matthieu.baerts@tessares.net>
To: mptcp@lists.linux.dev, mptcp@lists.01.org
Cc: Geliang Tang <geliangtang@gmail.com>,
	Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: [PATCH mptcp-next 2/3] Squash to "mptcp: use mptcp_addr_info in mptcp_options_received"
Date: Mon, 22 Mar 2021 17:21:31 +0100	[thread overview]
Message-ID: <20210322162132.2471823-2-matthieu.baerts@tessares.net> (raw)
In-Reply-To: <20210322162132.2471823-1-matthieu.baerts@tessares.net>

Fix issues reported by sparse because we were doing non explicit casting
from __be16 to u16 and the opposite.

  net/mptcp/options.c:251:51: warning: incorrect type in assignment (different base types)
  net/mptcp/options.c:251:51:    expected restricted __be16 [usertype] port
  net/mptcp/options.c:251:51:    got unsigned short
  net/mptcp/options.c:261:51: warning: incorrect type in assignment (different base types)
  net/mptcp/options.c:261:51:    expected restricted __be16 [usertype] port
  net/mptcp/options.c:261:51:    got unsigned short
  net/mptcp/options.c:998:59: warning: incorrect type in argument 5 (different base types)
  net/mptcp/options.c:998:59:    expected unsigned short [usertype] port
  net/mptcp/options.c:998:59:    got restricted __be16 [usertype] port
  net/mptcp/options.c:1004:60: warning: incorrect type in argument 5 (different base types)
  net/mptcp/options.c:1004:60:    expected unsigned short [usertype] port
  net/mptcp/options.c:1004:60:    got restricted __be16 [usertype] port

Before the mentioned commit, we were using port in u16 in
mptcp_options_received, everything was OK.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 net/mptcp/options.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 7fd40512df7f..43b85f2a5be1 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -248,7 +248,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 			ptr += 4;
 			if (opsize == TCPOLEN_MPTCP_ADD_ADDR_PORT ||
 			    opsize == TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT) {
-				mp_opt->addr.port = get_unaligned_be16(ptr);
+				mp_opt->addr.port = cpu_to_be16(get_unaligned_be16(ptr));
 				ptr += 2;
 			}
 		}
@@ -258,7 +258,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 			ptr += 16;
 			if (opsize == TCPOLEN_MPTCP_ADD_ADDR6_PORT ||
 			    opsize == TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT) {
-				mp_opt->addr.port = get_unaligned_be16(ptr);
+				mp_opt->addr.port = cpu_to_be16(get_unaligned_be16(ptr));
 				ptr += 2;
 			}
 		}
@@ -995,13 +995,13 @@ static bool add_addr_hmac_valid(struct mptcp_sock *msk,
 		hmac = add_addr_generate_hmac(msk->remote_key,
 					      msk->local_key,
 					      mp_opt->addr.id, &mp_opt->addr.addr,
-					      mp_opt->addr.port);
+					      be16_to_cpu(mp_opt->addr.port));
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
 	else
 		hmac = add_addr6_generate_hmac(msk->remote_key,
 					       msk->local_key,
 					       mp_opt->addr.id, &mp_opt->addr.addr6,
-					       mp_opt->addr.port);
+					       be16_to_cpu(mp_opt->addr.port));
 #endif
 
 	pr_debug("msk=%p, ahmac=%llu, mp_opt->ahmac=%llu\n",
-- 
2.30.2


  reply	other threads:[~2021-03-22 16:21 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 ` Matthieu Baerts [this message]
2021-03-23  4:02   ` [PATCH mptcp-next 2/3] Squash to "mptcp: use mptcp_addr_info in mptcp_options_received" 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 ` [PATCH mptcp-next 1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options" Geliang Tang

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=20210322162132.2471823-2-matthieu.baerts@tessares.net \
    --to=matthieu.baerts@tessares.net \
    --cc=geliangtang@gmail.com \
    --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).