[systemd-commits] 4 commits - src/libsystemd src/libsystemd-network src/network src/systemd

Tom Gundersen tomegun at kemper.freedesktop.org
Thu Aug 28 13:28:25 PDT 2014


 src/libsystemd-network/sd-dhcp-client.c  |   35 ++++++++++++++++++++++++
 src/libsystemd-network/sd-dhcp6-client.c |   30 ++++++++++++++++++++
 src/libsystemd-network/sd-icmp6-nd.c     |   13 ++++++++
 src/libsystemd-network/sd-ipv4ll.c       |   11 +++++++
 src/libsystemd/libsystemd.sym.m4         |    2 +
 src/libsystemd/sd-bus/sd-bus.c           |   16 +++++++++++
 src/libsystemd/sd-event/sd-event.c       |   45 ++++++++++++++++++++++++++++---
 src/libsystemd/sd-rtnl/rtnl-message.c    |    7 +++-
 src/libsystemd/sd-rtnl/sd-rtnl.c         |   12 ++++++++
 src/network/networkd-manager.c           |    4 ++
 src/systemd/sd-event.h                   |    2 +
 11 files changed, 171 insertions(+), 6 deletions(-)

New commits:
commit 9021bb9f935c93b516b10c88db2a212a9e3a8140
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Aug 28 15:46:29 2014 +0200

    sd-event: name event sources used in libraries
    
    This should help in debugging failing event sources.

diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 8a9887d..7cf1b80 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -700,6 +700,11 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
         if (r < 0)
                 goto error;
 
+        r = sd_event_source_set_name(client->timeout_resend,
+                                     "dhcp4-resend-timer");
+        if (r < 0)
+                goto error;
+
         switch (client->state) {
         case DHCP_STATE_INIT:
                 r = client_send_discover(client);
@@ -773,6 +778,11 @@ static int client_initialize_io_events(sd_dhcp_client *client,
         if (r < 0)
                 goto error;
 
+        r = sd_event_source_set_name(client->receive_message,
+                                     "dhcp4-receive-message");
+        if (r < 0)
+                goto error;
+
 error:
         if (r < 0)
                 client_stop(client, r);
@@ -799,6 +809,11 @@ static int client_initialize_time_events(sd_dhcp_client *client) {
         r = sd_event_source_set_priority(client->timeout_resend,
                                          client->event_priority);
 
+        r = sd_event_source_set_name(client->timeout_resend,
+                                     "dhcp4-resend-timer");
+        if (r < 0)
+                goto error;
+
 error:
         if (r < 0)
                 client_stop(client, r);
@@ -1107,6 +1122,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_name(client->timeout_expire,
+                                     "dhcp4-lifetime");
+        if (r < 0)
+                return r;
+
         log_dhcp_client(client, "lease expires in %s",
                         format_timespan(time_string, FORMAT_TIMESPAN_MAX,
                         lifetime_timeout - time_now, 0));
@@ -1130,6 +1150,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_name(client->timeout_t2,
+                                     "dhcp4-t2-timeout");
+        if (r < 0)
+                return r;
+
         log_dhcp_client(client, "T2 expires in %s",
                         format_timespan(time_string, FORMAT_TIMESPAN_MAX,
                         t2_timeout - time_now, 0));
@@ -1152,6 +1177,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_name(client->timeout_t1,
+                                     "dhcp4-t1-timer");
+        if (r < 0)
+                return r;
+
         log_dhcp_client(client, "T1 expires in %s",
                         format_timespan(time_string, FORMAT_TIMESPAN_MAX,
                         t1_timeout - time_now, 0));
@@ -1192,6 +1222,11 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
                                                          client->event_priority);
                         if (r < 0)
                                 goto error;
+
+                        r = sd_event_source_set_name(client->timeout_resend,
+                                                     "dhcp4-resend-timer");
+                        if (r < 0)
+                                goto error;
                 } else if (r == -ENOMSG)
                         /* invalid message, let's ignore it */
                         return 0;
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index f69c0ed..342a231 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -496,6 +496,11 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
         if (r < 0)
                 goto error;
 
+        r = sd_event_source_set_name(client->timeout_resend,
+                                     "dhcp6-resend-timer");
+        if (r < 0)
+                goto error;
+
         if (max_retransmit_duration && !client->timeout_resend_expire) {
 
                 log_dhcp6_client(client, "Max retransmission duration %"PRIu64" secs",
@@ -514,6 +519,11 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
                                                  client->event_priority);
                 if (r < 0)
                         goto error;
+
+                r = sd_event_source_set_name(client->timeout_resend_expire,
+                                             "dhcp6-resend-expire-timer");
+                if (r < 0)
+                        goto error;
         }
 
 error:
@@ -894,6 +904,11 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
                 if (r < 0)
                         return r;
 
+                r = sd_event_source_set_name(client->receive_message,
+                                             "dhcp6-receive-message");
+                if (r < 0)
+                        return r;
+
                 client->state = DHCP6_STATE_SOLICITATION;
 
                 break;
@@ -942,6 +957,11 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
                 if (r < 0)
                         return r;
 
+                r = sd_event_source_set_name(client->lease->ia.timeout_t1,
+                                             "dhcp6-t1-timeout");
+                if (r < 0)
+                        return r;
+
                 timeout = client_timeout_compute_random(be32toh(client->lease->ia.lifetime_t2) * USEC_PER_SEC);
 
                 log_dhcp6_client(client, "T2 expires in %s",
@@ -962,6 +982,11 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
                 if (r < 0)
                         return r;
 
+                r = sd_event_source_set_name(client->lease->ia.timeout_t2,
+                                             "dhcp6-t2-timeout");
+                if (r < 0)
+                        return r;
+
                 client->state = state;
 
                 return 0;
@@ -980,6 +1005,11 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_name(client->timeout_resend,
+                                     "dhcp6-resend-timeout");
+        if (r < 0)
+                return r;
+
         return 0;
 }
 
diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c
index b264e79..243f06a 100644
--- a/src/libsystemd-network/sd-icmp6-nd.c
+++ b/src/libsystemd-network/sd-icmp6-nd.c
@@ -277,6 +277,12 @@ static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
                         icmp6_nd_notify(nd, r);
                         return 0;
                 }
