diff options
author | Eric Dumazet <edumazet@google.com> | 2015-04-28 19:23:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-29 17:10:38 -0400 |
commit | 64f40ff5bbdb1b679fb3c4dbc8230d6517d2b8dc (patch) | |
tree | 4767b2030e5099a7a63c05c42a7d30c309d62474 /net | |
parent | bdd1f9edacb5f5835d1e6276571bbbe5b88ded48 (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/inet_diag.c | 8 | ||||
-rw-r--r-- | net/ipv4/tcp_dctcp.c | 20 | ||||
-rw-r--r-- | net/ipv4/tcp_illinois.c | 21 | ||||
-rw-r--r-- | net/ipv4/tcp_vegas.c | 19 | ||||
-rw-r--r-- | net/ipv4/tcp_vegas.h | 3 |
5 files changed, 38 insertions, 33 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index bb77ebdae3b3..4d32262c7502 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -224,14 +224,16 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, | |||
224 | handler->idiag_get_info(sk, r, info); | 224 | handler->idiag_get_info(sk, r, info); |
225 | 225 | ||
226 | if (sk->sk_state < TCP_TIME_WAIT) { | 226 | if (sk->sk_state < TCP_TIME_WAIT) { |
227 | int err = 0; | 227 | union tcp_cc_info info; |
228 | size_t sz = 0; | ||
229 | int attr; | ||
228 | 230 | ||
229 | rcu_read_lock(); | 231 | rcu_read_lock(); |
230 | ca_ops = READ_ONCE(icsk->icsk_ca_ops); | 232 | ca_ops = READ_ONCE(icsk->icsk_ca_ops); |
231 | if (ca_ops && ca_ops->get_info) | 233 | if (ca_ops && ca_ops->get_info) |
232 | err = ca_ops->get_info(sk, ext, skb); | 234 | sz = ca_ops->get_info(sk, ext, &attr, &info); |
233 | rcu_read_unlock(); | 235 | rcu_read_unlock(); |
234 | if (err < 0) | 236 | if (sz && nla_put(skb, attr, sz, &info) < 0) |
235 | goto errout; | 237 | goto errout; |
236 | } | 238 | } |
237 | 239 | ||
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c index 4376016f7fa5..4c41c1287197 100644 --- a/net/ipv4/tcp_dctcp.c +++ b/net/ipv4/tcp_dctcp.c | |||
@@ -277,7 +277,8 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) | |||
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 280 | static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr, |
281 | union tcp_cc_info *info) | ||
281 | { | 282 | { |
282 | const struct dctcp *ca = inet_csk_ca(sk); | 283 | const struct dctcp *ca = inet_csk_ca(sk); |
283 | 284 | ||
@@ -286,18 +287,17 @@ static int dctcp_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | |||
286 | */ | 287 | */ |
287 | if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || | 288 | if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || |
288 | ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 289 | ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
289 | struct tcp_dctcp_info info; | 290 | memset(info, 0, sizeof(struct tcp_dctcp_info)); |
290 | |||
291 | memset(&info, 0, sizeof(info)); | ||
292 | if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { | 291 | if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { |
293 | info.dctcp_enabled = 1; | 292 | info->dctcp.dctcp_enabled = 1; |
294 | info.dctcp_ce_state = (u16) ca->ce_state; | 293 | info->dctcp.dctcp_ce_state = (u16) ca->ce_state; |
295 | info.dctcp_alpha = ca->dctcp_alpha; | 294 | info->dctcp.dctcp_alpha = ca->dctcp_alpha; |
296 | info.dctcp_ab_ecn = ca->acked_bytes_ecn; | 295 | info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn; |
297 | info.dctcp_ab_tot = ca->acked_bytes_total; | 296 | info->dctcp.dctcp_ab_tot = ca->acked_bytes_total; |
298 | } | 297 | } |
299 | 298 | ||
300 | return nla_put(skb, INET_DIAG_DCTCPINFO, sizeof(info), &info); | 299 | *attr = INET_DIAG_DCTCPINFO; |
300 | return sizeof(*info); | ||
301 | } | 301 | } |
302 | return 0; | 302 | return 0; |
303 | } | 303 | } |
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c index 67476f085e48..f71002e4db0b 100644 --- a/net/ipv4/tcp_illinois.c +++ b/net/ipv4/tcp_illinois.c | |||
@@ -300,24 +300,25 @@ static u32 tcp_illinois_ssthresh(struct sock *sk) | |||
300 | } | 300 | } |
301 | 301 | ||
302 | /* Extract info for Tcp socket info provided via netlink. */ | 302 | /* Extract info for Tcp socket info provided via netlink. */ |
303 | static int tcp_illinois_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 303 | static size_t tcp_illinois_info(struct sock *sk, u32 ext, int *attr, |
304 | union tcp_cc_info *info) | ||
304 | { | 305 | { |
305 | const struct illinois *ca = inet_csk_ca(sk); | 306 | const struct illinois *ca = inet_csk_ca(sk); |
306 | 307 | ||
307 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 308 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
308 | struct tcpvegas_info info = { | 309 | info->vegas.tcpv_enabled = 1; |
309 | .tcpv_enabled = 1, | 310 | info->vegas.tcpv_rttcnt = ca->cnt_rtt; |
310 | .tcpv_rttcnt = ca->cnt_rtt, | 311 | info->vegas.tcpv_minrtt = ca->base_rtt; |
311 | .tcpv_minrtt = ca->base_rtt, | 312 | info->vegas.tcpv_rtt = 0; |
312 | }; | ||
313 | 313 | ||
314 | if (info.tcpv_rttcnt > 0) { | 314 | if (info->vegas.tcpv_rttcnt > 0) { |
315 | u64 t = ca->sum_rtt; | 315 | u64 t = ca->sum_rtt; |
316 | 316 | ||
317 | do_div(t, info.tcpv_rttcnt); | 317 | do_div(t, info->vegas.tcpv_rttcnt); |
318 | info.tcpv_rtt = t; | 318 | info->vegas.tcpv_rtt = t; |
319 | } | 319 | } |
320 | return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); | 320 | *attr = INET_DIAG_VEGASINFO; |
321 | return sizeof(struct tcpvegas_info); | ||
321 | } | 322 | } |
322 | return 0; | 323 | return 0; |
323 | } | 324 | } |
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c index c71a1b8f7bde..a6cea1d5e20d 100644 --- a/net/ipv4/tcp_vegas.c +++ b/net/ipv4/tcp_vegas.c | |||
@@ -286,18 +286,19 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | /* Extract info for Tcp socket info provided via netlink. */ | 288 | /* Extract info for Tcp socket info provided via netlink. */ |
289 | int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) | 289 | size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr, |
290 | union tcp_cc_info *info) | ||
290 | { | 291 | { |
291 | const struct vegas *ca = inet_csk_ca(sk); | 292 | const struct vegas *ca = inet_csk_ca(sk); |
293 | |||
292 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 294 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
293 | struct tcpvegas_info info = { | 295 | info->vegas.tcpv_enabled = ca->doing_vegas_now, |
294 | .tcpv_enabled = ca->doing_vegas_now, | 296 | info->vegas.tcpv_rttcnt = ca->cntRTT, |
295 | .tcpv_rttcnt = ca->cntRTT, | 297 | info->vegas.tcpv_rtt = ca->baseRTT, |
296 | .tcpv_rtt = ca->baseRTT, | 298 | info->vegas.tcpv_minrtt = ca->minRTT, |
297 | .tcpv_minrtt = ca->minRTT, | 299 | |
298 | }; | 300 | *attr = INET_DIAG_VEGASINFO; |
299 | 301 | return sizeof(struct tcpvegas_info); | |
300 | return nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); | ||
301 | } | 302 | } |
302 | return 0; | 303 | return 0; |
303 | } | 304 | } |
diff --git a/net/ipv4/tcp_vegas.h b/net/ipv4/tcp_vegas.h index e8a6b33cc61d..ef9da5306c68 100644 --- a/net/ipv4/tcp_vegas.h +++ b/net/ipv4/tcp_vegas.h | |||
@@ -19,6 +19,7 @@ void tcp_vegas_init(struct sock *sk); | |||
19 | void tcp_vegas_state(struct sock *sk, u8 ca_state); | 19 | void tcp_vegas_state(struct sock *sk, u8 ca_state); |
20 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); | 20 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us); |
21 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); | 21 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); |
22 | int tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb); | 22 | size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr, |
23 | union tcp_cc_info *info); | ||
23 | 24 | ||
24 | #endif /* __TCP_VEGAS_H */ | 25 | #endif /* __TCP_VEGAS_H */ |