diff options
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f3bfb9f29520..31fa1c080f28 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2594,6 +2594,10 @@ int tcp_disconnect(struct sock *sk, int flags) | |||
2594 | sk->sk_rx_dst = NULL; | 2594 | sk->sk_rx_dst = NULL; |
2595 | tcp_saved_syn_free(tp); | 2595 | tcp_saved_syn_free(tp); |
2596 | tp->compressed_ack = 0; | 2596 | tp->compressed_ack = 0; |
2597 | tp->bytes_sent = 0; | ||
2598 | tp->bytes_retrans = 0; | ||
2599 | tp->dsack_dups = 0; | ||
2600 | tp->reord_seen = 0; | ||
2597 | 2601 | ||
2598 | /* Clean up fastopen related fields */ | 2602 | /* Clean up fastopen related fields */ |
2599 | tcp_free_fastopen_req(tp); | 2603 | tcp_free_fastopen_req(tp); |
@@ -3201,10 +3205,41 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) | |||
3201 | info->tcpi_delivery_rate = rate64; | 3205 | info->tcpi_delivery_rate = rate64; |
3202 | info->tcpi_delivered = tp->delivered; | 3206 | info->tcpi_delivered = tp->delivered; |
3203 | info->tcpi_delivered_ce = tp->delivered_ce; | 3207 | info->tcpi_delivered_ce = tp->delivered_ce; |
3208 | info->tcpi_bytes_sent = tp->bytes_sent; | ||
3209 | info->tcpi_bytes_retrans = tp->bytes_retrans; | ||
3210 | info->tcpi_dsack_dups = tp->dsack_dups; | ||
3211 | info->tcpi_reord_seen = tp->reord_seen; | ||
3204 | unlock_sock_fast(sk, slow); | 3212 | unlock_sock_fast(sk, slow); |
3205 | } | 3213 | } |
3206 | EXPORT_SYMBOL_GPL(tcp_get_info); | 3214 | EXPORT_SYMBOL_GPL(tcp_get_info); |
3207 | 3215 | ||
3216 | static size_t tcp_opt_stats_get_size(void) | ||
3217 | { | ||
3218 | return | ||
3219 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BUSY */ | ||
3220 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_RWND_LIMITED */ | ||
3221 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_SNDBUF_LIMITED */ | ||
3222 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_DATA_SEGS_OUT */ | ||
3223 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_TOTAL_RETRANS */ | ||
3224 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_PACING_RATE */ | ||
3225 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_DELIVERY_RATE */ | ||
3226 | nla_total_size(sizeof(u32)) + /* TCP_NLA_SND_CWND */ | ||
3227 | nla_total_size(sizeof(u32)) + /* TCP_NLA_REORDERING */ | ||
3228 | nla_total_size(sizeof(u32)) + /* TCP_NLA_MIN_RTT */ | ||
3229 | nla_total_size(sizeof(u8)) + /* TCP_NLA_RECUR_RETRANS */ | ||
3230 | nla_total_size(sizeof(u8)) + /* TCP_NLA_DELIVERY_RATE_APP_LMT */ | ||
3231 | nla_total_size(sizeof(u32)) + /* TCP_NLA_SNDQ_SIZE */ | ||
3232 | nla_total_size(sizeof(u8)) + /* TCP_NLA_CA_STATE */ | ||
3233 | nla_total_size(sizeof(u32)) + /* TCP_NLA_SND_SSTHRESH */ | ||
3234 | nla_total_size(sizeof(u32)) + /* TCP_NLA_DELIVERED */ | ||
3235 | nla_total_size(sizeof(u32)) + /* TCP_NLA_DELIVERED_CE */ | ||
3236 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BYTES_SENT */ | ||
3237 | nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BYTES_RETRANS */ | ||
3238 | nla_total_size(sizeof(u32)) + /* TCP_NLA_DSACK_DUPS */ | ||
3239 | nla_total_size(sizeof(u32)) + /* TCP_NLA_REORD_SEEN */ | ||
3240 | 0; | ||
3241 | } | ||
3242 | |||
3208 | struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk) | 3243 | struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk) |
3209 | { | 3244 | { |
3210 | const struct tcp_sock *tp = tcp_sk(sk); | 3245 | const struct tcp_sock *tp = tcp_sk(sk); |
@@ -3213,9 +3248,7 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk) | |||
3213 | u64 rate64; | 3248 | u64 rate64; |
3214 | u32 rate; | 3249 | u32 rate; |
3215 | 3250 | ||
3216 | stats = alloc_skb(7 * nla_total_size_64bit(sizeof(u64)) + | 3251 | stats = alloc_skb(tcp_opt_stats_get_size(), GFP_ATOMIC); |
3217 | 7 * nla_total_size(sizeof(u32)) + | ||
3218 | 3 * nla_total_size(sizeof(u8)), GFP_ATOMIC); | ||
3219 | if (!stats) | 3252 | if (!stats) |
3220 | return NULL; | 3253 | return NULL; |
3221 | 3254 | ||
@@ -3251,6 +3284,13 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk) | |||
3251 | nla_put_u32(stats, TCP_NLA_SNDQ_SIZE, tp->write_seq - tp->snd_una); | 3284 | nla_put_u32(stats, TCP_NLA_SNDQ_SIZE, tp->write_seq - tp->snd_una); |
3252 | nla_put_u8(stats, TCP_NLA_CA_STATE, inet_csk(sk)->icsk_ca_state); | 3285 | nla_put_u8(stats, TCP_NLA_CA_STATE, inet_csk(sk)->icsk_ca_state); |
3253 | 3286 | ||
3287 | nla_put_u64_64bit(stats, TCP_NLA_BYTES_SENT, tp->bytes_sent, | ||
3288 | TCP_NLA_PAD); | ||
3289 | nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS, tp->bytes_retrans, | ||
3290 | TCP_NLA_PAD); | ||
3291 | nla_put_u32(stats, TCP_NLA_DSACK_DUPS, tp->dsack_dups); | ||
3292 | nla_put_u32(stats, TCP_NLA_REORD_SEEN, tp->reord_seen); | ||
3293 | |||
3254 | return stats; | 3294 | return stats; |
3255 | } | 3295 | } |
3256 | 3296 | ||