tcp: prepare CC get_info() access from getsockopt()

We would like that optional info provided by Congestion Control
modules using netlink can also be read using getsockopt()

This patch changes get_info() to put this information in a buffer,
instead of skb, like tcp_get_info(), so that following patch
can reuse this common infrastructure.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet
2015-04-28 16:23:48 -07:00
committed by David S. Miller
parent bdd1f9edac
commit 64f40ff5bb
7 changed files with 46 additions and 34 deletions

View File

@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk)
}
/* Extract info for Tcp socket info provided via netlink. */
static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb)
static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info)
{
const struct illinois *ca = inet_csk_ca(sk);
if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
struct tcpvegas_info info = {
.tcpv_enabled = 1,
.tcpv_rttcnt = ca->cnt_rtt,
.tcpv_minrtt = ca->base_rtt,
};
info->vegas.tcpv_enabled = 1;
info->vegas.tcpv_rttcnt = ca->cnt_rtt;
info->vegas.tcpv_minrtt = ca->base_rtt;
info->vegas.tcpv_rtt = 0;
if (info.tcpv_rttcnt > 0) {
if (info->vegas.tcpv_rttcnt > 0) {
u64 t = ca->sum_rtt;
do_div(t, info.tcpv_rttcnt);
info.tcpv_rtt = t;
do_div(t, info->vegas.tcpv_rttcnt);
info->vegas.tcpv_rtt = t;
}
return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
*attr = INET_DIAG_VEGASINFO;
return sizeof(struct tcpvegas_info);
}
return 0;
}