* [PATCH MPTCP-next] mptcp: fix checksum byte order
@ 2022-05-05 15:09 Paolo Abeni
2022-05-05 15:17 ` mptcp: fix checksum byte order: Build Failure MPTCP CI
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Paolo Abeni @ 2022-05-05 15:09 UTC (permalink / raw)
To: mptcp
The MPTCP code typecasts the checksum value to u16 and
then convert it to big endian while storing the value into
the MPTCP option.
As a result, the wire encoding for little endian host is
wrong, and that causes interoperabilty interoperability
issues with other implementation or host with different endianess.
Address the issue writing in the packet the unmodified __sum16 value.
The change is not backward compatible, but I can't see any
other option. MPTCP checksum is disabled by default, and there are
no backward issues with csum disabled.
Fixes: c5b39e26d003 ("mptcp: send out checksum for DSS")
Fixes: 390b95a5fb84 ("mptcp: receive checksum for DSS")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/mptcp/options.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index ac3b7b8a02f6..5b5849d9fe60 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -107,7 +107,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
ptr += 2;
}
if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM) {
- mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr);
+ mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
ptr += 2;
}
@@ -221,7 +221,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
if (opsize == expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) {
mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
- mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr);
+ mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
ptr += 2;
}
@@ -1282,7 +1282,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
}
}
-u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
+__sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
{
struct csum_pseudo_header header;
__wsum csum;
@@ -1298,15 +1298,23 @@ u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
header.csum = 0;
csum = csum_partial(&header, sizeof(header), sum);
- return (__force u16)csum_fold(csum);
+ return csum_fold(csum);
}
-static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
+static __sum16 mptcp_make_csum(const struct mptcp_ext *mpext)
{
return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data_len,
~csum_unfold(mpext->csum));
}
+static void put_len_csum(u16 len, __sum16 csum, __be16 *ptr)
+{
+ put_unaligned_be16(len, ptr);
+
+ ptr += 1;
+ put_unaligned(csum, ptr);
+}
+
void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
struct mptcp_out_options *opts)
{
@@ -1385,9 +1393,9 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
/* data_len == 0 is reserved for the infinite mapping,
* the checksum will also be set to 0.
*/
- put_unaligned_be32(mpext->data_len << 16 |
- (mpext->data_len ? mptcp_make_csum(mpext) : 0),
- ptr);
+ put_len_csum(mpext->data_len,
+ mpext->data_len ? mptcp_make_csum(mpext) : 0,
+ (__force __be16 *)ptr);
} else {
put_unaligned_be32(mpext->data_len << 16 |
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
@@ -1438,11 +1446,12 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
goto mp_capable_done;
if (opts->csum_reqd) {
- put_unaligned_be32(opts->data_len << 16 |
- __mptcp_make_csum(opts->data_seq,
- opts->subflow_seq,
- opts->data_len,
- ~csum_unfold(opts->csum)), ptr);
+ put_len_csum(opts->data_len,
+ __mptcp_make_csum(opts->data_seq,
+ opts->subflow_seq,
+ opts->data_len,
+ ~csum_unfold(opts->csum)),
+ (__force __be16 *)ptr);
} else {
put_unaligned_be32(opts->data_len << 16 |
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: mptcp: fix checksum byte order: Build Failure
2022-05-05 15:09 [PATCH MPTCP-next] mptcp: fix checksum byte order Paolo Abeni
@ 2022-05-05 15:17 ` MPTCP CI
2022-05-05 16:33 ` mptcp: fix checksum byte order: Tests Results MPTCP CI
2022-05-06 1:37 ` [PATCH MPTCP-next] mptcp: fix checksum byte order Mat Martineau
2 siblings, 0 replies; 5+ messages in thread
From: MPTCP CI @ 2022-05-05 15:17 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
Hi Paolo,
Thank you for your modifications, that's great!
But sadly, our CI spotted some issues with it when trying to build it.
You can find more details there:
https://patchwork.kernel.org/project/mptcp/patch/1a8201582e7fd63db7b5c9c4077af1ab1953c57e.1651763323.git.pabeni@redhat.com/
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/2276563461
Status: failure
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e13b663008d0
Feel free to reply to this email if you cannot access logs, if you need
some support to fix the error, if this doesn't seem to be caused by your
modifications or if the error is a false positive one.
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mptcp: fix checksum byte order: Tests Results
2022-05-05 15:09 [PATCH MPTCP-next] mptcp: fix checksum byte order Paolo Abeni
2022-05-05 15:17 ` mptcp: fix checksum byte order: Build Failure MPTCP CI
@ 2022-05-05 16:33 ` MPTCP CI
2022-05-06 1:37 ` [PATCH MPTCP-next] mptcp: fix checksum byte order Mat Martineau
2 siblings, 0 replies; 5+ messages in thread
From: MPTCP CI @ 2022-05-05 16:33 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
Hi Paolo,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal:
- Unstable: 2 failed test(s): selftest_mptcp_join selftest_simult_flows 🔴:
- Task: https://cirrus-ci.com/task/5796430060191744
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5796430060191744/summary/summary.txt
- KVM Validation: debug:
- Unstable: 2 failed test(s): selftest_diag selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5233480106770432
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5233480106770432/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e13b663008d0
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debug
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH MPTCP-next] mptcp: fix checksum byte order
2022-05-05 15:09 [PATCH MPTCP-next] mptcp: fix checksum byte order Paolo Abeni
2022-05-05 15:17 ` mptcp: fix checksum byte order: Build Failure MPTCP CI
2022-05-05 16:33 ` mptcp: fix checksum byte order: Tests Results MPTCP CI
@ 2022-05-06 1:37 ` Mat Martineau
2 siblings, 0 replies; 5+ messages in thread
From: Mat Martineau @ 2022-05-06 1:37 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
On Thu, 5 May 2022, Paolo Abeni wrote:
> The MPTCP code typecasts the checksum value to u16 and
> then convert it to big endian while storing the value into
> the MPTCP option.
>
> As a result, the wire encoding for little endian host is
> wrong, and that causes interoperabilty interoperability
> issues with other implementation or host with different endianess.
>
> Address the issue writing in the packet the unmodified __sum16 value.
>
> The change is not backward compatible, but I can't see any
> other option. MPTCP checksum is disabled by default, and there are
> no backward issues with csum disabled.
>
See my reply a few minutes ago on the "Re: apropos
https://github.com/multipath-tcp/mptcp_net-next/issues/265" thread, maybe
we do have some backward-compatibility-via-fallback options?
> Fixes: c5b39e26d003 ("mptcp: send out checksum for DSS")
> Fixes: 390b95a5fb84 ("mptcp: receive checksum for DSS")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> net/mptcp/options.c | 35 ++++++++++++++++++++++-------------
> 1 file changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> index ac3b7b8a02f6..5b5849d9fe60 100644
> --- a/net/mptcp/options.c
> +++ b/net/mptcp/options.c
> @@ -107,7 +107,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
> ptr += 2;
> }
> if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM) {
> - mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr);
> + mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
> mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
> ptr += 2;
> }
> @@ -221,7 +221,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
>
> if (opsize == expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) {
> mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
> - mp_opt->csum = (__force __sum16)get_unaligned_be16(ptr);
> + mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
> ptr += 2;
> }
>
> @@ -1282,7 +1282,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
> }
> }
>
> -u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
> +__sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
> {
> struct csum_pseudo_header header;
> __wsum csum;
> @@ -1298,15 +1298,23 @@ u16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
> header.csum = 0;
>
> csum = csum_partial(&header, sizeof(header), sum);
> - return (__force u16)csum_fold(csum);
> + return csum_fold(csum);
> }
>
> -static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
> +static __sum16 mptcp_make_csum(const struct mptcp_ext *mpext)
> {
> return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data_len,
> ~csum_unfold(mpext->csum));
> }
>
> +static void put_len_csum(u16 len, __sum16 csum, __be16 *ptr)
If ptr was a __be32, this code could do the casting inside this function
and the callers would look a little cleaner. Not a big deal though -
existing code ok if there's a good rationale for the __be16 that I'm
missing.
Other than that, there is the warning from CI to fix and basing this on
mptcp-net.
I haven't had a chance to try this in a mixed-endian setup yet but Maxim's
tests looked promising.
- Mat
> +{
> + put_unaligned_be16(len, ptr);
> +
> + ptr += 1;
> + put_unaligned(csum, ptr);
> +}
> +
> void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
> struct mptcp_out_options *opts)
> {
> @@ -1385,9 +1393,9 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
> /* data_len == 0 is reserved for the infinite mapping,
> * the checksum will also be set to 0.
> */
> - put_unaligned_be32(mpext->data_len << 16 |
> - (mpext->data_len ? mptcp_make_csum(mpext) : 0),
> - ptr);
> + put_len_csum(mpext->data_len,
> + mpext->data_len ? mptcp_make_csum(mpext) : 0,
> + (__force __be16 *)ptr);
> } else {
> put_unaligned_be32(mpext->data_len << 16 |
> TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
> @@ -1438,11 +1446,12 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
> goto mp_capable_done;
>
> if (opts->csum_reqd) {
> - put_unaligned_be32(opts->data_len << 16 |
> - __mptcp_make_csum(opts->data_seq,
> - opts->subflow_seq,
> - opts->data_len,
> - ~csum_unfold(opts->csum)), ptr);
> + put_len_csum(opts->data_len,
> + __mptcp_make_csum(opts->data_seq,
> + opts->subflow_seq,
> + opts->data_len,
> + ~csum_unfold(opts->csum)),
> + (__force __be16 *)ptr);
> } else {
> put_unaligned_be32(opts->data_len << 16 |
> TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
> --
> 2.35.1
>
>
>
--
Mat Martineau
Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH MPTCP-next] mptcp: fix checksum byte order
@ 2022-05-05 23:18 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-05-05 23:18 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 5367 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <1a8201582e7fd63db7b5c9c4077af1ab1953c57e.1651763323.git.pabeni@redhat.com>
References: <1a8201582e7fd63db7b5c9c4077af1ab1953c57e.1651763323.git.pabeni@redhat.com>
TO: Paolo Abeni <pabeni@redhat.com>
TO: mptcp(a)lists.linux.dev
Hi Paolo,
I love your patch! Perhaps something to improve:
[auto build test WARNING on mptcp/export]
[cannot apply to linus/master v5.18-rc5 next-20220505]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Paolo-Abeni/mptcp-fix-checksum-byte-order/20220505-233437
base: https://github.com/multipath-tcp/mptcp_net-next.git export
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago
config: i386-randconfig-s001 (https://download.01.org/0day-ci/archive/20220506/202205060733.fq2O0rJw-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/intel-lab-lkp/linux/commit/7c590435ab3cef4d69c98e00effb7882679a7861
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Paolo-Abeni/mptcp-fix-checksum-byte-order/20220505-233437
git checkout 7c590435ab3cef4d69c98e00effb7882679a7861
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash net/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
net/mptcp/options.c:1285:9: sparse: sparse: symbol '__mptcp_make_csum' redeclared with different type (different base types):
>> net/mptcp/options.c:1285:9: sparse: restricted __sum16 extern [addressable] [toplevel] __mptcp_make_csum( ... )
net/mptcp/options.c: note: in included file:
net/mptcp/protocol.h:766:5: sparse: note: previously declared as:
>> net/mptcp/protocol.h:766:5: sparse: unsigned short extern [addressable] [toplevel] [unsigned] __mptcp_make_csum( ... )
>> net/mptcp/options.c:1315:9: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 x @@ got restricted __sum16 [usertype] csum @@
net/mptcp/options.c:1315:9: sparse: expected restricted __be16 x
net/mptcp/options.c:1315:9: sparse: got restricted __sum16 [usertype] csum
vim +1285 net/mptcp/options.c
fa3fe2b150316b Florian Westphal 2020-11-19 1284
7c590435ab3cef Paolo Abeni 2022-05-05 @1285 __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
c94b1f96dcfb2e Geliang Tang 2021-06-17 1286 {
c94b1f96dcfb2e Geliang Tang 2021-06-17 1287 struct csum_pseudo_header header;
c94b1f96dcfb2e Geliang Tang 2021-06-17 1288 __wsum csum;
c94b1f96dcfb2e Geliang Tang 2021-06-17 1289
c94b1f96dcfb2e Geliang Tang 2021-06-17 1290 /* cfr RFC 8684 3.3.1.:
c94b1f96dcfb2e Geliang Tang 2021-06-17 1291 * the data sequence number used in the pseudo-header is
c94b1f96dcfb2e Geliang Tang 2021-06-17 1292 * always the 64-bit value, irrespective of what length is used in the
c94b1f96dcfb2e Geliang Tang 2021-06-17 1293 * DSS option itself.
c94b1f96dcfb2e Geliang Tang 2021-06-17 1294 */
f7cc8890f30d3d Davide Caratti 2021-10-27 1295 header.data_seq = cpu_to_be64(data_seq);
f7cc8890f30d3d Davide Caratti 2021-10-27 1296 header.subflow_seq = htonl(subflow_seq);
f7cc8890f30d3d Davide Caratti 2021-10-27 1297 header.data_len = htons(data_len);
c94b1f96dcfb2e Geliang Tang 2021-06-17 1298 header.csum = 0;
c94b1f96dcfb2e Geliang Tang 2021-06-17 1299
c312ee219100e8 Geliang Tang 2022-01-07 1300 csum = csum_partial(&header, sizeof(header), sum);
7c590435ab3cef Paolo Abeni 2022-05-05 1301 return csum_fold(csum);
c94b1f96dcfb2e Geliang Tang 2021-06-17 1302 }
c94b1f96dcfb2e Geliang Tang 2021-06-17 1303
7c590435ab3cef Paolo Abeni 2022-05-05 1304 static __sum16 mptcp_make_csum(const struct mptcp_ext *mpext)
f7cc8890f30d3d Davide Caratti 2021-10-27 1305 {
f7cc8890f30d3d Davide Caratti 2021-10-27 1306 return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data_len,
c312ee219100e8 Geliang Tang 2022-01-07 1307 ~csum_unfold(mpext->csum));
f7cc8890f30d3d Davide Caratti 2021-10-27 1308 }
f7cc8890f30d3d Davide Caratti 2021-10-27 1309
7c590435ab3cef Paolo Abeni 2022-05-05 1310 static void put_len_csum(u16 len, __sum16 csum, __be16 *ptr)
7c590435ab3cef Paolo Abeni 2022-05-05 1311 {
7c590435ab3cef Paolo Abeni 2022-05-05 1312 put_unaligned_be16(len, ptr);
7c590435ab3cef Paolo Abeni 2022-05-05 1313
7c590435ab3cef Paolo Abeni 2022-05-05 1314 ptr += 1;
7c590435ab3cef Paolo Abeni 2022-05-05 @1315 put_unaligned(csum, ptr);
7c590435ab3cef Paolo Abeni 2022-05-05 1316 }
7c590435ab3cef Paolo Abeni 2022-05-05 1317
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-06 1:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 15:09 [PATCH MPTCP-next] mptcp: fix checksum byte order Paolo Abeni
2022-05-05 15:17 ` mptcp: fix checksum byte order: Build Failure MPTCP CI
2022-05-05 16:33 ` mptcp: fix checksum byte order: Tests Results MPTCP CI
2022-05-06 1:37 ` [PATCH MPTCP-next] mptcp: fix checksum byte order Mat Martineau
2022-05-05 23:18 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.