aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_output.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-09-27 13:25:05 -0400
committerDavid S. Miller <davem@davemloft.net>2011-09-27 13:25:05 -0400
commit4de075e0438ba54b8f42cbbc1263d404229dc997 (patch)
treedc2400d1539cb462e9b441d841577e8bc8f0048d /net/ipv4/tcp_output.c
parentb82d1bb4fd206ed305f9e955eeffc4a678149442 (diff)
tcp: rename tcp_skb_cb flags
Rename struct tcp_skb_cb "flags" to "tcp_flags" to ease code review and maintenance. Its content is a combination of FIN/SYN/RST/PSH/ACK/URG/ECE/CWR flags Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r--net/ipv4/tcp_output.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 081dcd6fd0c4..dde6b5768316 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -297,9 +297,9 @@ static u16 tcp_select_window(struct sock *sk)
297/* Packet ECN state for a SYN-ACK */ 297/* Packet ECN state for a SYN-ACK */
298static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb) 298static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb)
299{ 299{
300 TCP_SKB_CB(skb)->flags &= ~TCPHDR_CWR; 300 TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_CWR;
301 if (!(tp->ecn_flags & TCP_ECN_OK)) 301 if (!(tp->ecn_flags & TCP_ECN_OK))
302 TCP_SKB_CB(skb)->flags &= ~TCPHDR_ECE; 302 TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE;
303} 303}
304 304
305/* Packet ECN state for a SYN. */ 305/* Packet ECN state for a SYN. */
@@ -309,7 +309,7 @@ static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
309 309
310 tp->ecn_flags = 0; 310 tp->ecn_flags = 0;
311 if (sysctl_tcp_ecn == 1) { 311 if (sysctl_tcp_ecn == 1) {
312 TCP_SKB_CB(skb)->flags |= TCPHDR_ECE | TCPHDR_CWR; 312 TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR;
313 tp->ecn_flags = TCP_ECN_OK; 313 tp->ecn_flags = TCP_ECN_OK;
314 } 314 }
315} 315}
@@ -356,7 +356,7 @@ static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags)
356 skb->ip_summed = CHECKSUM_PARTIAL; 356 skb->ip_summed = CHECKSUM_PARTIAL;
357 skb->csum = 0; 357 skb->csum = 0;
358 358
359 TCP_SKB_CB(skb)->flags = flags; 359 TCP_SKB_CB(skb)->tcp_flags = flags;
360 TCP_SKB_CB(skb)->sacked = 0; 360 TCP_SKB_CB(skb)->sacked = 0;
361 361
362 skb_shinfo(skb)->gso_segs = 1; 362 skb_shinfo(skb)->gso_segs = 1;
@@ -826,7 +826,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
826 tcb = TCP_SKB_CB(skb); 826 tcb = TCP_SKB_CB(skb);
827 memset(&opts, 0, sizeof(opts)); 827 memset(&opts, 0, sizeof(opts));
828 828
829 if (unlikely(tcb->flags & TCPHDR_SYN)) 829 if (unlikely(tcb->tcp_flags & TCPHDR_SYN))
830 tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5); 830 tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5);
831 else 831 else
832 tcp_options_size = tcp_established_options(sk, skb, &opts, 832 tcp_options_size = tcp_established_options(sk, skb, &opts,
@@ -850,9 +850,9 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
850 th->seq = htonl(tcb->seq); 850 th->seq = htonl(tcb->seq);
851 th->ack_seq = htonl(tp->rcv_nxt); 851 th->ack_seq = htonl(tp->rcv_nxt);
852 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 852 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
853 tcb->flags); 853 tcb->tcp_flags);
854 854
855 if (unlikely(tcb->flags & TCPHDR_SYN)) { 855 if (unlikely(tcb->tcp_flags & TCPHDR_SYN)) {
856 /* RFC1323: The window in SYN & SYN/ACK segments 856 /* RFC1323: The window in SYN & SYN/ACK segments
857 * is never scaled. 857 * is never scaled.
858 */ 858 */
@@ -875,7 +875,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
875 } 875 }
876 876
877 tcp_options_write((__be32 *)(th + 1), tp, &opts); 877 tcp_options_write((__be32 *)(th + 1), tp, &opts);
878 if (likely((tcb->flags & TCPHDR_SYN) == 0)) 878 if (likely((tcb->tcp_flags & TCPHDR_SYN) == 0))
879 TCP_ECN_send(sk, skb, tcp_header_size); 879 TCP_ECN_send(sk, skb, tcp_header_size);
880 880
881#ifdef CONFIG_TCP_MD5SIG 881#ifdef CONFIG_TCP_MD5SIG
@@ -889,7 +889,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
889 889
890 icsk->icsk_af_ops->send_check(sk, skb); 890 icsk->icsk_af_ops->send_check(sk, skb);
891 891
892 if (likely(tcb->flags & TCPHDR_ACK)) 892 if (likely(tcb->tcp_flags & TCPHDR_ACK))
893 tcp_event_ack_sent(sk, tcp_skb_pcount(skb)); 893 tcp_event_ack_sent(sk, tcp_skb_pcount(skb));
894 894
895 if (skb->len != tcp_header_size) 895 if (skb->len != tcp_header_size)
@@ -1032,9 +1032,9 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
1032 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; 1032 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq;
1033 1033
1034 /* PSH and FIN should only be set in the second packet. */ 1034 /* PSH and FIN should only be set in the second packet. */
1035 flags = TCP_SKB_CB(skb)->flags; 1035 flags = TCP_SKB_CB(skb)->tcp_flags;
1036 TCP_SKB_CB(skb)->flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); 1036 TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH);
1037 TCP_SKB_CB(buff)->flags = flags; 1037 TCP_SKB_CB(buff)->tcp_flags = flags;
1038 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; 1038 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked;
1039 1039
1040 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) { 1040 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) {
@@ -1340,7 +1340,8 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp,
1340 u32 in_flight, cwnd; 1340 u32 in_flight, cwnd;
1341 1341
1342 /* Don't be strict about the congestion window for the final FIN. */ 1342 /* Don't be strict about the congestion window for the final FIN. */
1343 if ((TCP_SKB_CB(skb)->flags & TCPHDR_FIN) && tcp_skb_pcount(skb) == 1) 1343 if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) &&
1344 tcp_skb_pcount(skb) == 1)
1344 return 1; 1345 return 1;
1345 1346
1346 in_flight = tcp_packets_in_flight(tp); 1347 in_flight = tcp_packets_in_flight(tp);
@@ -1409,7 +1410,7 @@ static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb,
1409 * Nagle can be ignored during F-RTO too (see RFC4138). 1410 * Nagle can be ignored during F-RTO too (see RFC4138).
1410 */ 1411 */
1411 if (tcp_urg_mode(tp) || (tp->frto_counter == 2) || 1412 if (tcp_urg_mode(tp) || (tp->frto_counter == 2) ||
1412 (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)) 1413 (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN))
1413 return 1; 1414 return 1;
1414 1415
1415 if (!tcp_nagle_check(tp, skb, cur_mss, nonagle)) 1416 if (!tcp_nagle_check(tp, skb, cur_mss, nonagle))
@@ -1497,9 +1498,9 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
1497 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; 1498 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq;
1498 1499
1499 /* PSH and FIN should only be set in the second packet. */ 1500 /* PSH and FIN should only be set in the second packet. */
1500 flags = TCP_SKB_CB(skb)->flags; 1501 flags = TCP_SKB_CB(skb)->tcp_flags;
1501 TCP_SKB_CB(skb)->flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); 1502 TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH);
1502 TCP_SKB_CB(buff)->flags = flags; 1503 TCP_SKB_CB(buff)->tcp_flags = flags;
1503 1504
1504 /* This packet was never sent out yet, so no SACK bits. */ 1505 /* This packet was never sent out yet, so no SACK bits. */
1505 TCP_SKB_CB(buff)->sacked = 0; 1506 TCP_SKB_CB(buff)->sacked = 0;
@@ -1530,7 +1531,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
1530 u32 send_win, cong_win, limit, in_flight; 1531 u32 send_win, cong_win, limit, in_flight;
1531 int win_divisor; 1532 int win_divisor;
1532 1533
1533 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) 1534 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
1534 goto send_now; 1535 goto send_now;
1535 1536
1536 if (icsk->icsk_ca_state != TCP_CA_Open) 1537 if (icsk->icsk_ca_state != TCP_CA_Open)
@@ -1657,7 +1658,7 @@ static int tcp_mtu_probe(struct sock *sk)
1657 1658
1658 TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; 1659 TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq;
1659 TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; 1660 TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size;
1660 TCP_SKB_CB(nskb)->flags = TCPHDR_ACK; 1661 TCP_SKB_CB(nskb)->tcp_flags = TCPHDR_ACK;
1661 TCP_SKB_CB(nskb)->sacked = 0; 1662 TCP_SKB_CB(nskb)->sacked = 0;
1662 nskb->csum = 0; 1663 nskb->csum = 0;
1663 nskb->ip_summed = skb->ip_summed; 1664 nskb->ip_summed = skb->ip_summed;
@@ -1677,11 +1678,11 @@ static int tcp_mtu_probe(struct sock *sk)
1677 if (skb->len <= copy) { 1678 if (skb->len <= copy) {
1678 /* We've eaten all the data from this skb. 1679 /* We've eaten all the data from this skb.
1679 * Throw it away. */ 1680 * Throw it away. */
1680 TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags; 1681 TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags;
1681 tcp_unlink_write_queue(skb, sk); 1682 tcp_unlink_write_queue(skb, sk);
1682 sk_wmem_free_skb(sk, skb); 1683 sk_wmem_free_skb(sk, skb);
1683 } else { 1684 } else {
1684 TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags & 1685 TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags &
1685 ~(TCPHDR_FIN|TCPHDR_PSH); 1686 ~(TCPHDR_FIN|TCPHDR_PSH);
1686 if (!skb_shinfo(skb)->nr_frags) { 1687 if (!skb_shinfo(skb)->nr_frags) {
1687 skb_pull(skb, copy); 1688 skb_pull(skb, copy);
@@ -1987,7 +1988,7 @@ static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb)
1987 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq; 1988 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq;
1988 1989
1989 /* Merge over control information. This moves PSH/FIN etc. over */ 1990 /* Merge over control information. This moves PSH/FIN etc. over */
1990 TCP_SKB_CB(skb)->flags |= TCP_SKB_CB(next_skb)->flags; 1991 TCP_SKB_CB(skb)->tcp_flags |= TCP_SKB_CB(next_skb)->tcp_flags;
1991 1992
1992 /* All done, get rid of second SKB and account for it so 1993 /* All done, get rid of second SKB and account for it so
1993 * packet counting does not break. 1994 * packet counting does not break.
@@ -2035,7 +2036,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
2035 2036
2036 if (!sysctl_tcp_retrans_collapse) 2037 if (!sysctl_tcp_retrans_collapse)
2037 return; 2038 return;
2038 if (TCP_SKB_CB(skb)->flags & TCPHDR_SYN) 2039 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
2039 return; 2040 return;
2040 2041
2041 tcp_for_write_queue_from_safe(skb, tmp, sk) { 2042 tcp_for_write_queue_from_safe(skb, tmp, sk) {
@@ -2127,12 +2128,12 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2127 * since it is cheap to do so and saves bytes on the network. 2128 * since it is cheap to do so and saves bytes on the network.
2128 */ 2129 */
2129 if (skb->len > 0 && 2130 if (skb->len > 0 &&
2130 (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) && 2131 (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) &&
2131 tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) { 2132 tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) {
2132 if (!pskb_trim(skb, 0)) { 2133 if (!pskb_trim(skb, 0)) {
2133 /* Reuse, even though it does some unnecessary work */ 2134 /* Reuse, even though it does some unnecessary work */
2134 tcp_init_nondata_skb(skb, TCP_SKB_CB(skb)->end_seq - 1, 2135 tcp_init_nondata_skb(skb, TCP_SKB_CB(skb)->end_seq - 1,
2135 TCP_SKB_CB(skb)->flags); 2136 TCP_SKB_CB(skb)->tcp_flags);
2136 skb->ip_summed = CHECKSUM_NONE; 2137 skb->ip_summed = CHECKSUM_NONE;
2137 } 2138 }
2138 } 2139 }
@@ -2322,7 +2323,7 @@ void tcp_send_fin(struct sock *sk)
2322 mss_now = tcp_current_mss(sk); 2323 mss_now = tcp_current_mss(sk);
2323 2324
2324 if (tcp_send_head(sk) != NULL) { 2325 if (tcp_send_head(sk) != NULL) {
2325 TCP_SKB_CB(skb)->flags |= TCPHDR_FIN; 2326 TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_FIN;
2326 TCP_SKB_CB(skb)->end_seq++; 2327 TCP_SKB_CB(skb)->end_seq++;
2327 tp->write_seq++; 2328 tp->write_seq++;
2328 } else { 2329 } else {
@@ -2384,11 +2385,11 @@ int tcp_send_synack(struct sock *sk)
2384 struct sk_buff *skb; 2385 struct sk_buff *skb;
2385 2386
2386 skb = tcp_write_queue_head(sk); 2387 skb = tcp_write_queue_head(sk);
2387 if (skb == NULL || !(TCP_SKB_CB(skb)->flags & TCPHDR_SYN)) { 2388 if (skb == NULL || !(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
2388 printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n"); 2389 printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n");
2389 return -EFAULT; 2390 return -EFAULT;
2390 } 2391 }
2391 if (!(TCP_SKB_CB(skb)->flags & TCPHDR_ACK)) { 2392 if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK)) {
2392 if (skb_cloned(skb)) { 2393 if (skb_cloned(skb)) {
2393 struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); 2394 struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
2394 if (nskb == NULL) 2395 if (nskb == NULL)
@@ -2402,7 +2403,7 @@ int tcp_send_synack(struct sock *sk)
2402 skb = nskb; 2403 skb = nskb;
2403 } 2404 }
2404 2405
2405 TCP_SKB_CB(skb)->flags |= TCPHDR_ACK; 2406 TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ACK;
2406 TCP_ECN_send_synack(tcp_sk(sk), skb); 2407 TCP_ECN_send_synack(tcp_sk(sk), skb);
2407 } 2408 }
2408 TCP_SKB_CB(skb)->when = tcp_time_stamp; 2409 TCP_SKB_CB(skb)->when = tcp_time_stamp;
@@ -2799,13 +2800,13 @@ int tcp_write_wakeup(struct sock *sk)
2799 if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq || 2800 if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq ||
2800 skb->len > mss) { 2801 skb->len > mss) {
2801 seg_size = min(seg_size, mss); 2802 seg_size = min(seg_size, mss);
2802 TCP_SKB_CB(skb)->flags |= TCPHDR_PSH; 2803 TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;
2803 if (tcp_fragment(sk, skb, seg_size, mss)) 2804 if (tcp_fragment(sk, skb, seg_size, mss))
2804 return -1; 2805 return -1;
2805 } else if (!tcp_skb_pcount(skb)) 2806 } else if (!tcp_skb_pcount(skb))
2806 tcp_set_skb_tso_segs(sk, skb, mss); 2807 tcp_set_skb_tso_segs(sk, skb, mss);
2807 2808
2808 TCP_SKB_CB(skb)->flags |= TCPHDR_PSH; 2809 TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;
2809 TCP_SKB_CB(skb)->when = tcp_time_stamp; 2810 TCP_SKB_CB(skb)->when = tcp_time_stamp;
2810 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); 2811 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
2811 if (!err) 2812 if (!err)