mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
resolve: rename Link.name -> Link.ifname
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.
This commit is contained in:
parent
dc653bf487
commit
6ff79f7640
@ -67,7 +67,7 @@ int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol protocol, int
|
||||
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);
|
||||
@ -98,7 +98,7 @@ DnsScope* dns_scope_free(DnsScope *s) {
|
||||
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);
|
||||
@ -1137,7 +1137,7 @@ void dns_scope_dump(DnsScope *s, FILE *f) {
|
||||
|
||||
if (s->link) {
|
||||
fputs(" interface=", f);
|
||||
fputs(s->link->name, f);
|
||||
fputs(s->link->ifname, f);
|
||||
}
|
||||
|
||||
if (s->family != AF_UNSPEC) {
|
||||
|
@ -836,7 +836,7 @@ void dns_server_dump(DnsServer *s, FILE *f) {
|
||||
assert(s->link);
|
||||
|
||||
fputs(" interface=", f);
|
||||
fputs(s->link->name, f);
|
||||
fputs(s->link->ifname, f);
|
||||
}
|
||||
|
||||
fputs("]\n", f);
|
||||
|
@ -268,7 +268,7 @@ static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
|
||||
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));
|
||||
|
||||
@ -333,7 +333,7 @@ void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state) {
|
||||
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),
|
||||
@ -1648,7 +1648,7 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
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 &&
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-util.h"
|
||||
@ -190,9 +192,9 @@ static int verify_unmanaged_link(Link *l, sd_bus_error *error) {
|
||||
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;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <net/if.h>
|
||||
#include <linux/if.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -98,6 +97,7 @@ Link *link_free(Link *l) {
|
||||
dns_scope_free(l->mdns_ipv6_scope);
|
||||
|
||||
free(l->state_file);
|
||||
free(l->ifname);
|
||||
|
||||
return mfree(l);
|
||||
}
|
||||
@ -239,8 +239,9 @@ int link_process_rtnl(Link *l, sd_netlink_message *m) {
|
||||
(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);
|
||||
@ -596,7 +597,7 @@ static void link_read_settings(Link *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) {
|
||||
@ -613,35 +614,35 @@ static void link_read_settings(Link *l) {
|
||||
|
||||
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) {
|
||||
@ -728,7 +729,7 @@ DnsServer* link_set_dns_server(Link *l, DnsServer *s) {
|
||||
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);
|
||||
|
@ -1,8 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "in-addr-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "resolve-util.h"
|
||||
@ -67,7 +65,7 @@ struct Link {
|
||||
|
||||
bool is_managed;
|
||||
|
||||
char name[IF_NAMESIZE];
|
||||
char *ifname;
|
||||
uint32_t mtu;
|
||||
uint8_t operstate;
|
||||
|
||||
|
@ -82,14 +82,14 @@ static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user