@@ -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);
@@ -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)
@@ -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)),
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@gmail.com> --- ip/ip_common.h | 2 +- ip/ipaddress.c | 3 ++- ip/iplink.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)