aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorAdam Langley <agl@imperialviolet.org>2008-07-19 03:07:02 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-19 03:07:02 -0400
commit4389dded7767d24290463f2a8302ba3253ebdd56 (patch)
treeed34a2084c47c6c707e0ce6b4eab8d442f20c4c3 /net/ipv4/tcp_input.c
parent33ad798c924b4a1afad3593f2796d465040aadd5 (diff)
tcp: Remove redundant checks when setting eff_sacks
Remove redundant checks when setting eff_sacks and make the number of SACKs a compile time constant. Now that the options code knows how many SACK blocks can fit in the header, we don't need to have the SACK code guessing at it. Signed-off-by: Adam Langley <agl@imperialviolet.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 88810bc01370..1f5e6049883e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1423,10 +1423,10 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb,
1423 unsigned char *ptr = (skb_transport_header(ack_skb) + 1423 unsigned char *ptr = (skb_transport_header(ack_skb) +
1424 TCP_SKB_CB(ack_skb)->sacked); 1424 TCP_SKB_CB(ack_skb)->sacked);
1425 struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2); 1425 struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2);
1426 struct tcp_sack_block sp[4]; 1426 struct tcp_sack_block sp[TCP_NUM_SACKS];
1427 struct tcp_sack_block *cache; 1427 struct tcp_sack_block *cache;
1428 struct sk_buff *skb; 1428 struct sk_buff *skb;
1429 int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE) >> 3; 1429 int num_sacks = min(TCP_NUM_SACKS, (ptr[1] - TCPOLEN_SACK_BASE) >> 3);
1430 int used_sacks; 1430 int used_sacks;
1431 int reord = tp->packets_out; 1431 int reord = tp->packets_out;
1432 int flag = 0; 1432 int flag = 0;
@@ -3735,8 +3735,7 @@ static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq)
3735 tp->rx_opt.dsack = 1; 3735 tp->rx_opt.dsack = 1;
3736 tp->duplicate_sack[0].start_seq = seq; 3736 tp->duplicate_sack[0].start_seq = seq;
3737 tp->duplicate_sack[0].end_seq = end_seq; 3737 tp->duplicate_sack[0].end_seq = end_seq;
3738 tp->rx_opt.eff_sacks = min(tp->rx_opt.num_sacks + 1, 3738 tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + 1;
3739 4 - tp->rx_opt.tstamp_ok);
3740 } 3739 }
3741} 3740}
3742 3741
@@ -3791,9 +3790,8 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp)
3791 * Decrease num_sacks. 3790 * Decrease num_sacks.
3792 */ 3791 */
3793 tp->rx_opt.num_sacks--; 3792 tp->rx_opt.num_sacks--;
3794 tp->rx_opt.eff_sacks = min(tp->rx_opt.num_sacks + 3793 tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks +
3795 tp->rx_opt.dsack, 3794 tp->rx_opt.dsack;
3796 4 - tp->rx_opt.tstamp_ok);
3797 for (i = this_sack; i < tp->rx_opt.num_sacks; i++) 3795 for (i = this_sack; i < tp->rx_opt.num_sacks; i++)
3798 sp[i] = sp[i + 1]; 3796 sp[i] = sp[i + 1];
3799 continue; 3797 continue;
@@ -3843,7 +3841,7 @@ static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq)
3843 * 3841 *
3844 * If the sack array is full, forget about the last one. 3842 * If the sack array is full, forget about the last one.
3845 */ 3843 */
3846 if (this_sack >= 4) { 3844 if (this_sack >= TCP_NUM_SACKS) {
3847 this_sack--; 3845 this_sack--;
3848 tp->rx_opt.num_sacks--; 3846 tp->rx_opt.num_sacks--;
3849 sp--; 3847 sp--;
@@ -3856,8 +3854,7 @@ new_sack:
3856 sp->start_seq = seq; 3854 sp->start_seq = seq;
3857 sp->end_seq = end_seq; 3855 sp->end_seq = end_seq;
3858 tp->rx_opt.num_sacks++; 3856 tp->rx_opt.num_sacks++;
3859 tp->rx_opt.eff_sacks = min(tp->rx_opt.num_sacks + tp->rx_opt.dsack, 3857 tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
3860 4 - tp->rx_opt.tstamp_ok);
3861} 3858}
3862 3859
3863/* RCV.NXT advances, some SACKs should be eaten. */ 3860/* RCV.NXT advances, some SACKs should be eaten. */
@@ -3894,9 +3891,8 @@ static void tcp_sack_remove(struct tcp_sock *tp)
3894 } 3891 }
3895 if (num_sacks != tp->rx_opt.num_sacks) { 3892 if (num_sacks != tp->rx_opt.num_sacks) {
3896 tp->rx_opt.num_sacks = num_sacks; 3893 tp->rx_opt.num_sacks = num_sacks;
3897 tp->rx_opt.eff_sacks = min(tp->rx_opt.num_sacks + 3894 tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks +
3898 tp->rx_opt.dsack, 3895 tp->rx_opt.dsack;
3899 4 - tp->rx_opt.tstamp_ok);
3900 } 3896 }
3901} 3897}
3902 3898
@@ -3975,8 +3971,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
3975 3971
3976 if (tp->rx_opt.dsack) { 3972 if (tp->rx_opt.dsack) {
3977 tp->rx_opt.dsack = 0; 3973 tp->rx_opt.dsack = 0;
3978 tp->rx_opt.eff_sacks = min_t(unsigned int, tp->rx_opt.num_sacks, 3974 tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks;
3979 4 - tp->rx_opt.tstamp_ok);
3980 } 3975 }
3981 3976
3982 /* Queue data for delivery to the user. 3977 /* Queue data for delivery to the user.