mirror of
https://github.com/systemd/systemd
synced 2024-07-24 11:44:41 +00:00
network: use link_get_by_name()
This commit is contained in:
parent
756755d0fc
commit
f0ad7aedd9
|
@ -14,7 +14,6 @@
|
|||
#include "networkd-manager-bus.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "path-util.h"
|
||||
#include "socket-netlink.h"
|
||||
#include "strv.h"
|
||||
#include "user-util.h"
|
||||
|
||||
|
@ -60,19 +59,14 @@ static int method_get_link_by_name(sd_bus_message *message, void *userdata, sd_b
|
|||
_cleanup_free_ char *path = NULL;
|
||||
Manager *manager = userdata;
|
||||
const char *name;
|
||||
int index, r;
|
||||
Link *link;
|
||||
int r;
|
||||
|
||||
r = sd_bus_message_read(message, "s", &name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
index = resolve_ifname(&manager->rtnl, name);
|
||||
if (index < 0)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_LINK, "Link %s cannot be resolved", name);
|
||||
|
||||
link = hashmap_get(manager->links, INT_TO_PTR(index));
|
||||
if (!link)
|
||||
if (link_get_by_name(manager, name, &link) < 0)
|
||||
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_LINK, "Link %s not known", name);
|
||||
|
||||
r = sd_bus_message_new_method_return(message, &reply);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "networkd-queue.h"
|
||||
#include "networkd-route.h"
|
||||
#include "parse-util.h"
|
||||
#include "socket-netlink.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
@ -708,13 +707,10 @@ int link_has_route(Link *link, const Route *route) {
|
|||
Link *l;
|
||||
|
||||
if (m->ifname) {
|
||||
r = resolve_interface(&link->manager->rtnl, m->ifname);
|
||||
if (r < 0)
|
||||
if (link_get_by_name(link->manager, m->ifname, &l) < 0)
|
||||
return false;
|
||||
m->ifindex = r;
|
||||
|
||||
if (link_get(link->manager, m->ifindex, &l) < 0)
|
||||
return false;
|
||||
m->ifindex = l->ifindex;
|
||||
} else
|
||||
l = link;
|
||||
|
||||
|
|
Loading…
Reference in a new issue