mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-14 19:24:13 +03:00
network: use FOREACH_DEVICE_CHILD_WITH_SUFFIX() macro
This commit is contained in:
parent
29c1fb3cb3
commit
96f974e47f
@ -2,7 +2,7 @@
|
|||||||
* Copyright © 2020 VMware, Inc. */
|
* Copyright © 2020 VMware, Inc. */
|
||||||
|
|
||||||
#include "device-enumerator-private.h"
|
#include "device-enumerator-private.h"
|
||||||
#include "dirent-util.h"
|
#include "device-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "networkd-link.h"
|
#include "networkd-link.h"
|
||||||
#include "networkd-manager.h"
|
#include "networkd-manager.h"
|
||||||
@ -229,9 +229,8 @@ static int link_set_sr_iov_phys_port(Link *link) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int link_set_sr_iov_virt_ports(Link *link) {
|
static int link_set_sr_iov_virt_ports(Link *link) {
|
||||||
const char *dev_port, *pci_syspath;
|
const char *dev_port, *name;
|
||||||
_cleanup_closedir_ DIR *dir = NULL;
|
sd_device *pci_dev, *child;
|
||||||
sd_device *pci_dev;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
@ -250,28 +249,15 @@ static int link_set_sr_iov_virt_ports(Link *link) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_device_get_syspath(pci_dev, &pci_syspath);
|
FOREACH_DEVICE_CHILD_WITH_SUFFIX(pci_dev, child, name) {
|
||||||
if (r < 0)
|
const char *n;
|
||||||
return r;
|
|
||||||
|
|
||||||
dir = opendir(pci_syspath);
|
|
||||||
if (!dir)
|
|
||||||
return -errno;
|
|
||||||
|
|
||||||
FOREACH_DIRENT_ALL(de, dir, break) {
|
|
||||||
_cleanup_(sd_device_unrefp) sd_device *pci_virtfn_dev = NULL;
|
|
||||||
|
|
||||||
if (de->d_type != DT_LNK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Accept name prefixed with "virtfn", but refuse "virtfn" itself. */
|
/* Accept name prefixed with "virtfn", but refuse "virtfn" itself. */
|
||||||
if (isempty(startswith(de->d_name, "virtfn")))
|
n = startswith(name, "virtfn");
|
||||||
|
if (isempty(n) || !in_charset(n, DIGITS))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sd_device_new_child(&pci_virtfn_dev, pci_dev, de->d_name) < 0)
|
r = find_ifindex_from_pci_dev_port(child, dev_port);
|
||||||
continue;
|
|
||||||
|
|
||||||
r = find_ifindex_from_pci_dev_port(pci_virtfn_dev, dev_port);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user