Initialize and fill IPv6 route age
Subsystems (3)
PATCH 3/3 Initialize and fill IPv6 route age
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.
--- include/net/ip6_fib.h | 1 + net/ipv6/addrconf.c | 5 +++++ net/ipv6/route.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 0 deletions(-)
include/net/ip6_fib.h +1 -0
@@ -98,6 +98,7 @@ struct rt6_infou32 rt6i_flags;u32 rt6i_metric; +time_t rt6i_age;atomic_t rt6i_ref;struct fib6_table *rt6i_table;
net/ipv6/addrconf.c +5 -0
@@ -4182,6 +4182,7 @@ EXPORT_SYMBOL(unregister_inet6addr_notifint __init addrconf_init (void ) { +struct timeval tv;int err =0 ;/* The addrconf netdev notifier requires that loopback_dev
@@ -4209,10 +4210,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 = tv.tv_sec;#ifdef CONFIG_IPV6_MULTIPLE_TABLES ip6_prohibit_entry.rt6i_idev =in6_dev_get (&loopback_dev); + ip6_prohibit_entry.rt6i_age = tv.tv_sec; ip6_blk_hole_entry.rt6i_idev =in6_dev_get (&loopback_dev); + ip6_blk_hole_entry.rt6i_age = tv.tv_sec;#endif register_netdevice_notifier (&ipv6_dev_notf);
net/ipv6/route.c +14 -0
@@ -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 = tv.tv_sec; table = rt->rt6i_table;write_lock_bh (&table->tb6_lock); err =fib6_add (&table->tb6_root, rt, info);
@@ -2112,6 +2119,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 )); }
@@ -2123,6 +2131,7 @@ static int rt6_fill_node(struct sk_buff {struct rtmsg *rtm;struct nlmsghdr *nlh; +struct timeval tv;long expires;u32 table;
@@ -2186,6 +2195,11 @@ static int rt6_fill_node(struct sk_buffif (ipv6_get_saddr (&rt->u.dst, dst, &saddr_buf) ==0 )NLA_PUT (skb,RTA_PREFSRC ,16 , &saddr_buf); } + +do_gettimeofday (&tv); +if (rt->rt6i_age) { +NLA_PUT_U32 (skb,RTA_AGE , (tv.tv_sec - rt->rt6i_age)); + }if (rtnetlink_put_metrics (skb, rt->u.dst.metrics) <0 ) goto nla_put_failure;
Signature · 1 line
1.4.3.4
Varun Chandramohan <[email protected]> wrote on 09/20/2007 08:59:03 PM:
Quoted 9 lines
net/ipv6/route.c +1
-0@@ -2123,6 +2131,7 @@ static int rt6_fill_node(struct sk_buff {struct rtmsg *rtm;struct nlmsghdr *nlh; +struct timeval tv;long expires;u32 table;
net/ipv6/route.c static int rt6_fill_node(struct sk_buff · line 2202
Quoted 8 lines
net/ipv6/route.c +5
-0@@ -2186,6 +2195,11 @@ static int rt6_fill_node(struct sk_buffif (ipv6_get_saddr (&rt->u.dst, dst, &saddr_buf) ==0 )NLA_PUT (skb,RTA_PREFSRC ,16 , &saddr_buf); } + +do_gettimeofday (&tv); +if (rt->rt6i_age) { +NLA_PUT_U32 (skb,RTA_AGE , (tv.tv_sec - rt->rt6i_age)); + }
Will rt6i_age ever be zero with this new patch? If it can be zero, the code should really be keeping the "tv" declaration and do_gettimeofday() inside the "if (rt->rt6i_age)" check.
And from your Patch2/3:
int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
- u32 tb_id, u8 type, u8 scope, __be32 dst, intdst_len, u8 tos,
+ u32 tb_id, u8 type, u8 scope, __be32 dst, intdst_len, u8 tos, time_t age,
struct fib_info *fi, unsigned int flags)
{
struct nlmsghdr *nlh;
struct rtmsg *rtm;+ struct timeval tv;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*rtm), flags);
if (nlh == NULL)
@@ -985,6 +987,11 @@ int fib_dump_info(struct sk_buff *skb, u
NLA_PUT_U32(skb, RTA_FLOW,
fi->fib_nh[0].nh_tclassid);
#endif
}+
+ do_gettimeofday(&tv);
+ if (age) {
+ NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - age));
+ }
Don't you want to return time the first time (and get zero)? Otherwise RTA_AGE is not returned to user. Something like:
do_gettimeofday(&tv);
NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - age));Once again, can age ever be zero?
- KK
Quoted 12 lines · Krishna Kumar2 wrote:
Varun Chandramohan <[email protected]> wrote on 09/20/2007 08:59:03 PM:
Quoted 8 lines
net/ipv6/route.c +1
-0@@ -2123,6 +2131,7 @@ static int rt6_fill_node(struct sk_buff {struct rtmsg *rtm;struct nlmsghdr *nlh; +struct timeval tv;long expires;u32 table;
Quoted 16 lines
net/ipv6/route.c static int rt6_fill_node(struct sk_buff · line 2203
Quoted 10 lines
net/ipv6/route.c +5
-0@@ -2186,6 +2195,11 @@ static int rt6_fill_node(struct sk_buffif (ipv6_get_saddr (&rt->u.dst, dst, &saddr_buf) ==0 )NLA_PUT (skb,RTA_PREFSRC ,16 , &saddr_buf); } + +do_gettimeofday (&tv); +if (rt->rt6i_age) { +NLA_PUT_U32 (skb,RTA_AGE , (tv.tv_sec - rt->rt6i_age)); + }Will
rt6i_ageever be zero with this new patch? If it can be zero, the code should really be keeping the "tv" declaration anddo_gettimeofday()inside the "if (rt->rt6i_age)" check.
No, it will be zero only if some new code added doesnt initialize the route age. I will update this change in my next patch release.
Quoted 26 lines
And from your Patch2/3:
int fib_dump_info(struct
sk_buff*skb, u32 pid, u32 seq, int event,
- u32tb_id, u8 type, u8 scope,__be32dst, intdst_len, u8 tos,
+ u32tb_id, u8 type, u8 scope,__be32dst, intdst_len, u8 tos,time_tage,
structfib_info*fi, unsigned int flags){ struct nlmsghdr *nlh; struct rtmsg *rtm;net/ipv6/addrconf.c +6
-0+struct timeval tv; nlh =nlmsg_put (skb, pid, seq, event,sizeof (*rtm), flags);if (nlh ==NULL )@@ -985,6 +987,11 @@ int fib_dump_info(struct sk_buff *skb, uNLA_PUT_U32 (skb,RTA_FLOW , fi->fib_nh[0 ].nh_tclassid);#endif } + +do_gettimeofday (&tv); +if (age) { +NLA_PUT_U32 (skb,RTA_AGE , (tv.tv_sec - age)); + }
Quoted 4 lines
Don't you want to return time the first time (and get zero)? Otherwise
RTA_AGEis not returned to user. Something like:
The first time it will be zero.
Quoted 6 lines
do_gettimeofday(&tv); NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - age));Once again, can age ever be zero?
same as above.
Quoted 3 lines
- KK