Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: accecn: add tcpi_ecn_mode and tcpi_option2 in tcp_info

Add 2-bit tcpi_ecn_mode feild within tcp_info to indicate which ECN
mode is negotiated: ECN_MODE_DISABLED, ECN_MODE_RFC3168, ECN_MODE_ACCECN,
or ECN_MODE_PENDING. This is done by utilizing available bits from
tcpi_accecn_opt_seen (reduced from 16 bits to 2 bits) and
tcpi_accecn_fail_mode (reduced from 16 bits to 4 bits).

Also, an extra 24-bit tcpi_options2 field is identified to represent
newer options and connection features, as all 8 bits of tcpi_options
field have been used.

Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Co-developed-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260131222515.8485-14-chia-yu.chang@nokia-bell-labs.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Chia-Yu Chang and committed by
Paolo Abeni
4fa4ac5e 1247fb19

+31 -14
-11
include/net/tcp_ecn.h
··· 67 67 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; 68 68 } 69 69 70 - /* tp->accecn_fail_mode */ 71 - #define TCP_ACCECN_ACE_FAIL_SEND BIT(0) 72 - #define TCP_ACCECN_ACE_FAIL_RECV BIT(1) 73 - #define TCP_ACCECN_OPT_FAIL_SEND BIT(2) 74 - #define TCP_ACCECN_OPT_FAIL_RECV BIT(3) 75 - 76 70 static inline bool tcp_accecn_ace_fail_send(const struct tcp_sock *tp) 77 71 { 78 72 return tp->accecn_fail_mode & TCP_ACCECN_ACE_FAIL_SEND; ··· 91 97 { 92 98 tp->accecn_fail_mode |= mode; 93 99 } 94 - 95 - #define TCP_ACCECN_OPT_NOT_SEEN 0x0 96 - #define TCP_ACCECN_OPT_EMPTY_SEEN 0x1 97 - #define TCP_ACCECN_OPT_COUNTER_SEEN 0x2 98 - #define TCP_ACCECN_OPT_FAIL_SEEN 0x3 99 100 100 101 static inline u8 tcp_accecn_ace(const struct tcphdr *th) 101 102 {
+23 -3
include/uapi/linux/tcp.h
··· 226 226 #define TCPF_CA_Loss (1<<TCP_CA_Loss) 227 227 }; 228 228 229 + /* Values for tcpi_ecn_mode after negotiation */ 230 + #define TCPI_ECN_MODE_DISABLED 0x0 231 + #define TCPI_ECN_MODE_RFC3168 0x1 232 + #define TCPI_ECN_MODE_ACCECN 0x2 233 + #define TCPI_ECN_MODE_PENDING 0x3 234 + 235 + /* Values for accecn_opt_seen */ 236 + #define TCP_ACCECN_OPT_NOT_SEEN 0x0 237 + #define TCP_ACCECN_OPT_EMPTY_SEEN 0x1 238 + #define TCP_ACCECN_OPT_COUNTER_SEEN 0x2 239 + #define TCP_ACCECN_OPT_FAIL_SEEN 0x3 240 + 241 + /* Values for accecn_fail_mode */ 242 + #define TCP_ACCECN_ACE_FAIL_SEND BIT(0) 243 + #define TCP_ACCECN_ACE_FAIL_RECV BIT(1) 244 + #define TCP_ACCECN_OPT_FAIL_SEND BIT(2) 245 + #define TCP_ACCECN_OPT_FAIL_RECV BIT(3) 246 + 229 247 struct tcp_info { 230 248 __u8 tcpi_state; 231 249 __u8 tcpi_ca_state; ··· 334 316 * in milliseconds, including any 335 317 * unfinished recovery. 336 318 */ 337 - __u32 tcpi_received_ce; /* # of CE marks received */ 319 + __u32 tcpi_received_ce; /* # of CE marked segments received */ 338 320 __u32 tcpi_delivered_e1_bytes; /* Accurate ECN byte counters */ 339 321 __u32 tcpi_delivered_e0_bytes; 340 322 __u32 tcpi_delivered_ce_bytes; 341 323 __u32 tcpi_received_e1_bytes; 342 324 __u32 tcpi_received_e0_bytes; 343 325 __u32 tcpi_received_ce_bytes; 344 - __u16 tcpi_accecn_fail_mode; 345 - __u16 tcpi_accecn_opt_seen; 326 + __u32 tcpi_ecn_mode:2, 327 + tcpi_accecn_opt_seen:2, 328 + tcpi_accecn_fail_mode:4, 329 + tcpi_options2:24; 346 330 }; 347 331 348 332 /* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */
+8
net/ipv4/tcp.c
··· 4373 4373 if (tp->rto_stamp) 4374 4374 info->tcpi_total_rto_time += tcp_clock_ms() - tp->rto_stamp; 4375 4375 4376 + if (tcp_ecn_disabled(tp)) 4377 + info->tcpi_ecn_mode = TCPI_ECN_MODE_DISABLED; 4378 + else if (tcp_ecn_mode_rfc3168(tp)) 4379 + info->tcpi_ecn_mode = TCPI_ECN_MODE_RFC3168; 4380 + else if (tcp_ecn_mode_accecn(tp)) 4381 + info->tcpi_ecn_mode = TCPI_ECN_MODE_ACCECN; 4382 + else if (tcp_ecn_mode_pending(tp)) 4383 + info->tcpi_ecn_mode = TCPI_ECN_MODE_PENDING; 4376 4384 info->tcpi_accecn_fail_mode = tp->accecn_fail_mode; 4377 4385 info->tcpi_accecn_opt_seen = tp->saw_accecn_opt; 4378 4386 info->tcpi_received_ce = tp->received_ce;