History

tcp: make TCP_INFO more consistent

tcp_get_info() has to lock the socket, so lets lock it for an extended critical section, so that various fields have consistent values. This solves an annoying issue that some applications reported when multiple counters are updated during one particular rx/rx event, and TCP_INFO was called from another cpu.

Eric Dumazet committed 9 years ago

Commit b369e7f1 parent c22e5c11 file · +4 −4Browse files

Unified · Split

net/ipv4/tcp.c+4−4
@@ -2766,6 +2766,9 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) · 2765 unmodified lines
2766 info->tcpi_sacked = sk->sk_max_ack_backlog;2766 info->tcpi_sacked = sk->sk_max_ack_backlog;
2767 return;2767 return;
2768 }2768 }
2769
2770 slow = lock_sock_fast(sk);
2771
2769 info->tcpi_ca_state = icsk->icsk_ca_state;2772 info->tcpi_ca_state = icsk->icsk_ca_state;
2770 info->tcpi_retransmits = icsk->icsk_retransmits;2773 info->tcpi_retransmits = icsk->icsk_retransmits;
2771 info->tcpi_probes = icsk->icsk_probes_out;2774 info->tcpi_probes = icsk->icsk_probes_out;
@@ -2816,15 +2819,11 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) · 44 unmodified lines
2816 2819
2817 info->tcpi_total_retrans = tp->total_retrans;2820 info->tcpi_total_retrans = tp->total_retrans;
2818 2821
2819 slow = lock_sock_fast(sk);
2820
2821 info->tcpi_bytes_acked = tp->bytes_acked;2822 info->tcpi_bytes_acked = tp->bytes_acked;
2822 info->tcpi_bytes_received = tp->bytes_received;2823 info->tcpi_bytes_received = tp->bytes_received;
2823 info->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);2824 info->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);
2824 tcp_get_info_chrono_stats(tp, info);2825 tcp_get_info_chrono_stats(tp, info);
2825 2826
2826 unlock_sock_fast(sk, slow);
2827
2828 info->tcpi_segs_out = tp->segs_out;2827 info->tcpi_segs_out = tp->segs_out;
2829 info->tcpi_segs_in = tp->segs_in;2828 info->tcpi_segs_in = tp->segs_in;
2830 2829
@@ -2840,6 +2839,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) · 9 unmodified lines
2840 do_div(rate64, intv);2839 do_div(rate64, intv);
2841 info->tcpi_delivery_rate = rate64;2840 info->tcpi_delivery_rate = rate64;
2842 }2841 }
2842 unlock_sock_fast(sk, slow);
2843}2843}
2844EXPORT_SYMBOL_GPL(tcp_get_info);2844EXPORT_SYMBOL_GPL(tcp_get_info);
2845 2845

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t