basic/in-addr-util: add IN_ADDR_TO_STRING

Since we don't need the error value, and the buffer is allocated with a fixed
size, the whole logic provided by in_addr_to_string() becomes unnecessary, so
it's enough to wrap inet_ntop() directly.

inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed
to be large enough, so this should never fail. A bunch of tests of this are added.
This allows all the wrappers like strna(), strnull(), strempty() to be dropped.

The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(),
because log_debug() implements the check outside of the function call. But
log_link_debug() does not, so it we need it to avoid unnecessary evaluation of
the formatting.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-06-03 11:24:02 +02:00
parent b547241728
commit 84dbb3fd83
23 changed files with 98 additions and 134 deletions

View File

@@ -444,7 +444,7 @@ int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
return -ENOMEM;
errno = 0;
if (!inet_ntop(family, u, x, l))
if (!typesafe_inet_ntop(family, u, x, l))
return errno_or_else(EINVAL);
*ret = TAKE_PTR(x);

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stddef.h>
#include <sys/socket.h>
@@ -68,10 +69,30 @@ int in_addr_prefix_range(
unsigned prefixlen,
union in_addr_union *ret_start,
union in_addr_union *ret_end);
int in_addr_to_string(int family, const union in_addr_union *u, char **ret);
static inline int in6_addr_to_string(const struct in6_addr *u, char **ret) {
return in_addr_to_string(AF_INET6, (const union in_addr_union*) u, ret);
}
static inline const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len) {
return inet_ntop(family, a, buf, len);
}
static inline const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len) {
return inet_ntop(AF_INET, a, buf, len);
}
static inline const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len) {
return inet_ntop(AF_INET6, a, buf, len);
}
/* Note: the lifetime of the compound literal is the immediately surrounding block,
* see C11 §6.5.2.5, and
* https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */
#define IN_ADDR_MAX CONST_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)
#define IN_ADDR_TO_STRING(family, addr) typesafe_inet_ntop(family, addr, (char[IN_ADDR_MAX]){}, IN_ADDR_MAX)
#define IN4_ADDR_TO_STRING(addr) typesafe_inet_ntop4(addr, (char[INET_ADDRSTRLEN]){}, INET_ADDRSTRLEN)
#define IN6_ADDR_TO_STRING(addr) typesafe_inet_ntop6(addr, (char[INET6_ADDRSTRLEN]){}, INET6_ADDRSTRLEN)
int in_addr_prefix_to_string(int family, const union in_addr_union *u, unsigned prefixlen, char **ret);
static inline int in6_addr_prefix_to_string(const struct in6_addr *u, unsigned prefixlen, char **ret) {
return in_addr_prefix_to_string(AF_INET6, (const union in_addr_union*) u, prefixlen, ret);

View File

@@ -1344,13 +1344,10 @@ int sd_dhcp6_client_start(sd_dhcp6_client *client) {
if (client->fd < 0) {
r = dhcp6_network_bind_udp_socket(client->ifindex, &client->local_address);
if (r < 0) {
_cleanup_free_ char *p = NULL;
(void) in6_addr_to_string(&client->local_address, &p);
if (r < 0)
return log_dhcp6_client_errno(client, r,
"Failed to bind to UDP socket at address %s: %m", strna(p));
}
"Failed to bind to UDP socket at address %s: %m",
IN6_ADDR_TO_STRING(&client->local_address));
client->fd = r;
}

View File

@@ -240,7 +240,6 @@ 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);
@@ -257,8 +256,7 @@ static int ipv4ll_pick_address(sd_ipv4ll *ll) {
} while (addr == ll->address ||
IN_SET(be32toh(addr) & 0x0000FF00U, 0x0000U, 0xFF00U));
(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));
log_ipv4ll(ll, "Picked new IP address %s.", IN4_ADDR_TO_STRING((const struct in_addr*) &addr));
return sd_ipv4ll_set_address(ll, &(struct in_addr) { addr });
}

View File

@@ -203,7 +203,6 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
sd_ndisc *nd = userdata;
ssize_t buflen;
int r;
_cleanup_free_ char *addr = NULL;
assert(s);
assert(nd);
@@ -229,8 +228,8 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
switch (r) {
case -EADDRNOTAVAIL:
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &rt->address, &addr);
log_ndisc(nd, "Received RA from non-link-local address %s. Ignoring", addr);
log_ndisc(nd, "Received RA from non-link-local address %s. Ignoring.",
IN6_ADDR_TO_STRING(&rt->address));
break;
case -EMULTIHOP:

View File

@@ -244,7 +244,6 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_us
static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_radv *ra = userdata;
_cleanup_free_ char *addr = NULL;
struct in6_addr src;
triple_timestamp timestamp;
int r;
@@ -275,8 +274,8 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
switch (r) {
case -EADDRNOTAVAIL:
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &src, &addr);
log_radv(ra, "Received RS from non-link-local address %s. Ignoring", addr);
log_radv(ra, "Received RS from non-link-local address %s. Ignoring",
IN6_ADDR_TO_STRING(&src));
break;
case -EMULTIHOP:
@@ -300,13 +299,13 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
return 0;
}
(void) in_addr_to_string(AF_INET6, (const union in_addr_union*) &src, &addr);
const char *addr = IN6_ADDR_TO_STRING(&src);
r = radv_send(ra, &src, ra->lifetime_usec);
if (r < 0)
log_radv_errno(ra, r, "Unable to send solicited Router Advertisement to %s, ignoring: %m", strnull(addr));
log_radv_errno(ra, r, "Unable to send solicited Router Advertisement to %s, ignoring: %m", addr);
else
log_radv(ra, "Sent solicited Router Advertisement to %s", strnull(addr));
log_radv(ra, "Sent solicited Router Advertisement to %s", addr);
return 0;
}

View File

@@ -19,23 +19,20 @@
#include "util.h"
static void ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
_cleanup_free_ char *address = NULL;
struct in_addr addr = {};
assert_se(ll);
if (sd_ipv4ll_get_address(ll, &addr) >= 0)
assert_se(in_addr_to_string(AF_INET, (const union in_addr_union*) &addr, &address) >= 0);
struct in_addr addr;
const char *pretty = sd_ipv4ll_get_address(ll, &addr) >= 0 ? IN4_ADDR_TO_STRING(&addr) : NULL;
switch (event) {
case SD_IPV4LL_EVENT_BIND:
log_info("bound %s", strna(address));
log_info("bound %s", strna(pretty));
break;
case SD_IPV4LL_EVENT_CONFLICT:
log_info("conflict on %s", strna(address));
log_info("conflict on %s", strna(pretty));
break;
case SD_IPV4LL_EVENT_STOP:
log_error("the client was stopped with address %s", strna(address));
log_error("the client was stopped with address %s", strna(pretty));
break;
default:
assert_not_reached();

View File

@@ -445,12 +445,9 @@ static int l2tp_create_tunnel(NetDev *netdev) {
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not find local address.");
if (t->local_address_type >= 0 && DEBUG_LOGGING) {
_cleanup_free_ char *str = NULL;
(void) in_addr_to_string(t->family, &local_address, &str);
log_netdev_debug(netdev, "Local address %s acquired.", strna(str));
}
if (t->local_address_type >= 0 && DEBUG_LOGGING)
log_netdev_debug(netdev, "Local address %s acquired.",
IN_ADDR_TO_STRING(t->family, &local_address));
r = netdev_l2tp_create_message_tunnel(netdev, &local_address, &m);
if (r < 0)

View File

@@ -648,7 +648,7 @@ const char* format_lifetime(char *buf, size_t l, usec_t lifetime_usec) {
}
static void log_address_debug(const Address *address, const char *str, const Link *link) {
_cleanup_free_ char *state = NULL, *addr = NULL, *peer = NULL, *flags_str = NULL, *scope_str = NULL;
_cleanup_free_ char *state = NULL, *flags_str = NULL, *scope_str = NULL;
assert(address);
assert(str);
@@ -658,16 +658,17 @@ static void log_address_debug(const Address *address, const char *str, const Lin
return;
(void) network_config_state_to_string_alloc(address->state, &state);
(void) in_addr_to_string(address->family, &address->in_addr, &addr);
if (in_addr_is_set(address->family, &address->in_addr_peer))
(void) in_addr_to_string(address->family, &address->in_addr_peer, &peer);
const char *peer = in_addr_is_set(address->family, &address->in_addr_peer) ?
IN_ADDR_TO_STRING(address->family, &address->in_addr_peer) : NULL;
(void) address_flags_to_string_alloc(address->flags, address->family, &flags_str);
(void) route_scope_to_string_alloc(address->scope, &scope_str);
log_link_debug(link, "%s %s address (%s): %s%s%s/%u (valid %s, preferred %s), flags: %s, scope: %s",
str, strna(network_config_source_to_string(address->source)), strna(state),
strnull(addr), peer ? " peer " : "", strempty(peer), address->prefixlen,
IN_ADDR_TO_STRING(address->family, &address->in_addr),
peer ? " peer " : "", strempty(peer), address->prefixlen,
FORMAT_LIFETIME(address->lifetime_valid_usec),
FORMAT_LIFETIME(address->lifetime_preferred_usec),
strna(flags_str), strna(scope_str));

View File

@@ -119,13 +119,9 @@ static int bridge_mdb_configure(BridgeMDB *mdb, Link *link, Request *req) {
assert(link->manager);
assert(req);
if (DEBUG_LOGGING) {
_cleanup_free_ char *a = NULL;
(void) in_addr_to_string(mdb->family, &mdb->group_addr, &a);
if (DEBUG_LOGGING)
log_link_debug(link, "Configuring bridge MDB entry: MulticastGroupAddress=%s, VLANId=%u",
strna(a), mdb->vlan_id);
}
IN_ADDR_TO_STRING(mdb->family, &mdb->group_addr), mdb->vlan_id);
entry = (struct br_mdb_entry) {
/* If MDB entry is added on bridge master, then the state must be MDB_TEMPORARY.

View File

@@ -153,7 +153,6 @@ static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Reques
}
static int verify_dhcp6_address(Link *link, const Address *address) {
_cleanup_free_ char *buffer = NULL;
bool by_ndisc = false;
Address *existing;
int log_level;
@@ -162,7 +161,7 @@ static int verify_dhcp6_address(Link *link, const Address *address) {
assert(address);
assert(address->family == AF_INET6);
(void) in6_addr_to_string(&address->in_addr.in6, &buffer);
const char *pretty = IN6_ADDR_TO_STRING(&address->in_addr.in6);
if (address_get(link, address, &existing) < 0 &&
link_get_address(link, AF_INET6, &address->in_addr, 0, &existing) < 0) {
@@ -180,10 +179,10 @@ static int verify_dhcp6_address(Link *link, const Address *address) {
by_ndisc = true;
log_link_warning(link, "Ignoring DHCPv6 address %s/%u (valid %s, preferred %s) which conflicts with %s/%u%s.",
strna(buffer), address->prefixlen,
pretty, address->prefixlen,
FORMAT_LIFETIME(address->lifetime_valid_usec),
FORMAT_LIFETIME(address->lifetime_preferred_usec),
strna(buffer), existing->prefixlen,
pretty, existing->prefixlen,
by_ndisc ? " assigned by NDisc" : "");
if (by_ndisc)
log_link_warning(link, "Hint: use IPv6Token= setting to change the address generated by NDisc or set UseAutonomousPrefix=no.");
@@ -192,7 +191,7 @@ static int verify_dhcp6_address(Link *link, const Address *address) {
simple_log:
log_link_full(link, log_level, "DHCPv6 address %s/%u (valid %s, preferred %s)",
strna(buffer), address->prefixlen,
pretty, address->prefixlen,
FORMAT_LIFETIME(address->lifetime_valid_usec),
FORMAT_LIFETIME(address->lifetime_preferred_usec));
return 0;
@@ -232,13 +231,9 @@ static int dhcp6_request_address(
r = link_request_address(link, TAKE_PTR(addr), true, &link->dhcp6_messages,
dhcp6_address_handler, NULL);
if (r < 0) {
_cleanup_free_ char *buffer = NULL;
(void) in6_addr_to_string(ip6_addr, &buffer);
return log_link_error_errno(link, r, "Failed to request DHCPv6 address %s/128: %m", strna(buffer));
}
if (r < 0)
return log_link_error_errno(link, r, "Failed to request DHCPv6 address %s/128: %m",
IN6_ADDR_TO_STRING(ip6_addr));
return 0;
}

View File

@@ -182,7 +182,6 @@ int link_update_ipv6ll_addrgen_mode(Link *link, sd_netlink_message *message) {
#define STABLE_SECRET_APP_ID_2 SD_ID128_MAKE(52,c4,40,a0,9f,2f,48,58,a9,3a,f6,29,25,ba,7a,7d)
int link_set_ipv6ll_stable_secret(Link *link) {
_cleanup_free_ char *str = NULL;
struct in6_addr a;
int r;
@@ -216,11 +215,8 @@ int link_set_ipv6ll_stable_secret(Link *link) {
memcpy(a.s6_addr + sizeof(v), &v, sizeof(v));
}
r = in6_addr_to_string(&a, &str);
if (r < 0)
return r;
return sysctl_write_ip_property(AF_INET6, link->ifname, "stable_secret", str);
return sysctl_write_ip_property(AF_INET6, link->ifname, "stable_secret",
IN6_ADDR_TO_STRING(&a));
}
int link_set_ipv6ll_addrgen_mode(Link *link, IPv6LinkLocalAddressGenMode mode) {

View File

@@ -327,13 +327,9 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
return log_link_error_errno(link, r, "Failed to get gateway address from RA: %m");
if (link_get_ipv6_address(link, &gateway, 0, NULL) >= 0) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *buffer = NULL;
(void) in6_addr_to_string(&gateway, &buffer);
if (DEBUG_LOGGING)
log_link_debug(link, "No NDisc route added, gateway %s matches local address",
strna(buffer));
}
IN6_ADDR_TO_STRING(&gateway));
return 0;
}
@@ -639,12 +635,9 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
return log_link_error_errno(link, r, "Failed to get gateway address from RA: %m");
if (link_get_ipv6_address(link, &gateway, 0, NULL) >= 0) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *buf = NULL;
(void) in6_addr_to_string(&gateway, &buf);
log_link_debug(link, "Advertised route gateway %s is local to the link, ignoring route", strna(buf));
}
if (DEBUG_LOGGING)
log_link_debug(link, "Advertised route gateway %s is local to the link, ignoring route",
IN6_ADDR_TO_STRING(&gateway));
return 0;
}
@@ -986,13 +979,10 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
if (in6_prefix_is_filtered(&router, 128, link->network->ndisc_allow_listed_router, link->network->ndisc_deny_listed_router)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *buf = NULL;
(void) in6_addr_to_string(&router, &buf);
if (!set_isempty(link->network->ndisc_allow_listed_router))
log_link_debug(link, "Router '%s' is not in allow list, ignoring", strna(buf));
log_link_debug(link, "Router %s is not in allow list, ignoring.", IN6_ADDR_TO_STRING(&router));
else
log_link_debug(link, "Router '%s' is in deny list, ignoring", strna(buf));
log_link_debug(link, "Router %s is in deny list, ignoring.", IN6_ADDR_TO_STRING(&router));
}
return 0;
}

View File

@@ -158,7 +158,7 @@ static int neighbor_add(Link *link, Neighbor *neighbor) {
}
static void log_neighbor_debug(const Neighbor *neighbor, const char *str, const Link *link) {
_cleanup_free_ char *state = NULL, *dst = NULL;
_cleanup_free_ char *state = NULL;
assert(neighbor);
assert(str);
@@ -167,12 +167,12 @@ static void log_neighbor_debug(const Neighbor *neighbor, const char *str, const
return;
(void) network_config_state_to_string_alloc(neighbor->state, &state);
(void) in_addr_to_string(neighbor->family, &neighbor->in_addr, &dst);
log_link_debug(link,
"%s %s neighbor (%s): lladdr: %s, dst: %s",
str, strna(network_config_source_to_string(neighbor->source)), strna(state),
HW_ADDR_TO_STR(&neighbor->ll_addr), strna(dst));
HW_ADDR_TO_STR(&neighbor->ll_addr),
IN_ADDR_TO_STRING(neighbor->family, &neighbor->in_addr));
}
static int neighbor_configure_message(Neighbor *neighbor, Link *link, sd_netlink_message *req) {

View File

@@ -346,7 +346,7 @@ static int nexthop_acquire_id(Manager *manager, NextHop *nexthop) {
}
static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Link *link) {
_cleanup_free_ char *state = NULL, *gw = NULL, *group = NULL, *flags = NULL;
_cleanup_free_ char *state = NULL, *group = NULL, *flags = NULL;
struct nexthop_grp *nhg;
assert(nexthop);
@@ -358,7 +358,6 @@ static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Lin
return;
(void) network_config_state_to_string_alloc(nexthop->state, &state);
(void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
(void) route_flags_to_string_alloc(nexthop->flags, &flags);
HASHMAP_FOREACH(nhg, nexthop->group)
@@ -366,7 +365,9 @@ static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Lin
log_link_debug(link, "%s %s nexthop (%s): id: %"PRIu32", gw: %s, blackhole: %s, group: %s, flags: %s",
str, strna(network_config_source_to_string(nexthop->source)), strna(state),
nexthop->id, strna(gw), yes_no(nexthop->blackhole), strna(group), strna(flags));
nexthop->id,
IN_ADDR_TO_STRING(nexthop->family, &nexthop->gw),
yes_no(nexthop->blackhole), strna(group), strna(flags));
}
static int nexthop_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {

View File

@@ -141,14 +141,9 @@ int expose_port_execute(sd_netlink *rtnl, FirewallContext **fw_ctx, ExposePort *
if (in_addr_equal(af, exposed, &new_exposed))
return 0;
if (DEBUG_LOGGING) {
_cleanup_free_ char *pretty = NULL;
in_addr_to_string(af, &new_exposed, &pretty);
log_debug("New container IP is %s.", strna(pretty));
}
log_debug("New container IP is %s.", IN_ADDR_TO_STRING(af, &new_exposed));
LIST_FOREACH(ports, p, l) {
r = fw_add_local_dnat(fw_ctx,
true,
af,

View File

@@ -596,11 +596,9 @@ static void bus_method_resolve_address_complete(DnsQuery *query) {
}
if (added <= 0) {
_cleanup_free_ char *ip = NULL;
(void) in_addr_to_string(q->request_family, &q->request_address, &ip);
r = reply_method_errorf(q, BUS_ERROR_NO_SUCH_RR,
"Address '%s' does not have any RR of requested type", strnull(ip));
"Address %s does not have any RR of requested type",
IN_ADDR_TO_STRING(q->request_family, &q->request_address));
goto finish;
}

View File

@@ -493,21 +493,15 @@ static int dns_cache_put_positive(
if (r < 0)
return r;
if (DEBUG_LOGGING) {
_cleanup_free_ char *t = NULL;
(void) in_addr_to_string(i->owner_family, &i->owner_address, &t);
log_debug("Added positive %s %s%s cache entry for %s "USEC_FMT"s on %s/%s/%s",
FLAGS_SET(i->query_flags, SD_RESOLVED_AUTHENTICATED) ? "authenticated" : "unauthenticated",
FLAGS_SET(i->query_flags, SD_RESOLVED_CONFIDENTIAL) ? "confidential" : "non-confidential",
i->shared_owner ? " shared" : "",
dns_resource_key_to_string(i->key, key_str, sizeof key_str),
(i->until - timestamp) / USEC_PER_SEC,
i->ifindex == 0 ? "*" : FORMAT_IFNAME(i->ifindex),
af_to_name_short(i->owner_family),
strna(t));
}
log_debug("Added positive %s %s%s cache entry for %s "USEC_FMT"s on %s/%s/%s",
FLAGS_SET(i->query_flags, SD_RESOLVED_AUTHENTICATED) ? "authenticated" : "unauthenticated",
FLAGS_SET(i->query_flags, SD_RESOLVED_CONFIDENTIAL) ? "confidential" : "non-confidential",
i->shared_owner ? " shared" : "",
dns_resource_key_to_string(i->key, key_str, sizeof key_str),
(i->until - timestamp) / USEC_PER_SEC,
i->ifindex == 0 ? "*" : FORMAT_IFNAME(i->ifindex),
af_to_name_short(i->owner_family),
IN_ADDR_TO_STRING(i->owner_family, &i->owner_address));
i = NULL;
return 0;

View File

@@ -333,7 +333,6 @@ static void dns_transaction_shuffle_id(DnsTransaction *t) {
}
static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
_cleanup_free_ char *pretty = NULL;
char key_str[DNS_RESOURCE_KEY_STRING_MAX];
DnsZoneItem *z;
@@ -344,15 +343,13 @@ static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
if (manager_packet_from_local_address(t->scope->manager, p) != 0)
return;
(void) in_addr_to_string(p->family, &p->sender, &pretty);
log_debug("Transaction %" PRIu16 " for <%s> on scope %s on %s/%s got tentative packet from %s.",
t->id,
dns_resource_key_to_string(dns_transaction_key(t), key_str, sizeof key_str),
dns_protocol_to_string(t->scope->protocol),
t->scope->link ? t->scope->link->ifname : "*",
af_to_name_short(t->scope->family),
strnull(pretty));
IN_ADDR_TO_STRING(p->family, &p->sender));
/* RFC 4795, Section 4.1 says that the peer with the
* lexicographically smaller IP address loses */

View File

@@ -870,16 +870,10 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
p->ifindex = manager_find_ifindex(m, p->family, &p->destination);
}
if (DEBUG_LOGGING) {
_cleanup_free_ char *sender_address = NULL, *destination_address = NULL;
(void) in_addr_to_string(p->family, &p->sender, &sender_address);
(void) in_addr_to_string(p->family, &p->destination, &destination_address);
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%i, fragsize=%zu, sender=%s, destination=%s",
dns_protocol_to_string(protocol), p->size, p->ifindex, p->ttl, p->fragsize,
strna(sender_address), strna(destination_address));
}
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%i, fragsize=%zu, sender=%s, destination=%s",
dns_protocol_to_string(protocol), p->size, p->ifindex, p->ttl, p->fragsize,
IN_ADDR_TO_STRING(p->family, &p->sender),
IN_ADDR_TO_STRING(p->family, &p->destination));
*ret = TAKE_PTR(p);
return 1;

Some files were not shown because too many files have changed in this diff Show More