]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
time-util: assume CLOCK_BOOTTIME always exists 22885/head
authorLennart Poettering <lennart@poettering.net>
Mon, 28 Mar 2022 14:41:10 +0000 (16:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Mar 2022 14:55:41 +0000 (16:55 +0200)
Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work
with timerfd in kernel 3.15 (i.e. back in 2014), let's require support
for it now.

This will raise our baseline only modestly from 3.13 → 3.15.

46 files changed:
README
src/basic/time-util.c
src/basic/time-util.h
src/core/timer.h
src/import/curl-util.c
src/libsystemd-network/lldp-neighbor.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-server.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-ipv4acd.c
src/libsystemd-network/sd-lldp-rx.c
src/libsystemd-network/sd-lldp-tx.c
src/libsystemd-network/sd-ndisc.c
src/libsystemd-network/sd-radv.c
src/libsystemd-network/test-dhcp-client.c
src/libsystemd-network/test-dhcp6-client.c
src/libsystemd-network/test-ndisc-ra.c
src/libsystemd-network/test-ndisc-rs.c
src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-event/test-event.c
src/machine/machined.c
src/network/netdev/wireguard.c
src/network/networkd-address.c
src/network/networkd-dhcp-prefix-delegation.c
src/network/networkd-dhcp4.c
src/network/networkd-dhcp6.c
src/network/networkd-link.c
src/network/networkd-ndisc.c
src/network/networkd-route.c
src/network/test-networkd-address.c
src/network/wait-online/manager.c
src/resolve/resolved-dns-cache.c
src/resolve/resolved-dns-packet.c
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-scope.c
src/resolve/resolved-dns-server.c
src/resolve/resolved-dns-stream.c
src/resolve/resolved-dns-transaction.c
src/resolve/resolved-etc-hosts.c
src/resolve/resolved-manager.c
src/resolve/resolved-socket-graveyard.c
src/shared/watchdog.c
src/test/test-time-util.c
src/timesync/timesyncd-manager.c
src/udev/udev-ctrl.c
src/udev/udevd.c

diff --git a/README b/README
index bbde47fda72fb94995055435c6e81380d58ec337..420276eda8951ce6e323559d0a0a6562e025f451 100644 (file)
--- a/README
+++ b/README
@@ -30,7 +30,7 @@ LICENSE:
         LGPL-2.1-or-later for all code, exceptions noted in LICENSES/README.md
 
 REQUIREMENTS:
-        Linux kernel >= 3.13
+        Linux kernel >= 3.15
         Linux kernel >= 4.2 for unified cgroup hierarchy support
         Linux kernel >= 4.10 for cgroup-bpf egress and ingress hooks
         Linux kernel >= 4.15 for cgroup-bpf device hook
index ebf1dddb569432e9bfe520cde80a69d7bb32806b..ad4a189ff7abefc2241f08209b2534c5fe7b1c7a 100644 (file)
@@ -77,7 +77,7 @@ triple_timestamp* triple_timestamp_get(triple_timestamp *ts) {
 
         ts->realtime = now(CLOCK_REALTIME);
         ts->monotonic = now(CLOCK_MONOTONIC);
-        ts->boottime = clock_boottime_supported() ? now(CLOCK_BOOTTIME) : USEC_INFINITY;
+        ts->boottime = now(CLOCK_BOOTTIME);
 
         return ts;
 }
@@ -150,9 +150,7 @@ triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u)
 
         ts->realtime = u;
         ts->monotonic = map_clock_usec_internal(u, nowr, now(CLOCK_MONOTONIC));
-        ts->boottime = clock_boottime_supported() ?
-                map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME)) :
-                USEC_INFINITY;
+        ts->boottime = map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME));
 
         return ts;
 }
@@ -170,8 +168,7 @@ dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) {
         return ts;
 }
 
-dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, usec_t u) {
-        clockid_t cid;
+dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u) {
         usec_t nowm;
 
         if (u == USEC_INFINITY) {
@@ -179,14 +176,8 @@ dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, us
                 return ts;
         }
 
-        cid = clock_boottime_or_monotonic();
-        nowm = now(cid);
-
-        if (cid == CLOCK_MONOTONIC)
-                ts->monotonic = u;
-        else
-                ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC));
-
+        nowm = now(CLOCK_BOOTTIME);
+        ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC));
         ts->realtime = map_clock_usec_internal(u, nowm, now(CLOCK_REALTIME));
         return ts;
 }
@@ -1461,33 +1452,6 @@ int verify_timezone(const char *name, int log_level) {
         return 0;
 }
 
-bool clock_boottime_supported(void) {
-        static int supported = -1;
-
-        /* Note that this checks whether CLOCK_BOOTTIME is available in general as well as available for timerfds()! */
-
-        if (supported < 0) {
-                int fd;
-
-                fd = timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK|TFD_CLOEXEC);
-                if (fd < 0)
-                        supported = false;
-                else {
-                        safe_close(fd);
-                        supported = true;
-                }
-        }
-
-        return supported;
-}
-
-clockid_t clock_boottime_or_monotonic(void) {
-        if (clock_boottime_supported())
-                return CLOCK_BOOTTIME;
-        else
-                return CLOCK_MONOTONIC;
-}
-
 bool clock_supported(clockid_t clock) {
         struct timespec ts;
 
@@ -1495,16 +1459,10 @@ bool clock_supported(clockid_t clock) {
 
         case CLOCK_MONOTONIC:
         case CLOCK_REALTIME:
-                return true;
-
         case CLOCK_BOOTTIME:
-                return clock_boottime_supported();
-
-        case CLOCK_BOOTTIME_ALARM:
-                if (!clock_boottime_supported())
-                        return false;
+                /* These three are always available in our baseline, and work in timerfd, as of kernel 3.15 */
+                return true;
 
-                _fallthrough_;
         default:
                 /* For everything else, check properly */
                 return clock_gettime(clock, &ts) >= 0;
index d3a88ed6e4bf274a1323fefcf694a52b52d7167f..bf312442b0eae741dddc77c7b9c731ce22a747dd 100644 (file)
@@ -82,7 +82,7 @@ usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock);
 dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
 dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
 dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u);
-dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, usec_t u);
+dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u);
 
 triple_timestamp* triple_timestamp_get(triple_timestamp *ts);
 triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u);
@@ -155,9 +155,7 @@ static inline bool timezone_is_valid(const char *name, int log_level) {
         return verify_timezone(name, log_level) >= 0;
 }
 
-bool clock_boottime_supported(void);
 bool clock_supported(clockid_t clock);
-clockid_t clock_boottime_or_monotonic(void);
 
 usec_t usec_shift_clock(usec_t, clockid_t from, clockid_t to);
 