+
+                r = sd_event_source_set_name(nd->timeout, "icmp6-timeout");
+                if (r < 0) {
+                        icmp6_nd_notify(nd, r);
+                        return 0;
+                }
         }
 
         return 0;
@@ -322,13 +328,20 @@ int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd) {
         if (r < 0)
                 goto error;
 
+        r = sd_event_source_set_name(nd->recv, "icmp6-receive-message");
+        if (r < 0)
+                goto error;
+
         r = sd_event_add_time(nd->event, &nd->timeout, clock_boottime_or_monotonic(),
                               0, 0, icmp6_router_solicitation_timeout, nd);
         if (r < 0)
                 goto error;
 
         r = sd_event_source_set_priority(nd->timeout, nd->event_priority);
+        if (r < 0)
+                goto error;
 
+        r = sd_event_source_set_name(nd->timeout, "icmp6-timeout");
 error:
         if (r < 0)
                 icmp6_nd_init(nd);
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index b179879..3d15fc8 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -352,6 +352,10 @@ static void ipv4ll_run_state_machine(sd_ipv4ll *ll, IPv4LLTrigger trigger, void
                 r = sd_event_source_set_priority(ll->timer, ll->event_priority);
                 if (r < 0)
                         goto out;
+
+                r = sd_event_source_set_name(ll->timer, "ipv4ll-timer");
+                if (r < 0)
+                        goto out;
         }
 
 out:
@@ -560,6 +564,10 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
         if (r < 0)
                 goto out;
 
+        r = sd_event_source_set_name(ll->timer, "ipv4ll-receive-message");
+        if (r < 0)
+                goto out;
+
         r = sd_event_add_time(ll->event,
                               &ll->timer,
                               clock_boottime_or_monotonic(),
@@ -570,7 +578,10 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
                 goto out;
 
         r = sd_event_source_set_priority(ll->timer, ll->event_priority);
+        if (r < 0)
+                goto out;
 
+        r = sd_event_source_set_name(ll->timer, "ipv4ll-timer");
 out:
         if (r < 0)
                 ipv4ll_stop(ll, IPV4LL_EVENT_STOP);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 8caa404..78e91b9 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3013,6 +3013,10 @@ static int attach_io_events(sd_bus *bus) {
                         return r;
 
                 r = sd_event_source_set_priority(bus->input_io_event_source, bus->event_priority);
+                if (r < 0)
+                        return r;
+
+                r = sd_event_source_set_name(bus->input_io_event_source, "bus-input");
         } else
                 r = sd_event_source_set_io_fd(bus->input_io_event_source, bus->input_fd);
 
@@ -3028,6 +3032,10 @@ static int attach_io_events(sd_bus *bus) {
                                 return r;
 
                         r = sd_event_source_set_priority(bus->output_io_event_source, bus->event_priority);
+                        if (r < 0)
+                                return r;
+
+                        r = sd_event_source_set_name(bus->input_io_event_source, "bus-output");
                 } else
                         r = sd_event_source_set_io_fd(bus->output_io_event_source, bus->output_fd);
 
@@ -3080,10 +3088,18 @@ _public_ int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) {
         if (r < 0)
                 goto fail;
 
+        r = sd_event_source_set_name(bus->time_event_source, "bus-time");
+        if (r < 0)
+                goto fail;
+
         r = sd_event_add_exit(bus->event, &bus->quit_event_source, quit_callback, bus);
         if (r < 0)
                 goto fail;
 
+        r = sd_event_source_set_name(bus->quit_event_source, "bus-exit");
+        if (r < 0)
+                goto fail;
+
         r = attach_io_events(bus);
         if (r < 0)
                 goto fail;
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index c19bad1..f883f28 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -859,6 +859,10 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
         if (r < 0)
                 goto fail;
 
+        r = sd_event_source_set_name(rtnl->io_event_source, "rtnl-receive-message");
+        if (r < 0)
+                goto fail;
+
         r = sd_event_source_set_prepare(rtnl->io_event_source, prepare_callback);
         if (r < 0)
                 goto fail;
@@ -871,10 +875,18 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
         if (r < 0)
                 goto fail;
 
+        r = sd_event_source_set_name(rtnl->time_event_source, "rtnl-timer");
+        if (r < 0)
+                goto fail;
+
         r = sd_event_add_exit(rtnl->event, &rtnl->exit_event_source, exit_callback, rtnl);
         if (r < 0)
                 goto fail;
 
+        r = sd_event_source_set_name(rtnl->exit_event_source, "rtnl-exit");
+        if (r < 0)
+                goto fail;
+
         return 0;
 
 fail:
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index f2fe5d5..5a4f93a 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -370,6 +370,10 @@ int manager_udev_listen(Manager *m) {
         if (r < 0)
                 return r;
 
+        r = sd_event_source_set_name(m->udev_event_source, "networkd-udev");
+        if (r < 0)
+                return r;
+
         return 0;
 }
 

commit 752bbf75b9b52c0faae29bb4b77a99c4bb0d298f
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Aug 28 15:48:07 2014 +0200

    sd-event: use event source name rather than address in debug messages

diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index a2935ab..c92e065 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2112,8 +2112,12 @@ static int source_dispatch(sd_event_source *s) {
 
         s->dispatching = false;
 
-        if (r < 0)
-                log_debug("Event source %p returned error, disabling: %s", s, strerror(-r));
+        if (r < 0) {
+                if (s->name)
+                        log_debug("Event source '%s' returned error, disabling: %s", s->name, strerror(-r));
+                else
+                        log_debug("Event source %p returned error, disabling: %s", s, strerror(-r));
+        }
 
         if (s->n_ref == 0)
                 source_free(s);
@@ -2146,8 +2150,12 @@ static int event_prepare(sd_event *e) {
                 r = s->prepare(s, s->userdata);
                 s->dispatching = false;
 
-                if (r < 0)
-                        log_debug("Prepare callback of event source %p returned error, disabling: %s", s, strerror(-r));
+                if (r < 0) {
+                        if (s->name)
+                                log_debug("Prepare callback of event source '%s' returned error, disabling: %s", s->name, strerror(-r));
+                        else
+                                log_debug("Prepare callback of event source %p returned error, disabling: %s", s, strerror(-r));
+                }
 
                 if (s->n_ref == 0)
                         source_free(s);

commit f7f53e9e6ebb9f656d880f5e779fc174a1d983bf
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Aug 28 15:47:39 2014 +0200

    sd-event: allow naming event sources

diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index 3fc9983..d1450fb 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -382,6 +382,8 @@ global:
         sd_event_get_watchdog;
         sd_event_source_ref;
         sd_event_source_unref;
+        sd_event_source_set_name;
+        sd_event_source_get_name;
         sd_event_source_set_prepare;
         sd_event_source_get_pending;
         sd_event_source_get_priority;
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 32777e3..a2935ab 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -66,6 +66,8 @@ struct sd_event_source {
         void *userdata;
         sd_event_handler_t prepare;
 
+        char *name;
+
         EventSourceType type:5;
         int enabled:3;
         bool pending:1;
@@ -685,6 +687,7 @@ static void source_free(sd_event_source *s) {
         assert(s);
 
         source_disconnect(s);
+        free(s->name);
         free(s);
 }
 
@@ -1223,6 +1226,32 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
         return NULL;
 }
 
+_public_ int sd_event_source_set_name(sd_event_source *s, const char *name) {
+        char *new_name = NULL;
+
+        assert_return(s, -EINVAL);
+
+        if (name) {
+                new_name = strdup(name);
+                if (!new_name)
+                        return -ENOMEM;
+        }
+
+        free(s->name);
+        s->name = new_name;
+
+        return 0;
+}
+
+_public_ int sd_event_source_get_name(sd_event_source *s, const char **name) {
+        assert_return(s, -EINVAL);
+        assert_return(name, -EINVAL);
+
+        *name = s->name;
+
+        return 0;
+}
+
 _public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
         assert_return(s, NULL);
 
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index 8e013b3..0dbdcdf 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -109,6 +109,8 @@ sd_event *sd_event_source_get_event(sd_event_source *s);
 void* sd_event_source_get_userdata(sd_event_source *s);
 void* sd_event_source_set_userdata(sd_event_source *s, void *userdata);
 
+int sd_event_source_set_name(sd_event_source *s, const char *name);
+int sd_event_source_get_name(sd_event_source *s, const char **name);
 int sd_event_source_set_prepare(sd_event_source *s, sd_event_handler_t callback);
 int sd_event_source_get_pending(sd_event_source *s);
 int sd_event_source_get_priority(sd_event_source *s, int64_t *priority);

commit 5968b1c304188e466759b8ba419fc10f150e5541
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Aug 28 15:59:13 2014 +0200

    sd-rtnl: log if kernel buffer is overrun as we currently can't handle that case

diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 1f596ca..906a9de 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -1132,10 +1132,13 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
         assert(iov);
 
         r = recvmsg(fd, &msg, MSG_TRUNC | (peek ? MSG_PEEK : 0));
-        if (r < 0)
+        if (r < 0) {
                 /* no data */
+                if (errno == ENOBUFS)
+                        log_debug("rtnl: kernel receive buffer overrun");
+
                 return (errno == EAGAIN) ? 0 : -errno;
-        else if (r == 0)
+        } else if (r == 0)
                 /* connection was closed by the kernel */
                 return -ECONNRESET;
 



More information about the systemd-commits mailing list