]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd-network: make sd_dhcp_client_get_ifname() or friends return negative errno... 20860/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Sep 2021 13:04:52 +0000 (22:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Sep 2021 18:37:09 +0000 (03:37 +0900)
27 files changed:
src/libsystemd-network/dhcp-internal.h
src/libsystemd-network/dhcp-server-internal.h
src/libsystemd-network/dhcp6-internal.h
src/libsystemd-network/lldp-rx-internal.h
src/libsystemd-network/ndisc-internal.h
src/libsystemd-network/network-common.c
src/libsystemd-network/network-common.h
src/libsystemd-network/radv-internal.h
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-ipv4ll.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/shared/log-link.h
src/systemd/sd-dhcp-client.h
src/systemd/sd-dhcp-server.h
src/systemd/sd-dhcp6-client.h
src/systemd/sd-ipv4acd.h
src/systemd/sd-ipv4ll.h
src/systemd/sd-lldp-rx.h
src/systemd/sd-lldp-tx.h
src/systemd/sd-ndisc.h
src/systemd/sd-radv.h

index 16999971d2a8bb35783be2760ffc0891fd089bb0..6538f05bdb44b559473139b9176e2b50b28a607d 100644 (file)
@@ -12,7 +12,7 @@
 #include "sd-dhcp-client.h"
 
 #include "dhcp-protocol.h"
-#include "log-link.h"
+#include "network-common.h"
 #include "socket-util.h"
 
 typedef struct sd_dhcp_option {
@@ -75,10 +75,10 @@ void dhcp_client_set_test_mode(sd_dhcp_client *client, bool test_mode);
 #define log_dhcp_client_errno(client, error, fmt, ...)          \
         log_interface_prefix_full_errno(                        \
                 "DHCPv4 client: ",                              \
-                sd_dhcp_client_get_ifname(client),              \
+                sd_dhcp_client, client,                         \
                 error, fmt, ##__VA_ARGS__)
 #define log_dhcp_client(client, fmt, ...)                       \
         log_interface_prefix_full_errno_zerook(                 \
                 "DHCPv4 client: ",                              \
-                sd_dhcp_client_get_ifname(client),              \
+                sd_dhcp_client, client,                         \
                 0, fmt, ##__VA_ARGS__)
index 2bb7f3cce3c2984a6f737eb0a4b9413183b9954d..3b87a4c0668f1a5596cff22e7f6f217c901ef6d7 100644 (file)
@@ -9,8 +9,8 @@
 #include "sd-event.h"
 
 #include "dhcp-internal.h"
+#include "network-common.h"
 #include "ordered-set.h"
-#include "log-link.h"
 #include "time-util.h"
 
 typedef enum DHCPRawOption {
@@ -112,10 +112,10 @@ int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
 #define log_dhcp_server_errno(server, error, fmt, ...)          \
         log_interface_prefix_full_errno(                        \
                 "DHCPv4 server: ",                              \
-                sd_dhcp_server_get_ifname(server),              \
+                sd_dhcp_server, server,                         \
                 error, fmt, ##__VA_ARGS__)
 #define log_dhcp_server(server, fmt, ...)                       \
         log_interface_prefix_full_errno_zerook(                 \
                 "DHCPv4 server: ",                              \
-                sd_dhcp_server_get_ifname(server),              \
+                sd_dhcp_server, server,                         \
                 0, fmt, ##__VA_ARGS__)
index 35cafc96ec9cd93f66b33100f8b0cde2a530879e..91418ad3515e63aaca3b0665d057f38a4aee9472 100644 (file)
@@ -13,8 +13,8 @@
 
 #include "hashmap.h"
 #include "list.h"
-#include "log-link.h"
 #include "macro.h"
+#include "network-common.h"
 #include "sparse-endian.h"
 
 typedef struct sd_dhcp6_option {
@@ -125,10 +125,10 @@ void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode);
 #define log_dhcp6_client_errno(client, error, fmt, ...)         \
         log_interface_prefix_full_errno(                        \
                 "DHCPv6 client: ",                              \
-                sd_dhcp6_client_get_ifname(client),             \
+                sd_dhcp6_client, client,                        \
                 error, fmt, ##__VA_ARGS__)
 #define log_dhcp6_client(client, fmt, ...)                      \
         log_interface_prefix_full_errno_zerook(                 \
                 "DHCPv6 client: ",                              \
-                sd_dhcp6_client_get_ifname(client),             \
+                sd_dhcp6_client, client,                        \
                 0, fmt, ##__VA_ARGS__)
index 6d3ce0e1bcb4f34f4d975ff49938de9390979b17..83d0bc460da018ddc0255734287069d9590c38ac 100644 (file)
@@ -5,7 +5,7 @@
 #include "sd-lldp-rx.h"
 
 #include "hashmap.h"
-#include "log-link.h"
+#include "network-common.h"
 #include "prioq.h"
 
 struct sd_lldp_rx {
@@ -39,10 +39,10 @@ sd_lldp_rx_event_t lldp_rx_event_from_string(const char *s) _pure_;
 #define log_lldp_rx_errno(lldp_rx, error, fmt, ...)     \
         log_interface_prefix_full_errno(                \
                 "LLDP Rx: ",                            \
-                sd_lldp_rx_get_ifname(lldp_rx),         \
+                sd_lldp_rx, lldp_rx,                    \
                 error, fmt, ##__VA_ARGS__)
 #define log_lldp_rx(lldp_rx, fmt, ...)                  \
         log_interface_prefix_full_errno_zerook(         \
                 "LLDP Rx: ",                            \
-                sd_lldp_rx_get_ifname(lldp_rx),         \
+                sd_lldp_rx, lldp_rx,                    \
                 0, fmt, ##__VA_ARGS__)
index d43b5753526cf3f6957e0766365dcb8bccc1fa78..d379b44519446829c85fb761b3a6fe4f370370cf 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "sd-ndisc.h"
 
-#include "log-link.h"
+#include "network-common.h"
 #include "time-util.h"
 
 #define NDISC_ROUTER_SOLICITATION_INTERVAL (4U * USEC_PER_SEC)
@@ -44,10 +44,10 @@ sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
 #define log_ndisc_errno(ndisc, error, fmt, ...)         \
         log_interface_prefix_full_errno(                \
                 "NDISC: ",                              \
-                sd_ndisc_get_ifname(ndisc),             \
+                sd_ndisc, ndisc,                        \
                 error, fmt, ##__VA_ARGS__)
 #define log_ndisc(ndisc, fmt, ...)                      \
         log_interface_prefix_full_errno_zerook(         \
                 "NDISC: ",                              \
-                sd_ndisc_get_ifname(ndisc),             \
+                sd_ndisc, ndisc,                        \
                 0, fmt, ##__VA_ARGS__)
index c8f3305b190f0ec4e86e6b2ba423b5ce623a3594..b8b4ecdaae4e1d27ec326f87e6934de755f02073 100644 (file)
@@ -3,16 +3,13 @@
 #include "format-util.h"
 #include "network-common.h"
 
-const char *get_ifname(int ifindex, char **ifname) {
+int get_ifname(int ifindex, char **ifname) {
         assert(ifname);
 
         /* This sets ifname only when it is not set yet. */
 
         if (*ifname)
-                return *ifname;
+                return 0;
 
-        if (format_ifname_alloc(ifindex, ifname) < 0)
-                return NULL;
-
-        return *ifname;
+        return format_ifname_alloc(ifindex, ifname);
 }
index 76a6c4a98913c0a968bd87de4be9a3e37e112ab5..d43b76d4b8f16510f787dc4b6a26b8a14fd19940 100644 (file)
@@ -1,4 +1,28 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-const char *get_ifname(int ifindex, char **ifname);
+#include "log-link.h"
+
+#define log_interface_prefix_full_errno_zerook(prefix, type, val, error, fmt, ...) \
+        ({                                                              \
+                int _e = (error);                                       \
+                if (DEBUG_LOGGING) {                                    \
+                        const char *_n = NULL;                          \
+                                                                        \
+                        (void) type##_get_ifname(val, &_n);             \
+                        log_interface_full_errno_zerook(                \
+                                _n, LOG_DEBUG, _e, prefix fmt,          \
+                                ##__VA_ARGS__);                         \
+                }                                                       \
+                -ERRNO_VALUE(_e);                                       \
+        })
+
+#define log_interface_prefix_full_errno(prefix, type, val, error, fmt, ...) \
+        ({                                                              \
+                int _error = (error);                                   \
+                ASSERT_NON_ZERO(_error);                                \
+                log_interface_prefix_full_errno_zerook(                 \
+                        prefix, type, val, _error, fmt, ##__VA_ARGS__); \
+        })
+
+int get_ifname(int ifindex, char **ifname);
index 209425548baac1a5f6dbfcdbcbc0e21cd76f1412..ef566ed8ec2fa65dac9d1655dd1753c75e1e302f 100644 (file)
@@ -7,8 +7,8 @@
 
 #include "sd-radv.h"
 
-#include "log-link.h"
 #include "list.h"
+#include "network-common.h"
 #include "sparse-endian.h"
 
 assert_cc(SD_RADV_DEFAULT_MIN_TIMEOUT_USEC <= SD_RADV_DEFAULT_MAX_TIMEOUT_USEC);
@@ -128,10 +128,10 @@ struct sd_radv_route_prefix {
 #define log_radv_errno(radv, error, fmt, ...)           \
         log_interface_prefix_full_errno(                \
                 "RADV: ",                               \
-                sd_radv_get_ifname(radv),               \
+                sd_radv, radv,                          \
                 error, fmt, ##__VA_ARGS__)
 #define log_radv(radv, fmt, ...)                        \
         log_interface_prefix_full_errno_zerook(         \
                 "RADV: ",                               \
-                sd_radv_get_ifname(radv),               \
+                sd_radv, radv,                          \
                 0, fmt, ##__VA_ARGS__)
index 72dbd95145f47944612d6e5f1d46fe369fec57f7..45c2351c53e4d0eeb71261a1a3e32f673e89429a 100644 (file)
@@ -297,11 +297,19 @@ int sd_dhcp_client_set_ifname(sd_dhcp_client *client, const char *ifname) {
         return free_and_strdup(&client->ifname, ifname);
 }
 
-const char *sd_dhcp_client_get_ifname(sd_dhcp_client *client) {
-        if (!client)
-                return NULL;
+int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret) {
+        int r;
 
-        return get_ifname(client->ifindex, &client->ifname);
+        assert_return(client, -EINVAL);
+
+        r = get_ifname(client->ifindex, &client->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = client->ifname;
+
+        return 0;
 }
 
 int sd_dhcp_client_set_mac(
index a075469e828b14e0cc179cc24bb86db7975db170..45ac70b4616322fec61a802ca246918059f4ed3a 100644 (file)
@@ -230,11 +230,19 @@ int sd_dhcp_server_set_ifname(sd_dhcp_server *server, const char *ifname) {
         return free_and_strdup(&server->ifname, ifname);
 }
 
-const char *sd_dhcp_server_get_ifname(sd_dhcp_server *server) {
-        if (!server)
-                return NULL;
+int sd_dhcp_server_get_ifname(sd_dhcp_server *server, const char **ret) {
+        int r;
+
+        assert_return(server, -EINVAL);
 
-        return get_ifname(server->ifindex, &server->ifname);
+        r = get_ifname(server->ifindex, &server->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = server->ifname;
+
+        return 0;
 }
 
 int sd_dhcp_server_attach_event(sd_dhcp_server *server, sd_event *event, int64_t priority) {
index adc65cd70e4299a547ef4f08c479d22084216bed..298a89b086b8754576b311df72cf53d847602ae6 100644 (file)
@@ -179,11 +179,19 @@ int sd_dhcp6_client_set_ifname(sd_dhcp6_client *client, const char *ifname) {
         return free_and_strdup(&client->ifname, ifname);
 }
 
-const char *sd_dhcp6_client_get_ifname(sd_dhcp6_client *client) {
-        if (!client)
-                return NULL;
+int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret) {
+        int r;
+
+        assert_return(client, -EINVAL);
+
+        r = get_ifname(client->ifindex, &client->ifname);
+        if (r < 0)
+                return r;
 
-        return get_ifname(client->ifindex, &client->ifname);
+        if (ret)
+                *ret = client->ifname;
+
+        return 0;
 }
 
 int sd_dhcp6_client_set_local_address(
index 1e30aad2310f9283251a53b17f60778e0962f06f..0a975fbbadf357ee8347ac136419100cd3e33000 100644 (file)
@@ -17,7 +17,6 @@
 #include "event-util.h"
 #include "fd-util.h"
 #include "in-addr-util.h"
-#include "log-link.h"
 #include "memory-util.h"
 #include "network-common.h"
 #include "random-util.h"
@@ -81,12 +80,12 @@ struct sd_ipv4acd {
 #define log_ipv4acd_errno(acd, error, fmt, ...)         \
         log_interface_prefix_full_errno(                \
                 "IPv4ACD: ",                            \
-                sd_ipv4acd_get_ifname(acd),             \
+                sd_ipv4acd, acd,                        \
                 error, fmt, ##__VA_ARGS__)
 #define log_ipv4acd(acd, fmt, ...)                      \
         log_interface_prefix_full_errno_zerook(         \
                 "IPv4ACD: ",                            \
-                sd_ipv4acd_get_ifname(acd),             \
+                sd_ipv4acd, acd,                        \
                 0, fmt, ##__VA_ARGS__)
 
 static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = {
@@ -445,11 +444,19 @@ int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *ifname) {
         return free_and_strdup(&acd->ifname, ifname);
 }
 
-const char *sd_ipv4acd_get_ifname(sd_ipv4acd *acd) {
-        if (!acd)
-                return NULL;
+int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret) {
+        int r;
 
-        return get_ifname(acd->ifindex, &acd->ifname);
+        assert_return(acd, -EINVAL);
+
+        r = get_ifname(acd->ifindex, &acd->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = acd->ifname;
+
+        return 0;
 }
 
 int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr) {
index f2cc22db266b1329bbfc6f29503f3fe9980da021..ff065fd1b6469d2658250d9ddd3321950d376b12 100644 (file)
@@ -15,7 +15,7 @@
 #include "alloc-util.h"
 #include "ether-addr-util.h"
 #include "in-addr-util.h"
-#include "log-link.h"
+#include "network-common.h"
 #include "random-util.h"
 #include "siphash24.h"
 #include "sparse-endian.h"
@@ -55,12 +55,12 @@ struct sd_ipv4ll {
 #define log_ipv4ll_errno(ll, error, fmt, ...)           \
         log_interface_prefix_full_errno(                \
                 "IPv4LL: ",                             \
-                sd_ipv4ll_get_ifname(ll),               \
+                sd_ipv4ll, ll,                          \
                 error, fmt, ##__VA_ARGS__)
 #define log_ipv4ll(ll, fmt, ...)                        \
         log_interface_prefix_full_errno_zerook(         \
                 "IPv4LL: ",                             \
-                sd_ipv4ll_get_ifname(ll),               \
+                sd_ipv4ll, ll,                          \
                 0, fmt, ##__VA_ARGS__)
 
 static void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata);
@@ -133,11 +133,10 @@ int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *ifname) {
         return sd_ipv4acd_set_ifname(ll->acd, ifname);
 }
 
-const char *sd_ipv4ll_get_ifname(sd_ipv4ll *ll) {
-        if (!ll)
-                return NULL;
+int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret) {
+        assert_return(ll, -EINVAL);
 
-        return sd_ipv4acd_get_ifname(ll->acd);
+        return sd_ipv4acd_get_ifname(ll->acd, ret);
 }
 
 int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) {
index 98bde8b306839b79b48448dee307348fd60dc9a2..7224d3a345db6ec1e5fe3d1c0b50a143eb086c95 100644 (file)
@@ -359,11 +359,19 @@ int sd_lldp_rx_set_ifname(sd_lldp_rx *lldp_rx, const char *ifname) {
         return free_and_strdup(&lldp_rx->ifname, ifname);
 }
 
-const char *sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx) {
-        if (!lldp_rx)
-                return NULL;
+int sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx, const char **ret) {
+        int r;
+
+        assert_return(lldp_rx, -EINVAL);
 
-        return get_ifname(lldp_rx->ifindex, &lldp_rx->ifname);
+        r = get_ifname(lldp_rx->ifindex, &lldp_rx->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = lldp_rx->ifname;
+
+        return 0;
 }
 
 static sd_lldp_rx *lldp_rx_free(sd_lldp_rx *lldp_rx) {
index 24003af7e148f20383c2e76d015181da6cc7ff3d..4d2ab0571344e6958323f90fa8837d91e03585a7 100644 (file)
@@ -12,7 +12,6 @@
 #include "ether-addr-util.h"
 #include "fd-util.h"
 #include "hostname-util.h"
-#include "log-link.h"
 #include "network-common.h"
 #include "random-util.h"
 #include "socket-util.h"
@@ -70,12 +69,12 @@ struct sd_lldp_tx {
 #define log_lldp_tx_errno(lldp_tx, error, fmt, ...)     \
         log_interface_prefix_full_errno(                \
                 "LLDP Tx: ",                            \
-                sd_lldp_tx_get_ifname(lldp_tx),         \
+                sd_lldp_tx, lldp_tx,                    \
                 error, fmt, ##__VA_ARGS__)
 #define log_lldp_tx(lldp_tx, fmt, ...)                  \
         log_interface_prefix_full_errno_zerook(         \
                 "LLDP Tx: ",                            \
-                sd_lldp_tx_get_ifname(lldp_tx),         \
+                sd_lldp_tx, lldp_tx,                    \
                 0, fmt, ##__VA_ARGS__)
 
 static sd_lldp_tx *lldp_tx_free(sd_lldp_tx *lldp_tx) {
@@ -131,11 +130,19 @@ int sd_lldp_tx_set_ifname(sd_lldp_tx *lldp_tx, const char *ifname) {
         return free_and_strdup(&lldp_tx->ifname, ifname);
 }
 
-const char *sd_lldp_tx_get_ifname(sd_lldp_tx *lldp_tx) {
-        if (!lldp_tx)
-                return NULL;
+int sd_lldp_tx_get_ifname(sd_lldp_tx *lldp_tx, const char **ret) {
+        int r;
 
-        return get_ifname(lldp_tx->ifindex, &lldp_tx->ifname);
+        assert_return(lldp_tx, -EINVAL);
+
+        r = get_ifname(lldp_tx->ifindex, &lldp_tx->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = lldp_tx->ifname;
+
+        return 0;
 }
 
 int sd_lldp_tx_set_multicast_mode(sd_lldp_tx *lldp_tx, sd_lldp_multicast_mode_t mode) {
@@ -222,7 +229,7 @@ static size_t lldp_tx_calculate_maximum_packet_size(sd_lldp_tx *lldp_tx, const c
                 /* Chassis ID */
                 2 + 1 + (SD_ID128_STRING_MAX - 1) +
                 /* Port ID */
-                2 + 1 + strlen_ptr(sd_lldp_tx_get_ifname(lldp_tx)) +
+                2 + 1 + strlen_ptr(lldp_tx->ifname) +
                 /* Port description */
                 2 + strlen_ptr(lldp_tx->port_description) +
                 /* System name */
@@ -334,6 +341,11 @@ static int lldp_tx_create_packet(sd_lldp_tx *lldp_tx, size_t *ret_packet_size, u
         assert(ret_packet_size);
         assert(ret_packet);
 
+        /* If ifname is not set yet, set ifname from ifindex. */
+        r = sd_lldp_tx_get_ifname(lldp_tx, NULL);
+        if (r < 0)
+                return r;
+
         r = sd_id128_get_machine(&machine_id);
         if (r < 0)
                 return r;
@@ -365,7 +377,7 @@ static int lldp_tx_create_packet(sd_lldp_tx *lldp_tx, size_t *ret_packet_size, u
 
         r = packet_append_prefixed_string(packet, packet_size, &offset, SD_LLDP_TYPE_PORT_ID,
                                           1, (const uint8_t[]) { SD_LLDP_PORT_SUBTYPE_INTERFACE_NAME },
-                                          sd_lldp_tx_get_ifname(lldp_tx));
+                                          lldp_tx->ifname);
         if (r < 0)
                 return r;
 
index 0c27b7ea72dca20773ce06489d7c410e35e8e7a5..65f75cc2506e555aba17e747505cc8626f97c316 100644 (file)
@@ -74,11 +74,19 @@ int sd_ndisc_set_ifname(sd_ndisc *nd, const char *ifname) {
         return free_and_strdup(&nd->ifname, ifname);
 }
 
-const char *sd_ndisc_get_ifname(sd_ndisc *nd) {
-        if (!nd)
-                return NULL;
+int sd_ndisc_get_ifname(sd_ndisc *nd, const char **ret) {
+        int r;
+
+        assert_return(nd, -EINVAL);
 
-        return get_ifname(nd->ifindex, &nd->ifname);
+        r = get_ifname(nd->ifindex, &nd->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = nd->ifname;
+
+        return 0;
 }
 
 _public_ int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr) {
index fd16a70a54547a4dff9050e01ded20d7f62a87f5..ae33894302b9da9fb290fde65cdb8e701edac376 100644 (file)
@@ -438,11 +438,19 @@ int sd_radv_set_ifname(sd_radv *ra, const char *ifname) {
         return free_and_strdup(&ra->ifname, ifname);
 }
 
-const char *sd_radv_get_ifname(sd_radv *ra) {
-        if (!ra)
-                return NULL;
+int sd_radv_get_ifname(sd_radv *ra, const char **ret) {
+        int r;
+
+        assert_return(ra, -EINVAL);
 
-        return get_ifname(ra->ifindex, &ra->ifname);
+        r = get_ifname(ra->ifindex, &ra->ifname);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = ra->ifname;
+
+        return 0;
 }
 
 _public_ int sd_radv_set_mac(sd_radv *ra, const struct ether_addr *mac_addr) {
index 51eaa0c06e28c13e444e7f37fbe0f923ec8ad696..5f2b176353b70f35f06aebda850869f71af178c0 100644 (file)
                 log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \
         })
 
-#define log_interface_prefix_full_errno_zerook(prefix, ifname_expr, error, fmt, ...) \
-        ({                                                              \
-                int _e = (error);                                       \
-                if (DEBUG_LOGGING)                                      \
-                        log_interface_full_errno_zerook(                \
-                                ifname_expr,                            \
-                                LOG_DEBUG, _e, prefix fmt,              \
-                                ##__VA_ARGS__);                         \
-                -ERRNO_VALUE(_e);                                       \
-        })
-
-#define log_interface_prefix_full_errno(prefix, ifname_expr, error, fmt, ...) \
-        ({                                                              \
-                int _error = (error);                                   \
-                ASSERT_NON_ZERO(_error);                                \
-                log_interface_prefix_full_errno_zerook(prefix, ifname_expr, _error, fmt, ##__VA_ARGS__); \
-        })
-
 /*
  * The following macros append INTERFACE= to the message.
  * The macros require a struct named 'Link' which contains 'char *ifname':
index 5300234098f9424069ab660a22c568c47ebb7b54..23979b1232da20913bf72ffb3e00627b6cdc4573 100644 (file)
@@ -135,7 +135,7 @@ int sd_dhcp_client_set_ifindex(
 int sd_dhcp_client_set_ifname(
                 sd_dhcp_client *client,
                 const char *interface_name);
-const char *sd_dhcp_client_get_ifname(sd_dhcp_client *client);
+int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret);
 int sd_dhcp_client_set_mac(
                 sd_dhcp_client *client,
                 const uint8_t *addr,
index 7d42bc1dab04695aecde0e035b6e208b99d534d2..149a14fdc6a8061cd3e3b6b3794f8cbbca7cb144 100644 (file)
@@ -38,7 +38,7 @@ enum {
 int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex);
 
 int sd_dhcp_server_set_ifname(sd_dhcp_server *server, const char *ifname);
-const char *sd_dhcp_server_get_ifname(sd_dhcp_server *server);
+int sd_dhcp_server_get_ifname(sd_dhcp_server *server, const char **ret);
 
 sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server);
 sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server);
index e02d67632a102f7f84d9d3cab6103d87a8b3067f..f3889782bc0d1b70304edf9da1b6447779630e51 100644 (file)
@@ -94,7 +94,7 @@ int sd_dhcp6_client_set_ifindex(
 int sd_dhcp6_client_set_ifname(
                 sd_dhcp6_client *client,
                 const char *interface_name);
-const char * sd_dhcp6_client_get_ifname(sd_dhcp6_client *client);
+int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret);
 int sd_dhcp6_client_set_local_address(
                 sd_dhcp6_client *client,
                 const struct in6_addr *local_address);
index 3213db553c8cae50639fef4affa9e1467e6e1a40..90d3f0a0d115900f9b8f4966ef0762958f7d1416 100644 (file)
@@ -47,7 +47,7 @@ int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr);
 int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int interface_index);
 int sd_ipv4acd_get_ifindex(sd_ipv4acd *acd);
 int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *interface_name);
-const char *sd_ipv4acd_get_ifname(sd_ipv4acd *acd);
+int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret);
 int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address);
 int sd_ipv4acd_is_running(sd_ipv4acd *acd);
 int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts);
index 27263bc837785de5fcc92da7e0fd68b1c927e88f..ed014b53f22f558818f1e672dc86d8b10df5b098 100644 (file)
@@ -47,7 +47,7 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr);
 int sd_ipv4ll_set_ifindex(sd_ipv4ll *ll, int interface_index);
 int sd_ipv4ll_get_ifindex(sd_ipv4ll *ll);
 int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *interface_name);
-const char *sd_ipv4ll_get_ifname(sd_ipv4ll *ll);
+int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret);
 int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address);
 int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed);
 int sd_ipv4ll_is_running(sd_ipv4ll *ll);
index 4653626eee0a3cf60bc8c16a0dc26fc3bd835dbc..bfeac14ce3e3621e554a3b767f3491fb375f6539 100644 (file)
@@ -59,7 +59,7 @@ sd_event *sd_lldp_rx_get_event(sd_lldp_rx *lldp_rx);
 int sd_lldp_rx_set_callback(sd_lldp_rx *lldp_rx, sd_lldp_rx_callback_t cb, void *userdata);
 int sd_lldp_rx_set_ifindex(sd_lldp_rx *lldp_rx, int ifindex);
 int sd_lldp_rx_set_ifname(sd_lldp_rx *lldp_rx, const char *ifname);
-const char *sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx);
+int sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx, const char **ret);
 
 /* Controls how much and what to store in the neighbors database */
 int sd_lldp_rx_set_neighbors_max(sd_lldp_rx *lldp_rx, uint64_t n);
index aef06ed7eb0d13f9a4497ff065b880b0334b1e3f..512d455c71d0daf9b161a647208dbbc9b306baba 100644 (file)
@@ -54,7 +54,7 @@ sd_event *sd_lldp_tx_get_event(sd_lldp_tx *lldp_tx);
 
 int sd_lldp_tx_set_ifindex(sd_lldp_tx *lldp_tx, int ifindex);
 int sd_lldp_tx_set_ifname(sd_lldp_tx *lldp_tx, const char *ifname);
-const char *sd_lldp_tx_get_ifname(sd_lldp_tx *lldp_tx);
+int sd_lldp_tx_get_ifname(sd_lldp_tx *lldp_tx, const char **ret);
 
 int sd_lldp_tx_set_multicast_mode(sd_lldp_tx *lldp_tx, sd_lldp_multicast_mode_t mode);
 int sd_lldp_tx_set_hwaddr(sd_lldp_tx *lldp_tx, const struct ether_addr *hwaddr);
index 6088def1b61d257582ca1412a529ef87fe9b48bf..f45b2ad65ecc6256a7d9a06f949a725a427c249e 100644 (file)
@@ -79,7 +79,7 @@ sd_event *sd_ndisc_get_event(sd_ndisc *nd);
 int sd_ndisc_set_callback(sd_ndisc *nd, sd_ndisc_callback_t cb, void *userdata);
 int sd_ndisc_set_ifindex(sd_ndisc *nd, int interface_index);
 int sd_ndisc_set_ifname(sd_ndisc *nd, const char *interface_name);
-const char *sd_ndisc_get_ifname(sd_ndisc *nd);
+int sd_ndisc_get_ifname(sd_ndisc *nd, const char **ret);
 int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr);
 
 int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *ret);
index be5cf1b94e65d867d87b20f4d7a1ed14ba77b66e..6bf56def403a8058ef4ebf343ac6c4beb148c7c7 100644 (file)
@@ -54,7 +54,7 @@ int sd_radv_is_running(sd_radv *ra);
 
 int sd_radv_set_ifindex(sd_radv *ra, int interface_index);
 int sd_radv_set_ifname(sd_radv *ra, const char *interface_name);
-const char *sd_radv_get_ifname(sd_radv *ra);
+int sd_radv_get_ifname(sd_radv *ra, const char **ret);
 int sd_radv_set_mac(sd_radv *ra, const struct ether_addr *mac_addr);
 int sd_radv_set_mtu(sd_radv *ra, uint32_t mtu);
 int sd_radv_set_hop_limit(sd_radv *ra, uint8_t hop_limit);