mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 05:58:01 +02:00
platform: fix setting valid lifetimes when constructing rtnl_addr object
build_rtnl_addr() has two parameters "lifetime" and "preferred". Both count from *now*. Fix nmp_object_to_nl() to properly set these timestamps. This bug had not real consequences, because the only place where we use nmp_object_to_nl() the arguments are 0.
This commit is contained in:
parent
626a85530e
commit
d0ed4de104
2 changed files with 21 additions and 12 deletions
|
|
@ -4022,13 +4022,9 @@ build_rtnl_addr (NMPlatform *platform,
|
||||||
}
|
}
|
||||||
|
|
||||||
_nl_rtnl_addr_set_prefixlen (rtnladdr, plen);
|
_nl_rtnl_addr_set_prefixlen (rtnladdr, plen);
|
||||||
if (lifetime) {
|
if ( lifetime != 0 || lifetime != NM_PLATFORM_LIFETIME_PERMANENT
|
||||||
/* note that here we set the relative timestamps (ticking from *now*).
|
|| preferred != 0 || preferred != NM_PLATFORM_LIFETIME_PERMANENT) {
|
||||||
* Contrary to the rtnl_addr objects from our cache, which have absolute
|
/* note that here we set the relative timestamps (ticking from *now*). */
|
||||||
* timestamps (see _rtnl_addr_hack_lifetimes_rel_to_abs()).
|
|
||||||
*
|
|
||||||
* This is correct, because we only use build_rtnl_addr() for
|
|
||||||
* add_object(), delete_object() and cache search (ip_address_exists). */
|
|
||||||
rtnl_addr_set_valid_lifetime (rtnladdr, lifetime);
|
rtnl_addr_set_valid_lifetime (rtnladdr, lifetime);
|
||||||
rtnl_addr_set_preferred_lifetime (rtnladdr, preferred);
|
rtnl_addr_set_preferred_lifetime (rtnladdr, preferred);
|
||||||
}
|
}
|
||||||
|
|
@ -4057,6 +4053,10 @@ struct nl_object *
|
||||||
_nmp_vt_cmd_plobj_to_nl_ip4_address (NMPlatform *platform, const NMPlatformObject *_obj, gboolean id_only)
|
_nmp_vt_cmd_plobj_to_nl_ip4_address (NMPlatform *platform, const NMPlatformObject *_obj, gboolean id_only)
|
||||||
{
|
{
|
||||||
const NMPlatformIP4Address *obj = (const NMPlatformIP4Address *) _obj;
|
const NMPlatformIP4Address *obj = (const NMPlatformIP4Address *) _obj;
|
||||||
|
guint32 lifetime, preferred;
|
||||||
|
|
||||||
|
nmp_utils_lifetime_get (obj->timestamp, obj->lifetime, obj->preferred,
|
||||||
|
0, 0, &lifetime, &preferred);
|
||||||
|
|
||||||
return build_rtnl_addr (platform,
|
return build_rtnl_addr (platform,
|
||||||
AF_INET,
|
AF_INET,
|
||||||
|
|
@ -4064,8 +4064,8 @@ _nmp_vt_cmd_plobj_to_nl_ip4_address (NMPlatform *platform, const NMPlatformObjec
|
||||||
&obj->address,
|
&obj->address,
|
||||||
obj->peer_address ? &obj->peer_address : NULL,
|
obj->peer_address ? &obj->peer_address : NULL,
|
||||||
obj->plen,
|
obj->plen,
|
||||||
obj->lifetime,
|
lifetime,
|
||||||
obj->preferred,
|
preferred,
|
||||||
0,
|
0,
|
||||||
obj->label[0] ? obj->label : NULL);
|
obj->label[0] ? obj->label : NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -4074,6 +4074,10 @@ struct nl_object *
|
||||||
_nmp_vt_cmd_plobj_to_nl_ip6_address (NMPlatform *platform, const NMPlatformObject *_obj, gboolean id_only)
|
_nmp_vt_cmd_plobj_to_nl_ip6_address (NMPlatform *platform, const NMPlatformObject *_obj, gboolean id_only)
|
||||||
{
|
{
|
||||||
const NMPlatformIP6Address *obj = (const NMPlatformIP6Address *) _obj;
|
const NMPlatformIP6Address *obj = (const NMPlatformIP6Address *) _obj;
|
||||||
|
guint32 lifetime, preferred;
|
||||||
|
|
||||||
|
nmp_utils_lifetime_get (obj->timestamp, obj->lifetime, obj->preferred,
|
||||||
|
0, 0, &lifetime, &preferred);
|
||||||
|
|
||||||
return build_rtnl_addr (platform,
|
return build_rtnl_addr (platform,
|
||||||
AF_INET6,
|
AF_INET6,
|
||||||
|
|
@ -4081,8 +4085,8 @@ _nmp_vt_cmd_plobj_to_nl_ip6_address (NMPlatform *platform, const NMPlatformObjec
|
||||||
&obj->address,
|
&obj->address,
|
||||||
!IN6_IS_ADDR_UNSPECIFIED (&obj->peer_address) ? &obj->peer_address : NULL,
|
!IN6_IS_ADDR_UNSPECIFIED (&obj->peer_address) ? &obj->peer_address : NULL,
|
||||||
obj->plen,
|
obj->plen,
|
||||||
obj->lifetime,
|
lifetime,
|
||||||
obj->preferred,
|
preferred,
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,9 +410,14 @@ nmp_utils_lifetime_get (guint32 timestamp,
|
||||||
* In that case we also expect that the other fields (timestamp and preferred) are left unset. */
|
* In that case we also expect that the other fields (timestamp and preferred) are left unset. */
|
||||||
g_return_val_if_fail (timestamp == 0 && preferred == 0, TRUE);
|
g_return_val_if_fail (timestamp == 0 && preferred == 0, TRUE);
|
||||||
} else {
|
} else {
|
||||||
|
if (!now)
|
||||||
|
now = nm_utils_get_monotonic_timestamp_s ();
|
||||||
t_lifetime = nmp_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now, padding);
|
t_lifetime = nmp_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now, padding);
|
||||||
if (!t_lifetime)
|
if (!t_lifetime) {
|
||||||
|
*out_lifetime = 0;
|
||||||
|
*out_preferred = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
t_preferred = nmp_utils_lifetime_rebase_relative_time_on_now (timestamp, preferred, now, padding);
|
t_preferred = nmp_utils_lifetime_rebase_relative_time_on_now (timestamp, preferred, now, padding);
|
||||||
|
|
||||||
*out_lifetime = t_lifetime;
|
*out_lifetime = t_lifetime;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue