* [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
@ 2015-12-09 16:27 Xin Long
2015-12-12 1:21 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Xin Long @ 2015-12-09 16:27 UTC (permalink / raw)
To: network dev; +Cc: davem, Hannes Frederic Sowa
Add the support for adding expire value to routes, requested by
Tom Gundersen <teg@jklm.no> for systemd-networkd, and NetworkManager
wants it too.
add it by using the field rta_expires of rta_cacheinfo
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
net/ipv6/route.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c83b6a5..7815bc0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2709,6 +2709,7 @@ static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = {
[RTA_PREF] = { .type = NLA_U8 },
[RTA_ENCAP_TYPE] = { .type = NLA_U16 },
[RTA_ENCAP] = { .type = NLA_NESTED },
+ [RTA_CACHEINFO] = { .len = sizeof(struct rta_cacheinfo) },
};
static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -2809,6 +2810,16 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
if (tb[RTA_ENCAP_TYPE])
cfg->fc_encap_type = nla_get_u16(tb[RTA_ENCAP_TYPE]);
+ if (tb[RTA_CACHEINFO]) {
+ struct rta_cacheinfo *ci = nla_data(tb[RTA_CACHEINFO]);
+ unsigned long timeout = addrconf_timeout_fixup(ci->rta_expires, HZ);
+
+ if (addrconf_finite_timeout(timeout)) {
+ cfg->fc_expires = jiffies_to_clock_t(timeout * HZ);
+ cfg->fc_flags |= RTF_EXPIRES;
+ }
+ }
+
err = 0;
errout:
return err;
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
2015-12-09 16:27 [PATCHv2 net-next] ipv6: allow routes to be configured with expire values Xin Long
@ 2015-12-12 1:21 ` David Miller
2015-12-14 11:48 ` Xin Long
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2015-12-12 1:21 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, hannes
From: Xin Long <lucien.xin@gmail.com>
Date: Thu, 10 Dec 2015 00:27:53 +0800
> Add the support for adding expire value to routes, requested by
> Tom Gundersen <teg@jklm.no> for systemd-networkd, and NetworkManager
> wants it too.
>
> add it by using the field rta_expires of rta_cacheinfo
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
This is the wrong way to do this.
Currently we only ever dump rta_cacheinfo values to the user.
If we use it to set things, we have to completely consider every
member of that structure as potentially having meaning either
intended by the user or choosen by us in the future.
Therefore it is a poor choice to start using for specifying the
expires value, and some other mechanism such as a new RTNETLINK
attribute, should be used for this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
2015-12-12 1:21 ` David Miller
@ 2015-12-14 11:48 ` Xin Long
2015-12-14 17:16 ` Hannes Frederic Sowa
0 siblings, 1 reply; 6+ messages in thread
From: Xin Long @ 2015-12-14 11:48 UTC (permalink / raw)
To: David Miller; +Cc: network dev, Hannes Frederic Sowa
>
> This is the wrong way to do this.
>
> Currently we only ever dump rta_cacheinfo values to the user.
>
> If we use it to set things, we have to completely consider every
> member of that structure as potentially having meaning either
> intended by the user or choosen by us in the future.
>
> Therefore it is a poor choice to start using for specifying the
> expires value, and some other mechanism such as a new RTNETLINK
> attribute, should be used for this.
we did it like this to avoid adding the new RTNETLINK attribute.
now I got your meaning, and rta_cacheinfo seems to be designed
for dumping info, not for seting info. i guess you hope we do it like:
+ if (tb[RTA_EXPIRES]) {
+ unsigned long timeout =
addrconf_timeout_fixup(nla_get_u32(tb[RTA_EXPIRES]), HZ);
+
+ if (addrconf_finite_timeout(timeout)) {
+ cfg->fc_expires = jiffies_to_clock_t(timeout * HZ);
+ cfg->fc_flags |= RTF_EXPIRES;
+ }
+ }
hi Hannes, we seem to go back here again, what do you think ?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
2015-12-14 11:48 ` Xin Long
@ 2015-12-14 17:16 ` Hannes Frederic Sowa
2015-12-14 19:36 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-14 17:16 UTC (permalink / raw)
To: Xin Long, David Miller; +Cc: network dev
Hi,
On 14.12.2015 12:48, Xin Long wrote:
>>
>> This is the wrong way to do this.
>>
>> Currently we only ever dump rta_cacheinfo values to the user.
>>
>> If we use it to set things, we have to completely consider every
>> member of that structure as potentially having meaning either
>> intended by the user or choosen by us in the future.
>>
>> Therefore it is a poor choice to start using for specifying the
>> expires value, and some other mechanism such as a new RTNETLINK
>> attribute, should be used for this.
>
> we did it like this to avoid adding the new RTNETLINK attribute.
> now I got your meaning, and rta_cacheinfo seems to be designed
> for dumping info, not for seting info. i guess you hope we do it like:
>
> + if (tb[RTA_EXPIRES]) {
> + unsigned long timeout =
> addrconf_timeout_fixup(nla_get_u32(tb[RTA_EXPIRES]), HZ);
> +
> + if (addrconf_finite_timeout(timeout)) {
> + cfg->fc_expires = jiffies_to_clock_t(timeout * HZ);
> + cfg->fc_flags |= RTF_EXPIRES;
> + }
> + }
>
> hi Hannes, we seem to go back here again, what do you think ?
Albeit I had the same idea and wanted to introduce a new netlink
attribute, I decided to recommend this patch. It aligns with the code we
already have for adding and listing ipv4 and ipv6 addresses
(ifa_cacheinfo) and reporting routing changes for ipv4 and ipv6
(rta_cacheinfo).
We can easily switch to new attributes. Should we introduce a new
interface for this?
Thanks,
Hannes
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
2015-12-14 17:16 ` Hannes Frederic Sowa
@ 2015-12-14 19:36 ` David Miller
2015-12-16 9:45 ` Xin Long
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2015-12-14 19:36 UTC (permalink / raw)
To: hannes; +Cc: lucien.xin, netdev
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Mon, 14 Dec 2015 18:16:59 +0100
> We can easily switch to new attributes. Should we introduce a new
> interface for this?
Yes.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 net-next] ipv6: allow routes to be configured with expire values
2015-12-14 19:36 ` David Miller
@ 2015-12-16 9:45 ` Xin Long
0 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2015-12-16 9:45 UTC (permalink / raw)
To: David Miller; +Cc: Hannes Frederic Sowa, network dev
On Tue, Dec 15, 2015 at 3:36 AM, David Miller <davem@davemloft.net> wrote:
> From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Date: Mon, 14 Dec 2015 18:16:59 +0100
>
>> We can easily switch to new attributes. Should we introduce a new
>> interface for this?
>
> Yes.
okay, I will repost the patch with a new netlink attribute
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-16 9:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 16:27 [PATCHv2 net-next] ipv6: allow routes to be configured with expire values Xin Long
2015-12-12 1:21 ` David Miller
2015-12-14 11:48 ` Xin Long
2015-12-14 17:16 ` Hannes Frederic Sowa
2015-12-14 19:36 ` David Miller
2015-12-16 9:45 ` Xin Long
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).