summaryrefslogtreecommitdiff
path: root/src/resolve/resolvconf-compat.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-06-26 16:41:22 +0900
committerFilipe Brandenburger <filbranden@google.com>2018-06-26 23:09:36 -0700
commita661dc36f68b5ebb1247a503533f8067ff8c0432 (patch)
treebf352cd932a56df77296ae807bb962e74a6fecc4 /src/resolve/resolvconf-compat.c
parent5a01b3f35d7b6182c78b6973db8d99bdabd4f9c3 (diff)
downloadsystemd-a661dc36f68b5ebb1247a503533f8067ff8c0432.tar.gz
resolve: reduce number of conversions between ifname and ifindex
This also fixes minor memleak introduced in 654457e560c5723b90b419f7651b87040aade07e.
Diffstat (limited to 'src/resolve/resolvconf-compat.c')
-rw-r--r--src/resolve/resolvconf-compat.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/resolve/resolvconf-compat.c b/src/resolve/resolvconf-compat.c
index 0723458945..bf7b7b1044 100644
--- a/src/resolve/resolvconf-compat.c
+++ b/src/resolve/resolvconf-compat.c
@@ -109,7 +109,6 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
TYPE_EXCLUSIVE, /* -x */
} type = TYPE_REGULAR;
- const char *dot, *iface;
int c, r;
assert(argc >= 0);
@@ -202,30 +201,11 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
- dot = strchr(argv[optind], '.');
- if (dot) {
- iface = strndup(argv[optind], dot - argv[optind]);
- log_debug("Ignoring protocol specifier '%s'.", dot + 1);
- } else
- iface = argv[optind];
- optind++;
-
- if (parse_ifindex(iface, &arg_ifindex) < 0) {
- int ifi;
-
- ifi = if_nametoindex(iface);
- if (ifi <= 0) {
- if (errno == ENODEV && arg_ifindex_permissive) {
- log_debug("Interface '%s' not found, but -f specified, ignoring.", iface);
- return 0; /* done */
- }
+ r = ifname_mangle(argv[optind], false);
+ if (r <= 0)
+ return r;
- return log_error_errno(errno, "Unknown interface '%s': %m", iface);
- }
-
- arg_ifindex = ifi;
- arg_ifname = iface;
- }
+ optind++;
if (arg_mode == MODE_SET_LINK) {
unsigned n = 0;