Interface for TCP Metrics
Subsystems (3)
v2 cover Interface for TCP Metrics
This patchset contains 2 patches, one for kernel
and one for iproute2. We add DUMP/GET/DEL support for genl "tcp_metrics" and minimal support for filtering by address prefix and family in user space.
I tested show/del/flush, filtering by family, IPv4 prefix,
output for metrics such as rtt, rttvar, cwnd, ssthresh (after modifying route). I didn't tested output for fast open.
May be some corrections in output can be desired.
The kernel patch has some parts to check:
- in tcp_metrics_nl_cmd_del I'm trying to flush all addresses with single request, eg. when no family, address or other selectors are provided. I use some arbitrary counter sync_count to force memory to be freed in parts by using synchronize_rcu, note that we are under genl_mutex, so may be this is bad idea to delay other genl users? My idea was to avoid many commands on "flush all", may be we should trigger flush by using some other mechanism that is pernet? And I don't know how to test it properly without large cache.
- I enabled lockdep in config and don't see any warnings. make C=2 net/ipv4/tcp_metrics.o is silent too.
v2:
- patch 1: remove rcu_assign_pointer, add tcp_metrics_flush_all
- patch 2: properly flush by specifying address, improve man page
RFC PATCH v2 1/2 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
--- include/linux/Kbuild | 1 + include/linux/tcp_metrics.h | 54 +++++++ net/ipv4/tcp_metrics.c | 357 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 399 insertions(+), 13 deletions(-) create mode 100644 include/linux/tcp_metrics.h
include/linux/Kbuild +1 -0
@@ -363,6 +363,7 @@ header-y += sysctl.h header-y += sysinfo.h header-y += taskstats.h header-y += tcp.h +header-y += tcp_metrics.h header-y += telephony.h header-y += termios.h header-y += time.h
include/linux/tcp_metrics.h new file +54 -0
54 lines not on this page · raw message
net/ipv4/tcp_metrics.c +344 -13
389 lines not on this page · raw message
Signature · 1 line
1.7.3.4
RFC PATCH v2 2/2 iproute2: add support for tcp_metrics
In reply to Julian Anastasovip tcp_metrics/tcpmetrics
v2:
- On flush we should provide the address in req2
- "flush all" should use single del, just like when "all" is not provided
- Explain printed information in man page
---
include/linux/tcp_metrics.h +54 -0
@@ -0,0 +1,54 @@ +/* tcp_metrics.h - TCP Metrics Interface */ + +#ifndef _LINUX_TCP_METRICS_H +#define _LINUX_TCP_METRICS_H + +#include <linux/types.h> + +/* NETLINK_GENERIC related info +*/ +#define TCP_METRICS_GENL_NAME "tcp_metrics" +#define TCP_METRICS_GENL_VERSION 0x1 + +enum tcp_metric_index { +TCP_METRIC_RTT , +TCP_METRIC_RTTVAR , +TCP_METRIC_SSTHRESH , +TCP_METRIC_CWND , +TCP_METRIC_REORDERING , + +/* Always last. */ + __TCP_METRIC_MAX, +}; + +#define TCP_METRIC_MAX (__TCP_METRIC_MAX - 1) + +enum { +TCP_METRICS_ATTR_UNSPEC , +TCP_METRICS_ATTR_ADDR_IPV4 ,/* u32 */ +TCP_METRICS_ATTR_ADDR_IPV6 ,/* binary */ +TCP_METRICS_ATTR_AGE ,/* msecs */ +TCP_METRICS_ATTR_TW_TSVAL ,/* u32, raw, rcv tsval */ +TCP_METRICS_ATTR_TW_TS_STAMP ,/* s32, sec age */ +TCP_METRICS_ATTR_VALS ,/* nested +1, u32 */ +TCP_METRICS_ATTR_FOPEN_MSS ,/* u16 */ +TCP_METRICS_ATTR_FOPEN_SYN_DROPS ,/* u16, count of drops */ +TCP_METRICS_ATTR_FOPEN_SYN_DROP_TS ,/* msecs age */ +TCP_METRICS_ATTR_FOPEN_COOKIE ,/* binary */ + + __TCP_METRICS_ATTR_MAX, +}; + +#define TCP_METRICS_ATTR_MAX (__TCP_METRICS_ATTR_MAX - 1) + +enum { +TCP_METRICS_CMD_UNSPEC , +TCP_METRICS_CMD_GET , +TCP_METRICS_CMD_DEL , + + __TCP_METRICS_CMD_MAX, +}; + +#define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1) + +#endif /* _LINUX_TCP_METRICS_H */
ip/Makefile +1 -1
@@ -3,7 +3,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o ipr ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o \ ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o \ iplink_vlan.o link_veth.o link_gre.o iplink_can.o \ - iplink_macvlan.o iplink_macvtap.o ipl2tp.o + iplink_macvlan.o iplink_macvtap.o ipl2tp.o tcp_metrics.o RTMONOBJ=rtmon.o
ip/ip.c +3 -1
@@ -45,7 +45,7 @@ static void usage(void)" ip [ -force ] -batch filename\n" "where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |\n" " tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |\n" -" netns | l2tp }\n" +" netns | l2tp | tcp_metrics }\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n" " -f[amily] { inet | inet6 | ipx | dnet | link } |\n" " -l[oops] { maximum-addr-flush-attempts } |\n"
@@ -78,6 +78,8 @@ static const struct cmd { { "tunl", do_iptunnel }, { "tuntap", do_iptuntap }, { "tap", do_iptuntap }, + { "tcpmetrics", do_tcp_metrics }, + { "tcp_metrics",do_tcp_metrics }, { "monitor", do_ipmonitor }, { "xfrm", do_xfrm }, { "mroute", do_multiroute },
ip/ip_common.h +1 -0
@@ -42,6 +42,7 @@ extern int do_multirule(int argc, char *extern int do_netns (int argc,char **argv);extern int do_xfrm (int argc,char **argv);extern int do_ipl2tp (int argc,char **argv); +extern int do_tcp_metrics (int argc,char **argv);static inline int rtm_get_table (struct rtmsg *r,struct rtattr **tb) {
ip/tcp_metrics.c +504 -0
504 lines not on this page · raw message
man/man8/Makefile +2 -1
@@ -7,7 +7,8 @@ MAN8PAGES = $(TARGETS) ip.8 arpd.8 lnsta bridge.8 rtstat.8 ctstat.8 nstat.8 routef.8 \ ip-tunnel.8 ip-rule.8 ip-ntable.8 \ ip-monitor.8 tc-stab.8 tc-hfsc.8 ip-xfrm.8 ip-netns.8 \ - ip-neighbour.8 ip-mroute.8 ip-maddress.8 ip-addrlabel.8 + ip-neighbour.8 ip-mroute.8 ip-maddress.8 ip-addrlabel.8 \ + ip-tcp_metrics.8 all: $(TARGETS)
man/man8/ip-tcp_metrics.8 +143 -0
143 lines not on this page · raw message
man/man8/ip.8 +6 -1
@@ -15,7 +15,7 @@ ip \- show / manipulate routing, devices .IR OBJECT " := { " .BR link " | " addr " | " addrlabel " | " route " | " rule " | " neigh " | "\ ntable " | " tunnel " | " tuntap " | " maddr " | " mroute " | " mrule " | "\ - monitor " | " xfrm " | " netns " | " l2tp " }" + monitor " | " xfrm " | " netns " | " l2tp " | " tcp_metrics " }" .sp .ti -8
@@ -156,6 +156,10 @@ host addresses. - rule in routing policy database. .TP +.B tcp_metrics/tcpmetrics +- manage TCP Metrics + +.TP .B tunnel - tunnel over IP.
@@ -215,6 +219,7 @@ was written by Alexey N. Kuznetsov and a .BR ip-ntable (8), .BR ip-route (8), .BR ip-rule (8), +.BR ip-tcp_metrics (8), .BR ip-tunnel (8), .BR ip-xfrm (8) .br