On Tue, 24 Jul 2007 09:50:57 +0530
Varun Chandramohan <[EMAIL PROTECTED]> wrote:
> Stephen Hemminger wrote:
> > On Mon, 23 Jul 2007 10:13:18 +0530
> > Varun Chandramohan <[EMAIL PROTECTED]> wrote:
> >
> >
> >> The age field of the ipv6 route structures are initilized with the current
> >> timeval at the time of route creation. When the route dump is called
> >> the route age value stored in the structure is subtracted from the
> >> present timeval and the difference is passed on as the route age.
> >>
> >> Signed-off-by: Varun Chandramohan <[EMAIL PROTECTED]>
> >> ---
> >> include/net/ip6_fib.h | 1 +
> >> include/net/ip6_route.h | 3 +++
> >> net/ipv6/addrconf.c | 5 +++++
> >> net/ipv6/route.c | 23 +++++++++++++++++++----
> >> 4 files changed, 28 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> >> index c48ea87..e30a1cf 100644
> >> --- a/include/net/ip6_fib.h
> >> +++ b/include/net/ip6_fib.h
> >> @@ -98,6 +98,7 @@ struct rt6_info
> >>
> >> u32 rt6i_flags;
> >> u32 rt6i_metric;
> >> + time_t rt6i_age;
> >> atomic_t rt6i_ref;
> >> struct fib6_table *rt6i_table;
> >>
> >> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
> >> index 5456fdd..fc9716c 100644
> >> --- a/include/net/ip6_route.h
> >> +++ b/include/net/ip6_route.h
> >> @@ -36,6 +36,9 @@ struct route_info {
> >> #define RT6_LOOKUP_F_REACHABLE 0x2
> >> #define RT6_LOOKUP_F_HAS_SADDR 0x4
> >>
> >> +#define RT6_SET_ROUTE_INFO 0x0
> >> +#define RT6_GET_ROUTE_INFO 0x1
> >> +
> >> extern struct rt6_info ip6_null_entry;
> >>
> >> #ifdef CONFIG_IPV6_MULTIPLE_TABLES
> >> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> >> index 5a5f8bd..715c766 100644
> >> --- a/net/ipv6/addrconf.c
> >> +++ b/net/ipv6/addrconf.c
> >> @@ -4187,6 +4187,7 @@ EXPORT_SYMBOL(unregister_inet6addr_notif
> >>
> >> int __init addrconf_init(void)
> >> {
> >> + struct timeval tv;
> >> int err = 0;
> >>
> >> /* The addrconf netdev notifier requires that loopback_dev
> >> @@ -4214,10 +4215,14 @@ int __init addrconf_init(void)
> >> if (err)
> >> return err;
> >>
> >> + do_gettimeofday(&tv);
> >>
> >
> > Better to use ktime_t or timespec in new code.
> >
> You are saying not to use timeval as its going to be removed sometime in
> future? If not, may i know why should we use timespec or ktime?
> I need only seconds granularity so i was wondering if that matters.
>
Timeval isn't going away, but ktime is easier for basic maths.
If all you need is seconds resolution, just use jiffies. Gettimeofday
(and ktime_get) both require expensive hardware accesses on
some platforms.
For the specific case IPV6 route ageing, this isn't a big deal it is just
that people tend to copy code.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html