lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20221102083811.3906521-1-a.s.protopopov@gmail.com>
Date:   Wed,  2 Nov 2022 09:38:11 +0100
From:   Anton Protopopov <a.s.protopopov@...il.com>
To:     netdev@...r.kernel.org
Cc:     Anton Protopopov <a.s.protopopov@...il.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2] iplink: fix accepting non-canonical ifxxx names

The ip link command is supposed to support names like if<index>, but at the
moment it fails like this:

  # ip link show dev if2
  RTNETLINK answers: No such device
  Cannot send link get request: No such device

This happens because the name 'if2' is used as an attribute in a RTM_GETLINK
message. Fix this by converting a given device name to the canonical name.

Signed-off-by: Anton Protopopov <a.s.protopopov@...il.com>
---
 ip/ip_common.h | 2 +-
 ip/ipaddress.c | 3 ++-
 ip/iplink.c    | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ip/ip_common.h b/ip/ip_common.h
index c4cb1bcb..9ca4905b 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -94,7 +94,7 @@ int do_mptcp(int argc, char **argv);
 int do_ioam6(int argc, char **argv);
 int do_ipstats(int argc, char **argv);
 
-int iplink_get(char *name, __u32 filt_mask);
+int iplink_get(const char *name, __u32 filt_mask);
 int iplink_ifla_xstats(int argc, char **argv);
 
 int ip_link_list(req_filter_fn_t filter_fn, struct nlmsg_chain *linfo);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 456545bb..1896d018 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -2109,7 +2109,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 	struct nlmsg_chain linfo = { NULL, NULL};
 	struct nlmsg_chain _ainfo = { NULL, NULL}, *ainfo = &_ainfo;
 	struct nlmsg_list *l;
-	char *filter_dev = NULL;
+	const char *filter_dev = NULL;
 	int no_link = 0;
 
 	ipaddr_reset_filter(oneline, 0);
@@ -2207,6 +2207,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			fprintf(stderr, "Device \"%s\" does not exist.\n", filter_dev);
 			return -1;
 		}
+		filter_dev = ll_index_to_name(filter.ifindex);
 	}
 
 	if (action == IPADD_FLUSH)
diff --git a/ip/iplink.c b/ip/iplink.c
index 92ce6c47..13ee5afe 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1137,7 +1137,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 	return 0;
 }
 
-int iplink_get(char *name, __u32 filt_mask)
+int iplink_get(const char *name, __u32 filt_mask)
 {
 	struct iplink_req req = {
 		.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