aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-11-27 09:27:07 -0800
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-02 21:30:44 -0800
commite3703b3de1f049b38733ba520e5038f23063068e (patch)
tree3566516bc8b87c8c8d78b0c3287761c8e2f49a2b /net/core/rtnetlink.c
parent4e9b82693542003b028c8494e9e3c49615b91ce7 (diff)
downloadkernel_samsung_aries-e3703b3de1f049b38733ba520e5038f23063068e.zip
kernel_samsung_aries-e3703b3de1f049b38733ba520e5038f23063068e.tar.gz
kernel_samsung_aries-e3703b3de1f049b38733ba520e5038f23063068e.tar.bz2
[RTNETLINK]: Add rtnl_put_cacheinfo() to unify some code
IPv4, IPv6, and DECNet all use struct rta_cacheinfo in a similiar way, therefore rtnl_put_cacheinfo() is added to reuse code. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 0cb4d9e..e76539a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -212,6 +212,26 @@ nla_put_failure:
return nla_nest_cancel(skb, mx);
}
+int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
+ u32 ts, u32 tsage, long expires, u32 error)
+{
+ struct rta_cacheinfo ci = {
+ .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse),
+ .rta_used = dst->__use,
+ .rta_clntref = atomic_read(&(dst->__refcnt)),
+ .rta_error = error,
+ .rta_id = id,
+ .rta_ts = ts,
+ .rta_tsage = tsage,
+ };
+
+ if (expires)
+ ci.rta_expires = jiffies_to_clock_t(expires);
+
+ return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci);
+}
+
+EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo);
static void set_operstate(struct net_device *dev, unsigned char transition)
{