diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-09 10:28:55 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-19 22:26:10 +0200 |
commit | 6f013183e8265c8498d52d223c6ee1ce3cdf07d5 (patch) | |
tree | b1c28cdaaee3e7829547d2a4e32f399b37bbbb0b | |
parent | c6d45a408351097d714b3b5a3992937d60097cca (diff) | |
download | NetworkManager-6f013183e8265c8498d52d223c6ee1ce3cdf07d5.tar.gz |
platform: extend nm_platform_ip_address_cmp_expiry() to handle addresses without timestamp
If the timestamp is set to zero, the to_string() functions treat the lifetime
as based on *now*. For nm_platform_ip_address_cmp_expiry() this makes no
sense, because there is no absolute exiry to compare. Instead compare
them as expire earlier then the other address.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/platform/nm-platform.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index e15de984f7..542b0faab2 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2506,31 +2506,32 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route int nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatformIPAddress *b) { - gint64 ta, tb; + gint64 ta = 0, tb = 0; _CMP_POINTER (a, b); if (a->lifetime == NM_PLATFORM_LIFETIME_PERMANENT || a->lifetime == 0) ta = G_MAXINT64; - else + else if (a->timestamp) ta = ((gint64) a->timestamp) + a->lifetime; if (b->lifetime == NM_PLATFORM_LIFETIME_PERMANENT || b->lifetime == 0) tb = G_MAXINT64; - else + else if (b->timestamp) tb = ((gint64) b->timestamp) + b->lifetime; if (ta == tb) { /* if the lifetime is equal, compare the preferred time. */ + ta = tb = 0; if (a->preferred == NM_PLATFORM_LIFETIME_PERMANENT || a->lifetime == 0 /* liftime==0 means permanent! */) ta = G_MAXINT64; - else + else if (a->timestamp) ta = ((gint64) a->timestamp) + a->preferred; if (b->preferred == NM_PLATFORM_LIFETIME_PERMANENT|| b->lifetime == 0) tb = G_MAXINT64; - else + else if (b->timestamp) tb = ((gint64) b->timestamp) + b->preferred; if (ta == tb) |