Message ID | b179cd8cddc1deb12561370d1fda19ad885b048d.1603952836.git.geliangtang@gmail.com |
---|---|
State | Superseded, archived |
Delegated to: | Mat Martineau |
Headers | show |
Series | ADD_ADDR: ports support | expand |
On Thu, 29 Oct 2020, Geliang Tang wrote: > The port field in mptcp_options_received should be big-endian, since we > use the following assignment statement in mptcp_parse_option: > > mp_opt->port = get_unaligned_be16(ptr); > > And the addr.port is also big-endian, so we need to drop htons in > mptcp_incoming_options. > Please keep mp_opt->port in CPU byte order and adjust other code to fit that. get_unaligned_be16 does the byte order conversion if needed. > Signed-off-by: Geliang Tang <geliangtang@gmail.com> > --- > net/mptcp/options.c | 3 ++- > net/mptcp/protocol.h | 2 +- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/net/mptcp/options.c b/net/mptcp/options.c > index f983deb534ae..87998edcce4e 100644 > --- a/net/mptcp/options.c > +++ b/net/mptcp/options.c > @@ -269,6 +269,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, > mp_opt->ahmac = get_unaligned_be64(ptr); > ptr += 8; > } > + pr_debug("port=%d, ahmac=%llu", ntohs(mp_opt->port), mp_opt->ahmac); > break; > > case MPTCPOPT_RM_ADDR: > @@ -936,7 +937,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) > if (mp_opt.add_addr && add_addr_hmac_valid(msk, &mp_opt)) { > struct mptcp_addr_info addr; > > - addr.port = htons(mp_opt.port); > + addr.port = mp_opt.port; > addr.id = mp_opt.addr_id; > if (mp_opt.family == MPTCP_ADDR_IPVERSION_4) { > addr.family = AF_INET; > diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h > index f2cf09afd542..4c3350ed8d92 100644 > --- a/net/mptcp/protocol.h > +++ b/net/mptcp/protocol.h > @@ -136,7 +136,7 @@ struct mptcp_options_received { > #endif > }; > u64 ahmac; > - u16 port; > + __be16 port; > }; > > static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field) > -- > 2.26.2 -- Mat Martineau Intel
diff --git a/net/mptcp/options.c b/net/mptcp/options.c index f983deb534ae..87998edcce4e 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -269,6 +269,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, mp_opt->ahmac = get_unaligned_be64(ptr); ptr += 8; } + pr_debug("port=%d, ahmac=%llu", ntohs(mp_opt->port), mp_opt->ahmac); break; case MPTCPOPT_RM_ADDR: @@ -936,7 +937,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) if (mp_opt.add_addr && add_addr_hmac_valid(msk, &mp_opt)) { struct mptcp_addr_info addr; - addr.port = htons(mp_opt.port); + addr.port = mp_opt.port; addr.id = mp_opt.addr_id; if (mp_opt.family == MPTCP_ADDR_IPVERSION_4) { addr.family = AF_INET; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f2cf09afd542..4c3350ed8d92 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -136,7 +136,7 @@ struct mptcp_options_received { #endif }; u64 ahmac; - u16 port; + __be16 port; }; static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
The port field in mptcp_options_received should be big-endian, since we use the following assignment statement in mptcp_parse_option: mp_opt->port = get_unaligned_be16(ptr); And the addr.port is also big-endian, so we need to drop htons in mptcp_incoming_options. Signed-off-by: Geliang Tang <geliangtang@gmail.com> --- net/mptcp/options.c | 3 ++- net/mptcp/protocol.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)