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.
Unified · Split
| @@ -67,12 +67,6 @@ static inline void tcp_ecn_withdraw_cwr(struct tcp_sock *tp) · 66 unmodified lines | ||
| 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; |
| @@ -98,11 +92,6 @@ static inline void tcp_accecn_fail_mode_set(struct tcp_sock *tp, u8 mode) · 19 unmodified lines | ||
| 98 | 92 | tp->accecn_fail_mode |= mode; |
| 99 | 93 | } |
| 100 | 94 | |
| 101 | −#define TCP_ACCECN_OPT_NOT_SEEN 0x0 | |
| 102 | −#define TCP_ACCECN_OPT_EMPTY_SEEN 0x1 | |
| 103 | −#define TCP_ACCECN_OPT_COUNTER_SEEN 0x2 | |
| 104 | −#define TCP_ACCECN_OPT_FAIL_SEEN 0x3 | |
| 105 | − | |
| 106 | 95 | static inline u8 tcp_accecn_ace(const struct tcphdr *th) |
| 107 | 96 | { |
| 108 | 97 | return (th->ae << 2) | (th->cwr << 1) | th->ece; |
| @@ -226,6 +226,24 @@ enum tcp_ca_state { · 225 unmodified lines | ||
| 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; |
| @@ -316,15 +334,17 @@ struct tcp_info { · 84 unmodified lines | ||
| 316 | 334 | * in milliseconds, including any |
| 317 | 335 | * unfinished recovery. |
| 318 | 336 | */ |
| 319 | − __u32 tcpi_received_ce; /* # of CE marks received */ | |
| 337 | + __u32 tcpi_received_ce; /* # of CE marked segments received */ | |
| 320 | 338 | __u32 tcpi_delivered_e1_bytes; /* Accurate ECN byte counters */ |
| 321 | 339 | __u32 tcpi_delivered_e0_bytes; |
| 322 | 340 | __u32 tcpi_delivered_ce_bytes; |
| 323 | 341 | __u32 tcpi_received_e1_bytes; |
| 324 | 342 | __u32 tcpi_received_e0_bytes; |
| 325 | 343 | __u32 tcpi_received_ce_bytes; |
| 326 | − __u16 tcpi_accecn_fail_mode; | |
| 327 | − __u16 tcpi_accecn_opt_seen; | |
| 344 | + __u32 tcpi_ecn_mode:2, | |
| 345 | + tcpi_accecn_opt_seen:2, | |
| 346 | + tcpi_accecn_fail_mode:4, | |
| 347 | + tcpi_options2:24; | |
| 328 | 348 | }; |
| 329 | 349 | |
| 330 | 350 | /* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */ |
| @@ -4373,6 +4373,14 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) · 4372 unmodified lines | ||
| 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; |