mirror of
https://github.com/systemd/systemd.git
synced 2025-02-03 17:47:28 +03:00
sd-device: use new interface name resolvers
This commit is contained in:
parent
4e235561d6
commit
3652891c39
@ -345,17 +345,11 @@ _public_ int sd_device_new_from_ifname(sd_device **ret, const char *ifname) {
|
||||
assert_return(ret, -EINVAL);
|
||||
assert_return(ifname, -EINVAL);
|
||||
|
||||
r = parse_ifindex(ifname);
|
||||
if (r > 0)
|
||||
return sd_device_new_from_ifindex(ret, r);
|
||||
r = device_new_from_main_ifname(ret, ifname);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
if (ifname_valid(ifname)) {
|
||||
r = device_new_from_main_ifname(ret, ifname);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = rtnl_resolve_link_alternative_name(NULL, ifname, &main_name);
|
||||
r = rtnl_resolve_ifname_full(NULL, RESOLVE_IFNAME_ALTERNATIVE | RESOLVE_IFNAME_NUMERIC, ifname, &main_name, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -364,14 +358,15 @@ _public_ int sd_device_new_from_ifname(sd_device **ret, const char *ifname) {
|
||||
|
||||
_public_ int sd_device_new_from_ifindex(sd_device **ret, int ifindex) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
||||
char ifname[IF_NAMESIZE];
|
||||
_cleanup_free_ char *ifname = NULL;
|
||||
int r, i;
|
||||
|
||||
assert_return(ret, -EINVAL);
|
||||
assert_return(ifindex > 0, -EINVAL);
|
||||
|
||||
if (format_ifname(ifindex, ifname) < 0)
|
||||
return -ENODEV;
|
||||
r = rtnl_get_ifname_full(NULL, ifindex, &ifname, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = device_new_from_main_ifname(&dev, ifname);
|
||||
if (r < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user