aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/tcp.h4
-rw-r--r--include/uapi/linux/tcp.h1
-rw-r--r--net/ipv4/tcp.c1
-rw-r--r--net/ipv4/tcp_fastopen.c1
-rw-r--r--net/ipv4/tcp_input.c17
5 files changed, 20 insertions, 4 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 0f73b43171da..3b2911502a8c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -145,6 +145,10 @@ struct tcp_sock {
145 * read the code and the spec side by side (and laugh ...) 145 * read the code and the spec side by side (and laugh ...)
146 * See RFC793 and RFC1122. The RFC writes these in capitals. 146 * See RFC793 and RFC1122. The RFC writes these in capitals.
147 */ 147 */
148 u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
149 * sum(delta(rcv_nxt)), or how many bytes
150 * were acked.
151 */
148 u32 rcv_nxt; /* What we want to receive next */ 152 u32 rcv_nxt; /* What we want to receive next */
149 u32 copied_seq; /* Head of yet unread data */ 153 u32 copied_seq; /* Head of yet unread data */
150 u32 rcv_wup; /* rcv_nxt on last window update sent */ 154 u32 rcv_wup; /* rcv_nxt on last window update sent */
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 6666e98a0af9..a48f93f3207b 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -190,6 +190,7 @@ struct tcp_info {
190 __u64 tcpi_pacing_rate; 190 __u64 tcpi_pacing_rate;
191 __u64 tcpi_max_pacing_rate; 191 __u64 tcpi_max_pacing_rate;
192 __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */ 192 __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
193 __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
193}; 194};
194 195
195/* for TCP_MD5SIG socket option */ 196/* for TCP_MD5SIG socket option */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4bf0e8ca7b5b..99fcc0b22c92 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2666,6 +2666,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2666 2666
2667 spin_lock_bh(&sk->sk_lock.slock); 2667 spin_lock_bh(&sk->sk_lock.slock);
2668 info->tcpi_bytes_acked = tp->bytes_acked; 2668 info->tcpi_bytes_acked = tp->bytes_acked;
2669 info->tcpi_bytes_received = tp->bytes_received;
2669 spin_unlock_bh(&sk->sk_lock.slock); 2670 spin_unlock_bh(&sk->sk_lock.slock);
2670} 2671}
2671EXPORT_SYMBOL_GPL(tcp_get_info); 2672EXPORT_SYMBOL_GPL(tcp_get_info);
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e3d87aca6be8..3c673d5e6cff 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -206,6 +206,7 @@ static bool tcp_fastopen_create_child(struct sock *sk,
206 skb_set_owner_r(skb2, child); 206 skb_set_owner_r(skb2, child);
207 __skb_queue_tail(&child->sk_receive_queue, skb2); 207 __skb_queue_tail(&child->sk_receive_queue, skb2);
208 tp->syn_data_acked = 1; 208 tp->syn_data_acked = 1;
209 tp->bytes_received = end_seq - TCP_SKB_CB(skb)->seq - 1;
209 } else { 210 } else {
210 end_seq = TCP_SKB_CB(skb)->seq + 1; 211 end_seq = TCP_SKB_CB(skb)->seq + 1;
211 } 212 }
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 378d3f4d4dc3..7e6962bcfc30 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3289,6 +3289,15 @@ static void tcp_snd_una_update(struct tcp_sock *tp, u32 ack)
3289 tp->snd_una = ack; 3289 tp->snd_una = ack;
3290} 3290}
3291 3291
3292/* If we update tp->rcv_nxt, also update tp->bytes_received */
3293static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq)
3294{
3295 u32 delta = seq - tp->rcv_nxt;
3296
3297 tp->bytes_received += delta;
3298 tp->rcv_nxt = seq;
3299}
3300
3292/* Update our send window. 3301/* Update our send window.
3293 * 3302 *
3294 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 3303 * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2
@@ -4245,7 +4254,7 @@ static void tcp_ofo_queue(struct sock *sk)
4245 4254
4246 tail = skb_peek_tail(&sk->sk_receive_queue); 4255 tail = skb_peek_tail(&sk->sk_receive_queue);
4247 eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); 4256 eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
4248 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4257 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
4249 if (!eaten) 4258 if (!eaten)
4250 __skb_queue_tail(&sk->sk_receive_queue, skb); 4259 __skb_queue_tail(&sk->sk_receive_queue, skb);
4251 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 4260 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -4413,7 +4422,7 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int
4413 __skb_pull(skb, hdrlen); 4422 __skb_pull(skb, hdrlen);
4414 eaten = (tail && 4423 eaten = (tail &&
4415 tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0; 4424 tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;
4416 tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4425 tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);
4417 if (!eaten) { 4426 if (!eaten) {
4418 __skb_queue_tail(&sk->sk_receive_queue, skb); 4427 __skb_queue_tail(&sk->sk_receive_queue, skb);
4419 skb_set_owner_r(skb, sk); 4428 skb_set_owner_r(skb, sk);
@@ -4506,7 +4515,7 @@ queue_and_out:
4506 4515
4507 eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen); 4516 eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
4508 } 4517 }
4509 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 4518 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
4510 if (skb->len) 4519 if (skb->len)
4511 tcp_event_data_recv(sk, skb); 4520 tcp_event_data_recv(sk, skb);
4512 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 4521 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -5254,7 +5263,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
5254 tcp_rcv_rtt_measure_ts(sk, skb); 5263 tcp_rcv_rtt_measure_ts(sk, skb);
5255 5264
5256 __skb_pull(skb, tcp_header_len); 5265 __skb_pull(skb, tcp_header_len);
5257 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 5266 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
5258 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER); 5267 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
5259 eaten = 1; 5268 eaten = 1;
5260 } 5269 }