summaryrefslogtreecommitdiffstats
path: root/src/network/networkctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-01-13 17:57:59 +0100
committerGitHub <noreply@github.com>2020-01-13 17:57:59 +0100
commit04d8507f687674b9b7a6820f0996b95cc1094bff (patch)
treeaded6791179d1b92f0a317ff17218277e02acf8c /src/network/networkctl.c
parentMerge pull request #11199 from dargad/restore-pam-setcred (diff)
parentnetworkctl: break long line (diff)
downloadsystemd-04d8507f687674b9b7a6820f0996b95cc1094bff.tar.xz
systemd-04d8507f687674b9b7a6820f0996b95cc1094bff.zip
Merge pull request #14381 from keszybz/ifindex-cleanup
Resolve alternative names
Diffstat (limited to 'src/network/networkctl.c')
-rw-r--r--src/network/networkctl.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 9a86dc6e8d..631b12cf51 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -38,6 +38,7 @@
#include "parse-util.h"
#include "pretty-print.h"
#include "set.h"
+#include "socket-netlink.h"
#include "socket-util.h"
#include "sort-util.h"
#include "sparse-endian.h"
@@ -1904,12 +1905,9 @@ static int link_delete(int argc, char *argv[], void *userdata) {
return log_oom();
for (i = 1; i < argc; i++) {
- r = parse_ifindex_or_ifname(argv[i], &index);
- if (r < 0) {
- r = rtnl_resolve_link_alternative_name(&rtnl, argv[i], &index);
- if (r < 0)
- return log_error_errno(r, "Failed to resolve interface %s", argv[i]);
- }
+ index = resolve_interface_or_warn(&rtnl, argv[i]);
+ if (index < 0)
+ return index;
r = set_put(indexes, INT_TO_PTR(index));
if (r < 0)
@@ -1960,12 +1958,9 @@ static int link_renew(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to connect system bus: %m");
for (i = 1; i < argc; i++) {
- r = parse_ifindex_or_ifname(argv[i], &index);
- if (r < 0) {
- r = rtnl_resolve_link_alternative_name(&rtnl, argv[i], &index);
- if (r < 0)
- return log_error_errno(r, "Failed to resolve interface %s", argv[i]);
- }
+ index = resolve_interface_or_warn(&rtnl, argv[i]);
+ if (index < 0)
+ return index;
r = link_renew_one(bus, index, argv[i]);
if (r < 0 && k >= 0)
@@ -2015,12 +2010,9 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) {
return log_oom();
for (i = 1; i < argc; i++) {
- r = parse_ifindex_or_ifname(argv[i], &index);
- if (r < 0) {
- r = rtnl_resolve_link_alternative_name(&rtnl, argv[i], &index);
- if (r < 0)
- return log_error_errno(r, "Failed to resolve interface %s", argv[i]);
- }
+ index = resolve_interface_or_warn(&rtnl, argv[i]);
+ if (index < 0)
+ return index;
r = set_put(indexes, INT_TO_PTR(index));
if (r < 0)
@@ -2039,7 +2031,8 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) {
if (r < 0) {
char ifname[IF_NAMESIZE + 1];
- return log_error_errno(r, "Failed to reconfigure network interface %s: %m", format_ifname_full(index, ifname, FORMAT_IFNAME_IFINDEX));
+ return log_error_errno(r, "Failed to reconfigure network interface %s: %m",
+ format_ifname_full(index, ifname, FORMAT_IFNAME_IFINDEX));
}
}