Skip to content

Commit ea66758

Browse files
Paolo Abenikuba-moo
authored andcommitted
tcp: allow MPTCP to update the announced window
The MPTCP RFC requires that the MPTCP-level receive window's right edge never moves backward. Currently the MPTCP code enforces such constraint while tracking the right edge, but it does not reflects it on the wire, as MPTCP lacks a suitable hook to update accordingly the TCP header. This change modifies the existing mptcp_write_options() hook, providing the current packet's TCP header to the MPTCP protocol, so that the next patch could implement the above mentioned constraint. No functional changes intended. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 92be2f5 commit ea66758

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

include/net/mptcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
125125
struct mptcp_out_options *opts);
126126
bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb);
127127

128-
void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
128+
void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
129129
struct mptcp_out_options *opts);
130130

131131
void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info);

net/ipv4/tcp_output.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,13 @@ struct tcp_out_options {
445445
struct mptcp_out_options mptcp;
446446
};
447447

448-
static void mptcp_options_write(__be32 *ptr, const struct tcp_sock *tp,
448+
static void mptcp_options_write(struct tcphdr *th, __be32 *ptr,
449+
struct tcp_sock *tp,
449450
struct tcp_out_options *opts)
450451
{
451452
#if IS_ENABLED(CONFIG_MPTCP)
452453
if (unlikely(OPTION_MPTCP & opts->options))
453-
mptcp_write_options(ptr, tp, &opts->mptcp);
454+
mptcp_write_options(th, ptr, tp, &opts->mptcp);
454455
#endif
455456
}
456457

@@ -606,9 +607,10 @@ static void bpf_skops_write_hdr_opt(struct sock *sk, struct sk_buff *skb,
606607
* At least SACK_PERM as the first option is known to lead to a disaster
607608
* (but it may well be that other scenarios fail similarly).
608609
*/
609-
static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
610+
static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp,
610611
struct tcp_out_options *opts)
611612
{
613+
__be32 *ptr = (__be32 *)(th + 1);
612614
u16 options = opts->options; /* mungable copy */
613615

614616
if (unlikely(OPTION_MD5 & options)) {
@@ -702,7 +704,7 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
702704

703705
smc_options_write(ptr, &options);
704706

705-
mptcp_options_write(ptr, tp, opts);
707+
mptcp_options_write(th, ptr, tp, opts);
706708
}
707709

708710
static void smc_set_option(const struct tcp_sock *tp,
@@ -1355,7 +1357,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
13551357
th->window = htons(min(tp->rcv_wnd, 65535U));
13561358
}
13571359

1358-
tcp_options_write((__be32 *)(th + 1), tp, &opts);
1360+
tcp_options_write(th, tp, &opts);
13591361

13601362
#ifdef CONFIG_TCP_MD5SIG
13611363
/* Calculate the MD5 hash, as we have all we need now */
@@ -3591,7 +3593,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
35913593

35923594
/* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
35933595
th->window = htons(min(req->rsk_rcv_wnd, 65535U));
3594-
tcp_options_write((__be32 *)(th + 1), NULL, &opts);
3596+
tcp_options_write(th, NULL, &opts);
35953597
th->doff = (tcp_header_size >> 2);
35963598
__TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS);
35973599

net/mptcp/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ static u16 mptcp_make_csum(const struct mptcp_ext *mpext)
12651265
~csum_unfold(mpext->csum));
12661266
}
12671267

1268-
void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
1268+
void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
12691269
struct mptcp_out_options *opts)
12701270
{
12711271
const struct sock *ssk = (const struct sock *)tp;

0 commit comments

Comments
 (0)