]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-ipv4ll: add a bit of logging to IPv4LL too
authorLennart Poettering <lennart@poettering.net>
Mon, 23 May 2016 17:35:54 +0000 (19:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 May 2016 13:34:43 +0000 (15:34 +0200)
src/libsystemd-network/sd-ipv4ll.c

index 4fcb06a308518ed8be65a7d0bc5337dcef11b80d..cba9a89b765b49d8280828037a9ca1584dbdb93d 100644 (file)
@@ -34,6 +34,7 @@
 #include "random-util.h"
 #include "siphash24.h"
 #include "sparse-endian.h"
+#include "string-util.h"
 #include "util.h"
 
 #define IPV4LL_NETWORK UINT32_C(0xA9FE0000)
@@ -63,6 +64,9 @@ struct sd_ipv4ll {
         void* userdata;
 };
 
+#define log_ipv4ll_errno(ll, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "IPV4LL: " fmt, ##__VA_ARGS__)
+#define log_ipv4ll(ll, fmt, ...) log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__)
+
 static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata);
 
 sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll) {
@@ -231,6 +235,7 @@ int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address) {
 #define PICK_HASH_KEY SD_ID128_MAKE(15,ac,82,a6,d6,3f,49,78,98,77,5d,0c,69,02,94,0b)
 
 static int ipv4ll_pick_address(sd_ipv4ll *ll) {
+        _cleanup_free_ char *address = NULL;
         be32_t addr;
 
         assert(ll);
@@ -248,6 +253,9 @@ static int ipv4ll_pick_address(sd_ipv4ll *ll) {
                 (be32toh(addr) & 0x0000FF00) == 0x0000 ||
                 (be32toh(addr) & 0x0000FF00) == 0xFF00);
 
+        (void) in_addr_to_string(AF_INET, &(union in_addr_union) { .in.s_addr = addr }, &address);
+        log_ipv4ll(ll, "Picked new IP address %s.", strna(address));
+
         return sd_ipv4ll_set_address(ll, &(struct in_addr) { addr });
 }