network: support alternative name to get bus path for the link
This commit is contained in:
parent
f7581ed6e0
commit
e7bdadb5c6
|
@ -7,6 +7,7 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
#include "netlink-util.h"
|
||||||
#include "networkd-link-bus.h"
|
#include "networkd-link-bus.h"
|
||||||
#include "networkd-link.h"
|
#include "networkd-link.h"
|
||||||
#include "networkd-manager-bus.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;
|
return r;
|
||||||
|
|
||||||
index = if_nametoindex(name);
|
index = if_nametoindex(name);
|
||||||
if (index <= 0)
|
if (index <= 0) {
|
||||||
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_LINK, "Link %s not known", name);
|
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));
|
link = hashmap_get(manager->links, INT_TO_PTR(index));
|
||||||
if (!link)
|
if (!link)
|
||||||
|
|
Loading…
Reference in a new issue