mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-27 03:21:32 +03:00
network: make sec_to_usec() map 0sec -> 0usec
Zero lifetime in RA is special, and we should not assign possibly very short lifetime addresses or friends. This should not change anything at least now, preparation for later commits. Note, DHCPv4 and v6 code also uses it, but sd-dhcp-client and sd-dhcp6-client already filtered messages with zero lifetime. Hence, the change should not affect DHCP code.
This commit is contained in:
parent
773024685b
commit
0cf1fe8888
@ -36,12 +36,15 @@ typedef enum NetworkConfigState {
|
|||||||
NETWORK_CONFIG_STATE_REMOVING = 1 << 4, /* e.g. address_remove() is called, but no response is received yet */
|
NETWORK_CONFIG_STATE_REMOVING = 1 << 4, /* e.g. address_remove() is called, but no response is received yet */
|
||||||
} NetworkConfigState;
|
} NetworkConfigState;
|
||||||
|
|
||||||
static inline usec_t sec16_to_usec(uint16_t sec, usec_t timestamp_usec) {
|
static inline usec_t sec_to_usec(uint32_t sec, usec_t timestamp_usec) {
|
||||||
return sec == UINT16_MAX ? USEC_INFINITY : usec_add(timestamp_usec, sec * USEC_PER_SEC);
|
return
|
||||||
|
sec == 0 ? 0 :
|
||||||
|
sec == UINT32_MAX ? USEC_INFINITY :
|
||||||
|
usec_add(timestamp_usec, sec * USEC_PER_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline usec_t sec_to_usec(uint32_t sec, usec_t timestamp_usec) {
|
static inline usec_t sec16_to_usec(uint16_t sec, usec_t timestamp_usec) {
|
||||||
return sec == UINT32_MAX ? USEC_INFINITY : usec_add(timestamp_usec, sec * USEC_PER_SEC);
|
return sec_to_usec(sec == UINT16_MAX ? UINT32_MAX : (uint32_t) sec, timestamp_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t usec_to_sec(usec_t usec, usec_t now_usec) {
|
static inline uint32_t usec_to_sec(usec_t usec, usec_t now_usec) {
|
||||||
|
Loading…
Reference in New Issue
Block a user