From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 91EB0A0096 for ; Thu, 6 Jun 2019 02:37:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D0A531B9F0; Thu, 6 Jun 2019 02:37:51 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 1CDDA1B9E0 for ; Thu, 6 Jun 2019 02:37:50 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id d126so361819pfd.2 for ; Wed, 05 Jun 2019 17:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GLJ6lmUg+6g8fhmrWgduebNon6nbTPrpNwfigMheGU0=; b=PP9sYj4wFVWtTZuOIqe1EcQz9yx+D0MUv7nrmFGJWb/KsaO/nvY3bJ9HmYQExKLTc/ lERr2wubG2mqrdVvVw8FNI80YHl7oJcJpbKBqUS8k5zdxLrzBRVAKIed9SGNvPnUjGQ7 Lps2g39Wd4V5FJo0z+rUphRqyOvbn+Y33pJjYMUo4AZOwZ/n9sN+NTwzKLEsAA2CCUGw 7x6eCsy6wnq4ivT/gccafUnoD76WvyACmGBgrBqanKxs3ht6emUIw08Z0pFub0Nj9eAS IY90PTf0BILRsGOdaED8CX93odvMV8jP1HLgJTda1KR4hr2HO8De4VBBG0BrqxLG5CnD 992g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GLJ6lmUg+6g8fhmrWgduebNon6nbTPrpNwfigMheGU0=; b=h5FNxqo3X2jagJszvMuunKqcZsyaWnb4Ln/6aKg/HAlcDIX/7fozvVh2ynqxSKGGev gZVOtin+TlgkM8M482NcXwy3BlwwbYCRYMzS7IA/RMd71zs30+0BJXjuFTYjYmZPf7yG r0arAa8d0LXQYXb4NjvizXQEQJZwHWy7pJloKbnngTzQ2rgGmExvFlLYwC7+kQdGvhk1 x3TQMEEyws99+cNvoYQiSweev9EsSD+CkUq8WlXcHDft20acfzgIrq0p/zqeiQgAlYZc ebe3eVgldYdZjckwuY+xuHVggSnL2gmCuaYndYx8l6A48ERz1TfXCE0e8YchaWdhKQqT UCaw== X-Gm-Message-State: APjAAAX80XO7ATyuPFCpsdjSwH2Hzvy+LukR2Jww8FHFvJQbH4mX+0cf JsThrCfSsPFfNLPoNkhdTHTtES5Xgto= X-Google-Smtp-Source: APXvYqxFcH0vjBubgZKTWXwtlbMX9CJxg2aenuxUsICPFIYY/OkIE81Cu9Vym62vfHl3+3UdSaAHiw== X-Received: by 2002:a62:2a0a:: with SMTP id q10mr47720901pfq.79.1559781469024; Wed, 05 Jun 2019 17:37:49 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t1sm126269pfh.113.2019.06.05.17.37.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 05 Jun 2019 17:37:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 5 Jun 2019 17:37:46 -0700 Message-Id: <20190606003746.29399-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] bus/vmbus: skip non-network devices X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Stephen Hemminger 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 --- 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