aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-04-28 18:28:17 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-29 17:10:37 -0400
commit0df48c26d8418c5c9fba63fac15b660d70ca2f1c (patch)
tree3dbdd83937001fde41106b43cae4a3cd1a84bdd0 /net/ipv4/tcp_input.c
parent2decb2682f80759f631c8332f9a2a34a02150a03 (diff)
tcp: add tcpi_bytes_acked to tcp_info
This patch tracks total number of bytes acked for a TCP socket. This is the sum of all changes done to tp->snd_una, and allows for precise tracking of delivered data. RFC4898 named this : tcpEStatsAppHCThruOctetsAcked This is a 64bit field, and can be fetched both from TCP_INFO getsockopt() if one has a handle on a TCP socket, or from inet_diag netlink facility (iproute2/ss patch will follow) Note that tp->bytes_acked was placed near tp->snd_una for best data locality and minimal performance impact. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Yuchung Cheng <ycheng@google.com> Cc: Matt Mathis <mattmathis@google.com> Cc: Eric Salo <salo@google.com> Cc: Martin Lau <kafai@fb.com> Cc: Chris Rapier <rapier@psc.edu> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3a4d9b34bed4..378d3f4d4dc3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3280,6 +3280,15 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp,
3280 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); 3280 (ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd);
3281} 3281}
3282 3282
3283/* If we update tp->snd_una, also update tp->bytes_acked */
3284static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack)
3285{
3286 u32 delta = ack - tp->snd_una;
3287
3288 tp->bytes_acked += delta;
3289 tp->snd_una = ack;
3290}
3291
3283/* Update our send window. 3292/* Update our send window.
3284 * 3293 *
3285 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 3294 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2
@@ -3315,7 +3324,7 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
3315 } 3324 }
3316 } 3325 }
3317 3326
3318 tp->snd_una = ack; 3327 tcp_snd_una_update(tp, ack);
3319 3328
3320 return flag; 3329 return flag;
3321} 3330}
@@ -3497,7 +3506,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
3497 * Note, we use the fact that SND.UNA>=SND.WL2. 3506 * Note, we use the fact that SND.UNA>=SND.WL2.
3498 */ 3507 */
3499 tcp_update_wl(tp, ack_seq); 3508 tcp_update_wl(tp, ack_seq);
3500 tp->snd_una = ack; 3509 tcp_snd_una_update(tp, ack);
3501 flag |= FLAG_WIN_UPDATE; 3510 flag |= FLAG_WIN_UPDATE;
3502 3511
3503 tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); 3512 tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE);