Skip to content

Commit d23ff70

Browse files
Julian Anastasovdavem330
authored andcommitted
tcp: add generic netlink support for tcp_metrics
Add support for genl "tcp_metrics". No locking is changed, only that now we can unlink and delete entries after grace period. We implement get/del for single entry and dump to support show/flush filtering in user space. Del without address attribute causes flush for all addresses, sadly under genl_mutex. v2: - remove rcu_assign_pointer as suggested by Eric Dumazet, it is not needed because there are no other writes under lock - move the flushing code in tcp_metrics_flush_all v3: - remove synchronize_rcu on flush as suggested by Eric Dumazet Signed-off-by: Julian Anastasov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ab86825 commit d23ff70

File tree

3 files changed

+396
-13
lines changed

3 files changed

+396
-13
lines changed

include/linux/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ header-y += sysctl.h
363363
header-y += sysinfo.h
364364
header-y += taskstats.h
365365
header-y += tcp.h
366+
header-y += tcp_metrics.h
366367
header-y += telephony.h
367368
header-y += termios.h
368369
header-y += time.h

include/linux/tcp_metrics.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* tcp_metrics.h - TCP Metrics Interface */
2+
3+
#ifndef _LINUX_TCP_METRICS_H
4+
#define _LINUX_TCP_METRICS_H
5+
6+
#include <linux/types.h>
7+
8+
/* NETLINK_GENERIC related info
9+
*/
10+
#define TCP_METRICS_GENL_NAME "tcp_metrics"
11+
#define TCP_METRICS_GENL_VERSION 0x1
12+
13+
enum tcp_metric_index {
14+
TCP_METRIC_RTT,
15+
TCP_METRIC_RTTVAR,
16+
TCP_METRIC_SSTHRESH,
17+
TCP_METRIC_CWND,
18+
TCP_METRIC_REORDERING,
19+
20+
/* Always last. */
21+
__TCP_METRIC_MAX,
22+
};
23+
24+
#define TCP_METRIC_MAX (__TCP_METRIC_MAX - 1)
25+
26+
enum {
27+
TCP_METRICS_ATTR_UNSPEC,
28+
TCP_METRICS_ATTR_ADDR_IPV4, /* u32 */
29+
TCP_METRICS_ATTR_ADDR_IPV6, /* binary */
30+
TCP_METRICS_ATTR_AGE, /* msecs */
31+
TCP_METRICS_ATTR_TW_TSVAL, /* u32, raw, rcv tsval */
32+
TCP_METRICS_ATTR_TW_TS_STAMP, /* s32, sec age */
33+
TCP_METRICS_ATTR_VALS, /* nested +1, u32 */
34+
TCP_METRICS_ATTR_FOPEN_MSS, /* u16 */
35+
TCP_METRICS_ATTR_FOPEN_SYN_DROPS, /* u16, count of drops */
36+
TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS, /* msecs age */
37+
TCP_METRICS_ATTR_FOPEN_COOKIE, /* binary */
38+
39+
__TCP_METRICS_ATTR_MAX,
40+
};
41+
42+
#define TCP_METRICS_ATTR_MAX (__TCP_METRICS_ATTR_MAX - 1)
43+
44+
enum {
45+
TCP_METRICS_CMD_UNSPEC,
46+
TCP_METRICS_CMD_GET,
47+
TCP_METRICS_CMD_DEL,
48+
49+
__TCP_METRICS_CMD_MAX,
50+
};
51+
52+
#define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1)
53+
54+
#endif /* _LINUX_TCP_METRICS_H */

0 commit comments

Comments
 (0)