summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/sd-ipv4acd.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-12-02 07:31:30 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-12-02 10:42:17 +0100
commit878c035a4846023ec154e1fcd32d07696c3e3606 (patch)
tree7430ad4795003c51be4279ea50e3aa142bd7587e /src/libsystemd-network/sd-ipv4acd.c
parentsd-ipv4acd,sd-ipv4ll: include interface name in the debug logs (diff)
downloadsystemd-878c035a4846023ec154e1fcd32d07696c3e3606.tar.xz
systemd-878c035a4846023ec154e1fcd32d07696c3e3606.zip
sd-ipv4acd: logs current state
Diffstat (limited to 'src/libsystemd-network/sd-ipv4acd.c')
-rw-r--r--src/libsystemd-network/sd-ipv4acd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
index 1bf0fb18f3..9426b65324 100644
--- a/src/libsystemd-network/sd-ipv4acd.c
+++ b/src/libsystemd-network/sd-ipv4acd.c
@@ -21,6 +21,7 @@
#include "log-link.h"
#include "random-util.h"
#include "siphash24.h"
+#include "string-table.h"
#include "string-util.h"
#include "time-util.h"
@@ -79,10 +80,25 @@ struct sd_ipv4acd {
#define log_ipv4acd(acd, fmt, ...) \
log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__)
+static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = {
+ [IPV4ACD_STATE_INIT] = "init",
+ [IPV4ACD_STATE_STARTED] = "started",
+ [IPV4ACD_STATE_WAITING_PROBE] = "waiting-probe",
+ [IPV4ACD_STATE_PROBING] = "probing",
+ [IPV4ACD_STATE_WAITING_ANNOUNCE] = "waiting-announce",
+ [IPV4ACD_STATE_ANNOUNCING] = "announcing",
+ [IPV4ACD_STATE_RUNNING] = "running",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(ipv4acd_state, IPv4ACDState);
+
static void ipv4acd_set_state(sd_ipv4acd *acd, IPv4ACDState st, bool reset_counter) {
assert(acd);
assert(st < _IPV4ACD_STATE_MAX);
+ if (st != acd->state)
+ log_ipv4acd(acd, "%s -> %s", ipv4acd_state_to_string(acd->state), ipv4acd_state_to_string(st));
+
if (st == acd->state && !reset_counter)
acd->n_iteration++;
else {