Import patch iproute2-hz

(Logical change 1.159)
parent d27d73ab
......@@ -113,4 +113,14 @@ static __inline__ int get_hz(void)
return __iproute2_hz_internal;
}
extern int __iproute2_user_hz_internal;
extern int __get_user_hz(void);
static __inline__ int get_user_hz(void)
{
if (__iproute2_user_hz_internal == 0)
__iproute2_user_hz_internal = __get_user_hz();
return __iproute2_user_hz_internal;
}
#endif /* __UTILS_H__ */
......@@ -410,7 +410,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
struct rta_cacheinfo *ci = RTA_DATA(tb[RTA_CACHEINFO]);
static int hz;
if (!hz)
hz = get_hz();
hz = get_user_hz();
if (ci->rta_expires != 0)
fprintf(fp, " expires %dsec", ci->rta_expires/hz);
if (ci->rta_error != 0)
......@@ -437,7 +437,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if ((r->rtm_flags & RTM_F_CLONED) || (ci && ci->rta_expires)) {
static int hz;
if (!hz)
hz = get_hz();
hz = get_user_hz();
if (r->rtm_flags & RTM_F_CLONED)
fprintf(fp, "%s cache ", _SL_);
if (ci->rta_expires)
......@@ -487,7 +487,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (i-2 < sizeof(mx_names)/sizeof(char*))
fprintf(fp, " %s", mx_names[i-2]);
else
fprintf(fp, " metric%d", i);
fprintf(fp, " metric %d", i);
if (mxlock & (1<<i))
fprintf(fp, " lock");
......
......@@ -384,6 +384,13 @@ int __get_hz(void)
return HZ;
}
int __iproute2_user_hz_internal;
int __get_user_hz(void)
{
return sysconf(_SC_CLK_TCK);
}
const char *rt_addr_n2a(int af, int len, const void *addr, char *buf, int buflen)
{
switch (af) {
......
......@@ -421,7 +421,7 @@ int action_a2n(char *arg, int *result)
void print_tm(FILE * f, const struct tcf_t *tm)
{
int hz = get_hz();
int hz = get_user_hz();
if (tm->install != 0)
fprintf(f, " installed %u sec", (unsigned)(tm->install/hz));
if (tm->lastuse != 0)
......
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