From: Varun Chandramohan <varunc@linux.vnet.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, kaber@trash.net, socketcan@hartkopp.net,
shemminger@linux-foundation.org, krkumar2@in.ibm.com,
tgraf@suug.ch, varuncha@in.ibm.com
Subject: [PATCH 3/3 Rev4] Initialize and fill IPv6 route age
Date: Thu, 20 Sep 2007 20:59:03 +0530 [thread overview]
Message-ID: <20070920205903.e40b37af.varunc@linux.vnet.ibm.com> (raw)
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 +
net/ipv6/addrconf.c | 5 +++++
net/ipv6/route.c | 14 ++++++++++++++
3 files changed, 20 insertions(+), 0 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/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 91ef3be..e77c6ad 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4182,6 +4182,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
@@ -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);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 55ea80f..e9a9d00 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 = 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_buff
if (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;
--
1.4.3.4
next reply other threads:[~2007-09-20 15:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-20 15:29 Varun Chandramohan [this message]
2007-09-21 3:05 ` [PATCH 3/3 Rev4] Initialize and fill IPv6 route age Krishna Kumar2
2007-09-21 4:30 ` Varun Chandramohan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070920205903.e40b37af.varunc@linux.vnet.ibm.com \
--to=varunc@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=krkumar2@in.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
--cc=socketcan@hartkopp.net \
--cc=tgraf@suug.ch \
--cc=varuncha@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).