systemd: byte order to host before using the lifetime

I've seen this in `NetworkManager-1.34.0-0.3.el8.x86_64` (latest in CentOS
Stream 8 at the time of writing this message) which does not use the latest
Systemd but probably the code base is the same (see
51f93e00a2).

Before the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 34y 3w 6d 45min 31s
libsystemd: eth0: DHCPv6 client: T2 expires in 54y 5month 3w 3d 23h 20min 35s
```

After the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 3d 7h 58min 3s
libsystemd: eth0: DHCPv6 client: T2 expires in 5d 2h 26min 50s
```

same box (x86_64 system) and same DHCPv6 server.

This regression has likely been introduced by 8a8955507af363c31297bbc5df79852db4ad39d6.

See-also: https://github.com/systemd/systemd/pull/21558

https://bugzilla.redhat.com/show_bug.cgi?id=2027267
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/863
This commit is contained in:
Nacho Barrientos 2021-11-29 14:17:55 +01:00 committed by Beniamino Galvani
parent 7f517e09d0
commit 906dbb280d

View file

@ -632,7 +632,7 @@ int dhcp6_option_parse_ia(
/* Ignore the sub-option on non-critical errors. */
continue;
lt_min = MIN(lt_min, a->iaaddr.lifetime_valid);
lt_min = MIN(lt_min, be32toh(a->iaaddr.lifetime_valid));
LIST_PREPEND(addresses, ia.addresses, a);
break;
}
@ -651,7 +651,7 @@ int dhcp6_option_parse_ia(
/* Ignore the sub-option on non-critical errors. */
continue;
lt_min = MIN(lt_min, a->iapdprefix.lifetime_valid);
lt_min = MIN(lt_min, be32toh(a->iapdprefix.lifetime_valid));
LIST_PREPEND(addresses, ia.addresses, a);
break;
}