summaryrefslogtreecommitdiff
path: root/include/net/ip6_fib.h
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2018-04-18 03:33:17 +0300
committerDavid S. Miller <davem@davemloft.net>2018-04-18 06:41:17 +0300
commit14895687d36805f051bb54014c32e48e5937f7e1 (patch)
tree2f72e7bd6f5b1c31e184191bdf2302a0ea3005e5 /include/net/ip6_fib.h
parentd4ead6b34b67fd711639324b6465a050bcb197d4 (diff)
downloadlinux-14895687d36805f051bb54014c32e48e5937f7e1.tar.xz
net/ipv6: move expires into rt6_info
Add expires to rt6_info for FIB entries, and add fib6 helpers to manage it. Data path use of dst.expires remains. The transition is fairly straightforward: when working with fib entries, rt->dst.expires is just rt->expires, rt6_clean_expires is replaced with fib6_clean_expires, rt6_set_expires becomes fib6_set_expires, and rt6_check_expired becomes fib6_check_expired, where the fib6 versions are added by this patch. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip6_fib.h')
-rw-r--r--include/net/ip6_fib.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 1f8dc9d12abb..c73b985734f5 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -179,6 +179,7 @@ struct rt6_info {
should_flush:1,
unused:6;
+ unsigned long expires;
struct dst_metrics *fib6_metrics;
#define fib6_pmtu fib6_metrics->metrics[RTAX_MTU-1]
struct fib6_nh fib6_nh;
@@ -197,6 +198,26 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
return ((struct rt6_info *)dst)->rt6i_idev;
}
+static inline void fib6_clean_expires(struct rt6_info *f6i)
+{
+ f6i->rt6i_flags &= ~RTF_EXPIRES;
+ f6i->expires = 0;
+}
+
+static inline void fib6_set_expires(struct rt6_info *f6i,
+ unsigned long expires)
+{
+ f6i->expires = expires;
+ f6i->rt6i_flags |= RTF_EXPIRES;
+}
+
+static inline bool fib6_check_expired(const struct rt6_info *f6i)
+{
+ if (f6i->rt6i_flags & RTF_EXPIRES)
+ return time_after(jiffies, f6i->expires);
+ return false;
+}
+
static inline void rt6_clean_expires(struct rt6_info *rt)
{
rt->rt6i_flags &= ~RTF_EXPIRES;
@@ -211,11 +232,9 @@ static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
{
- struct rt6_info *rt;
+ if (!(rt0->rt6i_flags & RTF_EXPIRES) && rt0->from)
+ rt0->dst.expires = rt0->from->expires;
- for (rt = rt0; rt && !(rt->rt6i_flags & RTF_EXPIRES); rt = rt->from);
- if (rt && rt != rt0)
- rt0->dst.expires = rt->dst.expires;
dst_set_expires(&rt0->dst, timeout);
rt0->rt6i_flags |= RTF_EXPIRES;
}