Message ID | 20210322162132.2471823-1-matthieu.baerts@tessares.net |
---|---|
State | Accepted, archived |
Commit | 8759990266aabc4590010a387fb35678ed988bda |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | [mptcp-next,1/3] Squash to "mptcp: use mptcp_addr_info in mptcp_out_options" | expand |
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 >
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;
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(-)