NAME
ip-tcp_metrics - management for TCP Metrics
SYNOPSIS
ip [ OPTIONS ] tcp_metrics { COMMAND | help }
ip tcp_metrics { show | flush } SELECTOR
ip tcp_metrics delete [ address ] ADDRESS
SELECTOR := [ [ address ] PREFIX ]
EXAMPLES
1234567891011121314151617181920
ip tcp_metrics show address 192.168.0.0/24
Shows the entries for destinations from subnet
ip tcp_metrics show 192.168.0.0/24
The same but address keyword is optional
ip tcp_metrics
Show all is the default action
ip tcp_metrics delete 192.168.0.1
Removes the entry for 192.168.0.1 from cache.
ip tcp_metrics flush 192.168.0.0/24
Removes entries for destinations from subnet
ip tcp_metrics flush all
Removes all entries from cache
ip -6 tcp_metrics flush all
Removes all IPv6 entries from cache keeping the IPv4 entries.
struct rtable
{
union
{
struct dst_entry dst;
} u;
...
// 以下为记录二元组的信息
__be32 rt_dst; /* Path destination */
__be32 rt_src; /* Path source */
int rt_iif;
/* Info on neighbour */
__be32 rt_gateway;
/* Miscellaneous cached information */
__be32 rt_spec_dst; /* RFC1122 specific destination */
// peer很重要!
struct inet_peer *peer; /* long-living peer info */
};
注意这个peer字段,很重要!peer结构体记如下:
123456789101112131415
struct inet_peer
{
/* group together avl_left,avl_right,v4daddr to speedup lookups */
struct inet_peer *avl_left, *avl_right;
__be32 v4daddr; /* peer's address */
__u16 avl_height;
__u16 ip_id_count; /* IP ID for the next packet */
struct list_head unused;
__u32 dtime; /* the time of last use of not
* referenced entries */
atomic_t refcnt;
atomic_t rid; /* Frag reception counter */
__u32 tcp_ts;
unsigned long tcp_ts_stamp;
};
struct inet_peer {
/* group together avl_left,avl_right,v4daddr to speedup lookups */
struct inet_peer __rcu *avl_left, *avl_right;
struct inetpeer_addr daddr;
__u32 avl_height;
// 此为关键!
u32 metrics[RTAX_MAX];
u32 rate_tokens; /* rate limiting for ICMP */
unsigned long rate_last;
union {
struct list_head gc_list;
struct rcu_head gc_rcu;
};
/*
* Once inet_peer is queued for deletion (refcnt == -1), following fields
* are not available: rid, ip_id_count
* We can share memory with rcu_head to help keep inet_peer small.
*/
union {
struct {
atomic_t rid; /* Frag reception counter */
atomic_t ip_id_count; /* IP ID for the next packet */
};
struct rcu_head rcu;
struct inet_peer *gc_next;
};
/* following fields might be frequently dirtied */
__u32 dtime; /* the time of last use of not referenced entries */
atomic_t refcnt;
};