* [PATCH 4/4] Initialize and fill IPv6 route age
@ 2007-07-23 4:43 Varun Chandramohan
2007-07-23 7:56 ` Krishna Kumar2
2007-07-23 11:34 ` Stephen Hemminger
0 siblings, 2 replies; 6+ messages in thread
From: Varun Chandramohan @ 2007-07-23 4:43 UTC (permalink / raw)
To: netdev; +Cc: sri, dlstevens, varuncha
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 <varunc@linux.vnet.ibm.com>
---
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);
ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev);
+ ip6_null_entry.rt6i_age = timeval_to_sec(&tv);
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
ip6_prohibit_entry.rt6i_idev = in6_dev_get(&loopback_dev);
+ ip6_prohibit_entry.rt6i_age = timeval_to_sec(&tv);
ip6_blk_hole_entry.rt6i_idev = in6_dev_get(&loopback_dev);
+ ip6_blk_hole_entry.rt6i_age = timeval_to_sec(&tv);
#endif
register_netdevice_notifier(&ipv6_dev_notf);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index fe8d983..9386c05 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -600,7 +600,14 @@ static int __ip6_ins_rt(struct rt6_info
{
int err;
struct fib6_table *table;
+ struct timeval tv;
+ do_gettimeofday(&tv);
+ /* Update the timeval for new routes
+ * We add it here to make it common irrespective
+ * of how the new route is added.
+ */
+ rt->rt6i_age = timeval_to_sec(&tv);
table = rt->rt6i_table;
write_lock_bh(&table->tb6_lock);
err = fib6_add(&table->tb6_root, rt, info);
@@ -2111,6 +2118,7 @@ static inline size_t rt6_nlmsg_size(void
+ nla_total_size(4) /* RTA_IIF */
+ nla_total_size(4) /* RTA_OIF */
+ nla_total_size(4) /* RTA_PRIORITY */
+ + nla_total_size(4) /*RTA_AGE*/
+ RTAX_MAX * nla_total_size(4) /* RTA_METRICS */
+ nla_total_size(sizeof(struct rta_cacheinfo));
}
@@ -2118,10 +2126,11 @@ static inline size_t rt6_nlmsg_size(void
static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
struct in6_addr *dst, struct in6_addr *src,
int iif, int type, u32 pid, u32 seq,
- int prefix, unsigned int flags)
+ int prefix, unsigned int flags, int dumpflg)
{
struct rtmsg *rtm;
struct nlmsghdr *nlh;
+ struct timeval tv;
long expires;
u32 table;
@@ -2185,6 +2194,12 @@ static int rt6_fill_node(struct sk_buff
if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
}
+
+ do_gettimeofday(&tv);
+ if (dumpflg)
+ NLA_PUT_U32(skb, RTA_AGE, timeval_to_sec(&tv) - rt->rt6i_age);
+ else
+ NLA_PUT_U32(skb, RTA_AGE, rt->rt6i_age);
if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
goto nla_put_failure;
@@ -2222,7 +2237,7 @@ int rt6_dump_route(struct rt6_info *rt,
return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
- prefix, NLM_F_MULTI);
+ prefix, NLM_F_MULTI, RT6_GET_ROUTE_INFO);
}
static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
@@ -2287,7 +2302,7 @@ static int inet6_rtm_getroute(struct sk_
err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,
RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
- nlh->nlmsg_seq, 0, 0);
+ nlh->nlmsg_seq, 0, 0, RT6_GET_ROUTE_INFO);
if (err < 0) {
kfree_skb(skb);
goto errout;
@@ -2316,7 +2331,7 @@ void inet6_rt_notify(int event, struct r
if (skb == NULL)
goto errout;
- err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0);
+ err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0, RT6_SET_ROUTE_INFO);
if (err < 0) {
/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
--
1.4.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Initialize and fill IPv6 route age
2007-07-23 4:43 [PATCH 4/4] Initialize and fill IPv6 route age Varun Chandramohan
@ 2007-07-23 7:56 ` Krishna Kumar2
2007-07-23 11:34 ` Stephen Hemminger
1 sibling, 0 replies; 6+ messages in thread
From: Krishna Kumar2 @ 2007-07-23 7:56 UTC (permalink / raw)
To: Varun Chandramohan; +Cc: dlstevens, netdev, sri, Varun Chandramohan
> + if (dumpflg)
> + NLA_PUT_U32(skb, RTA_AGE, timeval_to_sec(&tv) - rt->rt6i_age);
> + else
> + NLA_PUT_U32(skb, RTA_AGE, rt->rt6i_age);
Makes more sense (and easy to understand) if you use :
if (dumpflg == RT6_GET_ROUTE_INFO)
...
so that your code does not break if someone changed the #define values.
- KK
netdev-owner@vger.kernel.org wrote on 07/23/2007 10:13:18 AM:
> 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 <varunc@linux.vnet.ibm.com>
> ---
> 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);
> ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev);
> + ip6_null_entry.rt6i_age = timeval_to_sec(&tv);
> #ifdef CONFIG_IPV6_MULTIPLE_TABLES
> ip6_prohibit_entry.rt6i_idev = in6_dev_get(&loopback_dev);
> + ip6_prohibit_entry.rt6i_age = timeval_to_sec(&tv);
> ip6_blk_hole_entry.rt6i_idev = in6_dev_get(&loopback_dev);
> + ip6_blk_hole_entry.rt6i_age = timeval_to_sec(&tv);
> #endif
>
> register_netdevice_notifier(&ipv6_dev_notf);
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index fe8d983..9386c05 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -600,7 +600,14 @@ static int __ip6_ins_rt(struct rt6_info
> {
> int err;
> struct fib6_table *table;
> + struct timeval tv;
>
> + do_gettimeofday(&tv);
> + /* Update the timeval for new routes
> + * We add it here to make it common irrespective
> + * of how the new route is added.
> + */
> + rt->rt6i_age = timeval_to_sec(&tv);
> table = rt->rt6i_table;
> write_lock_bh(&table->tb6_lock);
> err = fib6_add(&table->tb6_root, rt, info);
> @@ -2111,6 +2118,7 @@ static inline size_t rt6_nlmsg_size(void
> + nla_total_size(4) /* RTA_IIF */
> + nla_total_size(4) /* RTA_OIF */
> + nla_total_size(4) /* RTA_PRIORITY */
> + + nla_total_size(4) /*RTA_AGE*/
> + RTAX_MAX * nla_total_size(4) /* RTA_METRICS */
> + nla_total_size(sizeof(struct rta_cacheinfo));
> }
> @@ -2118,10 +2126,11 @@ static inline size_t rt6_nlmsg_size(void
> static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
> struct in6_addr *dst, struct in6_addr *src,
> int iif, int type, u32 pid, u32 seq,
> - int prefix, unsigned int flags)
> + int prefix, unsigned int flags, int dumpflg)
> {
> struct rtmsg *rtm;
> struct nlmsghdr *nlh;
> + struct timeval tv;
> long expires;
> u32 table;
>
> @@ -2185,6 +2194,12 @@ static int rt6_fill_node(struct sk_buff
> if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
> NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
> }
> +
> + do_gettimeofday(&tv);
> + if (dumpflg)
> + NLA_PUT_U32(skb, RTA_AGE, timeval_to_sec(&tv) - rt->rt6i_age);
> + else
> + NLA_PUT_U32(skb, RTA_AGE, rt->rt6i_age);
>
> if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
> goto nla_put_failure;
> @@ -2222,7 +2237,7 @@ int rt6_dump_route(struct rt6_info *rt,
>
> return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
> NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
> - prefix, NLM_F_MULTI);
> + prefix, NLM_F_MULTI, RT6_GET_ROUTE_INFO);
> }
>
> static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr*
nlh, void *arg)
> @@ -2287,7 +2302,7 @@ static int inet6_rtm_getroute(struct sk_
>
> err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif,
> RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
> - nlh->nlmsg_seq, 0, 0);
> + nlh->nlmsg_seq, 0, 0, RT6_GET_ROUTE_INFO);
> if (err < 0) {
> kfree_skb(skb);
> goto errout;
> @@ -2316,7 +2331,7 @@ void inet6_rt_notify(int event, struct r
> if (skb == NULL)
> goto errout;
>
> - err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0);
> + err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0,
> RT6_SET_ROUTE_INFO);
> if (err < 0) {
> /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
> WARN_ON(err == -EMSGSIZE);
> --
> 1.4.3.4
>
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Initialize and fill IPv6 route age
2007-07-23 4:43 [PATCH 4/4] Initialize and fill IPv6 route age Varun Chandramohan
2007-07-23 7:56 ` Krishna Kumar2
@ 2007-07-23 11:34 ` Stephen Hemminger
2007-07-24 4:20 ` Varun Chandramohan
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2007-07-23 11:34 UTC (permalink / raw)
To: Varun Chandramohan; +Cc: netdev, sri, dlstevens, varuncha
On Mon, 23 Jul 2007 10:13:18 +0530
Varun Chandramohan <varunc@linux.vnet.ibm.com> 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 <varunc@linux.vnet.ibm.com>
> ---
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Initialize and fill IPv6 route age
2007-07-23 11:34 ` Stephen Hemminger
@ 2007-07-24 4:20 ` Varun Chandramohan
2007-07-24 7:26 ` Stephen Hemminger
0 siblings, 1 reply; 6+ messages in thread
From: Varun Chandramohan @ 2007-07-24 4:20 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, sri, dlstevens, varuncha
Stephen Hemminger wrote:
> On Mon, 23 Jul 2007 10:13:18 +0530
> Varun Chandramohan <varunc@linux.vnet.ibm.com> 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 <varunc@linux.vnet.ibm.com>
>> ---
>> 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.
Regards,
Varun
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Initialize and fill IPv6 route age
2007-07-24 4:20 ` Varun Chandramohan
@ 2007-07-24 7:26 ` Stephen Hemminger
2007-07-24 9:19 ` Varun Chandramohan
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2007-07-24 7:26 UTC (permalink / raw)
To: Varun Chandramohan; +Cc: netdev, sri, dlstevens, varuncha
On Tue, 24 Jul 2007 09:50:57 +0530
Varun Chandramohan <varunc@linux.vnet.ibm.com> wrote:
> Stephen Hemminger wrote:
> > On Mon, 23 Jul 2007 10:13:18 +0530
> > Varun Chandramohan <varunc@linux.vnet.ibm.com> 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 <varunc@linux.vnet.ibm.com>
> >> ---
> >> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Initialize and fill IPv6 route age
2007-07-24 7:26 ` Stephen Hemminger
@ 2007-07-24 9:19 ` Varun Chandramohan
0 siblings, 0 replies; 6+ messages in thread
From: Varun Chandramohan @ 2007-07-24 9:19 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, sri, dlstevens, varuncha
Stephen Hemminger wrote:
> On Tue, 24 Jul 2007 09:50:57 +0530
> Varun Chandramohan <varunc@linux.vnet.ibm.com> wrote:
>
>
>> Stephen Hemminger wrote:
>>
>>> On Mon, 23 Jul 2007 10:13:18 +0530
>>> Varun Chandramohan <varunc@linux.vnet.ibm.com> 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 <varunc@linux.vnet.ibm.com>
>>>> ---
>>>> 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
>
Thanks stephen for the review. As far as using jiffies (which is my
original implementation) i got a comment saying that on 32bit platform
jiffies wrap every 49 days. That's the reason for the do_gettimeofday()
implementation. However i understand that such calls require expensive
h/w accesses. Considering the fact that jiffies wrap around rather
quickly, can you suggest any other way of doing it?
> (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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-07-24 9:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 4:43 [PATCH 4/4] Initialize and fill IPv6 route age Varun Chandramohan
2007-07-23 7:56 ` Krishna Kumar2
2007-07-23 11:34 ` Stephen Hemminger
2007-07-24 4:20 ` Varun Chandramohan
2007-07-24 7:26 ` Stephen Hemminger
2007-07-24 9:19 ` Varun Chandramohan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).