aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>2016-09-20 10:17:22 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-21 00:58:23 -0400
commitb5036cd4ed3173ab8cdbc85e2ba74acf46bafb51 (patch)
treed56ab33c889d5c3276af636ae6c6c4c8031fc526 /net/ipv6
parent493d5f6db0ab12a9fcac587ae223f3e4e48dba6f (diff)
ipmr, ip6mr: return lastuse relative to now
When I introduced the lastuse member I made a subtle error because it was returned as an absolute value but that is meaningless to user-space as it doesn't allow to see how old exactly an entry is. Let's make it similar to how the bridge returns such values and make it relative to "now" (jiffies). This allows us to show the actual age of the entries and is much more useful (e.g. user-space daemons can age out entries, iproute2 can display the lastuse properly). Fixes: 43b9e1274060 ("net: ipmr/ip6mr: add support for keeping an entry age") Reported-by: Satish Ashok <sashok@cumulusnetworks.com> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/ip6mr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 6122f9c5cc49..fccb5dd91902 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -2239,6 +2239,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
2239 struct rta_mfc_stats mfcs; 2239 struct rta_mfc_stats mfcs;
2240 struct nlattr *mp_attr; 2240 struct nlattr *mp_attr;
2241 struct rtnexthop *nhp; 2241 struct rtnexthop *nhp;
2242 unsigned long lastuse;
2242 int ct; 2243 int ct;
2243 2244
2244 /* If cache is unresolved, don't try to parse IIF and OIF */ 2245 /* If cache is unresolved, don't try to parse IIF and OIF */
@@ -2269,12 +2270,14 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
2269 2270
2270 nla_nest_end(skb, mp_attr); 2271 nla_nest_end(skb, mp_attr);
2271 2272
2273 lastuse = READ_ONCE(c->mfc_un.res.lastuse);
2274 lastuse = time_after_eq(jiffies, lastuse) ? jiffies - lastuse : 0;
2275
2272 mfcs.mfcs_packets = c->mfc_un.res.pkt; 2276 mfcs.mfcs_packets = c->mfc_un.res.pkt;
2273 mfcs.mfcs_bytes = c->mfc_un.res.bytes; 2277 mfcs.mfcs_bytes = c->mfc_un.res.bytes;
2274 mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if; 2278 mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if;
2275 if (nla_put_64bit(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs, RTA_PAD) || 2279 if (nla_put_64bit(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs, RTA_PAD) ||
2276 nla_put_u64_64bit(skb, RTA_EXPIRES, 2280 nla_put_u64_64bit(skb, RTA_EXPIRES, jiffies_to_clock_t(lastuse),
2277 jiffies_to_clock_t(c->mfc_un.res.lastuse),
2278 RTA_PAD)) 2281 RTA_PAD))
2279 return -EMSGSIZE; 2282 return -EMSGSIZE;
2280 2283