network: support alternative name to get bus path for the link

This commit is contained in:
Yu Watanabe 2019-12-17 21:13:49 +09:00
parent f7581ed6e0
commit e7bdadb5c6
1 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "bus-util.h"
#include "netlink-util.h"
#include "networkd-link-bus.h"
#include "networkd-link.h"
#include "networkd-manager-bus.h"
@ -66,8 +67,11 @@ static int method_get_link_by_name(sd_bus_message *message, void *userdata, sd_b
return r;
index = if_nametoindex(name);
if (index <= 0)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_LINK, "Link %s not known", name);
if (index <= 0) {
r = rtnl_resolve_link_alternative_name(&manager->rtnl, name, &index);
if (r < 0)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_LINK, "Link %s not known", name);
}
link = hashmap_get(manager->links, INT_TO_PTR(index));
if (!link)