From: Andrew Yourtchenko <ayourtch@gmail.com>
To: netdev@vger.kernel.org
Cc: Andrew Yourtchenko <ayourtch@gmail.com>
Subject: [PATCH 1/2] ipv6: save route expiry in RTA_EXPIRES if RTF_EXPIRES set
Date: Tue, 16 Aug 2016 15:59:02 +0200 [thread overview]
Message-ID: <1471355943-21288-2-git-send-email-ayourtch@gmail.com> (raw)
In-Reply-To: <1471355943-21288-1-git-send-email-ayourtch@gmail.com>
This allows "ip -6 route save" to save the expiry for the routes
that have it, such that it can be correctly restored later by
"ip -6 route restore".
If a route has RTF_EXPIRES set, generate RTA_EXPIRES value which
will be used to restore the flag and expiry value by already
existing code in rtm_to_fib6_config.
The expiry was already being saved as part of RTA_CACHEINFO
in rtnl_put_cacheinfo(), but adding code to generate RTF_EXPIRES upon save
looked more appropriate than redundant cherrypicking from
RTA_CACHEINFO upon restore.
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
---
net/ipv6/route.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4981755..dc37017 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3244,6 +3244,14 @@ static int rt6_fill_node(struct net *net,
if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, rt->dst.error) < 0)
goto nla_put_failure;
+ /* Can't rely on expires == 0. It is zero if no expires flag,
+ * or if the timing is precisely at expiry. So, recheck the flag.
+ */
+ if (rt->rt6i_flags & RTF_EXPIRES)
+ if (nla_put_u32(skb, RTA_EXPIRES,
+ expires > 0 ? expires / HZ : 0))
+ goto nla_put_failure;
+
if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags)))
goto nla_put_failure;
--
2.7.4
next prev parent reply other threads:[~2016-08-16 13:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-16 13:59 [PATCH 0/2] ipv6: fix stuck RA-derived route in container after migration with criu Andrew Yourtchenko
2016-08-16 13:59 ` Andrew Yourtchenko [this message]
2016-08-16 13:59 ` [PATCH 2/2] ipv6: fixup RTF_* flags when restoring RTPROT_RA route from rtnetlink Andrew Yourtchenko
2016-08-19 4:09 ` [PATCH 0/2] ipv6: fix stuck RA-derived route in container after migration with criu David Miller
2016-08-19 16:41 ` [PATCH v2 " Andrew Yourtchenko
2016-08-19 16:41 ` [PATCH v2 1/2] ipv6: save route expiry in RTA_EXPIRES if RTF_EXPIRES set Andrew Yourtchenko
2016-08-19 20:26 ` Eric Dumazet
2016-08-22 11:41 ` Andrew Yourtchenko
2016-08-19 16:41 ` [PATCH v2 2/2] ipv6: fixup RTF_* flags when restoring RTPROT_RA route from rtnetlink Andrew Yourtchenko
2016-08-19 18:07 ` Sergei Shtylyov
2016-08-22 11:04 ` Andrew Yourtchenko
2016-08-22 11:06 ` Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471355943-21288-2-git-send-email-ayourtch@gmail.com \
--to=ayourtch@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).