aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-11-27 12:27:07 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:30:44 -0500
commite3703b3de1f049b38733ba520e5038f23063068e (patch)
tree3566516bc8b87c8c8d78b0c3287761c8e2f49a2b /net/ipv4/route.c
parent4e9b82693542003b028c8494e9e3c49615b91ce7 (diff)
[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/ipv4/route.c')
-rw-r--r--net/ipv4/route.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ee00b6506ab4..9f3924c4905e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2629,7 +2629,8 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2629 struct rtable *rt = (struct rtable*)skb->dst; 2629 struct rtable *rt = (struct rtable*)skb->dst;
2630 struct rtmsg *r; 2630 struct rtmsg *r;
2631 struct nlmsghdr *nlh; 2631 struct nlmsghdr *nlh;
2632 struct rta_cacheinfo ci; 2632 long expires;
2633 u32 id = 0, ts = 0, tsage = 0, error;
2633 2634
2634 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags); 2635 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags);
2635 if (nlh == NULL) 2636 if (nlh == NULL)
@@ -2676,20 +2677,13 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2676 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0) 2677 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
2677 goto nla_put_failure; 2678 goto nla_put_failure;
2678 2679
2679 ci.rta_lastuse = jiffies_to_clock_t(jiffies - rt->u.dst.lastuse); 2680 error = rt->u.dst.error;
2680 ci.rta_used = rt->u.dst.__use; 2681 expires = rt->u.dst.expires ? rt->u.dst.expires - jiffies : 0;
2681 ci.rta_clntref = atomic_read(&rt->u.dst.__refcnt);
2682 if (rt->u.dst.expires)
2683 ci.rta_expires = jiffies_to_clock_t(rt->u.dst.expires - jiffies);
2684 else
2685 ci.rta_expires = 0;
2686 ci.rta_error = rt->u.dst.error;
2687 ci.rta_id = ci.rta_ts = ci.rta_tsage = 0;
2688 if (rt->peer) { 2682 if (rt->peer) {
2689 ci.rta_id = rt->peer->ip_id_count; 2683 id = rt->peer->ip_id_count;
2690 if (rt->peer->tcp_ts_stamp) { 2684 if (rt->peer->tcp_ts_stamp) {
2691 ci.rta_ts = rt->peer->tcp_ts; 2685 ts = rt->peer->tcp_ts;
2692 ci.rta_tsage = xtime.tv_sec - rt->peer->tcp_ts_stamp; 2686 tsage = xtime.tv_sec - rt->peer->tcp_ts_stamp;
2693 } 2687 }
2694 } 2688 }
2695 2689
@@ -2708,7 +2702,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2708 } else { 2702 } else {
2709 if (err == -EMSGSIZE) 2703 if (err == -EMSGSIZE)
2710 goto nla_put_failure; 2704 goto nla_put_failure;
2711 ci.rta_error = err; 2705 error = err;
2712 } 2706 }
2713 } 2707 }
2714 } else 2708 } else
@@ -2716,7 +2710,9 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2716 NLA_PUT_U32(skb, RTA_IIF, rt->fl.iif); 2710 NLA_PUT_U32(skb, RTA_IIF, rt->fl.iif);
2717 } 2711 }
2718 2712
2719 NLA_PUT(skb, RTA_CACHEINFO, sizeof(ci), &ci); 2713 if (rtnl_put_cacheinfo(skb, &rt->u.dst, id, ts, tsage,
2714 expires, error) < 0)
2715 goto nla_put_failure;
2720 2716
2721 return nlmsg_end(skb, nlh); 2717 return nlmsg_end(skb, nlh);
2722 2718