mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH mptcp-next 1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options"
@ 2021-03-22 16:21 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
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Matthieu Baerts @ 2021-03-22 16:21 UTC (permalink / raw)
  To: mptcp, mptcp; +Cc: Geliang Tang, Matthieu Baerts

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-23 10:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH mptcp-next 1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options" Geliang Tang

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).