diff options
author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2007-09-20 14:33:43 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:10 -0400 |
commit | 7c46a03e67d11d917d6c3dbf501b465b2ca97a6f (patch) | |
tree | 57c719d14349406bd654b78007876da6d4e48eec /net/ipv4 | |
parent | 13fcf850cc20373db4dd8a5c9f349583ab3817c4 (diff) |
[TCP]: Cleanup tcp_tso_acked and tcp_clean_rtx_queue
Implements following cleanups:
- Comment re-placement (CodingStyle)
- tcp_tso_acked() local (wrapper-like) variable removal
(readability)
- __-types removed (IMHO they make local variables jumpy looking
and just was space)
- acked -> flag (naming conventions elsewhere in TCP code)
- linebreak adjustments (readability)
- nested if()s combined (reduced indentation)
- clarifying newlines added
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_input.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4238ed98acb9..8fe754be8076 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -2525,55 +2525,49 @@ static void tcp_rearm_rto(struct sock *sk) | |||
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | /* If we get here, the whole TSO packet has not been acked. */ | ||
2528 | static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb) | 2529 | static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb) |
2529 | { | 2530 | { |
2530 | struct tcp_sock *tp = tcp_sk(sk); | 2531 | struct tcp_sock *tp = tcp_sk(sk); |
2531 | struct tcp_skb_cb *scb = TCP_SKB_CB(skb); | 2532 | u32 packets_acked; |
2532 | __u32 seq = tp->snd_una; | ||
2533 | __u32 packets_acked; | ||
2534 | 2533 | ||
2535 | /* If we get here, the whole TSO packet has not been | 2534 | BUG_ON(!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)); |
2536 | * acked. | ||
2537 | */ | ||
2538 | BUG_ON(!after(scb->end_seq, seq)); | ||
2539 | 2535 | ||
2540 | packets_acked = tcp_skb_pcount(skb); | 2536 | packets_acked = tcp_skb_pcount(skb); |
2541 | if (tcp_trim_head(sk, skb, seq - scb->seq)) | 2537 | if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq)) |
2542 | return 0; | 2538 | return 0; |
2543 | packets_acked -= tcp_skb_pcount(skb); | 2539 | packets_acked -= tcp_skb_pcount(skb); |
2544 | 2540 | ||
2545 | if (packets_acked) { | 2541 | if (packets_acked) { |
2546 | BUG_ON(tcp_skb_pcount(skb) == 0); | 2542 | BUG_ON(tcp_skb_pcount(skb) == 0); |
2547 | BUG_ON(!before(scb->seq, scb->end_seq)); | 2543 | BUG_ON(!before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq)); |
2548 | } | 2544 | } |
2549 | 2545 | ||
2550 | return packets_acked; | 2546 | return packets_acked; |
2551 | } | 2547 | } |
2552 | 2548 | ||
2553 | /* Remove acknowledged frames from the retransmission queue. */ | 2549 | /* Remove acknowledged frames from the retransmission queue. If our packet |
2554 | static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) | 2550 | * is before the ack sequence we can discard it as it's confirmed to have |
2551 | * arrived at the other end. | ||
2552 | */ | ||
2553 | static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) | ||
2555 | { | 2554 | { |
2556 | struct tcp_sock *tp = tcp_sk(sk); | 2555 | struct tcp_sock *tp = tcp_sk(sk); |
2557 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2556 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2558 | struct sk_buff *skb; | 2557 | struct sk_buff *skb; |
2559 | __u32 now = tcp_time_stamp; | 2558 | u32 now = tcp_time_stamp; |
2560 | int fully_acked = 1; | 2559 | int fully_acked = 1; |
2561 | int acked = 0; | 2560 | int flag = 0; |
2562 | int prior_packets = tp->packets_out; | 2561 | int prior_packets = tp->packets_out; |
2563 | __s32 seq_rtt = -1; | 2562 | s32 seq_rtt = -1; |
2564 | ktime_t last_ackt = net_invalid_timestamp(); | 2563 | ktime_t last_ackt = net_invalid_timestamp(); |
2565 | 2564 | ||
2566 | while ((skb = tcp_write_queue_head(sk)) && | 2565 | while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { |
2567 | skb != tcp_send_head(sk)) { | ||
2568 | struct tcp_skb_cb *scb = TCP_SKB_CB(skb); | 2566 | struct tcp_skb_cb *scb = TCP_SKB_CB(skb); |
2569 | u32 end_seq; | 2567 | u32 end_seq; |
2570 | u32 packets_acked; | 2568 | u32 packets_acked; |
2571 | __u8 sacked = scb->sacked; | 2569 | u8 sacked = scb->sacked; |
2572 | 2570 | ||
2573 | /* If our packet is before the ack sequence we can | ||
2574 | * discard it as it's confirmed to have arrived at | ||
2575 | * the other end. | ||
2576 | */ | ||
2577 | if (after(scb->end_seq, tp->snd_una)) { | 2571 | if (after(scb->end_seq, tp->snd_una)) { |
2578 | if (tcp_skb_pcount(skb) == 1 || | 2572 | if (tcp_skb_pcount(skb) == 1 || |
2579 | !after(tp->snd_una, scb->seq)) | 2573 | !after(tp->snd_una, scb->seq)) |
@@ -2598,38 +2592,38 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) | |||
2598 | * quickly. This is severely frowned upon behavior. | 2592 | * quickly. This is severely frowned upon behavior. |
2599 | */ | 2593 | */ |
2600 | if (!(scb->flags & TCPCB_FLAG_SYN)) { | 2594 | if (!(scb->flags & TCPCB_FLAG_SYN)) { |
2601 | acked |= FLAG_DATA_ACKED; | 2595 | flag |= FLAG_DATA_ACKED; |
2602 | } else { | 2596 | } else { |
2603 | acked |= FLAG_SYN_ACKED; | 2597 | flag |= FLAG_SYN_ACKED; |
2604 | tp->retrans_stamp = 0; | 2598 | tp->retrans_stamp = 0; |
2605 | } | 2599 | } |
2606 | 2600 | ||
2607 | /* MTU probing checks */ | 2601 | /* MTU probing checks */ |
2608 | if (fully_acked && icsk->icsk_mtup.probe_size) { | 2602 | if (fully_acked && icsk->icsk_mtup.probe_size && |
2609 | if (!after(tp->mtu_probe.probe_seq_end, TCP_SKB_CB(skb)->end_seq)) { | 2603 | !after(tp->mtu_probe.probe_seq_end, scb->end_seq)) { |
2610 | tcp_mtup_probe_success(sk, skb); | 2604 | tcp_mtup_probe_success(sk, skb); |
2611 | } | ||
2612 | } | 2605 | } |
2613 | 2606 | ||
2614 | if (sacked) { | 2607 | if (sacked) { |
2615 | if (sacked & TCPCB_RETRANS) { | 2608 | if (sacked & TCPCB_RETRANS) { |
2616 | if (sacked & TCPCB_SACKED_RETRANS) | 2609 | if (sacked & TCPCB_SACKED_RETRANS) |
2617 | tp->retrans_out -= packets_acked; | 2610 | tp->retrans_out -= packets_acked; |
2618 | acked |= FLAG_RETRANS_DATA_ACKED; | 2611 | flag |= FLAG_RETRANS_DATA_ACKED; |
2619 | seq_rtt = -1; | 2612 | seq_rtt = -1; |
2620 | } else if (seq_rtt < 0) { | 2613 | } else if (seq_rtt < 0) { |
2621 | seq_rtt = now - scb->when; | 2614 | seq_rtt = now - scb->when; |
2622 | if (fully_acked) | 2615 | if (fully_acked) |
2623 | last_ackt = skb->tstamp; | 2616 | last_ackt = skb->tstamp; |
2624 | } | 2617 | } |
2618 | |||
2625 | if (sacked & TCPCB_SACKED_ACKED) | 2619 | if (sacked & TCPCB_SACKED_ACKED) |
2626 | tp->sacked_out -= packets_acked; | 2620 | tp->sacked_out -= packets_acked; |
2627 | if (sacked & TCPCB_LOST) | 2621 | if (sacked & TCPCB_LOST) |
2628 | tp->lost_out -= packets_acked; | 2622 | tp->lost_out -= packets_acked; |
2629 | if (sacked & TCPCB_URG) { | 2623 | |
2630 | if (tp->urg_mode && !before(end_seq, tp->snd_up)) | 2624 | if ((sacked & TCPCB_URG) && tp->urg_mode && |
2631 | tp->urg_mode = 0; | 2625 | !before(end_seq, tp->snd_up)) |
2632 | } | 2626 | tp->urg_mode = 0; |
2633 | } else if (seq_rtt < 0) { | 2627 | } else if (seq_rtt < 0) { |
2634 | seq_rtt = now - scb->when; | 2628 | seq_rtt = now - scb->when; |
2635 | if (fully_acked) | 2629 | if (fully_acked) |
@@ -2645,12 +2639,12 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) | |||
2645 | tcp_clear_all_retrans_hints(tp); | 2639 | tcp_clear_all_retrans_hints(tp); |
2646 | } | 2640 | } |
2647 | 2641 | ||
2648 | if (acked&FLAG_ACKED) { | 2642 | if (flag & FLAG_ACKED) { |
2649 | u32 pkts_acked = prior_packets - tp->packets_out; | 2643 | u32 pkts_acked = prior_packets - tp->packets_out; |
2650 | const struct tcp_congestion_ops *ca_ops | 2644 | const struct tcp_congestion_ops *ca_ops |
2651 | = inet_csk(sk)->icsk_ca_ops; | 2645 | = inet_csk(sk)->icsk_ca_ops; |
2652 | 2646 | ||
2653 | tcp_ack_update_rtt(sk, acked, seq_rtt); | 2647 | tcp_ack_update_rtt(sk, flag, seq_rtt); |
2654 | tcp_rearm_rto(sk); | 2648 | tcp_rearm_rto(sk); |
2655 | 2649 | ||
2656 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); | 2650 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); |
@@ -2664,7 +2658,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) | |||
2664 | s32 rtt_us = -1; | 2658 | s32 rtt_us = -1; |
2665 | 2659 | ||
2666 | /* Is the ACK triggering packet unambiguous? */ | 2660 | /* Is the ACK triggering packet unambiguous? */ |
2667 | if (!(acked & FLAG_RETRANS_DATA_ACKED)) { | 2661 | if (!(flag & FLAG_RETRANS_DATA_ACKED)) { |
2668 | /* High resolution needed and available? */ | 2662 | /* High resolution needed and available? */ |
2669 | if (ca_ops->flags & TCP_CONG_RTT_STAMP && | 2663 | if (ca_ops->flags & TCP_CONG_RTT_STAMP && |
2670 | !ktime_equal(last_ackt, | 2664 | !ktime_equal(last_ackt, |
@@ -2703,7 +2697,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) | |||
2703 | } | 2697 | } |
2704 | #endif | 2698 | #endif |
2705 | *seq_rtt_p = seq_rtt; | 2699 | *seq_rtt_p = seq_rtt; |
2706 | return acked; | 2700 | return flag; |
2707 | } | 2701 | } |
2708 | 2702 | ||
2709 | static void tcp_ack_probe(struct sock *sk) | 2703 | static void tcp_ack_probe(struct sock *sk) |