index a51fbf56f336ccaac13b15cdc0917b328a2271db..551e2833417d4be1b2383aea8a89bd32c5988b19 100644 (file)
@@ -64,7 +64,7 @@ struct Timer {
         char *stamp_path;
 };
 
-#define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
+#define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
 
 void timer_free_values(Timer *t);
 
index d6a16b4f57cf8c38962c766ed73bcea672cd1023..5b39251aa99c41d7f618abad09e4933468c0a8c1 100644 (file)
@@ -148,7 +148,7 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
                 if (sd_event_source_set_enabled(g->timer, SD_EVENT_ONESHOT) < 0)
                         return -1;
         } else {
-                if (sd_event_add_time_relative(g->event, &g->timer, clock_boottime_or_monotonic(), usec, 0, curl_glue_on_timer, g) < 0)
+                if (sd_event_add_time_relative(g->event, &g->timer, CLOCK_BOOTTIME, usec, 0, curl_glue_on_timer, g) < 0)
                         return -1;
 
                 (void) sd_event_source_set_description(g->timer, "curl-timer");
index 93f603686591d1e4adf49817dbecc8b7cdf06170..b05601998996d193b2dca1c30d27d0e14031bb60 100644 (file)
@@ -333,9 +333,9 @@ void lldp_neighbor_start_ttl(sd_lldp_neighbor *n) {
                 usec_t base;
 
                 /* Use the packet's timestamp if there is one known */
-                base = triple_timestamp_by_clock(&n->timestamp, clock_boottime_or_monotonic());
+                base = triple_timestamp_by_clock(&n->timestamp, CLOCK_BOOTTIME);
                 if (!timestamp_is_set(base))
-                        base = now(clock_boottime_or_monotonic()); /* Otherwise, take the current time */
+                        base = now(CLOCK_BOOTTIME); /* Otherwise, take the current time */
 
                 n->until = usec_add(base, n->ttl * USEC_PER_SEC);
         } else
index cdf49fc5865fcde989d060aa8a4dba76261e4f88..e8534e8e869b8bff08ef84589f162650826cf5f3 100644 (file)
@@ -821,7 +821,7 @@ static int client_message_init(
 
         /* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP servers
            refuse to issue an DHCP lease if 'secs' is set to zero */
-        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
         assert(time_now >= client->start_time);
@@ -1246,7 +1246,7 @@ static int client_timeout_resend(
         assert(client);
         assert(client->event);
 
-        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 goto error;
 
@@ -1294,7 +1294,7 @@ static int client_timeout_resend(
         }
 
         r = event_reset_time(client->event, &client->timeout_resend,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              next_timeout, 10 * USEC_PER_MSEC,
                              client_timeout_resend, client,
                              client->event_priority, "dhcp4-resend-timer", true);
@@ -1394,12 +1394,12 @@ static int client_initialize_time_events(sd_dhcp_client *client) {
         assert(client->event);
 
         if (client->start_delay > 0) {
-                assert_se(sd_event_now(client->event, clock_boottime_or_monotonic(), &usec) >= 0);
+                assert_se(sd_event_now(client->event, CLOCK_BOOTTIME, &usec) >= 0);
                 usec += client->start_delay;
         }
 
         r = event_reset_time(client->event, &client->timeout_resend,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              usec, 0,
                              client_timeout_resend, client,
                              client->event_priority, "dhcp4-resend-timer", true);
@@ -1440,7 +1440,7 @@ static int client_start_delayed(sd_dhcp_client *client) {
         client->fd = r;
 
         if (IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_INIT_REBOOT))
-                client->start_time = now(clock_boottime_or_monotonic());
+                client->start_time = now(CLOCK_BOOTTIME);
 
         return client_initialize_events(client, client_receive_message_raw);
 }
@@ -1684,7 +1684,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
                 return 0;
         }
 
-        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
         assert(client->request_sent <= time_now);
@@ -1717,7 +1717,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
 
         /* arm lifetime timeout */
         r = event_reset_time(client->event, &client->timeout_expire,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              client->expire_time, 10 * USEC_PER_MSEC,
                              client_timeout_expire, client,
                              client->event_priority, "dhcp4-lifetime", true);
@@ -1733,7 +1733,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
 
         /* arm T2 timeout */
         r = event_reset_time(client->event, &client->timeout_t2,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              client->t2_time, 10 * USEC_PER_MSEC,
                              client_timeout_t2, client,
                              client->event_priority, "dhcp4-t2-timeout", true);
@@ -1749,7 +1749,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
 
         /* arm T1 timeout */
         r = event_reset_time(client->event, &client->timeout_t1,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              client->t1_time, 10 * USEC_PER_MSEC,
                              client_timeout_t1, client,
                              client->event_priority, "dhcp4-t1-timer", true);
@@ -1784,7 +1784,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i
                 client->attempt = 0;
 
                 r = event_reset_time(client->event, &client->timeout_resend,
-                                     clock_boottime_or_monotonic(),
+                                     CLOCK_BOOTTIME,
                                      0, 0,
                                      client_timeout_resend, client,
                                      client->event_priority, "dhcp4-resend-timer", true);
index b9ff27b9e1e1e2ed98d8bfa9118689bddde11a8d..64f5286eadd4de6cea53a0e265b01b50565070ad 100644 (file)
@@ -987,7 +987,7 @@ static int server_ack_request(sd_dhcp_server *server, DHCPRequest *req, DHCPLeas
         assert(req);
         assert(address != 0);
 
-        r = sd_event_now(server->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(server->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
 
@@ -1039,7 +1039,7 @@ static int dhcp_server_cleanup_expired_leases(sd_dhcp_server *server) {
 
         assert(server);
 
-        r = sd_event_now(server->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(server->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
 
index a0faa1ec86812ce89734b2422c89b8bd99d5db3a..27864a0a49bb31368caa9afa4a4866878ff4cae5 100644 (file)
@@ -649,7 +649,7 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) {
         assert(client);
         assert(client->event);
 
-        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
 
@@ -830,7 +830,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
                          FORMAT_TIMESPAN(client->retransmit_time, USEC_PER_SEC));
 
         r = event_reset_time_relative(client->event, &client->timeout_resend,
-                                      clock_boottime_or_monotonic(),
+                                      CLOCK_BOOTTIME,
                                       client->retransmit_time, 10 * USEC_PER_MSEC,
                                       client_timeout_resend, client,
                                       client->event_priority, "dhcp6-resend-timer", true);
@@ -872,12 +872,12 @@ static int client_start_transaction(sd_dhcp6_client *client, DHCP6State state) {
         client->retransmit_count = 0;
         client->transaction_id = random_u32() & htobe32(0x00ffffff);
 
-        r = sd_event_now(client->event, clock_boottime_or_monotonic(), &client->transaction_start);
+        r = sd_event_now(client->event, CLOCK_BOOTTIME, &client->transaction_start);
         if (r < 0)
                 goto error;
 
         r = event_reset_time(client->event, &client->timeout_resend,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              0, 0,
                              client_timeout_resend, client,
                              client->event_priority, "dhcp6-resend-timeout", true);
@@ -969,7 +969,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
         } else {
                 log_dhcp6_client(client, "T1 expires in %s", FORMAT_TIMESPAN(lifetime_t1, USEC_PER_SEC));
                 r = event_reset_time_relative(client->event, &client->timeout_t1,
-                                              clock_boottime_or_monotonic(),
+                                              CLOCK_BOOTTIME,
                                               lifetime_t1, 10 * USEC_PER_SEC,
                                               client_timeout_t1, client,
                                               client->event_priority, "dhcp6-t1-timeout", true);
@@ -983,7 +983,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
         } else {
                 log_dhcp6_client(client, "T2 expires in %s", FORMAT_TIMESPAN(lifetime_t2, USEC_PER_SEC));
                 r = event_reset_time_relative(client->event, &client->timeout_t2,
-                                              clock_boottime_or_monotonic(),
+                                              CLOCK_BOOTTIME,
                                               lifetime_t2, 10 * USEC_PER_SEC,
                                               client_timeout_t2, client,
                                               client->event_priority, "dhcp6-t2-timeout", true);
@@ -998,7 +998,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
                 log_dhcp6_client(client, "Valid lifetime expires in %s", FORMAT_TIMESPAN(lifetime_valid, USEC_PER_SEC));
 
                 r = event_reset_time_relative(client->event, &client->timeout_expire,
-                                              clock_boottime_or_monotonic(),
+                                              CLOCK_BOOTTIME,
                                               lifetime_valid, USEC_PER_SEC,
                                               client_timeout_expire, client,
                                               client->event_priority, "dhcp6-lease-expire", true);
index 232b3b03335eb6354a8af1ce7f68f3205e76e6ca..8303e7fb3453a60afeb42c796adb71c42d3f8762 100644 (file)
@@ -200,10 +200,10 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u
         if (random_usec > 0)
                 next_timeout += (usec_t) random_u64() % random_usec;
 
-        assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &time_now) >= 0);
+        assert_se(sd_event_now(acd->event, CLOCK_BOOTTIME, &time_now) >= 0);
 
         return event_reset_time(acd->event, &acd->timer_event_source,
-                                clock_boottime_or_monotonic(),
+                                CLOCK_BOOTTIME,
                                 time_now + next_timeout, 0,
                                 ipv4acd_on_timeout, acd,
                                 acd->event_priority, "ipv4acd-timer", true);
@@ -381,7 +381,7 @@ static int ipv4acd_on_packet(
                 if (ipv4acd_arp_conflict(acd, &packet, true)) {
                         usec_t ts;
 
-                        assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &ts) >= 0);
+                        assert_se(sd_event_now(acd->event, CLOCK_BOOTTIME, &ts) >= 0);
 
                         /* Defend address */
                         if (ts > acd->defend_window) {
index 34bdcb644bdc931c7055b1934c3e69d56d72dc66..d4762bf097726ba29dddd35cebaf21fda8350a8f 100644 (file)
@@ -69,7 +69,7 @@ static int lldp_rx_make_space(sd_lldp_rx *lldp_rx, size_t extra) {
                         goto remove_one;
 
                 if (t == USEC_INFINITY)
-                        t = now(clock_boottime_or_monotonic());
+                        t = now(CLOCK_BOOTTIME);
 
                 if (n->until > t)
                         break;
@@ -448,7 +448,7 @@ static int lldp_rx_start_timer(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *neighbor)
                 return event_source_disable(lldp_rx->timer_event_source);
 
         return event_reset_time(lldp_rx->event, &lldp_rx->timer_event_source,
-                                clock_boottime_or_monotonic(),
+                                CLOCK_BOOTTIME,
                                 n->until, 0,
                                 on_timer_event, lldp_rx,
                                 lldp_rx->event_priority, "lldp-rx-timer", true);
index a5f60346eb0c1b2dd5d2d4466554b3109fd03e80..136059fa7f528cbf67ac699afb31aeb4287dfbcf 100644 (file)
@@ -609,7 +609,7 @@ int sd_lldp_tx_start(sd_lldp_tx *lldp_tx) {
         delay = lldp_tx_get_delay(lldp_tx);
 
         r = sd_event_add_time_relative(lldp_tx->event, &lldp_tx->timer_event_source,
-                                       clock_boottime_or_monotonic(), delay, 0,
+                                       CLOCK_BOOTTIME, delay, 0,
                                        on_timer_event, lldp_tx);
         if (r < 0)
                 return r;
index 7e16f5129996ca34cf9593417bbc1d518dca9615..ecd552ca0cbf7dc84e39f72fb98484ff1e973b69 100644 (file)
@@ -269,7 +269,7 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         assert(nd);
         assert(nd->event);
 
-        assert_se(sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now) >= 0);
+        assert_se(sd_event_now(nd->event, CLOCK_BOOTTIME, &time_now) >= 0);
 
         if (!nd->retransmit_time)
                 nd->retransmit_time = ndisc_timeout_compute_random(NDISC_ROUTER_SOLICITATION_INTERVAL);
@@ -281,7 +281,7 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         }
 
         r = event_reset_time(nd->event, &nd->timeout_event_source,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              time_now + nd->retransmit_time, 10 * USEC_PER_MSEC,
                              ndisc_timeout, nd,
                              nd->event_priority, "ndisc-timeout-no-ra", true);
@@ -344,7 +344,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
 
         assert(!nd->recv_event_source);
 
-        r = sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(nd->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 goto fail;
 
@@ -363,7 +363,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
         (void) sd_event_source_set_description(nd->recv_event_source, "ndisc-receive-message");
 
         r = event_reset_time(nd->event, &nd->timeout_event_source,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              time_now + USEC_PER_SEC / 2, 1 * USEC_PER_SEC, /* See RFC 8415 sec. 18.2.1 */
                              ndisc_timeout, nd,
                              nd->event_priority, "ndisc-timeout", true);
@@ -371,7 +371,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
                 goto fail;
 
         r = event_reset_time(nd->event, &nd->timeout_no_ra,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              time_now + NDISC_TIMEOUT_NO_RA_USEC, 10 * USEC_PER_MSEC,
                              ndisc_timeout_no_ra, nd,
                              nd->event_priority, "ndisc-timeout-no-ra", true);
index 370a10a013a43d4c40f0cc4faf3e573d34d235e8..7b5c12e4893925eeba905b15429f1e79b94e65c0 100644 (file)
@@ -181,7 +181,7 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_us
         assert(ra);
         assert(router_lifetime_is_valid(lifetime_usec));
 
-        r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(ra->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 return r;
 
@@ -321,7 +321,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         assert(ra->event);
         assert(router_lifetime_is_valid(ra->lifetime_usec));
 
-        r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now);
+        r = sd_event_now(ra->event, CLOCK_BOOTTIME, &time_now);
         if (r < 0)
                 goto fail;
 
@@ -357,7 +357,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         log_radv(ra, "Next Router Advertisement in %s", FORMAT_TIMESPAN(timeout, USEC_PER_SEC));
 
         r = event_reset_time(ra->event, &ra->timeout_event_source,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              usec_add(time_now, timeout), MSEC_PER_SEC,
                              radv_timeout, ra,
                              ra->event_priority, "radv-timeout", true);
@@ -409,7 +409,7 @@ int sd_radv_start(sd_radv *ra) {
                 return 0;
 
         r = event_reset_time(ra->event, &ra->timeout_event_source,
-                             clock_boottime_or_monotonic(),
+                             CLOCK_BOOTTIME,
                              0, 0,
                              radv_timeout, ra,
                              ra->event_priority, "radv-timeout", true);
index dd95aaf58872400325d3a5056bfc19e0765b5daa..7497c3ef3a52ba3129fc12f49b4eb7753bbf758e 100644 (file)
@@ -507,7 +507,7 @@ static void test_addr_acq(sd_event *e) {
 
         callback_recv = test_addr_acq_recv_discover;
 
-        assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(),
+        assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
                                              2 * USEC_PER_SEC, 0,
                                              NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
 
index dfd9042c29c31930ae28ba1331b0643e8e655435..8278a3875abc7a5bb50e190f8f861968360e67d4 100644 (file)
@@ -965,7 +965,7 @@ TEST(dhcp6_client) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
 
         assert_se(sd_event_new(&e) >= 0);
-        assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(),
+        assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
                                              2 * USEC_PER_SEC, 0,
                                              NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
 
index cbf065d4fb332d5fb0f8a573b4369bbf882bbdf2..d4f8cf89b916276c729f9fab4df217198869bbf9 100644 (file)
@@ -327,7 +327,7 @@ TEST(ra) {
         assert_se(sd_event_add_io(e, &recv_router_advertisement, test_fd[0],
                                   EPOLLIN, radv_recv, ra) >= 0);
 
-        assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(),
+        assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
                                              2 * USEC_PER_SEC, 0,
                                              NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
 
index 2c27d12b09b02d52b2fba9128df4e0b15f7f9aae..13db49ea4d1b5792ec75c360d8f06c9a6edfdcb1 100644 (file)
@@ -274,7 +274,7 @@ TEST(rs) {
         assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
         assert_se(sd_ndisc_set_callback(nd, test_callback, e) >= 0);
 
-        assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(),
+        assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
                                              30 * USEC_PER_SEC, 0,
                                              NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
 
@@ -362,7 +362,7 @@ TEST(timeout) {
         assert_se(sd_ndisc_set_ifindex(nd, 42) >= 0);
         assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
 
-        assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(),
+        assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
                                              30 * USEC_PER_SEC, 0,
                                              NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
 
index 38b2ef510b7c6de7197ea3d1d65aee4b9f2609f5..4dbdf1987241a8b2829a91d4894d94e1109748a5 100644 (file)
@@ -4313,12 +4313,6 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
         if (!TRIPLE_TIMESTAMP_HAS_CLOCK(clock))
                 return -EOPNOTSUPP;
 
-        /* Generate a clean error in case CLOCK_BOOTTIME is not available. Note that don't use clock_supported() here,
-         * for a reason: there are systems where CLOCK_BOOTTIME is supported, but CLOCK_BOOTTIME_ALARM is not, but for
-         * the purpose of getting the time this doesn't matter. */
-        if (IN_SET(clock, CLOCK_BOOTTIME, CLOCK_BOOTTIME_ALARM) && !clock_boottime_supported())
-                return -EOPNOTSUPP;
-
         if (!triple_timestamp_is_set(&e->timestamp)) {
                 /* Implicitly fall back to now() if we never ran before and thus have no cached time. */
                 *usec = now(clock);
index f902c4e3ffc24842247bfd5684cf299ec45d1430..ea29def3d5f91124cc9b0f0f2baf198c52a49a4c 100644 (file)
@@ -315,10 +315,8 @@ TEST(sd_event_now) {
         assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) > 0);
         assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) > 0);
         assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) > 0);
-        if (clock_boottime_supported()) {
-                assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) > 0);
-                assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) > 0);
-        }
+        assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) > 0);
+        assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) > 0);
         assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP);
         assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP);
 
