summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-event/test-event.c9
-rw-r--r--src/locale/kbd-model-map5
-rw-r--r--src/locale/test-keymap-util.c4
-rw-r--r--src/network/networkd-address-label.c3
-rw-r--r--src/network/networkd-address.c28
-rw-r--r--src/network/networkd-address.h3
-rw-r--r--src/network/networkd-dhcp4.c60
-rw-r--r--src/network/networkd-dhcp6.c16
-rw-r--r--src/network/networkd-ipv4ll.c2
-rw-r--r--src/network/networkd-link.c90
-rw-r--r--src/network/networkd-link.h2
-rw-r--r--src/network/networkd-manager.c1
-rw-r--r--src/network/networkd-manager.h1
-rw-r--r--src/network/networkd-ndisc.c4
-rw-r--r--src/network/networkd-route.c57
-rw-r--r--src/network/networkd-route.h3
-rw-r--r--src/systemctl/systemctl-show.c2
17 files changed, 139 insertions, 151 deletions
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index 0bc2f507aa..7ff1452e08 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -438,13 +438,12 @@ static int inotify_handler(sd_event_source *s, const struct inotify_event *ev, v
log_info("inotify-handler <%s>: overflow", description);
c->create_overflow |= bit;
} else if (ev->mask & IN_CREATE) {
- unsigned i;
-
- log_debug("inotify-handler <%s>: create on %s", description, ev->name);
+ if (streq(ev->name, "sub"))
+ log_debug("inotify-handler <%s>: create on %s", description, ev->name);
+ else {
+ unsigned i;
- if (!streq(ev->name, "sub")) {
assert_se(safe_atou(ev->name, &i) >= 0);
-
assert_se(i < c->n_create_events);
c->create_called[i] |= bit;
}
diff --git a/src/locale/kbd-model-map b/src/locale/kbd-model-map
index 8fa984f83b..81d55853ca 100644
--- a/src/locale/kbd-model-map
+++ b/src/locale/kbd-model-map
@@ -1,4 +1,4 @@
-# Generated from system-config-keyboard's model list
+# Originally generated from system-config-keyboard's model list.
# consolelayout xlayout xmodel xvariant xoptions
sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp
nl nl pc105 - terminate:ctrl_alt_bksp
@@ -63,6 +63,7 @@ by by,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
il il pc105 - terminate:ctrl_alt_bksp
kazakh kz,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
lt.baltic lt pc105 - terminate:ctrl_alt_bksp
-lt.l4 lt pc105 - terminate:ctrl_alt_bksp
+lt.l4 lt pc105 - terminate:ctrl_alt_bksp
lt lt pc105 - terminate:ctrl_alt_bksp
khmer kh,us pc105 - terminate:ctrl_alt_bksp
+es-dvorak es microsoftpro dvorak terminate:ctrl_alt_bksp
diff --git a/src/locale/test-keymap-util.c b/src/locale/test-keymap-util.c
index bded122399..6f60aba38c 100644
--- a/src/locale/test-keymap-util.c
+++ b/src/locale/test-keymap-util.c
@@ -93,9 +93,9 @@ static void test_vconsole_convert_to_x11(void) {
log_info("/* test with known variant, new mapping (es:dvorak) */");
assert_se(free_and_strdup(&c.vc_keymap, "es-dvorak") >= 0);
- assert_se(vconsole_convert_to_x11(&c) == 0); // FIXME
+ assert_se(vconsole_convert_to_x11(&c) == 1);
assert_se(streq(c.x11_layout, "es"));
- assert_se(c.x11_variant == NULL); // FIXME: "dvorak"
+ assert_se(streq(c.x11_variant, "dvorak"));
log_info("/* test with old mapping (fr:latin9) */");
assert_se(free_and_strdup(&c.vc_keymap, "fr-latin9") >= 0);
diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c
index 9c9d283868..3152cbcca9 100644
--- a/src/network/networkd-address-label.c
+++ b/src/network/networkd-address-label.c
@@ -82,8 +82,7 @@ static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
log_link_message_warning_errno(link, m, r, "Could not set address label");
link_enter_failed(link);
return 1;
- } else if (r >= 0)
- (void) manager_rtnl_process_address(rtnl, m, link->manager);
+ }
if (link->address_label_messages == 0)
log_link_debug(link, "Addresses label set");
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 2bc860954b..1a7e626f08 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -653,14 +653,13 @@ static int address_set_netlink_message(const Address *address, sd_netlink_messag
return 0;
}
-int address_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg) {
+static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
assert(rtnl);
assert(m);
assert(link);
assert(link->address_remove_messages > 0);
- assert(error_msg);
link->address_remove_messages--;
@@ -669,22 +668,12 @@ int address_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Lin
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
- log_link_message_warning_errno(link, m, r, error_msg);
- else if (r >= 0)
- (void) manager_rtnl_process_address(rtnl, m, link->manager);
+ log_link_message_warning_errno(link, m, r, "Could not drop address");
return 1;
}
-static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- return address_remove_handler_internal(rtnl, m, link, "Could not drop address");
-}
-
-int address_remove(
- const Address *address,
- Link *link,
- link_netlink_message_handler_t callback) {
-
+int address_remove(const Address *address, Link *link) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
int r;
@@ -707,7 +696,7 @@ int address_remove(
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req,
- callback ?: address_remove_handler,
+ address_remove_handler,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
@@ -834,7 +823,7 @@ int link_drop_foreign_addresses(Link *link) {
r = k;
}
} else {
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0 && r >= 0)
r = k;
}
@@ -854,7 +843,7 @@ int link_drop_addresses(Link *link) {
if (address->family == AF_INET6 && in6_addr_is_link_local(&address->in_addr.in6) == 1 && link_ipv6ll_enabled(link))
continue;
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0 && r >= 0) {
r = k;
continue;
@@ -934,8 +923,7 @@ int address_configure_handler_internal(sd_netlink *rtnl, sd_netlink_message *m,
log_link_message_warning_errno(link, m, r, error_msg);
link_enter_failed(link);
return 0;
- } else if (r >= 0)
- (void) manager_rtnl_process_address(rtnl, m, link->manager);
+ }
return 1;
}
@@ -1434,7 +1422,7 @@ static void static_address_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
case SD_IPV4ACD_EVENT_CONFLICT:
log_link_warning(link, "DAD conflict. Dropping address "IPV4_ADDRESS_FMT_STR,
IPV4_ADDRESS_FMT_VAL(address->in_addr.in));
- r = address_remove(address, link, NULL);
+ r = address_remove(address, link);
if (r < 0)
log_link_error_errno(link, r, "Failed to drop DAD conflicted address "IPV4_ADDRESS_FMT_STR,
IPV4_ADDRESS_FMT_VAL(address->in_addr.in));
diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h
index f63848e2e7..af9f05c1e9 100644
--- a/src/network/networkd-address.h
+++ b/src/network/networkd-address.h
@@ -53,8 +53,7 @@ int address_new(Address **ret);
Address *address_free(Address *address);
int address_get(Link *link, const Address *in, Address **ret);
int address_configure_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
-int address_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
-int address_remove(const Address *address, Link *link, link_netlink_message_handler_t callback);
+int address_remove(const Address *address, Link *link);
bool address_equal(const Address *a1, const Address *a2);
bool address_is_ready(const Address *a);
void address_set_broadcast(Address *a);
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index abb37a3d26..e9e6fe72c4 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -66,13 +66,13 @@ static int dhcp4_release_old_lease(Link *link) {
log_link_debug(link, "Removing old DHCPv4 address and routes.");
SET_FOREACH(route, link->dhcp_routes_old) {
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
}
if (link->dhcp_address_old) {
- k = address_remove(link->dhcp_address_old, link, NULL);
+ k = address_remove(link->dhcp_address_old, link);
if (k < 0)
r = k;
}
@@ -180,6 +180,10 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
if (r < 0)
link_enter_failed(link);
+ r = dhcp4_request_address_and_routes(link, false);
+ if (r < 0)
+ link_enter_failed(link);
+
return 1;
}
@@ -712,48 +716,6 @@ static int dhcp_reset_hostname(Link *link) {
return 0;
}
-static int dhcp4_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- int r;
-
- assert(link);
- assert(link->dhcp4_remove_messages > 0);
-
- link->dhcp4_remove_messages--;
-
- r = link_route_remove_handler_internal(rtnl, m, link, "Failed to remove DHCPv4 route, ignoring");
- if (r <= 0)
- return r;
-
- if (link->dhcp4_remove_messages == 0) {
- r = dhcp4_request_address_and_routes(link, false);
- if (r < 0)
- link_enter_failed(link);
- }
-
- return 1;
-}
-
-static int dhcp4_address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- int r;
-
- assert(link);
- assert(link->dhcp4_remove_messages > 0);
-
- link->dhcp4_remove_messages--;
-
- r = address_remove_handler_internal(rtnl, m, link, "Failed to remove DHCPv4 address, ignoring");
- if (r <= 0)
- return r;
-
- if (link->dhcp4_remove_messages == 0) {
- r = dhcp4_request_address_and_routes(link, false);
- if (r < 0)
- link_enter_failed(link);
- }
-
- return 1;
-}
-
static int dhcp4_remove_all(Link *link) {
Route *route;
int k, r = 0;
@@ -761,19 +723,15 @@ static int dhcp4_remove_all(Link *link) {
assert(link);
SET_FOREACH(route, link->dhcp_routes) {
- k = route_remove(route, NULL, link, dhcp4_route_remove_handler);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
- else
- link->dhcp4_remove_messages++;
}
if (link->dhcp_address) {
- k = address_remove(link->dhcp_address, link, dhcp4_address_remove_handler);
+ k = address_remove(link->dhcp_address, link);
if (k < 0)
r = k;
- else
- link->dhcp4_remove_messages++;
}
return r;
@@ -990,7 +948,7 @@ static int dhcp4_after_address_configure(Request *req, void *object) {
if (link->dhcp_address_old &&
!address_equal(link->dhcp_address_old, link->dhcp_address)) {
/* Still too old address exists? Let's remove it immediately. */
- r = address_remove(link->dhcp_address_old, link, NULL);
+ r = address_remove(link->dhcp_address_old, link);
if (r < 0)
return r;
}
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index e8c7d8ebd8..7a2e7c106c 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -170,7 +170,7 @@ static int dhcp6_pd_remove_old(Link *link, bool force) {
log_link_debug(link, "Removing old DHCPv6 Prefix Delegation addresses and routes.");
SET_FOREACH(route, link->dhcp6_pd_routes_old) {
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
@@ -180,7 +180,7 @@ static int dhcp6_pd_remove_old(Link *link, bool force) {
}
SET_FOREACH(address, link->dhcp6_pd_addresses_old) {
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0)
r = k;
}
@@ -212,7 +212,7 @@ int dhcp6_pd_remove(Link *link) {
log_link_debug(link, "Removing DHCPv6 Prefix Delegation addresses and routes.");
SET_FOREACH(route, link->dhcp6_pd_routes) {
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
@@ -222,7 +222,7 @@ int dhcp6_pd_remove(Link *link) {
}
SET_FOREACH(address, link->dhcp6_pd_addresses) {
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0)
r = k;
}
@@ -761,13 +761,13 @@ static int dhcp6_remove_old(Link *link, bool force) {
log_link_debug(link, "Removing old DHCPv6 addresses and routes.");
SET_FOREACH(route, link->dhcp6_routes_old) {
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
}
SET_FOREACH(address, link->dhcp6_addresses_old) {
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0)
r = k;
}
@@ -795,13 +795,13 @@ static int dhcp6_remove(Link *link) {
log_link_debug(link, "Removing DHCPv6 addresses and routes.");
SET_FOREACH(route, link->dhcp6_routes) {
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0)
r = k;
}
SET_FOREACH(address, link->dhcp6_addresses) {
- k = address_remove(address, link, NULL);
+ k = address_remove(address, link);
if (k < 0)
r = k;
}
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 12ba5c085a..2ad7f2c5dc 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -56,7 +56,7 @@ static int ipv4ll_address_lost(Link *link) {
log_link_debug(link, "IPv4 link-local release "IPV4_ADDRESS_FMT_STR,
IPV4_ADDRESS_FMT_VAL(address->in_addr.in));
- return address_remove(address, link, NULL);
+ return address_remove(address, link);
}
static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 0c2e759180..55141860ae 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -138,7 +138,7 @@ bool link_ipv6_enabled(Link *link) {
bool link_is_ready_to_configure(Link *link, bool allow_unmanaged) {
assert(link);
- if (!link->network || link->network->unmanaged) {
+ if (!link->network) {
if (!allow_unmanaged)
return false;
@@ -552,14 +552,28 @@ int link_get(Manager *m, int ifindex, Link **ret) {
assert(m);
assert(ifindex > 0);
- assert(ret);
link = hashmap_get(m->links, INT_TO_PTR(ifindex));
if (!link)
return -ENODEV;
- *ret = link;
+ if (ret)
+ *ret = link;
+ return 0;
+}
+int link_get_by_name(Manager *m, const char *ifname, Link **ret) {
+ Link *link;
+
+ assert(m);
+ assert(ifname);
+
+ link = hashmap_get(m->links_by_name, ifname);
+ if (!link)
+ return -ENODEV;
+
+ if (ret)
+ *ret = link;
return 0;
}
@@ -1709,6 +1723,8 @@ static void link_drop_requests(Link *link) {
static Link *link_drop(Link *link) {
+ char **n;
+
if (!link)
return NULL;
@@ -1734,6 +1750,11 @@ static Link *link_drop(Link *link) {
(void) unlink(link->state_file);
link_clean(link);
+ STRV_FOREACH(n, link->alternative_names)
+ hashmap_remove(link->manager->links_by_name, *n);
+
+ hashmap_remove(link->manager->links_by_name, link->ifname);
+
/* The following must be called at last. */
assert_se(hashmap_remove(link->manager->links, INT_TO_PTR(link->ifindex)) == link);
return link_unref(link);
@@ -2204,8 +2225,33 @@ static int link_get_network(Link *link, Network **ret) {
return -ENOENT;
}
+static int link_update_alternative_names(Link *link, sd_netlink_message *message) {
+ _cleanup_strv_free_ char **altnames = NULL;
+ char **n;
+ int r;
+
+ assert(link);
+ assert(message);
+
+ r = sd_netlink_message_read_strv(message, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &altnames);
+ if (r < 0 && r != -ENODATA)
+ return r;
+
+ STRV_FOREACH(n, link->alternative_names)
+ hashmap_remove(link->manager->links_by_name, *n);
+
+ strv_free_and_replace(link->alternative_names, altnames);
+
+ STRV_FOREACH(n, link->alternative_names) {
+ r = hashmap_ensure_put(&link->manager->links_by_name, &string_hash_ops, *n, link);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static int link_reconfigure_internal(Link *link, sd_netlink_message *m, bool force) {
- _cleanup_strv_free_ char **s = NULL;
Network *network;
int r;
@@ -2215,12 +2261,10 @@ static int link_reconfigure_internal(Link *link, sd_netlink_message *m, bool for
if (r < 0)
return r;
- r = sd_netlink_message_read_strv(m, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &s);
- if (r < 0 && r != -ENODATA)
+ r = link_update_alternative_names(link, m);
+ if (r < 0)
return r;
- strv_free_and_replace(link->alternative_names, s);
-
r = link_get_network(link, &network);
if (r == -ENOENT) {
link_enter_unmanaged(link);
@@ -2386,7 +2430,6 @@ static int link_initialized_and_synced(Link *link) {
}
static int link_initialized_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- _cleanup_strv_free_ char **s = NULL;
int r;
r = sd_netlink_message_get_errno(m);
@@ -2396,14 +2439,12 @@ static int link_initialized_handler(sd_netlink *rtnl, sd_netlink_message *m, Lin
return 0;
}
- r = sd_netlink_message_read_strv(m, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &s);
- if (r < 0 && r != -ENODATA) {
+ r = link_update_alternative_names(link, m);
+ if (r < 0) {
link_enter_failed(link);
- return 0;
+ return r;
}
- strv_free_and_replace(link->alternative_names, s);
-
r = link_initialized_and_synced(link);
if (r < 0)
link_enter_failed(link);
@@ -2547,10 +2588,6 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
if (r < 0)
log_link_debug_errno(link, r, "Failed to get driver, continuing without: %m");
- r = sd_netlink_message_read_strv(message, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &link->alternative_names);
- if (r < 0 && r != -ENODATA)
- return r;
-
if (asprintf(&link->state_file, "/run/systemd/netif/links/%d", link->ifindex) < 0)
return -ENOMEM;
@@ -2560,6 +2597,14 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
if (asprintf(&link->lldp_file, "/run/systemd/netif/lldp/%d", link->ifindex) < 0)
return -ENOMEM;
+ r = hashmap_ensure_put(&manager->links_by_name, &string_hash_ops, link->ifname, link);
+ if (r < 0)
+ return r;
+
+ r = link_update_alternative_names(link, message);
+ if (r < 0)
+ return r;
+
r = link_update_flags(link, message, false);
if (r < 0)
return r;
@@ -2877,7 +2922,6 @@ static int link_admin_state_down(Link *link) {
}
static int link_update(Link *link, sd_netlink_message *m) {
- _cleanup_strv_free_ char **s = NULL;
hw_addr_data hw_addr;
const char *ifname;
uint32_t mtu;
@@ -2907,12 +2951,12 @@ static int link_update(Link *link, sd_netlink_message *m) {
r = link_add(manager, m, &link);
if (r < 0)
return r;
+ } else {
+ r = link_update_alternative_names(link, m);
+ if (r < 0)
+ return r;
}
- r = sd_netlink_message_read_strv(m, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &s);
- if (r >= 0)
- strv_free_and_replace(link->alternative_names, s);
-
r = sd_netlink_message_read_u32(m, IFLA_MTU, &mtu);
if (r >= 0 && mtu > 0) {
link->mtu = mtu;
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index f6317d4cb3..ddfc32b294 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -112,7 +112,6 @@ typedef struct Link {
char *lease_file;
uint32_t original_mtu;
unsigned dhcp4_messages;
- unsigned dhcp4_remove_messages;
sd_ipv4acd *dhcp_acd;
bool dhcp4_route_failed:1;
bool dhcp4_route_retrying:1;
@@ -211,6 +210,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
int link_get(Manager *m, int ifindex, Link **ret);
+int link_get_by_name(Manager *m, const char *ifname, Link **ret);
int link_up(Link *link);
int link_down(Link *link, link_netlink_message_handler_t callback);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 2b06657590..d4b4043211 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -459,6 +459,7 @@ Manager* manager_free(Manager *m) {
m->dirty_links = set_free_with_destructor(m->dirty_links, link_unref);
m->links_requesting_uuid = set_free_with_destructor(m->links_requesting_uuid, link_unref);
+ m->links_by_name = hashmap_free(m->links_by_name);
m->links = hashmap_free_with_destructor(m->links, link_unref);
m->networks = ordered_hashmap_free_with_destructor(m->networks, network_unref);
diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h
index ef98c519d6..6b9b0697b2 100644
--- a/src/network/networkd-manager.h
+++ b/src/network/networkd-manager.h
@@ -45,6 +45,7 @@ struct Manager {
LinkOnlineState online_state;
Hashmap *links;
+ Hashmap *links_by_name;
Hashmap *netdevs;
OrderedHashmap *networks;
Hashmap *dhcp6_prefixes;
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 56aa5ec8a7..d678d49bde 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -171,14 +171,14 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool
SET_FOREACH(na, link->ndisc_addresses)
if (na->marked && in6_addr_equal(&na->router, router)) {
- k = address_remove(na->address, link, NULL);
+ k = address_remove(na->address, link);
if (k < 0)
r = k;
}
SET_FOREACH(nr, link->ndisc_routes)
if (nr->marked && in6_addr_equal(&nr->router, router)) {
- k = route_remove(nr->route, NULL, link, NULL);
+ k = route_remove(nr->route, NULL, link);
if (k < 0)
r = k;
}
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index e6c1d71265..60eef08074 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -903,13 +903,12 @@ static int route_set_netlink_message(const Route *route, sd_netlink_message *req
return 0;
}
-int link_route_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg) {
+static int link_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
assert(m);
assert(link);
assert(link->route_remove_messages > 0);
- assert(error_msg);
link->route_remove_messages--;
@@ -918,15 +917,11 @@ int link_route_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m,
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -ESRCH)
- log_link_message_warning_errno(link, m, r, error_msg);
+ log_link_message_warning_errno(link, m, r, "Could not drop route, ignoring");
return 1;
}
-static int link_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- return link_route_remove_handler_internal(rtnl, m, link, "Could not drop route, ignoring");
-}
-
static int manager_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Manager *manager) {
int r;
@@ -943,12 +938,7 @@ static int manager_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m,
return 1;
}
-int route_remove(
- const Route *route,
- Manager *manager,
- Link *link,
- link_netlink_message_handler_t callback) {
-
+int route_remove(const Route *route, Manager *manager, Link *link) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
unsigned char type;
int r;
@@ -988,7 +978,7 @@ int route_remove(
if (link) {
r = netlink_call_async(manager->rtnl, NULL, req,
- callback ?: link_route_remove_handler,
+ link_route_remove_handler,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
@@ -1062,7 +1052,7 @@ static int manager_drop_routes_internal(Manager *manager, bool foreign, const Li
/* The existing links do not have the route. Let's drop this now. It may be
* re-configured later. */
- k = route_remove(route, manager, NULL, NULL);
+ k = route_remove(route, manager, NULL);
if (k < 0 && r >= 0)
r = k;
@@ -1112,7 +1102,7 @@ int link_drop_foreign_routes(Link *link) {
if (link_has_static_route(link, route))
k = route_add(NULL, link, route, NULL, NULL, NULL);
else
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0 && r >= 0)
r = k;
}
@@ -1135,7 +1125,7 @@ int link_drop_routes(Link *link) {
if (route->protocol == RTPROT_KERNEL)
continue;
- k = route_remove(route, NULL, link, NULL);
+ k = route_remove(route, NULL, link);
if (k < 0 && r >= 0)
r = k;
}
@@ -1153,7 +1143,7 @@ static int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdat
assert(route);
- r = route_remove(route, route->manager, route->link, NULL);
+ r = route_remove(route, route->manager, route->link);
if (r < 0) {
log_link_warning_errno(route->link, r, "Could not remove route: %m");
route_free(route);
@@ -1575,25 +1565,23 @@ static int route_is_ready_to_configure(const Route *route, Link *link) {
ORDERED_SET_FOREACH(m, route->multipath_routes) {
union in_addr_union a = m->gateway.address;
+ Link *l = NULL;
if (route->gateway_onlink <= 0 &&
!manager_address_is_reachable(link->manager, m->gateway.family, &a))
return false;
if (m->ifname) {
- Link *l;
-
- r = resolve_interface(&link->manager->rtnl, m->ifname);
- if (r < 0)
+ if (link_get_by_name(link->manager, m->ifname, &l) < 0)
return false;
- m->ifindex = r;
+ m->ifindex = l->ifindex;
+ } else if (m->ifindex > 0) {
if (link_get(link->manager, m->ifindex, &l) < 0)
return false;
-
- if (!link_is_ready_to_configure(l, true))
- return false;
}
+ if (l && !link_is_ready_to_configure(l, true))
+ return false;
}
return true;
@@ -2755,9 +2743,20 @@ int config_parse_multipath_route(
if (dev) {
*dev++ = '\0';
- m->ifname = strdup(dev);
- if (!m->ifname)
- return log_oom();
+ r = parse_ifindex(dev);
+ if (r > 0)
+ m->ifindex = r;
+ else {
+ if (!ifname_valid_full(dev, IFNAME_VALID_ALTERNATIVE)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Invalid interface name '%s' in %s=, ignoring: %s", dev, lvalue, rvalue);
+ return 0;
+ }
+
+ m->ifname = strdup(dev);
+ if (!m->ifname)
+ return log_oom();
+ }
}
r = in_addr_from_string_auto(word, &family, &a);
diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h
index bb007dd74a..095a07e05d 100644
--- a/src/network/networkd-route.h
+++ b/src/network/networkd-route.h
@@ -74,8 +74,7 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
int route_dup(const Route *src, Route **ret);
int route_configure_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
-int link_route_remove_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
-int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback);
+int route_remove(const Route *route, Manager *manager, Link *link);
int link_has_route(Link *link, const Route *route);
bool manager_address_is_reachable(Manager *manager, int family, const union in_addr_union *address);
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 4d68e08c80..a45f5fa363 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -324,7 +324,7 @@ static void print_status_info(
printf("\n");
if (i->following)
- printf(" Follow: unit currently follows state of %s\n", i->following);
+ printf(" Follows: unit currently follows state of %s\n", i->following);
if (STRPTR_IN_SET(i->load_state, "error", "not-found", "bad-setting")) {
on = ansi_highlight_red();