From nobody Mon Jun 8 06:36:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08C45396D0A for ; Mon, 1 Jun 2026 09:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780307236; cv=none; b=LKnyHEdk5Bl3xqlX5Y6QML7b/EcxF69vDAJRna/LDGNa6780F70E7p7fleK3fgGvdYoghJRB5KTMXFRLDHVSpICZAXQWLqTGp8LfdpX+0zLFM8yS8/l/QlCkgJmezO8p1ytOxOnHvTcGKfDP8MGgk2SqKrPQ6B7J9yNvqtuaP4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780307236; c=relaxed/simple; bh=Nnbvm3KJc5pJz3axRyuFx5NX5tC+6aGL322rgvxPN1o=; h=Message-ID:Date:MIME-Version:From:Subject:References:To: In-Reply-To:Content-Type; b=FXd3PrAlcorWJ7EfqBsBeaT/Ii2whyrpK0IHFli/JpM9OggKlEJn1DGJHHc++yQlEPatTVtIQ57gFtyZW6KSsregfUZoPyiSVwt2I8lBF6em2DwZYKjpvdxqpBPA45O3HSzcTb9eib7lPjKrGv9UJjcugEmca84yz99dSikNUbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gjsNCZ3D; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gjsNCZ3D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9D681F00893 for ; Mon, 1 Jun 2026 09:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780307223; bh=9jcW5YWcJt1EBJ8h2uli8qTovIMy54Ws0O/8wEiLEt0=; h=Date:From:Subject:References:To:In-Reply-To; b=gjsNCZ3DpAycSLPkYMvt9XY+mL/0R5XyJI8SlsBQl2dPdRVsOk6EOmt7kQ7JfC15E rqZx2uVRN1YMZPpUMul/hgPG+sGk4CZkV4R4QmULK9FTRGWthgGn2CxLoNnDRQE2uX r1elgTzDI+1AuJsvbPOlF7MzEf33Ew5romAiAkRkPsxuc//alQvdKiA5SB8g7PB9kb wEPEagy6a4q9dWWvA9XXSsaHKOfFdrcmIdSqn31ZSt/fACzXoTe77hTfhCs8izVR89 9huOaoNjJSA6qvvilQGOQSCL7z/j088Wbl3xIKSYqZc5ub34lvSteUeRKo4m4a5N7y Utn9KUfxd/M4A== Message-ID: <7a377984-5a2e-4981-96dc-c76076f93f4a@kernel.org> Date: Mon, 1 Jun 2026 19:47:00 +1000 Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta From: Matthieu Baerts Subject: [PATCH net-next] mptcp: change mptcp_established_options() to return opt_size References: <20260601091816.444738-1-edumazet@google.com> Content-Language: fr To: MPTCP Linux Autocrypt: addr=matttbe@kernel.org; keydata= xsFNBFXj+ekBEADxVr99p2guPcqHFeI/JcFxls6KibzyZD5TQTyfuYlzEp7C7A9swoK5iCvf YBNdx5Xl74NLSgx6y/1NiMQGuKeu+2BmtnkiGxBNanfXcnl4L4Lzz+iXBvvbtCbynnnqDDqU c7SPFMpMesgpcu1xFt0F6bcxE+0ojRtSCZ5HDElKlHJNYtD1uwY4UYVGWUGCF/+cY1YLmtfb WdNb/SFo+Mp0HItfBC12qtDIXYvbfNUGVnA5jXeWMEyYhSNktLnpDL2gBUCsdbkov5VjiOX7 CRTkX0UgNWRjyFZwThaZADEvAOo12M5uSBk7h07yJ97gqv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ojfWsbq05zwYU+SCWS3NiyF6QghbW voxbFwX1i/0xRwJiX9NNbRj1huVKQuS4W7rbWA87TrVQPXUAdkyd7FRYICNW+0gddysIwPoa KrLfx3Ba6Rpx0JznbrVOtXlihjl4KV8mtOPjYDY9u+8x412xXnlGl6AC4HLu2F3ECkamY4G6 UxejX+E6vW6Xe4n7H+rEX5UFgPRdYkS1TA/X3nMen9bouxNsvIJv7C6adZmMHqu/2azX7S7I vrxxySzOw9GxjoVTuzWMKWpDGP8n71IFeOot8JuPZtJ8omz+DZel+WCNZMVdVNLPOd5frqOv mpz0VhFAlNTjU1Vy0CnuxX3AM51J8dpdNyG0S8rADh6C8AKCDOfUstpq28/6oTaQv7QZdge0 JY6dglzGKnCi/zsmp2+1w559frz4+IC7j/igvJGX4KDDKUs0mlld8J2u2sBXv7CGxdzQoHaz lzVbFe7fduHbABmYz9cefQpO7wDE/Q== Organization: NGI0 Core In-Reply-To: <20260601091816.444738-1-edumazet@google.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet Instead of passing opt_size address to mptcp_established_options(), change this function to return it by value. This removes the need for an expensive stack canary in tcp_established_options() when CONFIG_STACKPROTECTOR_STRONG=3Dy. $ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-92 (-92) Function old new delta tcp_options_write.isra 1423 1407 -16 mptcp_established_options 2746 2720 -26 tcp_established_options 553 503 -50 Total: Before=3D22110750, After=3D22110658, chg -0.00% Signed-off-by: Eric Dumazet --- include/net/mptcp.h | 18 +++++++++--------- net/ipv4/tcp_output.c | 7 ++++--- net/mptcp/options.c | 31 ++++++++++++++++--------------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index f7263fe2a2e40b507257c3720cc2d78d37357d6d..cd4639beceaa53c573135ddaeb7= 528a80b4ca824 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -149,9 +149,9 @@ bool mptcp_syn_options(struct sock *sk, const struct sk= _buff *skb, unsigned int *size, struct mptcp_out_options *opts); bool mptcp_synack_options(const struct request_sock *req, unsigned int *si= ze, struct mptcp_out_options *opts); -bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, - unsigned int *size, unsigned int remaining, - struct mptcp_out_options *opts); +int mptcp_established_options(struct sock *sk, struct sk_buff *skb, + unsigned int remaining, + struct mptcp_out_options *opts); bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb); void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock = *tp, @@ -266,13 +266,13 @@ static inline bool mptcp_synack_options(const struct = request_sock *req, return false; } -static inline bool mptcp_established_options(struct sock *sk, - struct sk_buff *skb, - unsigned int *size, - unsigned int remaining, - struct mptcp_out_options *opts) +static inline int mptcp_established_options(struct sock *sk, + struct sk_buff *skb, + unsigned int *size, + unsigned int remaining, + struct mptcp_out_options *opts) { - return false; + return -1; } static inline bool mptcp_incoming_options(struct sock *sk, diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ef0c10cd31c71ff585a937fde37f2b08b1214b5a..31b459ecbe8307a8660623038fe= a6fa7b0860f7f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1181,10 +1181,11 @@ static unsigned int tcp_established_options(struct = sock *sk, struct sk_buff *skb */ if (sk_is_mptcp(sk)) { unsigned int remaining =3D MAX_TCP_OPTION_SPACE - size; - unsigned int opt_size =3D 0; + int opt_size; - if (mptcp_established_options(sk, skb, &opt_size, remaining, - &opts->mptcp)) { + opt_size =3D mptcp_established_options(sk, skb, remaining, + &opts->mptcp); + if (opt_size >=3D 0) { opts->options |=3D OPTION_MPTCP; size +=3D opt_size; } diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8a1c5698983cff3082d68290626dd8f1e044527f..53528301394d70072dde6614fec= a6128ea949436 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -836,13 +836,14 @@ static bool mptcp_established_options_mp_fail(struct = sock *sk, return true; } -bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, - unsigned int *size, unsigned int remaining, - struct mptcp_out_options *opts) +int mptcp_established_options(struct sock *sk, struct sk_buff *skb, + unsigned int remaining, + struct mptcp_out_options *opts) { struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(sk); struct mptcp_sock *msk =3D mptcp_sk(subflow->conn); unsigned int opt_size =3D 0; + int total_size =3D 0; bool snd_data_fin; bool ret =3D false; @@ -852,20 +853,20 @@ bool mptcp_established_options(struct sock *sk, stru= ct sk_buff *skb, * option space. */ if (unlikely(__mptcp_check_fallback(msk) && !mptcp_check_infinite_map(skb= ))) - return true; + return 0; if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { if (mptcp_established_options_fastclose(sk, &opt_size, remaining, opts) = || mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) { - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; } /* MP_RST can be used with MP_FASTCLOSE and MP_FAIL if there is room */ if (mptcp_established_options_rst(sk, skb, &opt_size, remaining, opts)) { - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; } - return true; + return total_size; } snd_data_fin =3D mptcp_data_fin_enabled(msk); @@ -877,9 +878,9 @@ bool mptcp_established_options(struct sock *sk, struct = sk_buff *skb, ret =3D true; if (mptcp_established_options_mp_fail(sk, &mp_fail_size, remaining - opt_size, opts)) { - *size +=3D opt_size + mp_fail_size; + total_size +=3D opt_size + mp_fail_size; remaining -=3D opt_size - mp_fail_size; - return true; + return total_size; } } @@ -887,27 +888,27 @@ bool mptcp_established_options(struct sock *sk, stru= ct sk_buff *skb, * TCP option space would be fatal */ if (WARN_ON_ONCE(opt_size > remaining)) - return false; + return -1; - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; if (mptcp_established_options_add_addr(sk, skb, &opt_size, remaining, opt= s)) { - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; ret =3D true; } else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, op= ts)) { - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; ret =3D true; } if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) { - *size +=3D opt_size; + total_size +=3D opt_size; remaining -=3D opt_size; ret =3D true; } - return ret; + return ret ? total_size : -1; } bool mptcp_synack_options(const struct request_sock *req, unsigned int *s= ize, --=20 2.54.0.1013.g208068f2d8-goog