|
26 | 26 | #include <linux/kref.h> |
27 | 27 | #include <linux/ktime.h> |
28 | 28 | #include <linux/indirect_call_wrapper.h> |
| 29 | +#include <linux/bits.h> |
29 | 30 |
|
30 | 31 | #include <net/inet_connection_sock.h> |
31 | 32 | #include <net/inet_timewait_sock.h> |
@@ -373,16 +374,53 @@ static inline void tcp_dec_quickack_mode(struct sock *sk) |
373 | 374 | } |
374 | 375 | } |
375 | 376 |
|
376 | | -#define TCP_ECN_OK 1 |
377 | | -#define TCP_ECN_QUEUE_CWR 2 |
378 | | -#define TCP_ECN_DEMAND_CWR 4 |
379 | | -#define TCP_ECN_SEEN 8 |
| 377 | +#define TCP_ECN_MODE_RFC3168 BIT(0) |
| 378 | +#define TCP_ECN_QUEUE_CWR BIT(1) |
| 379 | +#define TCP_ECN_DEMAND_CWR BIT(2) |
| 380 | +#define TCP_ECN_SEEN BIT(3) |
| 381 | +#define TCP_ECN_MODE_ACCECN BIT(4) |
| 382 | + |
| 383 | +#define TCP_ECN_DISABLED 0 |
| 384 | +#define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN) |
| 385 | +#define TCP_ECN_MODE_ANY (TCP_ECN_MODE_RFC3168 | TCP_ECN_MODE_ACCECN) |
| 386 | + |
| 387 | +static inline bool tcp_ecn_mode_any(const struct tcp_sock *tp) |
| 388 | +{ |
| 389 | + return tp->ecn_flags & TCP_ECN_MODE_ANY; |
| 390 | +} |
| 391 | + |
| 392 | +static inline bool tcp_ecn_mode_rfc3168(const struct tcp_sock *tp) |
| 393 | +{ |
| 394 | + return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_RFC3168; |
| 395 | +} |
| 396 | + |
| 397 | +static inline bool tcp_ecn_mode_accecn(const struct tcp_sock *tp) |
| 398 | +{ |
| 399 | + return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_ACCECN; |
| 400 | +} |
| 401 | + |
| 402 | +static inline bool tcp_ecn_disabled(const struct tcp_sock *tp) |
| 403 | +{ |
| 404 | + return !tcp_ecn_mode_any(tp); |
| 405 | +} |
| 406 | + |
| 407 | +static inline bool tcp_ecn_mode_pending(const struct tcp_sock *tp) |
| 408 | +{ |
| 409 | + return (tp->ecn_flags & TCP_ECN_MODE_PENDING) == TCP_ECN_MODE_PENDING; |
| 410 | +} |
| 411 | + |
| 412 | +static inline void tcp_ecn_mode_set(struct tcp_sock *tp, u8 mode) |
| 413 | +{ |
| 414 | + tp->ecn_flags &= ~TCP_ECN_MODE_ANY; |
| 415 | + tp->ecn_flags |= mode; |
| 416 | +} |
380 | 417 |
|
381 | 418 | enum tcp_tw_status { |
382 | 419 | TCP_TW_SUCCESS = 0, |
383 | 420 | TCP_TW_RST = 1, |
384 | 421 | TCP_TW_ACK = 2, |
385 | | - TCP_TW_SYN = 3 |
| 422 | + TCP_TW_SYN = 3, |
| 423 | + TCP_TW_ACK_OOW = 4 |
386 | 424 | }; |
387 | 425 |
|
388 | 426 |
|
@@ -669,7 +707,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority, |
669 | 707 | enum sk_rst_reason reason); |
670 | 708 | int tcp_send_synack(struct sock *); |
671 | 709 | void tcp_push_one(struct sock *, unsigned int mss_now); |
672 | | -void __tcp_send_ack(struct sock *sk, u32 rcv_nxt); |
| 710 | +void __tcp_send_ack(struct sock *sk, u32 rcv_nxt, u16 flags); |
673 | 711 | void tcp_send_ack(struct sock *sk); |
674 | 712 | void tcp_send_delayed_ack(struct sock *sk); |
675 | 713 | void tcp_send_loss_probe(struct sock *sk); |
@@ -934,15 +972,22 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) |
934 | 972 |
|
935 | 973 | #define tcp_flag_byte(th) (((u_int8_t *)th)[13]) |
936 | 974 |
|
937 | | -#define TCPHDR_FIN 0x01 |
938 | | -#define TCPHDR_SYN 0x02 |
939 | | -#define TCPHDR_RST 0x04 |
940 | | -#define TCPHDR_PSH 0x08 |
941 | | -#define TCPHDR_ACK 0x10 |
942 | | -#define TCPHDR_URG 0x20 |
943 | | -#define TCPHDR_ECE 0x40 |
944 | | -#define TCPHDR_CWR 0x80 |
945 | | - |
| 975 | +#define TCPHDR_FIN BIT(0) |
| 976 | +#define TCPHDR_SYN BIT(1) |
| 977 | +#define TCPHDR_RST BIT(2) |
| 978 | +#define TCPHDR_PSH BIT(3) |
| 979 | +#define TCPHDR_ACK BIT(4) |
| 980 | +#define TCPHDR_URG BIT(5) |
| 981 | +#define TCPHDR_ECE BIT(6) |
| 982 | +#define TCPHDR_CWR BIT(7) |
| 983 | +#define TCPHDR_AE BIT(8) |
| 984 | +#define TCPHDR_FLAGS_MASK (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \ |
| 985 | + TCPHDR_PSH | TCPHDR_ACK | TCPHDR_URG | \ |
| 986 | + TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) |
| 987 | +#define tcp_flags_ntohs(th) (ntohs(*(__be16 *)&tcp_flag_word(th)) & \ |
| 988 | + TCPHDR_FLAGS_MASK) |
| 989 | + |
| 990 | +#define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) |
946 | 991 | #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) |
947 | 992 |
|
948 | 993 | /* State flags for sacked in struct tcp_skb_cb */ |
@@ -977,7 +1022,7 @@ struct tcp_skb_cb { |
977 | 1022 | u16 tcp_gso_size; |
978 | 1023 | }; |
979 | 1024 | }; |
980 | | - __u8 tcp_flags; /* TCP header flags. (tcp[13]) */ |
| 1025 | + __u16 tcp_flags; /* TCP header flags (tcp[12-13])*/ |
981 | 1026 |
|
982 | 1027 | __u8 sacked; /* State flags for SACK. */ |
983 | 1028 | __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */ |
@@ -1132,9 +1177,9 @@ enum tcp_ca_ack_event_flags { |
1132 | 1177 | #define TCP_CA_UNSPEC 0 |
1133 | 1178 |
|
1134 | 1179 | /* Algorithm can be set on socket without CAP_NET_ADMIN privileges */ |
1135 | | -#define TCP_CONG_NON_RESTRICTED 0x1 |
| 1180 | +#define TCP_CONG_NON_RESTRICTED BIT(0) |
1136 | 1181 | /* Requires ECN/ECT set on all packets */ |
1137 | | -#define TCP_CONG_NEEDS_ECN 0x2 |
| 1182 | +#define TCP_CONG_NEEDS_ECN BIT(1) |
1138 | 1183 | #define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN) |
1139 | 1184 |
|
1140 | 1185 | union tcp_cc_info; |
|
0 commit comments