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

tcp: extend TCP flags to allow AE bit/ACE field

With AccECN, there's one additional TCP flag to be used (AE)
and ACE field that overloads the definition of AE, CWR, and
ECE flags. As tcp_flags was previously only 1 byte, the
byte-order stuff needs to be added to it's handling.

Signed-off-by: Ilpo Järvinen <ij@kernel.org>
Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ilpo Järvinen and committed by
David S. Miller
2c2f08d3 0114a91d

+25 -13
+8 -1
include/net/tcp.h
··· 943 943 #define TCPHDR_URG BIT(5) 944 944 #define TCPHDR_ECE BIT(6) 945 945 #define TCPHDR_CWR BIT(7) 946 + #define TCPHDR_AE BIT(8) 947 + #define TCPHDR_FLAGS_MASK (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \ 948 + TCPHDR_PSH | TCPHDR_ACK | TCPHDR_URG | \ 949 + TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) 950 + #define tcp_flags_ntohs(th) (ntohs(*(__be16 *)&tcp_flag_word(th)) & \ 951 + TCPHDR_FLAGS_MASK) 946 952 953 + #define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) 947 954 #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) 948 955 949 956 /* State flags for sacked in struct tcp_skb_cb */ ··· 985 978 u16 tcp_gso_size; 986 979 }; 987 980 }; 988 - __u8 tcp_flags; /* TCP header flags. (tcp[13]) */ 981 + __u16 tcp_flags; /* TCP header flags (tcp[12-13])*/ 989 982 990 983 __u8 sacked; /* State flags for SACK. */ 991 984 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
+6 -3
include/uapi/linux/tcp.h
··· 28 28 __be32 seq; 29 29 __be32 ack_seq; 30 30 #if defined(__LITTLE_ENDIAN_BITFIELD) 31 - __u16 res1:4, 31 + __u16 ae:1, 32 + res1:3, 32 33 doff:4, 33 34 fin:1, 34 35 syn:1, ··· 41 40 cwr:1; 42 41 #elif defined(__BIG_ENDIAN_BITFIELD) 43 42 __u16 doff:4, 44 - res1:4, 43 + res1:3, 44 + ae:1, 45 45 cwr:1, 46 46 ece:1, 47 47 urg:1, ··· 72 70 #define tcp_flag_word(tp) (((union tcp_word_hdr *)(tp))->words[3]) 73 71 74 72 enum { 73 + TCP_FLAG_AE = __constant_cpu_to_be32(0x01000000), 75 74 TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), 76 75 TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), 77 76 TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), ··· 81 78 TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), 82 79 TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), 83 80 TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), 84 - TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), 81 + TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0E000000), 85 82 TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) 86 83 }; 87 84
+1 -1
net/ipv4/tcp_ipv4.c
··· 2159 2159 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + 2160 2160 skb->len - th->doff * 4); 2161 2161 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 2162 - TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); 2162 + TCP_SKB_CB(skb)->tcp_flags = tcp_flags_ntohs(th); 2163 2163 TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph); 2164 2164 TCP_SKB_CB(skb)->sacked = 0; 2165 2165 TCP_SKB_CB(skb)->has_rxtstamp =
+4 -4
net/ipv4/tcp_output.c
··· 403 403 /* Constructs common control bits of non-data skb. If SYN/FIN is present, 404 404 * auto increment end seqno. 405 405 */ 406 - static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags) 406 + static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u16 flags) 407 407 { 408 408 skb->ip_summed = CHECKSUM_PARTIAL; 409 409 ··· 1395 1395 th->seq = htonl(tcb->seq); 1396 1396 th->ack_seq = htonl(rcv_nxt); 1397 1397 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 1398 - tcb->tcp_flags); 1398 + (tcb->tcp_flags & TCPHDR_FLAGS_MASK)); 1399 1399 1400 1400 th->check = 0; 1401 1401 th->urg_ptr = 0; ··· 1616 1616 struct sk_buff *buff; 1617 1617 int old_factor; 1618 1618 long limit; 1619 + u16 flags; 1619 1620 int nlen; 1620 - u8 flags; 1621 1621 1622 1622 if (WARN_ON(len > skb->len)) 1623 1623 return -EINVAL; ··· 2171 2171 { 2172 2172 int nlen = skb->len - len; 2173 2173 struct sk_buff *buff; 2174 - u8 flags; 2174 + u16 flags; 2175 2175 2176 2176 /* All of a TSO frame must be composed of paged data. */ 2177 2177 DEBUG_NET_WARN_ON_ONCE(skb->len != skb->data_len);
+1 -1
net/ipv6/tcp_ipv6.c
··· 1731 1731 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + 1732 1732 skb->len - th->doff*4); 1733 1733 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 1734 - TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); 1734 + TCP_SKB_CB(skb)->tcp_flags = tcp_flags_ntohs(th); 1735 1735 TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr); 1736 1736 TCP_SKB_CB(skb)->sacked = 0; 1737 1737 TCP_SKB_CB(skb)->has_rxtstamp =
+5 -3
net/netfilter/nf_log_syslog.c
··· 216 216 /* Max length: 9 "RES=0x3C " */ 217 217 nf_log_buf_add(m, "RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(th) & 218 218 TCP_RESERVED_BITS) >> 22)); 219 - /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */ 219 + /* Max length: 35 "AE CWR ECE URG ACK PSH RST SYN FIN " */ 220 + if (th->ae) 221 + nf_log_buf_add(m, "AE "); 220 222 if (th->cwr) 221 223 nf_log_buf_add(m, "CWR "); 222 224 if (th->ece) ··· 518 516 519 517 /* Proto Max log string length */ 520 518 /* IP: 40+46+6+11+127 = 230 */ 521 - /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */ 519 + /* TCP: 10+max(25,20+30+13+9+35+11+127) = 255 */ 522 520 /* UDP: 10+max(25,20) = 35 */ 523 521 /* UDPLITE: 14+max(25,20) = 39 */ 524 522 /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */ ··· 528 526 529 527 /* (ICMP allows recursion one level deep) */ 530 528 /* maxlen = IP + ICMP + IP + max(TCP,UDP,ICMP,unknown) */ 531 - /* maxlen = 230+ 91 + 230 + 252 = 803 */ 529 + /* maxlen = 230+ 91 + 230 + 255 = 806 */ 532 530 } 533 531 534 532 static noinline_for_stack void