Skip to content

Commit

Permalink
added some statistics entries to rtentry to collect access history
Browse files Browse the repository at this point in the history
of each route entry.
  • Loading branch information
jinmei committed Apr 9, 2002
1 parent b5a7883 commit 4b30461
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions freebsd4/sys/net/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ rtrequest1(req, info, ret_nrt)
if (rt == 0)
senderr(ENOBUFS);
Bzero(rt, sizeof(*rt));
rt->rt_createtime = time_second; /* for statistics */
rt->rt_flags = RTF_UP | flags;
LIST_INIT(&rt->rt_timer);
/*
Expand Down
16 changes: 16 additions & 0 deletions freebsd4/sys/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ struct rtentry {
struct rtentry *rt_parent; /* cloning parent of this route */
void *rt_filler2; /* more filler */
LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */

/* the following entries are for statistics*/
time_t rt_createtime; /* timestamp at creation of this route */
time_t rt_lastreftime; /* timestamp when the latest reference time */
u_long rt_usehist[12]; /* histogram of references for every 5 min */
};

/*
Expand Down Expand Up @@ -309,6 +314,17 @@ struct rttimer_queue {
(rt)->rt_refcnt--; \
} while (0)

#define RTUSE(rt) \
do { \
int i; \
(rt)->rt_use++; \
(rt)->rt_lastreftime = time_second; \
i = ((rt)->rt_lastreftime - (rt)->rt_createtime) / 300; \
if (i > 11) \
i = 11; \
(rt)->rt_usehist[i]++; \
} while (0)

extern struct route_cb route_cb;
extern struct radix_node_head *rt_tables[AF_MAX+1];

Expand Down

0 comments on commit 4b30461

Please sign in to comment.