Implementation of RFC 4898 Extended TCP Statistics (Web10G)
Subsystems (3)
PATCH 2/3 Implementation of RFC 4898 Extended TCP Statistics (Web10G)
This set of patches provide control and management routines for the kernel instrument set (KIS). This set of patches can be applied against net-next independently of the KIS. While the kernel can be patched, compiled, and run with this patch set it provides no real functionality without the KIS implementation.
The reason is that the development team is primarily focused on ensuring that the KIS is taken up by the community. Alternative control and management methods can be developed and implemented as long as the KIS is in the kernel.
In order for this patch set to compile on its own we have included two files/patches that were previously introduced in the KIS implementation. These are include/net/tcp_estats.h and include/linux/tcp.h. If patching against a source tree that includes the KIS implementation net/ipv4/[tcp_estats.c, sysctl_net_ipv4.c, Kconfig, Makefile] are required.
--- include/linux/tcp.h | 8 + include/net/tcp_estats.h | 376 +++++++++++++++++++++++ net/ipv4/Kconfig | 25 ++ net/ipv4/Makefile | 1 + net/ipv4/sysctl_net_ipv4.c | 14 + net/ipv4/tcp_estats.c | 736 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1160 insertions(+) create mode 100644 include/net/tcp_estats.h create mode 100644 net/ipv4/tcp_estats.c
include/linux/tcp.h +8 -0
@@ -126,6 +126,10 @@ static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)return (struct tcp_request_sock *)req; } +#ifdef CONFIG_TCP_ESTATS +struct tcp_estats ; +#endif +struct tcp_sock {/* inet_connection_sock has to be the first member of tcp_sock */ struct inet_connection_sock inet_conn;
@@ -309,6 +313,10 @@ struct tcp_sock {struct tcp_md5sig_info __rcu *md5sig_info;#endif +#ifdef CONFIG_TCP_ESTATS +struct tcp_estats *tcp_stats; +#endif +/* TCP fastopen related information */ struct tcp_fastopen_request *fastopen_req;/* fastopen_rsk points to request_sock that resulted in this big
include/net/tcp_estats.h new file +376 -0
376 lines not on this page · raw message
net/ipv4/Kconfig +25 -0
@@ -680,3 +680,28 @@ config TCP_MD5SIG on the Internet. If unsure, say N. + +config TCP_ESTATS + bool "TCP: Extended TCP statistics (RFC4898) MIB" + ---help--- + RFC 4898 specifies a number of extended statistics for TCP. This + data can be accessed using netlink. See http://www.web10g.org for + more details. + +if TCP_ESTATS + +config TCP_ESTATS_STRICT_ELAPSEDTIME + bool "TCP: ESTATS strict ElapsedSecs/Msecs counters" + depends on TCP_ESTATS + default n + ---help--- + Elapsed time since beginning of connection. + RFC4898 defines ElapsedSecs/Msecs as being updated via ktime_get + at each protocol event (sending or receiving of a segment); + as this can be a performance hit, leaving this config option off + will update elapsed based on on the jiffies counter instead. + Set to Y for strict conformance with the MIB. + + If unsure, say N. + +endif
net/ipv4/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_INET_TUNNEL) += tunnel4.o obj-$(CONFIG_INET_XFRM_MODE_TRANSPORT) += xfrm4_mode_transport.o obj-$(CONFIG_INET_XFRM_MODE_TUNNEL) += xfrm4_mode_tunnel.o obj-$(CONFIG_IP_PNP) += ipconfig.o +obj-$(CONFIG_TCP_ESTATS) += tcp_estats.o obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/ obj-$(CONFIG_INET_DIAG) += inet_diag.o obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o
net/ipv4/sysctl_net_ipv4.c +14 -0
@@ -42,6 +42,11 @@ static int tcp_syn_retries_max = MAX_TCP_SYNCNT;static int ip_ping_group_range_min[] = {0 ,0 };static int ip_ping_group_range_max[] = {GID_T_MAX ,GID_T_MAX }; +/* Extended statistics (RFC4898). */ +#ifdef CONFIG_TCP_ESTATS +int sysctl_tcp_estats__read_mostly ; +#endif /* CONFIG_TCP_ESTATS */ +/* Update system visible IP port range */ static void set_local_port_range (struct net *net,int range[2 ]) {
@@ -767,6 +772,15 @@ static struct ctl_table ipv4_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &one }, +#ifdef CONFIG_TCP_ESTATS + { + .procname = "tcp_estats", + .data = &sysctl_tcp_estats, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec + }, +#endif /* CONFIG TCP ESTATS */ { } };
net/ipv4/tcp_estats.c new file +736 -0
736 lines not on this page · raw message
Signature · 1 line
1.9.3
Quoted 16 lines · rapier
net/ipv4/tcp_estats.c new file +16
-0+ +void tcp_estats_update_rtt (struct sock *sk,unsigned long rtt_sample) +{ +struct tcp_estats *stats =tcp_sk (sk)->tcp_stats; +struct tcp_estats_path_table *path_table = stats->tables.path_table; +unsigned long rtt_sample_msec = rtt_sample/1000 ; +u32 rto; + +if (path_table ==NULL ) +return ; + + path_table->SampleRTT = rtt_sample_msec; + +if (rtt_sample_msec > path_table->MaxRTT) + path_table->MaxRTT = rtt_sample_msec; +if (rtt_sample_msec < path_table->MinRTT)
net/ipv4/tcp_estats.c line 364
Quoted 10 lines
net/ipv4/tcp_estats.c new file +10
-0+ path_table->MinRTT = rtt_sample_msec; + + path_table->CountRTT++; + path_table->SumRTT += rtt_sample_msec; + + rto =jiffies_to_msecs (inet_csk (sk)->icsk_rto); +if (rto > path_table->MaxRTO) + path_table->MaxRTO = rto; +if (rto < path_table->MinRTO) + path_table->MinRTO = rto;
Looking through your hooks it seem that many basically do simple value profiling in a very open coded way.
Perhaps you could simplify things a lot by just having a couple of trace points for these values (e.g. trace_change_rtt). Then have a library of different data profiling types.
Then you could register a new value oriented trace point type with different backend for whatever you currently need from the value: like min/max/avg/ or full histogram or even reservoir sampling or EWMA.
I guess such a generic infrastructure would be useful elsewhere too.
One challenge would be how to associate such value profiles with sockets, but I'm sure this could be done in some nice generic way too.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only