Commit 51c5d0c4 authored by David S. Miller's avatar David S. Miller

tcp: Maintain dynamic metrics in local cache.

Maintain a local hash table of TCP dynamic metrics blobs.

Computed TCP metrics are no longer maintained in the route metrics.

The table uses RCU and an extremely simple hash so that it has low
latency and low overhead.  A simple hash is legitimate because we only
make metrics blobs for fully established connections.

Some tweaking of the default hash table sizes, metric timeouts, and
the hash chain length limit certainly could use some tweaking.  But
the basic design seems sound.

With help from Eric Dumazet and Joe Perches.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ab92bb2f
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <net/inet_frag.h> #include <net/inet_frag.h>
struct tcpm_hash_bucket;
struct ctl_table_header; struct ctl_table_header;
struct ipv4_devconf; struct ipv4_devconf;
struct fib_rules_ops; struct fib_rules_ops;
...@@ -39,6 +40,8 @@ struct netns_ipv4 { ...@@ -39,6 +40,8 @@ struct netns_ipv4 {
struct sock **icmp_sk; struct sock **icmp_sk;
struct sock *tcp_sock; struct sock *tcp_sock;
struct inet_peer_base *peers; struct inet_peer_base *peers;
struct tcpm_hash_bucket *tcp_metrics_hash;
unsigned int tcp_metrics_hash_mask;
struct netns_frags frags; struct netns_frags frags;
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
struct xt_table *iptable_filter; struct xt_table *iptable_filter;
......
...@@ -389,6 +389,7 @@ extern void tcp_enter_loss(struct sock *sk, int how); ...@@ -389,6 +389,7 @@ extern void tcp_enter_loss(struct sock *sk, int how);
extern void tcp_clear_retrans(struct tcp_sock *tp); extern void tcp_clear_retrans(struct tcp_sock *tp);
extern void tcp_update_metrics(struct sock *sk); extern void tcp_update_metrics(struct sock *sk);
extern void tcp_init_metrics(struct sock *sk); extern void tcp_init_metrics(struct sock *sk);
extern void tcp_metrics_init(void);
extern bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst); extern bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst);
extern void tcp_disable_fack(struct tcp_sock *tp); extern void tcp_disable_fack(struct tcp_sock *tp);
extern void tcp_close(struct sock *sk, long timeout); extern void tcp_close(struct sock *sk, long timeout);
......
...@@ -3563,6 +3563,8 @@ void __init tcp_init(void) ...@@ -3563,6 +3563,8 @@ void __init tcp_init(void)
pr_info("Hash tables configured (established %u bind %u)\n", pr_info("Hash tables configured (established %u bind %u)\n",
tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size); tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);
tcp_metrics_init();
tcp_register_congestion_control(&tcp_reno); tcp_register_congestion_control(&tcp_reno);
memset(&tcp_secret_one.secrets[0], 0, sizeof(tcp_secret_one.secrets)); memset(&tcp_secret_one.secrets[0], 0, sizeof(tcp_secret_one.secrets));
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment