* [PATCH net-next 0/2] tcp: tcp_info extensions
@ 2015-04-28 17:32 Eric Dumazet
2015-04-28 17:32 ` [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info Eric Dumazet
2015-04-28 17:32 ` [PATCH net-next 2/2] tcp: add tcpi_bytes_received " Eric Dumazet
0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2015-04-28 17:32 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, Matt Mathis, Eric Salo,
Yuchung Cheng, Martin Lau, Chris Rapier
As discussed during Chris Rapier presentation in Ottawa / netdev0.1,
we add to tcp_info the first two fields are highly wanted.
Each field is added into a single patch for easy code review.
(Corresponding iproute2/ss patches will be sent)
Next fields will follow once consensus is reached.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Eric Salo <salo@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Martin Lau <kafai@fb.com>
Cc: Chris Rapier <rapier@psc.edu>
Eric Dumazet (2):
tcp: add tcpi_bytes_acked to tcp_info
tcp: add tcpi_bytes_received to tcp_info
include/linux/tcp.h | 8 ++++++++
include/net/tcp.h | 2 +-
include/uapi/linux/tcp.h | 2 ++
net/ipv4/tcp.c | 7 ++++++-
net/ipv4/tcp_input.c | 30 ++++++++++++++++++++++++------
5 files changed, 41 insertions(+), 8 deletions(-)
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info
2015-04-28 17:32 [PATCH net-next 0/2] tcp: tcp_info extensions Eric Dumazet
@ 2015-04-28 17:32 ` Eric Dumazet
2015-04-28 21:01 ` Yuchung Cheng
2015-04-28 17:32 ` [PATCH net-next 2/2] tcp: add tcpi_bytes_received " Eric Dumazet
1 sibling, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2015-04-28 17:32 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, Matt Mathis, Eric Salo,
Yuchung Cheng, Martin Lau, Chris Rapier
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>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Eric Salo <salo@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Martin Lau <kafai@fb.com>
Cc: Chris Rapier <rapier@psc.edu>
---
include/linux/tcp.h | 4 ++++
include/net/tcp.h | 2 +-
include/uapi/linux/tcp.h | 1 +
net/ipv4/tcp.c | 6 +++++-
net/ipv4/tcp_input.c | 13 +++++++++++--
5 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 0caa3a2d4106..0f73b43171da 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -150,6 +150,10 @@ struct tcp_sock {
u32 rcv_wup; /* rcv_nxt on last window update sent */
u32 snd_nxt; /* Next sequence we send */
+ u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
+ * sum(delta(snd_una)), or how many bytes
+ * were acked.
+ */
u32 snd_una; /* First byte we want an ack for */
u32 snd_sml; /* Last byte of the most recently transmitted small packet */
u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 051dc5c2802d..dd7b4ea6a10c 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
}
/* tcp.c */
-void tcp_get_info(const struct sock *, struct tcp_info *);
+void tcp_get_info(struct sock *, struct tcp_info *);
/* Read 'sendfile()'-style from a TCP socket */
typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 3b9718328d8b..6666e98a0af9 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -189,6 +189,7 @@ struct tcp_info {
__u64 tcpi_pacing_rate;
__u64 tcpi_max_pacing_rate;
+ __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
};
/* for TCP_MD5SIG socket option */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8c5cd9efebbc..4bf0e8ca7b5b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2592,7 +2592,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt);
#endif
/* Return information about state of tcp endpoint in API format. */
-void tcp_get_info(const struct sock *sk, struct tcp_info *info)
+void tcp_get_info(struct sock *sk, struct tcp_info *info)
{
const struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -2663,6 +2663,10 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info)
rate = READ_ONCE(sk->sk_max_pacing_rate);
info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL;
+
+ spin_lock_bh(&sk->sk_lock.slock);
+ info->tcpi_bytes_acked = tp->bytes_acked;
+ spin_unlock_bh(&sk->sk_lock.slock);
}
EXPORT_SYMBOL_GPL(tcp_get_info);
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,
(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);
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/2] tcp: add tcpi_bytes_received to tcp_info
2015-04-28 17:32 [PATCH net-next 0/2] tcp: tcp_info extensions Eric Dumazet
2015-04-28 17:32 ` [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info Eric Dumazet
@ 2015-04-28 17:32 ` Eric Dumazet
2015-04-28 21:07 ` Yuchung Cheng
1 sibling, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2015-04-28 17:32 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, Matt Mathis, Eric Salo,
Yuchung Cheng, Martin Lau, Chris Rapier
This patch tracks total number of payload bytes received on a TCP socket.
This is the sum of all changes done to tp->rcv_nxt
RFC4898 named this : tcpEStatsAppHCThruOctetsReceived
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_received was placed near tp->rcv_nxt for
best data locality and minimal performance impact.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Eric Salo <salo@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Martin Lau <kafai@fb.com>
Cc: Chris Rapier <rapier@psc.edu>
---
include/linux/tcp.h | 4 ++++
include/uapi/linux/tcp.h | 1 +
net/ipv4/tcp.c | 1 +
net/ipv4/tcp_input.c | 17 +++++++++++++----
4 files changed, 19 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 {
* read the code and the spec side by side (and laugh ...)
* See RFC793 and RFC1122. The RFC writes these in capitals.
*/
+ u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
+ * sum(delta(rcv_nxt)), or how many bytes
+ * were acked.
+ */
u32 rcv_nxt; /* What we want to receive next */
u32 copied_seq; /* Head of yet unread data */
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 {
__u64 tcpi_pacing_rate;
__u64 tcpi_max_pacing_rate;
__u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
+ __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
};
/* 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)
spin_lock_bh(&sk->sk_lock.slock);
info->tcpi_bytes_acked = tp->bytes_acked;
+ info->tcpi_bytes_received = tp->bytes_received;
spin_unlock_bh(&sk->sk_lock.slock);
}
EXPORT_SYMBOL_GPL(tcp_get_info);
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)
tp->snd_una = ack;
}
+/* If we update tp->rcv_nxt, also update tp->bytes_received */
+static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq)
+{
+ u32 delta = seq - tp->rcv_nxt;
+
+ tp->bytes_received += delta;
+ tp->rcv_nxt = seq;
+}
+
/* Update our send window.
*
* Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2
@@ -4245,7 +4254,7 @@ static void tcp_ofo_queue(struct sock *sk)
tail = skb_peek_tail(&sk->sk_receive_queue);
eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
- tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
+ tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
if (!eaten)
__skb_queue_tail(&sk->sk_receive_queue, skb);
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
__skb_pull(skb, hdrlen);
eaten = (tail &&
tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;
- tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
+ tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);
if (!eaten) {
__skb_queue_tail(&sk->sk_receive_queue, skb);
skb_set_owner_r(skb, sk);
@@ -4506,7 +4515,7 @@ queue_and_out:
eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
}
- tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
+ tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
if (skb->len)
tcp_event_data_recv(sk, skb);
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
@@ -5254,7 +5263,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
tcp_rcv_rtt_measure_ts(sk, skb);
__skb_pull(skb, tcp_header_len);
- tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
+ tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
eaten = 1;
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info
2015-04-28 17:32 ` [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info Eric Dumazet
@ 2015-04-28 21:01 ` Yuchung Cheng
0 siblings, 0 replies; 6+ messages in thread
From: Yuchung Cheng @ 2015-04-28 21:01 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, netdev, Eric Dumazet, Matt Mathis, Eric Salo,
Martin Lau, Chris Rapier
On Tue, Apr 28, 2015 at 10:32 AM, Eric Dumazet <edumazet@google.com> wrote:
>
> 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>
> Cc: Matt Mathis <mattmathis@google.com>
> Cc: Eric Salo <salo@google.com>
> Cc: Yuchung Cheng <ycheng@google.com>
> Cc: Martin Lau <kafai@fb.com>
> Cc: Chris Rapier <rapier@psc.edu>
Acked-by: Yuchung Cheng <ycheng@google.com>
> ---
> include/linux/tcp.h | 4 ++++
> include/net/tcp.h | 2 +-
> include/uapi/linux/tcp.h | 1 +
> net/ipv4/tcp.c | 6 +++++-
> net/ipv4/tcp_input.c | 13 +++++++++++--
> 5 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/tcp.h b/include/linux/tcp.h
> index 0caa3a2d4106..0f73b43171da 100644
> --- a/include/linux/tcp.h
> +++ b/include/linux/tcp.h
> @@ -150,6 +150,10 @@ struct tcp_sock {
> u32 rcv_wup; /* rcv_nxt on last window update sent */
> u32 snd_nxt; /* Next sequence we send */
>
> + u64 bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked
> + * sum(delta(snd_una)), or how many bytes
> + * were acked.
> + */
> u32 snd_una; /* First byte we want an ack for */
> u32 snd_sml; /* Last byte of the most recently transmitted small packet */
> u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 051dc5c2802d..dd7b4ea6a10c 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -576,7 +576,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
> }
>
> /* tcp.c */
> -void tcp_get_info(const struct sock *, struct tcp_info *);
> +void tcp_get_info(struct sock *, struct tcp_info *);
>
> /* Read 'sendfile()'-style from a TCP socket */
> typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
> diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
> index 3b9718328d8b..6666e98a0af9 100644
> --- a/include/uapi/linux/tcp.h
> +++ b/include/uapi/linux/tcp.h
> @@ -189,6 +189,7 @@ struct tcp_info {
>
> __u64 tcpi_pacing_rate;
> __u64 tcpi_max_pacing_rate;
> + __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
> };
>
> /* for TCP_MD5SIG socket option */
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 8c5cd9efebbc..4bf0e8ca7b5b 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2592,7 +2592,7 @@ EXPORT_SYMBOL(compat_tcp_setsockopt);
> #endif
>
> /* Return information about state of tcp endpoint in API format. */
> -void tcp_get_info(const struct sock *sk, struct tcp_info *info)
> +void tcp_get_info(struct sock *sk, struct tcp_info *info)
> {
> const struct tcp_sock *tp = tcp_sk(sk);
> const struct inet_connection_sock *icsk = inet_csk(sk);
> @@ -2663,6 +2663,10 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info)
>
> rate = READ_ONCE(sk->sk_max_pacing_rate);
> info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL;
> +
> + spin_lock_bh(&sk->sk_lock.slock);
> + info->tcpi_bytes_acked = tp->bytes_acked;
> + spin_unlock_bh(&sk->sk_lock.slock);
> }
> EXPORT_SYMBOL_GPL(tcp_get_info);
>
> 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,
> (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);
> --
> 2.2.0.rc0.207.ga3a616c
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] tcp: add tcpi_bytes_received to tcp_info
2015-04-28 17:32 ` [PATCH net-next 2/2] tcp: add tcpi_bytes_received " Eric Dumazet
@ 2015-04-28 21:07 ` Yuchung Cheng
2015-04-28 22:21 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: Yuchung Cheng @ 2015-04-28 21:07 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, netdev, Eric Dumazet, Matt Mathis, Eric Salo,
Martin Lau, Chris Rapier
On Tue, Apr 28, 2015 at 10:32 AM, Eric Dumazet <edumazet@google.com> wrote:
> This patch tracks total number of payload bytes received on a TCP socket.
> This is the sum of all changes done to tp->rcv_nxt
>
> RFC4898 named this : tcpEStatsAppHCThruOctetsReceived
>
> 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_received was placed near tp->rcv_nxt for
> best data locality and minimal performance impact.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Matt Mathis <mattmathis@google.com>
> Cc: Eric Salo <salo@google.com>
> Cc: Yuchung Cheng <ycheng@google.com>
> Cc: Martin Lau <kafai@fb.com>
> Cc: Chris Rapier <rapier@psc.edu>
> ---
> include/linux/tcp.h | 4 ++++
> include/uapi/linux/tcp.h | 1 +
> net/ipv4/tcp.c | 1 +
> net/ipv4/tcp_input.c | 17 +++++++++++++----
> 4 files changed, 19 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 {
> * read the code and the spec side by side (and laugh ...)
> * See RFC793 and RFC1122. The RFC writes these in capitals.
> */
> + u64 bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived
> + * sum(delta(rcv_nxt)), or how many bytes
> + * were acked.
> + */
> u32 rcv_nxt; /* What we want to receive next */
> u32 copied_seq; /* Head of yet unread data */
> 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 {
> __u64 tcpi_pacing_rate;
> __u64 tcpi_max_pacing_rate;
> __u64 tcpi_bytes_acked; /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
> + __u64 tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
> };
>
> /* 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)
>
> spin_lock_bh(&sk->sk_lock.slock);
> info->tcpi_bytes_acked = tp->bytes_acked;
> + info->tcpi_bytes_received = tp->bytes_received;
> spin_unlock_bh(&sk->sk_lock.slock);
> }
> EXPORT_SYMBOL_GPL(tcp_get_info);
> 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)
> tp->snd_una = ack;
> }
>
> +/* If we update tp->rcv_nxt, also update tp->bytes_received */
> +static void tcp_rcv_nxt_update(struct tcp_sock *tp, u32 seq)
> +{
> + u32 delta = seq - tp->rcv_nxt;
> +
> + tp->bytes_received += delta;
> + tp->rcv_nxt = seq;
> +}
Account for received syn-data when rcv_nxt is updated in tcp_fastopen.c?
> +
> /* Update our send window.
> *
> * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2
> @@ -4245,7 +4254,7 @@ static void tcp_ofo_queue(struct sock *sk)
>
> tail = skb_peek_tail(&sk->sk_receive_queue);
> eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
> - tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
> + tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
> if (!eaten)
> __skb_queue_tail(&sk->sk_receive_queue, skb);
> 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
> __skb_pull(skb, hdrlen);
> eaten = (tail &&
> tcp_try_coalesce(sk, tail, skb, fragstolen)) ? 1 : 0;
> - tcp_sk(sk)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
> + tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq);
> if (!eaten) {
> __skb_queue_tail(&sk->sk_receive_queue, skb);
> skb_set_owner_r(skb, sk);
> @@ -4506,7 +4515,7 @@ queue_and_out:
>
> eaten = tcp_queue_rcv(sk, skb, 0, &fragstolen);
> }
> - tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
> + tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
> if (skb->len)
> tcp_event_data_recv(sk, skb);
> if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
> @@ -5254,7 +5263,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
> tcp_rcv_rtt_measure_ts(sk, skb);
>
> __skb_pull(skb, tcp_header_len);
> - tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
> + tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
> NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPHITSTOUSER);
> eaten = 1;
> }
> --
> 2.2.0.rc0.207.ga3a616c
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 2/2] tcp: add tcpi_bytes_received to tcp_info
2015-04-28 21:07 ` Yuchung Cheng
@ 2015-04-28 22:21 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2015-04-28 22:21 UTC (permalink / raw)
To: Yuchung Cheng
Cc: Eric Dumazet, David S. Miller, netdev, Matt Mathis, Eric Salo,
Martin Lau, Chris Rapier
On Tue, 2015-04-28 at 14:07 -0700, Yuchung Cheng wrote:
> Account for received syn-data when rcv_nxt is updated in tcp_fastopen.c?
Right, I'll send a v2 with the following FO part :
Note that I do not call the helper to keep it static and inline
candidate.
Thanks !
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index e3d87aca6be8..b1b110d07816 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,
skb_set_owner_r(skb2, child);
__skb_queue_tail(&child->sk_receive_queue, skb2);
tp->syn_data_acked = 1;
+ tp->bytes_received = end_seq - (TCP_SKB_CB(skb)->seq + 1);
} else {
end_seq = TCP_SKB_CB(skb)->seq + 1;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-28 22:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 17:32 [PATCH net-next 0/2] tcp: tcp_info extensions Eric Dumazet
2015-04-28 17:32 ` [PATCH net-next 1/2] tcp: add tcpi_bytes_acked to tcp_info Eric Dumazet
2015-04-28 21:01 ` Yuchung Cheng
2015-04-28 17:32 ` [PATCH net-next 2/2] tcp: add tcpi_bytes_received " Eric Dumazet
2015-04-28 21:07 ` Yuchung Cheng
2015-04-28 22:21 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).