if (random_sec)
next_timeout += random_u32() % (random_sec * USEC_PER_SEC);
- if (sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now) < 0)
- time_now = now(CLOCK_MONOTONIC);
+ if (sd_event_now(ll->event, clock_boottime_or_monotonic(), &time_now) < 0)
+ time_now = now(clock_boottime_or_monotonic());
ll->next_wakeup = time_now + next_timeout;
ll->next_wakeup_valid = 1;
if (ipv4ll_arp_conflict(ll, in_packet)) {
- r = sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(ll->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
goto out;
if (ll->next_wakeup_valid) {
ll->timer = sd_event_source_unref(ll->timer);
- r = sd_event_add_time(ll->event, &ll->timer, CLOCK_MONOTONIC,
+ r = sd_event_add_time(ll->event, &ll->timer, clock_boottime_or_monotonic(),
ll->next_wakeup, 0, ipv4ll_timer, ll);
if (r < 0)
goto out;
r = sd_event_source_set_priority(ll->timer, ll->event_priority);
if (r < 0)
goto out;
+
+ r = sd_event_source_set_description(ll->timer, "ipv4ll-timer");
+ if (r < 0)
+ goto out;
}
out:
int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index) {
assert_return(ll, -EINVAL);
- assert_return(interface_index >= -1, -EINVAL);
+ assert_return(interface_index > 0, -EINVAL);
assert_return(IN_SET(ll->state, IPV4LL_STATE_INIT,
IPV4LL_STATE_STOPPED), -EBUSY);
}
int sd_ipv4ll_set_address_seed (sd_ipv4ll *ll, uint8_t seed[8]) {
- unsigned int entropy = *seed;
+ unsigned int entropy;
int r;
assert_return(ll, -EINVAL);
+ assert_return(seed, -EINVAL);
+
+ entropy = *seed;
free(ll->random_data);
free(ll->random_data_state);
if (r < 0)
goto out;
+ r = sd_event_source_set_description(ll->receive_message, "ipv4ll-receive-message");
+ if (r < 0)
+ goto out;
+
r = sd_event_add_time(ll->event,
&ll->timer,
- CLOCK_MONOTONIC,
- now(CLOCK_MONOTONIC), 0,
+ clock_boottime_or_monotonic(),
+ now(clock_boottime_or_monotonic()), 0,
ipv4ll_timer, ll);
if (r < 0)
goto out;
r = sd_event_source_set_priority(ll->timer, ll->event_priority);
+ if (r < 0)
+ goto out;
+ r = sd_event_source_set_description(ll->timer, "ipv4ll-timer");
out:
if (r < 0)
ipv4ll_stop(ll, IPV4LL_EVENT_STOP);
}
sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll) {
- if (ll && REFCNT_DEC(ll->n_ref) <= 0) {
+ if (ll && REFCNT_DEC(ll->n_ref) == 0) {
ll->receive_message =
sd_event_source_unref(ll->receive_message);
ll->fd = safe_close(ll->fd);