* [dpdk-dev] [PATCH v2] bus/vmbus: skip non-network devices
@ 2019-06-06 0:37 Stephen Hemminger
2019-06-27 21:13 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2019-06-06 0:37 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
From: Stephen Hemminger <sthemmin@microsoft.com>
The vmbus scan code can just skip non-network devices.
More importantly, this fixes the bug where some vmbus devices
don't have all the attributes (like monitor_id) and a single
failure would cause the scan to break the loop.
Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
v2 - don't leak memory for skipped devices
drivers/bus/vmbus/linux/vmbus_bus.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c
index a4755a3878df..3c924eee1412 100644
--- a/drivers/bus/vmbus/linux/vmbus_bus.c
+++ b/drivers/bus/vmbus/linux/vmbus_bus.c
@@ -25,6 +25,18 @@
/** Pathname of VMBUS devices directory. */
#define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices"
+/*
+ * GUID associated with network devices
+ * {f8615163-df3e-46c5-913f-f2d2f965ed0e}
+ */
+static const rte_uuid_t vmbus_nic_uuid = {
+ 0xf8, 0x61, 0x51, 0x63,
+ 0xdf, 0x3e,
+ 0x46, 0xc5,
+ 0x91, 0x3f,
+ 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe
+};
+
extern struct rte_vmbus_bus rte_vmbus_bus;
/* Read sysfs file to get UUID */
@@ -242,16 +254,22 @@ vmbus_scan_one(const char *name)
snprintf(dirname, sizeof(dirname), "%s/%s",
SYSFS_VMBUS_DEVICES, name);
- /* get device id */
- snprintf(filename, sizeof(filename), "%s/device_id", dirname);
- if (parse_sysfs_uuid(filename, dev->device_id) < 0)
- goto error;
-
/* get device class */
snprintf(filename, sizeof(filename), "%s/class_id", dirname);
if (parse_sysfs_uuid(filename, dev->class_id) < 0)
goto error;
+ /* skip non-network devices */
+ if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) {
+ free(dev);
+ return 0;
+ }
+
+ /* get device id */
+ snprintf(filename, sizeof(filename), "%s/device_id", dirname);
+ if (parse_sysfs_uuid(filename, dev->device_id) < 0)
+ goto error;
+
/* get relid */
snprintf(filename, sizeof(filename), "%s/id", dirname);
if (eal_parse_sysfs_value(filename, &tmp) < 0)
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH v2] bus/vmbus: skip non-network devices
2019-06-06 0:37 [dpdk-dev] [PATCH v2] bus/vmbus: skip non-network devices Stephen Hemminger
@ 2019-06-27 21:13 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2019-06-27 21:13 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Stephen Hemminger, stable
06/06/2019 02:37, Stephen Hemminger:
> From: Stephen Hemminger <sthemmin@microsoft.com>
>
> The vmbus scan code can just skip non-network devices.
> More importantly, this fixes the bug where some vmbus devices
> don't have all the attributes (like monitor_id) and a single
> failure would cause the scan to break the loop.
>
> Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
Cc: stable@dpdk.org
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-27 21:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 0:37 [dpdk-dev] [PATCH v2] bus/vmbus: skip non-network devices Stephen Hemminger
2019-06-27 21:13 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).