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>
This commit is contained in:
		
					parent
					
						
							
								2decb2682f
							
						
					
				
			
			
				commit
				
					
						0df48c26d8
					
				
			
		
					 5 changed files with 22 additions and 4 deletions
				
			
		|  | @ -3280,6 +3280,15 @@ static inline bool tcp_may_update_window(const struct tcp_sock *tp, | |||
| 		(ack_seq == tp->snd_wl1 && nwin > tp->snd_wnd); | ||||
| } | ||||
| 
 | ||||
| /* If we update tp->snd_una, also update tp->bytes_acked */ | ||||
| static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack) | ||||
| { | ||||
| 	u32 delta = ack - tp->snd_una; | ||||
| 
 | ||||
| 	tp->bytes_acked += delta; | ||||
| 	tp->snd_una = ack; | ||||
| } | ||||
| 
 | ||||
| /* Update our send window.
 | ||||
|  * | ||||
|  * 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 | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	tp->snd_una = ack; | ||||
| 	tcp_snd_una_update(tp, ack); | ||||
| 
 | ||||
| 	return flag; | ||||
| } | ||||
|  | @ -3497,7 +3506,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) | |||
| 		 * Note, we use the fact that SND.UNA>=SND.WL2. | ||||
| 		 */ | ||||
| 		tcp_update_wl(tp, ack_seq); | ||||
| 		tp->snd_una = ack; | ||||
| 		tcp_snd_una_update(tp, ack); | ||||
| 		flag |= FLAG_WIN_UPDATE; | ||||
| 
 | ||||
| 		tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Dumazet
				Eric Dumazet