From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA1B9A09FF; Wed, 6 Jan 2021 03:51:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A6861607FE; Wed, 6 Jan 2021 03:51:05 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770099.outbound.protection.outlook.com [40.107.77.99]) by mails.dpdk.org (Postfix) with ESMTP id 6D20B1607B6 for ; Wed, 6 Jan 2021 03:51:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYM6YMnmwEl0X2ZTQRfgZnI2k2Pl1vjrFhc0Hw1akoHo8zb0RgHIwhD/DI6Jxi8PCHkGGt3Sx4paWflhOP1nFdn9HaPISDxds6Crs21SzWjDqvVGVJccw3YCUAMgi5hOmdYwjkj6zaIZ+p4RAxBFnNFm2ZtYG5NblgEsmJKU5efxvy6zf7jMyAuy8P1Fdt31nqwI443F4Fyg/nckX2sbysTMZDTQr3MaT1aQueoarXyizTSjt9xTvXJM1QIKYijA/p1WtK+2RTUenTWz8Kp4qjdfH1bkCyAeRAV8YUeU2BKlsNCW7P2RMjrnVmntwgdyKkvINKZyv1sVOf9FK4ZChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fIHqYpOAd4tOoMey7M25SIL3L35g2N/cEg7wSomkZ7k=; b=UfEKmXWIpEJTI9wS/gdtn3WzFHbSLpiDzylpJmoM8537/wy3vy8yMXw/aYNiV3mHweshI28vDvVFGqWvGZCJdlChNlbG89Ql8HpaxNvQ0VJRpN1XMIeLyPNdOJK8Pl0uQhDyTNUKYSecV3LAoh2S2u+RTvdWh3GFDzsP/KfPs4ztLqhJpNfW9hVbcanye+Nc+KkZ9YVuUXb3SX3Dn59vDweK/dNERKV2w+1l7QUQU6cZMDGIQu3VKTrpISPKuqmFkQD5gyIogxomAWqvpxQ4izNUl77KXBWRZB7ua/QoUZpqSyzhsnJdWXSW7D8CllXUUaVffr0unw7Y/5IuR8+8tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fIHqYpOAd4tOoMey7M25SIL3L35g2N/cEg7wSomkZ7k=; b=WPhTXhaZpuF4Lfiyy6mzL/Yd/F2z1jNIgfWy3KZ9P61KBpfL/mDk3GJARYWcJZDraDrYXwsjPsbDf0EHKCn0Qk/IZ7bUhFKshM3oJOggaHYsbjHnNa/PpMGDl3MD92LTlDfI5xbs+jt77QgOp3Fn7YhnIrM4xpKbKePRgucdrWk= Received: from (2603:10b6:408:73::10) by BN7PR21MB1682.namprd21.prod.outlook.com (2603:10b6:406:ba::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.0; Wed, 6 Jan 2021 02:50:58 +0000 Received: from BN8PR21MB1155.namprd21.prod.outlook.com ([fe80::e535:7045:e1e2:5e23]) by BN8PR21MB1155.namprd21.prod.outlook.com ([fe80::e535:7045:e1e2:5e23%8]) with mapi id 15.20.3763.002; Wed, 6 Jan 2021 02:50:58 +0000 From: Long Li To: Stephen Hemminger , Long Li CC: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot add/remove Thread-Index: AQHW1+Ds4SuuRxVdl0OFftRFf59oP6oCOMaAgBfD6pA= Date: Wed, 6 Jan 2021 02:50:58 +0000 Message-ID: References: <1606809383-26660-2-git-send-email-longli@linuxonhyperv.com> <1608586402-20145-1-git-send-email-longli@linuxonhyperv.com> <20201221155157.374d990b@hermes.local> In-Reply-To: <20201221155157.374d990b@hermes.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=6c90dd9c-39df-448c-a55e-198e40611392; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2021-01-06T02:47:07Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [67.168.111.68] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a0e8f91f-fbe1-4195-e4a1-08d8b1ede539 x-ms-traffictypediagnostic: BN7PR21MB1682: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3826; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uTktfcFsWwDMjaxYBAaaKUAVu7v9rjy8wLu1bU7A5LXubD31Db9QqrHhADgKUX4hA550n/al7Of9pfDZEvqjfRZd4jlWYmWNty86ybyI/aUZA23mKj2cG7+41zqYjz1Bg4ZqY0SWgiXjAVW77lB1g/CcGlU6ipuqEzmdMY2JORH6DvCz8Dtl7wjd27oj2eTz1WoVwJRI+eqXVnoWW/13K5FvaF15uYbODGYiT9x/IBvdk8rfeEB4hU1A6KYTbs7RJ+EtQkRbjp7mLS67hZeEPR+++AwZs61TJEifE8qC0C+U9mUNAimOpvSEKKh/RAgoSrc/JRU2Ye8TWC/o//EtwISdpmV4sPhow6QqK7huIeOLDtdrfw73MfasyTE0DaJg10T+2up/7znbtQvJkfHNyA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR21MB1155.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(366004)(136003)(346002)(376002)(86362001)(2906002)(5660300002)(8990500004)(8936002)(82950400001)(52536014)(66476007)(71200400001)(83380400001)(26005)(82960400001)(478600001)(316002)(33656002)(7696005)(10290500003)(110136005)(66556008)(64756008)(6506007)(186003)(54906003)(4326008)(66946007)(66446008)(55016002)(76116006)(9686003)(8676002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?JAg+47SOvz/iGdox/KhGGJyOy/yzz3BC9AQt8oKds2XL7vFiLXJZVdP0Seg9?= =?us-ascii?Q?iDsC5pS8LYEMEKd8NQTH/8p5zL1ULZEBEqJKfEbIwC6ZBVr6wj1geebx0BcS?= =?us-ascii?Q?zKR/yQssC2ssNs9OML3JKPDm24LU0tkY2TzF8I2bkeZAo1Vv4VOyeEtfNomI?= =?us-ascii?Q?4XNlwXM9sXStiYzS18vQb22eM4XBbfscBwMwAQJrV+Chg8e2+XtYjo9kQtem?= =?us-ascii?Q?Prb5SlmiEqBnHIDJzSII9Lu5cC9o/8jyE0OYJDNazTgbe1AEgw+Z6EkMcSoE?= =?us-ascii?Q?3TefzmSPpOhBuyAZsH5tIDqXX5qdbftx/j2OCtXHq5p1fVZTi6u8X1Eo6B95?= =?us-ascii?Q?LDweRIceu2GKob/BDS0KRJEguULaeV5NjCIegMlgEq62ieUkvbQ9H7Uzwa8E?= =?us-ascii?Q?X1VQTYNJJ7dRROMQLKLMZrmVjdWYLSG+3uBqbe65keZlouTrAd0pjCLz73MV?= =?us-ascii?Q?c9KKwDcZUZ5hGDs8jrOUG677mPLlWtlZx+sQRQoKoOat9r/H7UloBIwioRbM?= =?us-ascii?Q?/nvPWaw4PDJv/AFy3qsUCXoQAd2E9g/EE3kPuoVzCOr9Zik6m6Fiy3hAK7qT?= =?us-ascii?Q?5O/CTpP7yk8oAFT0nP3xP8pko46cKWnm/au4pVZtq/bIM1zkt3iW21pEFFoV?= =?us-ascii?Q?AjycCZY5ADkCbg/WiNm0tx/L3Fs3GmXeW/uBnoPU3etx3BVf6LtHwrkGIqQr?= =?us-ascii?Q?1IIa9Eiu43ZhL7ixBkw43oFMf2iy1UyjbH33GvUMVWlmzHO9ZNMgHNcNDlma?= =?us-ascii?Q?Mi6UiWwkFeNne9ZbKleuFHnXUZRmD0MqefW6Zv4IjF3poFYgvQb6qKXoPUgV?= =?us-ascii?Q?fY1M+kaIB9foTC9TP/nJtJSy4rZ1ENSmt9LrBCcOwNA6FbUq5Lrs6mi77T9C?= =?us-ascii?Q?4zT8cVhdEXqrza9H4bgPOjz2hyVXjVl/IAywcX/ej9sNN1Ib+ssw8T7VrM1S?= =?us-ascii?Q?cKFhuflw4KTpY+jXXalaPwifwQCXOEh742Aqg2+PtyA=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR21MB1155.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0e8f91f-fbe1-4195-e4a1-08d8b1ede539 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2021 02:50:58.2598 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6QP84xKo+jbMuFlN+HkorSJjzjoH7s3FfQtOrAMK3ms5DaENWhKCbILj7Vn4Fz3F1C65OaL6GVHGgC3JOBdLzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR21MB1682 Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot add/remove X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" > Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot > add/remove >=20 > On Mon, 21 Dec 2020 13:33:22 -0800 > Long Li wrote: >=20 > > /* trying to get mac address if this is a network device*/ > > + s =3D socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); > > + if (s =3D=3D -1) { > > + PMD_DRV_LOG(ERR, "Failed to create socket > errno %d\n", > > + errno); > > + break; > > + } > > + strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name)); > > + ret =3D ioctl(s, SIOCGIFHWADDR, &req); > > + close(s); > > + if (ret =3D=3D -1) { > > + PMD_DRV_LOG(ERR, "Failed to send > SIOCGIFHWADDR for " > > + "device %s\n", dir->d_name); > > + break; > > + } > > + if (req.ifr_hwaddr.sa_family !=3D ARPHRD_ETHER) { > > + closedir(di); > > + return; > > + } >=20 > You have sysfs directory open at this point, would it be easier to contin= ue > with sysfs to find the mac address? >=20 > snprintf(ifpath, sizeof(ifpath), "%s/address", dir->d_name); > fd =3D openat(dirfd(di), ifpath, O_RDONLY); > read(fd...) I think sending SIOCGIFHWADDR through socket is safer. This is the same as = vdev_netvsc does. If the network hardware is not ethernet, reading the addr= ess directly from sysfs may require some additional parsing.