Subject: linux-next: manual merge of the net-next tree with the net tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 19 May 2022 11:51:46 +1000

Hi all,

Today's linux-next merge of the net-next tree got conflicts in:

  net/mptcp/options.c

between commit:

  ba2c89e0ea74 ("mptcp: fix checksum byte order")

from the net tree and commits:

  1e39e5a32ad7 ("mptcp: infinite mapping sending")
  ea66758c1795 ("tcp: allow MPTCP to update the announced window")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc net/mptcp/options.c
index b548cec86c9d,ac3b7b8a02f6..000000000000
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@@ -1234,13 -1236,53 +1236,53 @@@ static void mptcp_set_rwin(struct tcp_s
  	subflow = mptcp_subflow_ctx(ssk);
  	msk = mptcp_sk(subflow->conn);
  
- 	ack_seq = READ_ONCE(msk->ack_seq) + tp->rcv_wnd;
+ 	ack_seq = READ_ONCE(msk->ack_seq);
+ 	rcv_wnd_new = ack_seq + tp->rcv_wnd;
+ 
+ 	rcv_wnd_old = atomic64_read(&msk->rcv_wnd_sent);
+ 	if (after64(rcv_wnd_new, rcv_wnd_old)) {
+ 		u64 rcv_wnd;
+ 
+ 		for (;;) {
+ 			rcv_wnd = atomic64_cmpxchg(&msk->rcv_wnd_sent, rcv_wnd_old, rcv_wnd_new);
+ 
+ 			if (rcv_wnd == rcv_wnd_old)
+ 				break;
+ 			if (before64(rcv_wnd_new, rcv_wnd)) {
+ 				MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICTUPDATE);
+ 				goto raise_win;
+ 			}
+ 			MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT);
+ 			rcv_wnd_old = rcv_wnd;
+ 		}
+ 		return;
+ 	}
+ 
+ 	if (rcv_wnd_new != rcv_wnd_old) {
+ raise_win:
+ 		win = rcv_wnd_old - ack_seq;
+ 		tp->rcv_wnd = min_t(u64, win, U32_MAX);
+ 		new_win = tp->rcv_wnd;
  
- 	if (after64(ack_seq, READ_ONCE(msk->rcv_wnd_sent)))
- 		WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
+ 		/* Make sure we do not exceed the maximum possible
+ 		 * scaled window.
+ 		 */
+ 		if (unlikely(th->syn))
+ 			new_win = min(new_win, 65535U) << tp->rx_opt.rcv_wscale;
+ 		if (!tp->rx_opt.rcv_wscale &&
+ 		    sock_net(ssk)->ipv4.sysctl_tcp_workaround_signed_windows)
+ 			new_win = min(new_win, MAX_TCP_WINDOW);
+ 		else
+ 			new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
+ 
+ 		/* RFC1323 scaling applied */
+ 		new_win >>= tp->rx_opt.rcv_wscale;
+ 		th->window = htons(new_win);
+ 		MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDSHARED);
+ 	}
  }
  
 -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;
@@@ -1265,17 -1307,7 +1307,17 @@@ static __sum16 mptcp_make_csum(const st
  				 ~csum_unfold(mpext->csum));
  }
  
 +static void put_len_csum(u16 len, __sum16 csum, void *data)
 +{
 +	__sum16 *sumptr = data + 2;
 +	__be16 *ptr = data;
 +
 +	put_unaligned_be16(len, ptr);
 +
 +	put_unaligned(csum, sumptr);
 +}
 +
- void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
+ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
  			 struct mptcp_out_options *opts)
  {
  	const struct sock *ssk = (const struct sock *)tp;
@@@ -1350,9 -1382,12 +1392,12 @@@
  			put_unaligned_be32(mpext->subflow_seq, ptr);
  			ptr += 1;
  			if (opts->csum_reqd) {
+ 				/* 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,
- 					     mptcp_make_csum(mpext),
++					     (mpext->data_len ? mptcp_make_csum(mpext) : 0),
 +					     ptr);
  			} else {
  				put_unaligned_be32(mpext->data_len << 16 |
  						   TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);