diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-09 09:29:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-19 22:13:48 +0200 |
commit | 6723745fe005ac6656ecf735e1301a6def24ffe6 (patch) | |
tree | 38af91978b76783cb3da1a3c4015491ffafb6edf | |
parent | 5174976cc1ec59c25050abd9c8d9c9f69c447815 (diff) | |
download | NetworkManager-6723745fe005ac6656ecf735e1301a6def24ffe6.tar.gz |
dhcp: nm_dhcp_dhclient_read_lease_ip_configs() must anchor the address lifetime at *now*
nm_dhcp_dhclient_read_lease_ip_configs() calculates the remaining time
until the address expires. It must anchor the lifetimes by setting the
@timestamp to nm_utils_get_monotonic_timestamp_s().
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhclient-utils.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c index 3e7173aec3..8527e6c0fb 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c +++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c @@ -27,6 +27,7 @@ #include "nm-dhcp-dhclient-utils.h" #include "nm-ip4-config.h" #include "nm-utils.h" +#include "NetworkManagerUtils.h" #define CLIENTID_TAG "send dhcp-client-identifier" #define CLIENTID_FORMAT CLIENTID_TAG " \"%s\"; # added by NetworkManager" @@ -530,6 +531,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, GSList *parsed = NULL, *iter, *leases = NULL; char **line, **split = NULL; GHashTable *hash = NULL; + gint32 now_monotonic_ts; g_return_val_if_fail (contents != NULL, NULL); @@ -570,6 +572,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, g_date_time_ref (now); else now = g_date_time_new_now_utc (); + now_monotonic_ts = nm_utils_get_monotonic_timestamp_s (); for (iter = parsed; iter; iter = g_slist_next (iter)) { NMIP4Config *ip4; @@ -593,7 +596,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, continue; /* scale expiry to seconds (and CLAMP into the range of guint32) */ - expiry = CLAMP (expiry / G_TIME_SPAN_SECOND, 0, G_MAXUINT32-1); + expiry = CLAMP (expiry / G_TIME_SPAN_SECOND, 0, NM_PLATFORM_LIFETIME_PERMANENT-1); if (expiry <= 0) { /* the address is already expired. Don't even add it. */ continue; @@ -624,6 +627,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, if (!address.plen) address.plen = nm_utils_ip4_get_default_prefix (address.address); + address.timestamp = now_monotonic_ts; address.lifetime = address.preferred = expiry; address.source = NM_PLATFORM_SOURCE_DHCP; |