guint32
nm_utils_lifetime_rebase_relative_time_on_now (guint32 timestamp,
guint32 duration,
- guint32 now,
- guint32 padding)
+ guint32 now)
{
gint64 t;
/* For timestamp > now, just accept it and calculate the expected(?) result. */
t = (gint64) timestamp + (gint64) duration - (gint64) now;
- /* Optional padding to avoid potential races. */
- t += (gint64) padding;
-
if (t <= 0)
return 0;
if (t >= NM_PLATFORM_LIFETIME_PERMANENT)
guint32 lifetime,
guint32 preferred,
guint32 now,
- guint32 padding,
guint32 *out_lifetime,
guint32 *out_preferred)
{
} else {
if (!now)
now = nm_utils_get_monotonic_timestamp_s ();
- t_lifetime = nm_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now, padding);
+ t_lifetime = nm_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now);
if (!t_lifetime) {
*out_lifetime = 0;
*out_preferred = 0;
return FALSE;
}
- t_preferred = nm_utils_lifetime_rebase_relative_time_on_now (timestamp, preferred, now, padding);
+ t_preferred = nm_utils_lifetime_rebase_relative_time_on_now (timestamp, preferred, now);
*out_lifetime = t_lifetime;
*out_preferred = MIN (t_preferred, t_lifetime);
/*****************************************************************************/
-#define ADDRESS_LIFETIME_PADDING 5
-
G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWADDR_LEN_MAX);
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_OFFSET (NMPlatformIP4Address, address));
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_OFFSET (NMPlatformIP6Address, address));
}
static gboolean
-array_contains_ip4_address (const GArray *addresses, const NMPlatformIP4Address *address, gint64 now, guint32 padding)
+array_contains_ip4_address (const GArray *addresses, const NMPlatformIP4Address *address, gint64 now)
{
guint len = addresses ? addresses->len : 0;
guint i;
guint32 lifetime, preferred;
if (nm_utils_lifetime_get (candidate->timestamp, candidate->lifetime, candidate->preferred,
- now, padding, &lifetime, &preferred))
+ now, &lifetime, &preferred))
return TRUE;
}
}
}
static gboolean
-array_contains_ip6_address (const GArray *addresses, const NMPlatformIP6Address *address, gint64 now, guint32 padding)
+array_contains_ip6_address (const GArray *addresses, const NMPlatformIP6Address *address, gint64 now)
{
guint len = addresses ? addresses->len : 0;
guint i;
guint32 lifetime, preferred;
if (nm_utils_lifetime_get (candidate->timestamp, candidate->lifetime, candidate->preferred,
- now, padding, &lifetime, &preferred))
+ now, &lifetime, &preferred))
return TRUE;
}
}
for (i = 0; i < addresses->len; i++) {
address = &g_array_index (addresses, NMPlatformIP4Address, i);
- if (!array_contains_ip4_address (known_addresses, address, now, ADDRESS_LIFETIME_PADDING))
+ if (!array_contains_ip4_address (known_addresses, address, now))
nm_platform_ip4_address_delete (self, ifindex, address->address, address->plen, address->peer_address);
}
g_array_free (addresses, TRUE);
guint32 lifetime, preferred;
if (!nm_utils_lifetime_get (known_address->timestamp, known_address->lifetime, known_address->preferred,
- now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
+ now, &lifetime, &preferred))
continue;
if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->plen,
if (keep_link_local && IN6_IS_ADDR_LINKLOCAL (&address->address))
continue;
- if (!array_contains_ip6_address (known_addresses, address, now, ADDRESS_LIFETIME_PADDING))
+ if (!array_contains_ip6_address (known_addresses, address, now))
nm_platform_ip6_address_delete (self, ifindex, address->address, address->plen);
}
g_array_free (addresses, TRUE);
guint32 lifetime, preferred;
if (!nm_utils_lifetime_get (known_address->timestamp, known_address->lifetime, known_address->preferred,
- now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
+ now, &lifetime, &preferred))
continue;
if (!nm_platform_ip6_address_add (self, ifindex, known_address->address,
return "forever";
g_snprintf (buf, buf_size, "%usec",
- nm_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now, 0));
+ nm_utils_lifetime_rebase_relative_time_on_now (timestamp, lifetime, now));
return buf;
}