@@ -327,10 +325,8 @@ TEST(sd_event_now) {
         assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) == 0);
         assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) == 0);
         assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) == 0);
-        if (clock_boottime_supported()) {
-                assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) == 0);
-                assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) == 0);
-        }
+        assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) == 0);
+        assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) == 0);
         assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP);
         assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP);
 }
index a433afb1a6b1ad0148fa94e31fd776ffca962276..9ecba8720fdd81c9e26bf30a4c009ab63d921f63 100644 (file)
@@ -127,7 +127,7 @@ static int manager_add_host_machine(Manager *m) {
         t->root_directory = TAKE_PTR(rd);
         t->unit = TAKE_PTR(unit);
 
-        dual_timestamp_from_boottime_or_monotonic(&t->timestamp, 0);
+        dual_timestamp_from_boottime(&t->timestamp, 0);
 
         m->host_machine = t;
 
index 9e98b93a5cf890cd7fe2b4d50175509999c6de4c..32525e6200c7c9799b4319400663048dd5c4acbb 100644 (file)
@@ -375,7 +375,7 @@ static int wireguard_peer_resolve_handler(
         if (peer->n_retries > 0) {
                 r = event_reset_time_relative(netdev->manager->event,
                                               &peer->resolve_retry_event_source,
-                                              clock_boottime_or_monotonic(),
+                                              CLOCK_BOOTTIME,
                                               peer_next_resolve_usec(peer), 0,
                                               on_resolve_retry, peer, 0, "wireguard-resolve-retry", true);
                 if (r < 0)
index eba28cfc678e41ad77abe6aa6ee5862561df0a9f..afcd53cbc780ea3a80ec74e3bd3d9a1f45d19f7f 100644 (file)
@@ -218,7 +218,7 @@ static struct ifa_cacheinfo *address_set_cinfo(const Address *a, struct ifa_cach
         assert(a);
         assert(cinfo);
 
-        now_usec = now(clock_boottime_or_monotonic());
+        now_usec = now(CLOCK_BOOTTIME);
 
         *cinfo = (struct ifa_cacheinfo) {
                 .ifa_valid = MIN(usec_sub_unsigned(a->lifetime_valid_usec, now_usec) / USEC_PER_SEC, UINT32_MAX),
@@ -234,7 +234,7 @@ static void address_set_lifetime(Address *a, const struct ifa_cacheinfo *cinfo)
         assert(a);
         assert(cinfo);
 
-        now_usec = now(clock_boottime_or_monotonic());
+        now_usec = now(CLOCK_BOOTTIME);
 
         if (cinfo->ifa_valid == UINT32_MAX)
                 a->lifetime_valid_usec = USEC_INFINITY;
@@ -643,7 +643,7 @@ const char* format_lifetime(char *buf, size_t l, usec_t lifetime_usec) {
 
         sprintf(buf, "for ");
         /* format_timespan() never fails */
-        assert_se(format_timespan(buf + 4, l - 4, usec_sub_unsigned(lifetime_usec, now(clock_boottime_or_monotonic())), USEC_PER_SEC));
+        assert_se(format_timespan(buf + 4, l - 4, usec_sub_unsigned(lifetime_usec, now(CLOCK_BOOTTIME)), USEC_PER_SEC));
         return buf;
 }
 
index 775acb3f95a1c19d20385766ca311b82f0b3f7cd..d8d9475635b051ccac09b8395602b8f851e0b7af 100644 (file)
@@ -886,7 +886,7 @@ static int dhcp4_pd_assign_subnet_prefix(Link *link, Link *uplink) {
         if (r < 0)
                 return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
 
-        lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic()));
+        lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
 
         r = sd_dhcp_lease_get_6rd(uplink->dhcp_lease, &ipv4masklen, &sixrd_prefixlen, &sixrd_prefix, &br_addresses, NULL);
         if (r < 0)
@@ -958,7 +958,7 @@ int dhcp4_pd_prefix_acquired(Link *uplink) {
         if (r < 0)
                 return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
 
-        lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic()));
+        lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
 
         r = sd_dhcp_lease_get_server_identifier(uplink->dhcp_lease, &server_address.in);
         if (r < 0)
@@ -1045,7 +1045,7 @@ static int dhcp6_pd_assign_subnet_prefixes(Link *link, Link *uplink) {
         if (r <= 0)
                 return r;
 
-        r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return r;
 
@@ -1094,7 +1094,7 @@ int dhcp6_pd_prefix_acquired(Link *uplink) {
         if (r < 0)
                 return log_link_warning_errno(uplink, r, "Failed to get server address of DHCPv6 lease: %m");
 
-        r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_warning_errno(uplink, r, "Failed to get timestamp of DHCPv6 lease: %m");
 
index 0f7be769ea1c8bd8044d707fa5123fc9cfca619d..6bfcf67dd953181da720d95710c9930b7cf77620 100644 (file)
@@ -871,7 +871,7 @@ static int dhcp4_request_address(Link *link, bool announce) {
                 if (r < 0)
                         return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m");
 
-                lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic()));
+                lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
         } else
                 lifetime_usec = USEC_INFINITY;
 
index c443098889c35bb75cca96c5d7220d762a5efadb..d4b61ad79e6e7f864f7147d0c9536bcab16426a5 100644 (file)
@@ -258,7 +258,7 @@ static int dhcp6_address_acquired(Link *link) {
         if (r < 0)
                 return log_link_warning_errno(link, r, "Failed to get server address of DHCPv6 lease: %m");
 
-        r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_warning_errno(link, r, "Failed to get timestamp of DHCPv6 lease: %m");
 
index 4312c6c7bbcd4753ffaa677e3aeaabcb7c7ba235..d509855f48d05d4a42dc8a433a19609588f1b0dc 100644 (file)
@@ -1659,7 +1659,7 @@ static int link_carrier_lost(Link *link) {
 
         return event_reset_time_relative(link->manager->event,
                                          &link->carrier_lost_timer,
-                                         clock_boottime_or_monotonic(),
+                                         CLOCK_BOOTTIME,
                                          link->network->ignore_carrier_loss_usec,
                                          0,
                                          link_carrier_lost_handler,
index 63e5ff6cc6657edd648fedf210962fa32be85c2d..3078f82a44c1699bb856e19fb0f9626627c8e186 100644 (file)
@@ -316,7 +316,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
         if (lifetime_sec == 0) /* not a default router */
                 return 0;
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -410,7 +410,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
         if (!link->network->ipv6_accept_ra_use_autonomous_prefix)
                 return 0;
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -510,7 +510,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
         if (lifetime_sec == 0)
                 return 0;
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -652,7 +652,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get default router preference from RA: %m");
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -709,7 +709,7 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get router address from RA: %m");
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -803,7 +803,7 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get router address from RA: %m");
 
-        r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec);
+        r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
 
@@ -1168,7 +1168,7 @@ void ndisc_vacuum(Link *link) {
 
         /* Removes all RDNSS and DNSSL entries whose validity time has passed */
 
-        time_now = now(clock_boottime_or_monotonic());
+        time_now = now(CLOCK_BOOTTIME);
 
         SET_FOREACH(r, link->ndisc_rdnss)
                 if (r->lifetime_usec < time_now)
index c9fb872ae57e2fd0f3fbcd6d52e6dce90e199dd7..934fed3b7f32391d21be4c647188d15e0e44b4f9 100644 (file)
@@ -1041,7 +1041,7 @@ static int route_setup_timer(Route *route, const struct rta_cacheinfo *cacheinfo
                 /* Assume that non-zero rta_expires means kernel will handle the route expiration. */
                 return 0;
 
-        r = event_reset_time(manager->event, &route->expire, clock_boottime_or_monotonic(),
+        r = event_reset_time(manager->event, &route->expire, CLOCK_BOOTTIME,
                              route->lifetime_usec, 0, route_expire_handler, route, 0, "route-expiration", true);
         if (r < 0)
                 return r;
@@ -1179,7 +1179,7 @@ static int route_configure(const Route *route, Link *link, Request *req) {
 
         if (route->lifetime_usec != USEC_INFINITY) {
                 r = sd_netlink_message_append_u32(m, RTA_EXPIRES,
-                        MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(clock_boottime_or_monotonic())), USEC_PER_SEC), UINT32_MAX));
+                        MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(CLOCK_BOOTTIME)), USEC_PER_SEC), UINT32_MAX));
                 if (r < 0)
                         return r;
         }
index e0d85b2b796408fc96ae933100cc9560587328d1..a40c571483a84267f4d0e51af07b7ea96ca7853b 100644 (file)
@@ -14,7 +14,7 @@ static void test_FORMAT_LIFETIME_one(usec_t lifetime, const char *expected) {
 TEST(FORMAT_LIFETIME) {
         usec_t now_usec;
 
-        now_usec = now(clock_boottime_or_monotonic());
+        now_usec = now(CLOCK_BOOTTIME);
 
         test_FORMAT_LIFETIME_one(now_usec, "for 0");
         test_FORMAT_LIFETIME_one(usec_add(now_usec, 2 * USEC_PER_SEC - 1), "for 1s");
index 093622270db9a4817b61c4cdf13f2983a5c0e8da..e5e23979eae85691fcc5a6b47237b2ff4b8f92f4 100644 (file)
@@ -380,7 +380,7 @@ int manager_new(Manager **ret,
         (void) sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
 
         if (timeout > 0) {
-                r = sd_event_add_time_relative(m->event, NULL, clock_boottime_or_monotonic(), timeout, 0, NULL, INT_TO_PTR(-ETIMEDOUT));
+                r = sd_event_add_time_relative(m->event, NULL, CLOCK_BOOTTIME, timeout, 0, NULL, INT_TO_PTR(-ETIMEDOUT));
                 if (r < 0 && r != -EOVERFLOW)
                         return r;
         }
index 3dce32ed387953b67d477ce5b55a17ec9971cfc9..45bcbfd9d788339efed232b1ba4a21c7bb589e9e 100644 (file)
@@ -214,7 +214,7 @@ void dns_cache_prune(DnsCache *c) {
                         break;
 
                 if (t <= 0)
-                        t = now(clock_boottime_or_monotonic());
+                        t = now(CLOCK_BOOTTIME);
 
                 if (i->until > t)
                         break;
@@ -735,7 +735,7 @@ int dns_cache_put(
         /* Make some space for our new entries */
         dns_cache_make_space(c, cache_keys);
 
-        timestamp = now(clock_boottime_or_monotonic());
+        timestamp = now(CLOCK_BOOTTIME);
 
         /* Second, add in positive entries for all contained RRs */
         DNS_ANSWER_FOREACH_ITEM(item, answer) {
@@ -1016,7 +1016,7 @@ int dns_cache_lookup(
         if (FLAGS_SET(query_flags, SD_RESOLVED_CLAMP_TTL)) {
                 /* 'current' is always passed to answer_add_clamp_ttl(), but is only used conditionally.
                  * We'll do the same assert there to make sure that it was initialized properly. */
-                current = now(clock_boottime_or_monotonic());
+                current = now(CLOCK_BOOTTIME);
                 assert(current > 0);
         }
 
index 74396f14a870d11bfc6334d3e93ff2ba5f362a23..48b91d6870556cd7337f36fc1bc791f1e5aa9af3 100644 (file)
@@ -2502,7 +2502,7 @@ int dns_packet_patch_ttls(DnsPacket *p, usec_t timestamp) {
         usec_t k;
         int r;
 
-        k = now(clock_boottime_or_monotonic());
+        k = now(CLOCK_BOOTTIME);
         assert(k >= timestamp);
         k -= timestamp;
 
index b7cb21dd49d9f127c4f3debaeb6d4cc52b9ffdb3..b62c5c349f5d0567c1e5e8ab5ddc65cbedc04519 100644 (file)
@@ -777,7 +777,7 @@ int dns_query_go(DnsQuery *q) {
         r = event_reset_time_relative(
                         q->manager->event,
                         &q->timeout_event_source,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         SD_RESOLVED_QUERY_TIMEOUT_USEC,
                         0, on_query_timeout, q,
                         0, "query-timeout", true);
index 96978f8ac3b825ecdcdd470829cf2cef7538920d..a872e9d255017325d24d3e49c9e0ea9113672769 100644 (file)
@@ -1239,7 +1239,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
         r = sd_event_add_time_relative(
                         scope->manager->event,
                         &scope->conflict_event_source,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         jitter,
                         LLMNR_JITTER_INTERVAL_USEC,
                         on_conflict_dispatch, scope);
@@ -1509,7 +1509,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
                 r = sd_event_add_time_relative(
                                 scope->manager->event,
                                 &scope->announce_event_source,
-                                clock_boottime_or_monotonic(),
+                                CLOCK_BOOTTIME,
                                 MDNS_ANNOUNCE_DELAY,
                                 MDNS_JITTER_RANGE_USEC,
                                 on_announcement_timeout, scope);
index c2b608d383c25cd304b450f4dd4e518616c73acb..2ef2568dac1820c2d1c06c700feedec5ca04c50f 100644 (file)
@@ -230,7 +230,7 @@ static void dns_server_verified(DnsServer *s, DnsServerFeatureLevel level) {
                 s->verified_feature_level = level;
         }
 
-        assert_se(sd_event_now(s->manager->event, clock_boottime_or_monotonic(), &s->verified_usec) >= 0);
+        assert_se(sd_event_now(s->manager->event, CLOCK_BOOTTIME, &s->verified_usec) >= 0);
 }
 
 static void dns_server_reset_counters(DnsServer *s) {
@@ -405,7 +405,7 @@ static bool dns_server_grace_period_expired(DnsServer *s) {
         if (s->verified_usec == 0)
                 return false;
 
-        assert_se(sd_event_now(s->manager->event, clock_boottime_or_monotonic(), &ts) >= 0);
+        assert_se(sd_event_now(s->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
 
         if (s->verified_usec + s->features_grace_period_usec > ts)
                 return false;
index 61e92bea831e8580334dcad482138f8bc22373d5..4018113d548656fad63b43062266edbeba49565d 100644 (file)
@@ -390,7 +390,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
                                         s->read_packet->family = s->peer.sa.sa_family;
                                         s->read_packet->ttl = s->ttl;
                                         s->read_packet->ifindex = s->ifindex;
-                                        s->read_packet->timestamp = now(clock_boottime_or_monotonic());
+                                        s->read_packet->timestamp = now(CLOCK_BOOTTIME);
 
                                         if (s->read_packet->family == AF_INET) {
                                                 s->read_packet->sender.in = s->peer.in.sin_addr;
@@ -543,7 +543,7 @@ int dns_stream_new(
         r = sd_event_add_time_relative(
                         m->event,
                         &s->timeout_event_source,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         connect_timeout_usec, 0,
                         on_stream_timeout, s);
         if (r < 0)
index 52897649d159f0a783a114341ce2160681c0df38..cec3cea7c5867bddad422ac6555db9c1f6d903ae 100644 (file)
@@ -1422,7 +1422,7 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
                  * next recvmsg(). Treat this like a lost packet. */
 
                 log_debug_errno(r, "Connection failure for DNS UDP packet: %m");
-                assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &usec) >= 0);
+                assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &usec) >= 0);
                 dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level);
 
                 dns_transaction_close_connection(t, /* use_graveyard = */ false);
@@ -1797,7 +1797,7 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
          * in our current scope, and see whether their timing constraints allow them to be sent.
          */
 
-        assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &ts) >= 0);
+        assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
 
         LIST_FOREACH(transactions_by_scope, other, t->scope->transactions) {
 
@@ -1835,7 +1835,7 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
                 r = sd_event_add_time(
                                 other->scope->manager->event,
                                 &other->timeout_event_source,
-                                clock_boottime_or_monotonic(),
+                                CLOCK_BOOTTIME,
                                 ts, 0,
                                 on_transaction_timeout, other);
                 if (r < 0)
@@ -1937,7 +1937,7 @@ int dns_transaction_go(DnsTransaction *t) {
          * finished now. In the latter case, the transaction and query candidate objects must not be accessed.
          */
 
-        assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &ts) >= 0);
+        assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
 
         r = dns_transaction_prepare(t, ts);
         if (r <= 0)
@@ -1981,7 +1981,7 @@ int dns_transaction_go(DnsTransaction *t) {
                 r = sd_event_add_time_relative(
                                 t->scope->manager->event,
                                 &t->timeout_event_source,
-                                clock_boottime_or_monotonic(),
+                                CLOCK_BOOTTIME,
                                 jitter, accuracy,
                                 on_transaction_timeout, t);
                 if (r < 0)
@@ -2071,7 +2071,7 @@ int dns_transaction_go(DnsTransaction *t) {
         r = sd_event_add_time(
                         t->scope->manager->event,
                         &t->timeout_event_source,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         ts, 0,
                         on_transaction_timeout, t);
         if (r < 0)
index 72d6b4218953e516bdb7d8521f72d396edb08761..a1d797b1119aeb5970a20c97e73caf299103d478 100644 (file)
@@ -294,7 +294,7 @@ static int manager_etc_hosts_read(Manager *m) {
         usec_t ts;
         int r;
 
-        assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &ts) >= 0);
+        assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &ts) >= 0);
 
         /* See if we checked /etc/hosts recently already */
         if (m->etc_hosts_last != USEC_INFINITY && m->etc_hosts_last + ETC_HOSTS_RECHECK_USEC > ts)
index 916ad3ce03b6fddabb8e5c943f47727290927066..12e7d87f221ca8e787b08e8f683e409853d2fa9c 100644 (file)
@@ -803,7 +803,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
         } else
                 return -EAFNOSUPPORT;
 
-        p->timestamp = now(clock_boottime_or_monotonic());
+        p->timestamp = now(CLOCK_BOOTTIME);
 
         CMSG_FOREACH(cmsg, &mh) {
 
index e659ae91833375509271a6d1bd25e9cce4211bf8..6d4105bc0abe3e0973e3937e9595b620739ca97c 100644 (file)
@@ -53,7 +53,7 @@ void manager_socket_graveyard_process(Manager *m) {
                 SocketGraveyard *g = m->socket_graveyard_oldest;
 
                 if (n == USEC_INFINITY)
-                        assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &n) >= 0);
+                        assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &n) >= 0);
 
                 if (g->deadline > n)
                         break;
@@ -113,7 +113,7 @@ int manager_add_socket_to_graveyard(Manager *m, int fd) {
 
         m->n_socket_graveyard++;
 
-        assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &g->deadline) >= 0);
+        assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &g->deadline) >= 0);
         g->deadline += SOCKET_GRAVEYARD_USEC;
 
         r = sd_event_add_io(m->event, &g->io_event_source, fd, EPOLLIN, on_io_event, g);
index c4a4702a37c20b9fb3b969cb476b001dc63a84e5..2476778c942b2f59355390e818ea5d06f8f70558 100644 (file)
@@ -195,7 +195,7 @@ static int watchdog_ping_now(void) {
         if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0)
                 return log_warning_errno(errno, "Failed to ping hardware watchdog, ignoring: %m");
 
-        watchdog_last_ping = now(clock_boottime_or_monotonic());
+        watchdog_last_ping = now(CLOCK_BOOTTIME);
 
         return 0;
 }
@@ -411,7 +411,7 @@ usec_t watchdog_runtime_wait(void) {
 
         /* Sleep half the watchdog timeout since the last successful ping at most */
         if (timestamp_is_set(watchdog_last_ping)) {
-                usec_t ntime = now(clock_boottime_or_monotonic());
+                usec_t ntime = now(CLOCK_BOOTTIME);
 
                 assert(ntime >= watchdog_last_ping);
                 return usec_sub_unsigned(watchdog_last_ping + (timeout / 2), ntime);
@@ -430,7 +430,7 @@ int watchdog_ping(void) {
                 /* open_watchdog() will automatically ping the device for us if necessary */
                 return open_watchdog();
 
-        ntime = now(clock_boottime_or_monotonic());
+        ntime = now(CLOCK_BOOTTIME);
         timeout = calc_timeout();
 
         /* Never ping earlier than watchdog_timeout/4 and try to ping
index 15f4a0c169b04933af47d6bf656390cebaa7a19d..86a60604da1ce25a230711504c53877356779bbc 100644 (file)
@@ -522,25 +522,25 @@ TEST(usec_shift_clock) {
 
         rt = now(CLOCK_REALTIME);
         mn = now(CLOCK_MONOTONIC);
-        bt = now(clock_boottime_or_monotonic());
+        bt = now(CLOCK_BOOTTIME);
 
         assert_se(usec_shift_clock(USEC_INFINITY, CLOCK_REALTIME, CLOCK_MONOTONIC) == USEC_INFINITY);
 
         assert_similar(usec_shift_clock(rt + USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_MONOTONIC), mn + USEC_PER_HOUR);
-        assert_similar(usec_shift_clock(rt + 2*USEC_PER_HOUR, CLOCK_REALTIME, clock_boottime_or_monotonic()), bt + 2*USEC_PER_HOUR);
+        assert_similar(usec_shift_clock(rt + 2*USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_BOOTTIME), bt + 2*USEC_PER_HOUR);
         assert_se(usec_shift_clock(rt + 3*USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_REALTIME_ALARM) == rt + 3*USEC_PER_HOUR);
 
         assert_similar(usec_shift_clock(mn + 4*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_REALTIME_ALARM), rt + 4*USEC_PER_HOUR);
-        assert_similar(usec_shift_clock(mn + 5*USEC_PER_HOUR, CLOCK_MONOTONIC, clock_boottime_or_monotonic()), bt + 5*USEC_PER_HOUR);
+        assert_similar(usec_shift_clock(mn + 5*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_BOOTTIME), bt + 5*USEC_PER_HOUR);
         assert_se(usec_shift_clock(mn + 6*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_MONOTONIC) == mn + 6*USEC_PER_HOUR);
 
-        assert_similar(usec_shift_clock(bt + 7*USEC_PER_HOUR, clock_boottime_or_monotonic(), CLOCK_MONOTONIC), mn + 7*USEC_PER_HOUR);
-        assert_similar(usec_shift_clock(bt + 8*USEC_PER_HOUR, clock_boottime_or_monotonic(), CLOCK_REALTIME_ALARM), rt + 8*USEC_PER_HOUR);
-        assert_se(usec_shift_clock(bt + 9*USEC_PER_HOUR, clock_boottime_or_monotonic(), clock_boottime_or_monotonic()) == bt + 9*USEC_PER_HOUR);
+        assert_similar(usec_shift_clock(bt + 7*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_MONOTONIC), mn + 7*USEC_PER_HOUR);
+        assert_similar(usec_shift_clock(bt + 8*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_REALTIME_ALARM), rt + 8*USEC_PER_HOUR);
+        assert_se(usec_shift_clock(bt + 9*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_BOOTTIME) == bt + 9*USEC_PER_HOUR);
 
         if (mn > USEC_PER_MINUTE) {
                 assert_similar(usec_shift_clock(rt - 30 * USEC_PER_SEC, CLOCK_REALTIME_ALARM, CLOCK_MONOTONIC), mn - 30 * USEC_PER_SEC);
-                assert_similar(usec_shift_clock(rt - 50 * USEC_PER_SEC, CLOCK_REALTIME, clock_boottime_or_monotonic()), bt - 50 * USEC_PER_SEC);
+                assert_similar(usec_shift_clock(rt - 50 * USEC_PER_SEC, CLOCK_REALTIME, CLOCK_BOOTTIME), bt - 50 * USEC_PER_SEC);
         }
 }
 
@@ -598,7 +598,7 @@ static int intro(void) {
                  "boottime=" USEC_FMT "\n",
                  now(CLOCK_REALTIME),
                  now(CLOCK_MONOTONIC),
-                 now(clock_boottime_or_monotonic()));
+                 now(CLOCK_BOOTTIME));
 
         /* Ensure time_t is signed */
         assert_cc((time_t) -1 < (time_t) 1);
index 7392edbe27b2b6af669a510929d0b4be5afbabcb..ae906a631dee98fc65b5ddcb827ca1dbd00c2bd2 100644 (file)
@@ -130,7 +130,7 @@ static int manager_send_request(Manager *m) {
          * The actual value does not matter, We do not care about the correct
          * NTP UINT_MAX fraction; we just pass the plain nanosecond value.
          */
-        assert_se(clock_gettime(clock_boottime_or_monotonic(), &m->trans_time_mon) >= 0);
+        assert_se(clock_gettime(CLOCK_BOOTTIME, &m->trans_time_mon) >= 0);
         assert_se(clock_gettime(CLOCK_REALTIME, &m->trans_time) >= 0);
         ntpmsg.trans_time.sec = htobe32(graceful_add_offset_1900_1970(m->trans_time.tv_sec));
         ntpmsg.trans_time.frac = htobe32(m->trans_time.tv_nsec);
@@ -161,8 +161,8 @@ static int manager_send_request(Manager *m) {
                 r = sd_event_add_time(
                                 m->event,
                                 &m->event_timeout,
-                                clock_boottime_or_monotonic(),
-                                now(clock_boottime_or_monotonic()) + TIMEOUT_USEC, 0,
+                                CLOCK_BOOTTIME,
+                                now(CLOCK_BOOTTIME) + TIMEOUT_USEC, 0,
                                 manager_timeout, m);
                 if (r < 0)
                         return log_error_errno(r, "Failed to arm timeout timer: %m");
@@ -200,7 +200,7 @@ static int manager_arm_timer(Manager *m, usec_t next) {
         return sd_event_add_time_relative(
                         m->event,
                         &m->event_timer,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         next, 0,
                         manager_timer, m);
 }
@@ -799,7 +799,7 @@ int manager_connect(Manager *m) {
         if (!ratelimit_below(&m->ratelimit)) {
                 log_debug("Delaying attempts to contact servers.");
 
-                r = sd_event_add_time_relative(m->event, &m->event_retry, clock_boottime_or_monotonic(), m->connection_retry_usec,
+                r = sd_event_add_time_relative(m->event, &m->event_retry, CLOCK_BOOTTIME, m->connection_retry_usec,
                                                0, manager_retry_connect, m);
                 if (r < 0)
                         return log_error_errno(r, "Failed to create retry timer: %m");
@@ -854,7 +854,7 @@ int manager_connect(Manager *m) {
 
                         if (restart && !m->exhausted_servers && m->poll_interval_usec) {
                                 log_debug("Waiting after exhausting servers.");
-                                r = sd_event_add_time_relative(m->event, &m->event_retry, clock_boottime_or_monotonic(), m->poll_interval_usec, 0, manager_retry_connect, m);
+                                r = sd_event_add_time_relative(m->event, &m->event_retry, CLOCK_BOOTTIME, m->poll_interval_usec, 0, manager_retry_connect, m);
                                 if (r < 0)
                                         return log_error_errno(r, "Failed to create retry timer: %m");
 
@@ -1165,7 +1165,7 @@ int manager_setup_save_time_event(Manager *m) {
         /* NB: we'll accumulate scheduling latencies here, but this doesn't matter */
         r = sd_event_add_time_relative(
                         m->event, &m->event_save_time,
-                        clock_boottime_or_monotonic(),
+                        CLOCK_BOOTTIME,
                         m->save_time_interval_usec,
                         10 * USEC_PER_SEC,
                         manager_save_time_handler, m);
index 45e45162ae534b2f6bf220f859d66e4047ce9753..4913d0262b57fe8cd656b954836e01af6c646708 100644 (file)
@@ -356,7 +356,7 @@ int udev_ctrl_wait(UdevCtrl *uctrl, usec_t timeout) {
 
         if (timeout != USEC_INFINITY) {
                 r = sd_event_add_time_relative(
-                                uctrl->event, &source_timeout, clock_boottime_or_monotonic(),
+                                uctrl->event, &source_timeout, CLOCK_BOOTTIME,
                                 timeout,
                                 0, NULL, INT_TO_PTR(-ETIMEDOUT));
                 if (r < 0)
index 4d03f82faebd1c9a0879bd5153c96c3eff7c2f2c..67d7733be2ddb4a0259569a2aef4bfb2debdf1fb 100644 (file)
@@ -807,7 +807,7 @@ static int event_is_blocked(Event *event) {
         if (event->retry_again_next_usec > 0) {
                 usec_t now_usec;
 
-                r = sd_event_now(event->manager->event, clock_boottime_or_monotonic(), &now_usec);
+                r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec);
                 if (r < 0)
                         return r;
 
@@ -1013,7 +1013,7 @@ static int event_requeue(Event *event) {
         event->timeout_event = sd_event_source_disable_unref(event->timeout_event);
 
         /* add a short delay to suppress busy loop */
-        r = sd_event_now(event->manager->event, clock_boottime_or_monotonic(), &now_usec);
+        r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec);
         if (r < 0)
                 return log_device_warning_errno(event->dev, r,
                                                 "Failed to get current time, "