mptcp: change mptcp_established_options() to return opt_size
Subsystems (4)
PATCH 1/1 mptcp: change mptcp_established_options() to return opt_size
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=y.
$ 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=22110750, After=22110658, chg -0.00%
--- include/net/mptcp.h | 18 +++++++++--------- net/ipv4/tcp_output.c | 7 ++++--- net/mptcp/options.c | 31 ++++++++++++++++--------------- 3 files changed, 29 insertions(+), 27 deletions(-)
include/net/mptcp.h +9 -9
@@ -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 *size,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,
net/ipv4/tcp_output.c +4 -3
@@ -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 =MAX_TCP_OPTION_SPACE - size; -unsigned int opt_size =0 ; +int opt_size; -if (mptcp_established_options (sk, skb, &opt_size, remaining, - &opts->mptcp)) { + opt_size =mptcp_established_options (sk, skb, remaining, + &opts->mptcp); +if (opt_size >=0 ) { opts->options |=OPTION_MPTCP ; size += opt_size; }
net/mptcp/options.c +16 -15
@@ -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 =mptcp_subflow_ctx (sk);struct mptcp_sock *msk =mptcp_sk (subflow->conn);unsigned int opt_size =0 ; +int total_size =0 ;bool snd_data_fin;bool ret = false;
@@ -852,20 +853,20 @@ bool mptcp_established_options(struct sock *sk, struct 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 += opt_size; + total_size += opt_size; remaining -= 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 += opt_size; + total_size += opt_size; remaining -= opt_size; } -return true; +return total_size; } snd_data_fin =mptcp_data_fin_enabled (msk);
@@ -877,9 +878,9 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, ret = true;if (mptcp_established_options_mp_fail (sk, &mp_fail_size, remaining - opt_size, opts)) { - *size += opt_size + mp_fail_size; + total_size += opt_size + mp_fail_size; remaining -= opt_size - mp_fail_size; -return true; +return total_size; } }
@@ -887,27 +888,27 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,* TCP option space would be fatal */ if (WARN_ON_ONCE (opt_size > remaining)) -return false; +return -1 ; - *size += opt_size; + total_size += opt_size; remaining -= opt_size;if (mptcp_established_options_add_addr (sk, skb, &opt_size, remaining, opts)) { - *size += opt_size; + total_size += opt_size; remaining -= opt_size; ret = true; }else if (mptcp_established_options_rm_addr (sk, &opt_size, remaining, opts)) { - *size += opt_size; + total_size += opt_size; remaining -= opt_size; ret = true; }if (mptcp_established_options_mp_prio (sk, &opt_size, remaining, opts)) { - *size += opt_size; + total_size += opt_size; remaining -= opt_size; ret = true; } -return ret; +return ret ? total_size :-1 ; } bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
Signature · 1 line
2.54.0.1013.g208068f2d8-goog
Matthieu Baerts
maintainerPATCH 1/1 mptcp: change mptcp_established_options() to return opt_size
From: Eric Dumazet <[email protected]>
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=y.
$ 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=22110750, After=22110658, chg -0.00%
--- include/net/mptcp.h | 18 +++++++++--------- net/ipv4/tcp_output.c | 7 ++++--- net/mptcp/options.c | 31 ++++++++++++++++--------------- 3 files changed, 29 insertions(+), 27 deletions(-)
include/net/mptcp.h +9 -8
@@ -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 *size,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,
net/ipv4/tcp_output.c +4 -2
@@ -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 =MAX_TCP_OPTION_SPACE - size; -unsigned int opt_size =0 ; +int opt_size; - if (mptcp_established_options(sk, skb, &opt_size, remaining, - &opts->mptcp)) { + opt_size = mptcp_established_options(sk, skb, remaining, + &opts->mptcp); + if (opt_size >= 0) { opts->options |= OPTION_MPTCP; size += opt_size; }
net/mptcp/options.c +4 -2
@@ -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 = mptcp_subflow_ctx(sk);struct mptcp_sock *msk =mptcp_sk (subflow->conn);unsigned int opt_size =0 ; +int total_size =0 ;bool snd_data_fin;bool ret = false; @@ -852,20 +853,20 @@ bool mptcp_established_options(struct sock *sk, struct 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 += opt_size;
+ total_size += opt_size;
remaining -= 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 += opt_size;
+ total_size += opt_size;
remaining -= opt_size;
}
- return true;
+ return total_size;
}
snd_data_fin = mptcp_data_fin_enabled(msk);
@@ -877,9 +878,9 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
ret = true;
if (mptcp_established_options_mp_fail(sk, &mp_fail_size,
remaining - opt_size, opts)) {
- *size += opt_size + mp_fail_size;
+ total_size += opt_size + mp_fail_size;
remaining -= opt_size - mp_fail_size;
- return true;
+ return total_size;
}
}
@@ -887,27 +888,27 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
* TCP option space would be fatal
*/
if (WARN_ON_ONCE(opt_size > remaining))
- return false;
+ return -1;
- *size += opt_size;
+ total_size += opt_size;
remaining -= opt_size;
if (mptcp_established_options_add_addr(sk, skb, &opt_size, remaining, opts)) {
- *size += opt_size;
+ total_size += opt_size;
remaining -= opt_size;
ret = true;
} else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
- *size += opt_size;
+ total_size += opt_size;
remaining -= opt_size;
ret = true;
}
if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
- *size += opt_size;
+ total_size += opt_size;
remaining -= opt_size;
ret = true;
}
- return ret;
+ return ret ? total_size : -1;
}
bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
Signature · 1 line
2.54.0.1013.g208068f2d8-goog
Hi Eric,
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://github.com/multipath-tcp/mptcp_net-next/actions/runs/26748250142
Status: failure
Initiator: Matthieu Baerts (NGI0)
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4514016d2e89
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1103913
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 (NGI0 Core)
Hi Eric,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_add_addr ⚠️
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/26748250136
Initiator: Matthieu Baerts (NGI0)
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4514016d2e89
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1103913
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-normalFor 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 (NGI0 Core)
Matthieu Baerts
maintainerHello,
01 Jun 2026 21:13:02 MPTCP CI <[email protected]>:
Quoted 1 line
- KVM Validation: normal (except
selftest_mptcp_join): Unstable: 1 failed test(s):packetdrill_add_addr⚠️
FYI, this failed test is expected: the patch has been applied on an older base to avoid conflicts, and these tests depend on new features.
Cheers,
Matt
Matthieu Baerts
maintainerHi Eric,
Quoted 6 lines · Eric Dumazet
Instead of passing
opt_sizeaddress tomptcp_established_options(), change this function to return it by value.This removes the need for an expensive stack canary in
tcp_established_options()whenCONFIG_STACKPROTECTOR_STRONG=y.
Quoted 7 lines
$ 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=22110750, After=22110658, chg -0.00%
Thank you for looking at that!
Quoted 19 lines
include/net/mptcp.h +3
-3@@ -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 *size,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;
include/net/mptcp.h static inline bool mptcp_synack_options(const struct request_sock *req, · line 271
Quoted 10 lines
include/net/mptcp.h +3
-5} -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,
I guess this line should be removed: that's the version when MPTCP is not enabled.
Apart from that, the rest looks good to me!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Quoted 40 lines · Matthieu Baerts
Hi Eric,
Quoted 6 lines · Eric Dumazet
Instead of passing
opt_sizeaddress tomptcp_established_options(), change this function to return it by value.This removes the need for an expensive stack canary in
tcp_established_options()whenCONFIG_STACKPROTECTOR_STRONG=y.Quoted 7 lines
$ 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=22110750, After=22110658, chg -0.00%Thank you for looking at that!
Quoted 21 lines
include/net/mptcp.h +3
-3@@ -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 *size,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; }
Quoted 11 lines
include/net/mptcp.h static inline bool mptcp_synack_options(const struct request_sock *req, · line 271
Quoted 8 lines
include/net/mptcp.h +3
-5-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,I guess this line should be removed: that's the version when MPTCP is not enabled.
Ack, I am sending a V2 fixing this. Thanks!
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/mptcp-change-mptcp_established_options-to-return-opt_size/20260601-174435 base: net-next/main patch link: https://lore.kernel.org/r/20260601091816.444738-1-edumazet%40google.com patch subject: [PATCH net-next] mptcp: change mptcp_established_options() to return opt_size config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260601/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260601/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> net/ipv4/tcp_output.c:1187:24: error: too few arguments to function call, expected 5, have 4
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ~~~~~~~~~~~~~~~~~~~~~~~~~
1187 | &opts->mptcp);
| ^
include/net/mptcp.h:269:19: note: 'mptcp_established_options' declared here
269 | static inline int mptcp_established_options(struct sock *sk,
| ^ ~~~~~~~~~~~~~~~~
270 | struct sk_buff *skb,
| ~~~~~~~~~~~~~~~~~~~~
271 | unsigned int *size,
| ~~~~~~~~~~~~~~~~~~~
272 | unsigned int remaining,
| ~~~~~~~~~~~~~~~~~~~~~~~
273 | struct mptcp_out_options *opts)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
vim +1187 net/ipv4/tcp_output.c
1145
1146 /* Compute TCP options for ESTABLISHED sockets. This is not the
1147 * final wire format yet.
1148 */
1149 static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,
1150 struct tcp_out_options *opts,
1151 struct tcp_key *key)
1152 {
1153 struct tcp_sock *tp = tcp_sk(sk);
1154 unsigned int size = 0;
1155 unsigned int eff_sacks;
1156
1157 opts->options = 0;
1158
1159 /* Better than switch (key.type) as it has static branches */
1160 if (tcp_key_is_md5(key)) {
1161 opts->options |= OPTION_MD5;
1162 size += TCPOLEN_MD5SIG_ALIGNED;
1163 } else if (tcp_key_is_ao(key)) {
1164 opts->options |= OPTION_AO;
1165 size += tcp_ao_len_aligned(key->ao_key);
1166 }
1167
1168 if (likely(tp->rx_opt.tstamp_ok)) {
1169 opts->options |= OPTION_TS;
1170 opts->tsval = skb ? tcp_skb_timestamp_ts(tp->tcp_usec_ts, skb) +
1171 tp->tsoffset : 0;
1172 opts->tsecr = tp->rx_opt.ts_recent;
1173 size += TCPOLEN_TSTAMP_ALIGNED;
1174 }
1175
1176 /* MPTCP options have precedence over SACK for the limited TCP
1177 * option space because a MPTCP connection would be forced to
1178 * fall back to regular TCP if a required multipath option is
1179 * missing. SACK still gets a chance to use whatever space is
1180 * left.
1181 */
1182 if (sk_is_mptcp(sk)) {
1183 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1184 int opt_size;
1185
1186 opt_size = mptcp_established_options(sk, skb, remaining,
> 1187 &opts->mptcp);
1188 if (opt_size >= 0) {
1189 opts->options |= OPTION_MPTCP;
1190 size += opt_size;
1191 }
1192 }
1193
1194 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
1195 if (unlikely(eff_sacks)) {
1196 const unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1197 if (likely(remaining >= TCPOLEN_SACK_BASE_ALIGNED +
1198 TCPOLEN_SACK_PERBLOCK)) {
1199 opts->num_sack_blocks =
1200 min_t(unsigned int, eff_sacks,
1201 (remaining - TCPOLEN_SACK_BASE_ALIGNED) /
1202 TCPOLEN_SACK_PERBLOCK);
1203
1204 size += TCPOLEN_SACK_BASE_ALIGNED +
1205 opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
1206 } else {
1207 opts->num_sack_blocks = 0;
1208 }
1209 } else {
1210 opts->num_sack_blocks = 0;
1211 }
1212
1213 if (tcp_ecn_mode_accecn(tp)) {
1214 int ecn_opt = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option);
1215
1216 if (ecn_opt && tp->saw_accecn_opt &&
1217 (ecn_opt >= TCP_ACCECN_OPTION_PERSIST ||
1218 !tcp_accecn_opt_fail_send(tp)) &&
1219 (ecn_opt >= TCP_ACCECN_OPTION_FULL || tp->accecn_opt_demand ||
1220 tcp_accecn_option_beacon_check(sk))) {
1221 opts->use_synack_ecn_bytes = 0;
1222 size += tcp_options_fit_accecn(opts, tp->accecn_minlen,
1223 MAX_TCP_OPTION_SPACE - size);
1224 }
1225 }
1226
1227 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp,
1228 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG))) {
1229 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1230
1231 bpf_skops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts, &remaining);
1232
1233 size = MAX_TCP_OPTION_SPACE - remaining;
1234 }
1235
1236 return size;
1237 }
1238
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/mptcp-change-mptcp_established_options-to-return-opt_size/20260601-174435 base: net-next/main patch link: https://lore.kernel.org/r/20260601091816.444738-1-edumazet%40google.com patch subject: [PATCH net-next] mptcp: change mptcp_established_options() to return opt_size config: i386-randconfig-007-20260602 (https://download.01.org/0day-ci/archive/20260602/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260602/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
net/ipv4/tcp_output.c: In function 'tcp_established_options':
>> net/ipv4/tcp_output.c:1186:63: error: passing argument 3 of 'mptcp_established_options' makes pointer from integer without a cast [-Wint-conversion]
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~
| |
| unsigned int
In file included from include/net/tcp.h:44,
from net/ipv4/tcp_output.c:40:
include/net/mptcp.h:271:59: note: expected 'unsigned int *' but argument is of type 'unsigned int'
271 | unsigned int *size,
| ~~~~~~~~~~~~~~^~~~
>> net/ipv4/tcp_output.c:1187:54: error: passing argument 4 of 'mptcp_established_options' makes integer from pointer without a cast [-Wint-conversion]
1187 | &opts->mptcp);
| ^~~~~~~~~~~~
| |
| struct mptcp_out_options *
include/net/mptcp.h:272:58: note: expected 'unsigned int' but argument is of type 'struct mptcp_out_options *'
272 | unsigned int remaining,
| ~~~~~~~~~~~~~^~~~~~~~~
>> net/ipv4/tcp_output.c:1186:28: error: too few arguments to function 'mptcp_established_options' 1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/net/mptcp.h:269:19: note: declared here
269 | static inline int mptcp_established_options(struct sock *sk,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
vim +/mptcp_established_options +1186 net/ipv4/tcp_output.c
1145
1146 /* Compute TCP options for ESTABLISHED sockets. This is not the
1147 * final wire format yet.
1148 */
1149 static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,
1150 struct tcp_out_options *opts,
1151 struct tcp_key *key)
1152 {
1153 struct tcp_sock *tp = tcp_sk(sk);
1154 unsigned int size = 0;
1155 unsigned int eff_sacks;
1156
1157 opts->options = 0;
1158
1159 /* Better than switch (key.type) as it has static branches */
1160 if (tcp_key_is_md5(key)) {
1161 opts->options |= OPTION_MD5;
1162 size += TCPOLEN_MD5SIG_ALIGNED;
1163 } else if (tcp_key_is_ao(key)) {
1164 opts->options |= OPTION_AO;
1165 size += tcp_ao_len_aligned(key->ao_key);
1166 }
1167
1168 if (likely(tp->rx_opt.tstamp_ok)) {
1169 opts->options |= OPTION_TS;
1170 opts->tsval = skb ? tcp_skb_timestamp_ts(tp->tcp_usec_ts, skb) +
1171 tp->tsoffset : 0;
1172 opts->tsecr = tp->rx_opt.ts_recent;
1173 size += TCPOLEN_TSTAMP_ALIGNED;
1174 }
1175
1176 /* MPTCP options have precedence over SACK for the limited TCP
1177 * option space because a MPTCP connection would be forced to
1178 * fall back to regular TCP if a required multipath option is
1179 * missing. SACK still gets a chance to use whatever space is
1180 * left.
1181 */
1182 if (sk_is_mptcp(sk)) {
1183 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1184 int opt_size;
1185
> 1186 opt_size = mptcp_established_options(sk, skb, remaining, > 1187 &opts->mptcp);
1188 if (opt_size >= 0) {
1189 opts->options |= OPTION_MPTCP;
1190 size += opt_size;
1191 }
1192 }
1193
1194 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
1195 if (unlikely(eff_sacks)) {
1196 const unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1197 if (likely(remaining >= TCPOLEN_SACK_BASE_ALIGNED +
1198 TCPOLEN_SACK_PERBLOCK)) {
1199 opts->num_sack_blocks =
1200 min_t(unsigned int, eff_sacks,
1201 (remaining - TCPOLEN_SACK_BASE_ALIGNED) /
1202 TCPOLEN_SACK_PERBLOCK);
1203
1204 size += TCPOLEN_SACK_BASE_ALIGNED +
1205 opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
1206 } else {
1207 opts->num_sack_blocks = 0;
1208 }
1209 } else {
1210 opts->num_sack_blocks = 0;
1211 }
1212
1213 if (tcp_ecn_mode_accecn(tp)) {
1214 int ecn_opt = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option);
1215
1216 if (ecn_opt && tp->saw_accecn_opt &&
1217 (ecn_opt >= TCP_ACCECN_OPTION_PERSIST ||
1218 !tcp_accecn_opt_fail_send(tp)) &&
1219 (ecn_opt >= TCP_ACCECN_OPTION_FULL || tp->accecn_opt_demand ||
1220 tcp_accecn_option_beacon_check(sk))) {
1221 opts->use_synack_ecn_bytes = 0;
1222 size += tcp_options_fit_accecn(opts, tp->accecn_minlen,
1223 MAX_TCP_OPTION_SPACE - size);
1224 }
1225 }
1226
1227 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp,
1228 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG))) {
1229 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1230
1231 bpf_skops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts, &remaining);
1232
1233 size = MAX_TCP_OPTION_SPACE - remaining;
1234 }
1235
1236 return size;
1237 }
1238
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/mptcp-change-mptcp_established_options-to-return-opt_size/20260601-174435 base: net-next/main patch link: https://lore.kernel.org/r/20260601091816.444738-1-edumazet%40google.com patch subject: [PATCH net-next] mptcp: change mptcp_established_options() to return opt_size config: powerpc-arches_defconfig (https://download.01.org/0day-ci/archive/20260602/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260602/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
net/ipv4/tcp_output.c: In function 'tcp_established_options':
net/ipv4/tcp_output.c:1186:63: error: passing argument 3 of 'mptcp_established_options' makes pointer from integer without a cast [-Wint-conversion]
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~
| |
| unsigned int
net/ipv4/tcp_output.c:1186:63: note: possible fix: take the address with '&'
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~
| &
In file included from include/net/tcp.h:44,
from net/ipv4/tcp_output.c:40:
include/net/mptcp.h:271:59: note: expected 'unsigned int *' but argument is of type 'unsigned int'
271 | unsigned int *size,
| ~~~~~~~~~~~~~~^~~~
net/ipv4/tcp_output.c:1187:54: error: passing argument 4 of 'mptcp_established_options' makes integer from pointer without a cast [-Wint-conversion]
1187 | &opts->mptcp);
| ^~~~~~~~~~~~
| |
| struct mptcp_out_options *
include/net/mptcp.h:272:58: note: expected 'unsigned int' but argument is of type 'struct mptcp_out_options *'
272 | unsigned int remaining,
| ~~~~~~~~~~~~~^~~~~~~~~
>> net/ipv4/tcp_output.c:1186:28: error: too few arguments to function 'mptcp_established_options'; expected 5, have 4 1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/net/mptcp.h:269:19: note: declared here
269 | static inline int mptcp_established_options(struct sock *sk,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
vim +/mptcp_established_options +1186 net/ipv4/tcp_output.c
1145
1146 /* Compute TCP options for ESTABLISHED sockets. This is not the
1147 * final wire format yet.
1148 */
1149 static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,
1150 struct tcp_out_options *opts,
1151 struct tcp_key *key)
1152 {
1153 struct tcp_sock *tp = tcp_sk(sk);
1154 unsigned int size = 0;
1155 unsigned int eff_sacks;
1156
1157 opts->options = 0;
1158
1159 /* Better than switch (key.type) as it has static branches */
1160 if (tcp_key_is_md5(key)) {
1161 opts->options |= OPTION_MD5;
1162 size += TCPOLEN_MD5SIG_ALIGNED;
1163 } else if (tcp_key_is_ao(key)) {
1164 opts->options |= OPTION_AO;
1165 size += tcp_ao_len_aligned(key->ao_key);
1166 }
1167
1168 if (likely(tp->rx_opt.tstamp_ok)) {
1169 opts->options |= OPTION_TS;
1170 opts->tsval = skb ? tcp_skb_timestamp_ts(tp->tcp_usec_ts, skb) +
1171 tp->tsoffset : 0;
1172 opts->tsecr = tp->rx_opt.ts_recent;
1173 size += TCPOLEN_TSTAMP_ALIGNED;
1174 }
1175
1176 /* MPTCP options have precedence over SACK for the limited TCP
1177 * option space because a MPTCP connection would be forced to
1178 * fall back to regular TCP if a required multipath option is
1179 * missing. SACK still gets a chance to use whatever space is
1180 * left.
1181 */
1182 if (sk_is_mptcp(sk)) {
1183 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1184 int opt_size;
1185
> 1186 opt_size = mptcp_established_options(sk, skb, remaining,
1187 &opts->mptcp);
1188 if (opt_size >= 0) {
1189 opts->options |= OPTION_MPTCP;
1190 size += opt_size;
1191 }
1192 }
1193
1194 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
1195 if (unlikely(eff_sacks)) {
1196 const unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1197 if (likely(remaining >= TCPOLEN_SACK_BASE_ALIGNED +
1198 TCPOLEN_SACK_PERBLOCK)) {
1199 opts->num_sack_blocks =
1200 min_t(unsigned int, eff_sacks,
1201 (remaining - TCPOLEN_SACK_BASE_ALIGNED) /
1202 TCPOLEN_SACK_PERBLOCK);
1203
1204 size += TCPOLEN_SACK_BASE_ALIGNED +
1205 opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
1206 } else {
1207 opts->num_sack_blocks = 0;
1208 }
1209 } else {
1210 opts->num_sack_blocks = 0;
1211 }
1212
1213 if (tcp_ecn_mode_accecn(tp)) {
1214 int ecn_opt = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option);
1215
1216 if (ecn_opt && tp->saw_accecn_opt &&
1217 (ecn_opt >= TCP_ACCECN_OPTION_PERSIST ||
1218 !tcp_accecn_opt_fail_send(tp)) &&
1219 (ecn_opt >= TCP_ACCECN_OPTION_FULL || tp->accecn_opt_demand ||
1220 tcp_accecn_option_beacon_check(sk))) {
1221 opts->use_synack_ecn_bytes = 0;
1222 size += tcp_options_fit_accecn(opts, tp->accecn_minlen,
1223 MAX_TCP_OPTION_SPACE - size);
1224 }
1225 }
1226
1227 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp,
1228 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG))) {
1229 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1230
1231 bpf_skops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts, &remaining);
1232
1233 size = MAX_TCP_OPTION_SPACE - remaining;
1234 }
1235
1236 return size;
1237 }
1238
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Eric,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/mptcp-change-mptcp_established_options-to-return-opt_size/20260601-174435 base: net-next/main patch link: https://lore.kernel.org/r/20260601091816.444738-1-edumazet%40google.com patch subject: [PATCH net-next] mptcp: change mptcp_established_options() to return opt_size config: nios2-defconfig (https://download.01.org/0day-ci/archive/20260602/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260602/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
net/ipv4/tcp_output.c: In function 'tcp_established_options':
>> net/ipv4/tcp_output.c:1186:63: warning: passing argument 3 of 'mptcp_established_options' makes pointer from integer without a cast [-Wint-conversion]
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~
| |
| unsigned int
In file included from include/net/tcp.h:44,
from net/ipv4/tcp_output.c:40:
include/net/mptcp.h:271:59: note: expected 'unsigned int *' but argument is of type 'unsigned int'
271 | unsigned int *size,
| ~~~~~~~~~~~~~~^~~~
>> net/ipv4/tcp_output.c:1187:54: warning: passing argument 4 of 'mptcp_established_options' makes integer from pointer without a cast [-Wint-conversion]
1187 | &opts->mptcp);
| ^~~~~~~~~~~~
| |
| struct mptcp_out_options *
In file included from include/net/tcp.h:44,
from net/ipv4/tcp_output.c:40:
include/net/mptcp.h:272:58: note: expected 'unsigned int' but argument is of type 'struct mptcp_out_options *'
272 | unsigned int remaining,
| ~~~~~~~~~~~~~^~~~~~~~~
net/ipv4/tcp_output.c:1186:28: error: too few arguments to function 'mptcp_established_options'
1186 | opt_size = mptcp_established_options(sk, skb, remaining,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/net/tcp.h:44,
from net/ipv4/tcp_output.c:40: include/net/mptcp.h:269:19: note: declared here
269 | static inline int mptcp_established_options(struct sock *sk,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
vim +/mptcp_established_options +1186 net/ipv4/tcp_output.c
1145
1146 /* Compute TCP options for ESTABLISHED sockets. This is not the
1147 * final wire format yet.
1148 */
1149 static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,
1150 struct tcp_out_options *opts,
1151 struct tcp_key *key)
1152 {
1153 struct tcp_sock *tp = tcp_sk(sk);
1154 unsigned int size = 0;
1155 unsigned int eff_sacks;
1156
1157 opts->options = 0;
1158
1159 /* Better than switch (key.type) as it has static branches */
1160 if (tcp_key_is_md5(key)) {
1161 opts->options |= OPTION_MD5;
1162 size += TCPOLEN_MD5SIG_ALIGNED;
1163 } else if (tcp_key_is_ao(key)) {
1164 opts->options |= OPTION_AO;
1165 size += tcp_ao_len_aligned(key->ao_key);
1166 }
1167
1168 if (likely(tp->rx_opt.tstamp_ok)) {
1169 opts->options |= OPTION_TS;
1170 opts->tsval = skb ? tcp_skb_timestamp_ts(tp->tcp_usec_ts, skb) +
1171 tp->tsoffset : 0;
1172 opts->tsecr = tp->rx_opt.ts_recent;
1173 size += TCPOLEN_TSTAMP_ALIGNED;
1174 }
1175
1176 /* MPTCP options have precedence over SACK for the limited TCP
1177 * option space because a MPTCP connection would be forced to
1178 * fall back to regular TCP if a required multipath option is
1179 * missing. SACK still gets a chance to use whatever space is
1180 * left.
1181 */
1182 if (sk_is_mptcp(sk)) {
1183 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1184 int opt_size;
1185
> 1186 opt_size = mptcp_established_options(sk, skb, remaining, > 1187 &opts->mptcp);
1188 if (opt_size >= 0) {
1189 opts->options |= OPTION_MPTCP;
1190 size += opt_size;
1191 }
1192 }
1193
1194 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
1195 if (unlikely(eff_sacks)) {
1196 const unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1197 if (likely(remaining >= TCPOLEN_SACK_BASE_ALIGNED +
1198 TCPOLEN_SACK_PERBLOCK)) {
1199 opts->num_sack_blocks =
1200 min_t(unsigned int, eff_sacks,
1201 (remaining - TCPOLEN_SACK_BASE_ALIGNED) /
1202 TCPOLEN_SACK_PERBLOCK);
1203
1204 size += TCPOLEN_SACK_BASE_ALIGNED +
1205 opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
1206 } else {
1207 opts->num_sack_blocks = 0;
1208 }
1209 } else {
1210 opts->num_sack_blocks = 0;
1211 }
1212
1213 if (tcp_ecn_mode_accecn(tp)) {
1214 int ecn_opt = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_option);
1215
1216 if (ecn_opt && tp->saw_accecn_opt &&
1217 (ecn_opt >= TCP_ACCECN_OPTION_PERSIST ||
1218 !tcp_accecn_opt_fail_send(tp)) &&
1219 (ecn_opt >= TCP_ACCECN_OPTION_FULL || tp->accecn_opt_demand ||
1220 tcp_accecn_option_beacon_check(sk))) {
1221 opts->use_synack_ecn_bytes = 0;
1222 size += tcp_options_fit_accecn(opts, tp->accecn_minlen,
1223 MAX_TCP_OPTION_SPACE - size);
1224 }
1225 }
1226
1227 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp,
1228 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG))) {
1229 unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
1230
1231 bpf_skops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts, &remaining);
1232
1233 size = MAX_TCP_OPTION_SPACE - remaining;
1234 }
1235
1236 return size;
1237 }
1238
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki