This also changes the type from char[IF_NAMESIZE] to char*.
By changing the type, now resolved-link.h can drop the dependency to
the header net/if.h.
dns_scope_llmnr_membership(s, true);
dns_scope_mdns_membership(s, true);
- log_debug("New scope on link %s, protocol %s, family %s", l ? l->name : "*", dns_protocol_to_string(protocol), family == AF_UNSPEC ? "*" : af_to_name(family));
+ log_debug("New scope on link %s, protocol %s, family %s", l ? l->ifname : "*", dns_protocol_to_string(protocol), family == AF_UNSPEC ? "*" : af_to_name(family));
/* Enforce ratelimiting for the multicast protocols */
RATELIMIT_INIT(s->ratelimit, MULTICAST_RATELIMIT_INTERVAL_USEC, MULTICAST_RATELIMIT_BURST);
if (!s)
return NULL;
- log_debug("Removing scope on link %s, protocol %s, family %s", s->link ? s->link->name : "*", dns_protocol_to_string(s->protocol), s->family == AF_UNSPEC ? "*" : af_to_name(s->family));
+ log_debug("Removing scope on link %s, protocol %s, family %s", s->link ? s->link->ifname : "*", dns_protocol_to_string(s->protocol), s->family == AF_UNSPEC ? "*" : af_to_name(s->family));
dns_scope_llmnr_membership(s, false);
dns_scope_mdns_membership(s, false);
if (s->link) {
fputs(" interface=", f);
- fputs(s->link->name, f);
+ fputs(s->link->ifname, f);
}
if (s->family != AF_UNSPEC) {
assert(s->link);
fputs(" interface=", f);
- fputs(s->link->name, f);
+ fputs(s->link->ifname, f);
}
fputs("]\n", f);
t->id,
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
dns_protocol_to_string(t->scope->protocol),
- t->scope->link ? t->scope->link->name : "*",
+ t->scope->link ? t->scope->link->ifname : "*",
af_to_name_short(t->scope->family),
strnull(pretty));
t->id,
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
dns_protocol_to_string(t->scope->protocol),
- t->scope->link ? t->scope->link->name : "*",
+ t->scope->link ? t->scope->link->ifname : "*",
af_to_name_short(t->scope->family),
st,
t->answer_source < 0 ? "none" : dns_transaction_source_to_string(t->answer_source),
t->id,
dns_resource_key_to_string(t->key, key_str, sizeof key_str),
dns_protocol_to_string(t->scope->protocol),
- t->scope->link ? t->scope->link->name : "*",
+ t->scope->link ? t->scope->link->ifname : "*",
af_to_name_short(t->scope->family));
if (!t->initial_jitter_scheduled &&
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <net/if.h>
+
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "bus-util.h"
assert(l);
if (l->flags & IFF_LOOPBACK)
- return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is loopback device.", l->name);
+ return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is loopback device.", l->ifname);
if (l->is_managed)
- return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is managed.", l->name);
+ return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is managed.", l->ifname);
return 0;
}
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <net/if.h>
#include <linux/if.h>
#include <unistd.h>
dns_scope_free(l->mdns_ipv6_scope);
free(l->state_file);
+ free(l->ifname);
return mfree(l);
}
(void) sd_netlink_message_read_u8(m, IFLA_OPERSTATE, &l->operstate);
if (sd_netlink_message_read_string(m, IFLA_IFNAME, &n) >= 0) {
- strncpy(l->name, n, sizeof(l->name)-1);
- char_array_0(l->name);
+ r = free_and_strdup(&l->ifname, n);
+ if (r < 0)
+ return r;
}
link_allocate_scopes(l);
r = link_is_managed(l);
if (r < 0) {
- log_warning_errno(r, "Failed to determine whether interface %s is managed: %m", l->name);
+ log_warning_errno(r, "Failed to determine whether interface %s is managed: %m", l->ifname);
return;
}
if (r == 0) {
r = link_update_dns_servers(l);
if (r < 0)
- log_warning_errno(r, "Failed to read DNS servers for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read DNS servers for interface %s, ignoring: %m", l->ifname);
r = link_update_llmnr_support(l);
if (r < 0)
- log_warning_errno(r, "Failed to read LLMNR support for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read LLMNR support for interface %s, ignoring: %m", l->ifname);
r = link_update_mdns_support(l);
if (r < 0)
- log_warning_errno(r, "Failed to read mDNS support for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read mDNS support for interface %s, ignoring: %m", l->ifname);
r = link_update_dns_over_tls_mode(l);
if (r < 0)
- log_warning_errno(r, "Failed to read DNS-over-TLS mode for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read DNS-over-TLS mode for interface %s, ignoring: %m", l->ifname);
r = link_update_dnssec_mode(l);
if (r < 0)
- log_warning_errno(r, "Failed to read DNSSEC mode for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read DNSSEC mode for interface %s, ignoring: %m", l->ifname);
r = link_update_dnssec_negative_trust_anchors(l);
if (r < 0)
- log_warning_errno(r, "Failed to read DNSSEC negative trust anchors for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read DNSSEC negative trust anchors for interface %s, ignoring: %m", l->ifname);
r = link_update_search_domains(l);
if (r < 0)
- log_warning_errno(r, "Failed to read search domains for interface %s, ignoring: %m", l->name);
+ log_warning_errno(r, "Failed to read search domains for interface %s, ignoring: %m", l->ifname);
r = link_update_default_route(l);
if (r < 0)
- log_warning_errno(r, "Failed to read default route setting for interface %s, proceeding anyway: %m", l->name);
+ log_warning_errno(r, "Failed to read default route setting for interface %s, proceeding anyway: %m", l->ifname);
}
int link_update(Link *l) {
return s;
if (s)
- log_debug("Switching to DNS server %s for interface %s.", dns_server_string(s), l->name);
+ log_debug("Switching to DNS server %s for interface %s.", dns_server_string(s), l->ifname);
dns_server_unref(l->current_dns_server);
l->current_dns_server = dns_server_ref(s);
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-#include <net/if.h>
-
#include "in-addr-util.h"
#include "ratelimit.h"
#include "resolve-util.h"
bool is_managed;
- char name[IF_NAMESIZE];
+ char *ifname;
uint32_t mtu;
uint8_t operstate;
goto fail;
if (is_new)
- log_debug("Found new link %i/%s", ifindex, l->name);
+ log_debug("Found new link %i/%s", ifindex, l->ifname);
break;
}
case RTM_DELLINK:
if (l) {
- log_debug("Removing link %i/%s", l->ifindex, l->name);
+ log_debug("Removing link %i/%s", l->ifindex, l->ifname);
link_remove_user(l);
link_free(l);
}