diff options
-rw-r--r-- | net/ipv4/ipmr.c | 7 | ||||
-rw-r--r-- | net/ipv6/ip6mr.c | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 26253328d227..a87bcd2d4a94 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -2076,6 +2076,7 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, | |||
2076 | struct rta_mfc_stats mfcs; | 2076 | struct rta_mfc_stats mfcs; |
2077 | struct nlattr *mp_attr; | 2077 | struct nlattr *mp_attr; |
2078 | struct rtnexthop *nhp; | 2078 | struct rtnexthop *nhp; |
2079 | unsigned long lastuse; | ||
2079 | int ct; | 2080 | int ct; |
2080 | 2081 | ||
2081 | /* If cache is unresolved, don't try to parse IIF and OIF */ | 2082 | /* If cache is unresolved, don't try to parse IIF and OIF */ |
@@ -2105,12 +2106,14 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, | |||
2105 | 2106 | ||
2106 | nla_nest_end(skb, mp_attr); | 2107 | nla_nest_end(skb, mp_attr); |
2107 | 2108 | ||
2109 | lastuse = READ_ONCE(c->mfc_un.res.lastuse); | ||
2110 | lastuse = time_after_eq(jiffies, lastuse) ? jiffies - lastuse : 0; | ||
2111 | |||
2108 | mfcs.mfcs_packets = c->mfc_un.res.pkt; | 2112 | mfcs.mfcs_packets = c->mfc_un.res.pkt; |
2109 | mfcs.mfcs_bytes = c->mfc_un.res.bytes; | 2113 | mfcs.mfcs_bytes = c->mfc_un.res.bytes; |
2110 | mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if; | 2114 | mfcs.mfcs_wrong_if = c->mfc_un.res.wrong_if; |
2111 | if (nla_put_64bit(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs, RTA_PAD) || | 2115 | if (nla_put_64bit(skb, RTA_MFC_STATS, sizeof(mfcs), &mfcs, RTA_PAD) || |
2112 | nla_put_u64_64bit(skb, RTA_EXPIRES, | 2116 | nla_put_u64_64bit(skb, RTA_EXPIRES, jiffies_to_clock_t(lastuse), |
2113 | jiffies_to_clock_t(c->mfc_un.res.lastuse), | ||
2114 | RTA_PAD)) | 2117 | RTA_PAD)) |
2115 | return -EMSGSIZE; | 2118 | return -EMSGSIZE; |
2116 | 2119 | ||
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 | ||