utils: allow valid_lft=0 addresses

We use the lifetime of 0 to indicate permanent addresses while
DHCP uses that lifetime to indicate the addresses should be removed.
Use the presence of a timestamp to differentiate the two.

  dhclient[10867]: XMT: Rebind on wls1, interval 1030ms.
  dhclient[10867]: RCV: Reply message on wls1 from fe80::21e:8cff:feec:3ca2.
  NetworkManager[10481]: <info>  [1478020967.7634] dhcp6 (wls1):   valid_lft 0
  NetworkManager[10481]: <info>  [1478020967.7634] dhcp6 (wls1):   preferred_lft 0
  NetworkManager[10481]: <info>  [1478020967.7636] dhcp6 (wls1):   address fd25:d463:2f14::927
  NetworkManager[10481]: <info>  [1478020967.7636] dhcp6 (wls1):   nameserver 'fe80::21e:8cff:feec:3ca2'
  NetworkManager[10481]: <info>  [1478020967.7637] dhcp (wls1):   domain search 'venom.'
  NetworkManager[10481]: <info>  [1478020967.7637] dhcp6 (wls1): state changed unknown -> bound, event ID="fa💿2c:86|1478020967"
  NetworkManager[10481]: ((src/nm-core-utils.c:3521)): assertion '<dropped>' failed
This commit is contained in:
Lubomir Rintel 2016-11-01 19:25:40 +01:00
parent ccb789edc2
commit 2dd384c817

View file

@ -3511,14 +3511,15 @@ nm_utils_lifetime_get (guint32 timestamp,
nm_assert (now >= 0);
if (lifetime == 0) {
if (timestamp == 0 && lifetime == 0) {
/* We treat lifetime==0 && timestamp == 0 addresses as permanent addresses to allow easy
* creation of such addresses (without requiring to set the lifetime fields to
* NM_PLATFORM_LIFETIME_PERMANENT). The real lifetime==0 addresses (E.g. DHCP6 telling us
* to drop an address will have timestamp set.
*/
*out_lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
*out_preferred = NM_PLATFORM_LIFETIME_PERMANENT;
/* We treat lifetime==0 as permanent addresses to allow easy creation of such addresses
* (without requiring to set the lifetime fields to NM_PLATFORM_LIFETIME_PERMANENT).
* 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 (preferred == 0, TRUE);
} else {
if (now <= 0)
now = nm_utils_get_monotonic_timestamp_s ();