From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00085.outbound.protection.outlook.com [40.107.0.85]) by dpdk.org (Postfix) with ESMTP id 06021324D for ; Tue, 19 Jun 2018 12:13:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2TxQKWcbya19qJrcGLGAO8jGGVKRnyL1yLEvx9/o6ww=; b=vq2uA688O3uOIntszgvPtf4btpUsy2E9tRa+HE359mtwNEziZlfpPWOc2Ot4/q980Ls4eGGdetnQUs491teu3kqZD3mxVu/RbLr+3rCRAIzGNHpmESQ5EF1x9m3t8vo9ICQIcj4X+IVsqpZ+2oVt0vejuGMDfMAEc4/YkT/mCSM= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2688.eurprd05.prod.outlook.com (10.172.15.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.19; Tue, 19 Jun 2018 10:13:19 +0000 Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::4548:a183:6278:6d9f]) by VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::4548:a183:6278:6d9f%2]) with mapi id 15.20.0863.016; Tue, 19 Jun 2018 10:13:19 +0000 From: Matan Azrad To: Alex Kiselev , "dev@dpdk.org" , Chas Williams <3chas3@gmail.com>, Stephen Hemminger Thread-Topic: [PATCH v3] net/bonding: add add/remove mac addrs Thread-Index: AQHUB6gE1ABdmYF0+ki0J7ZTCtW20qRnRWoggAAIlQCAAA6fQA== Date: Tue, 19 Jun 2018 10:13:19 +0000 Message-ID: References: <0d1c4f28-e08b-40e7-9b9e-0d4bdd15279a@VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com> <162811227.20180619121942@therouter.net> In-Reply-To: <162811227.20180619121942@therouter.net> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2688; 7:OA6et9R0RGGKD2fv4JM4ey5qImmdvxvhPhouY7GHmBPWofYd/LErl4D0dkvMBu3uysslD6+kUNKwap5fcKXDfDmXNhSTayqAQq22RFis5Hft+CSGrOkkjfetuhV0ySdc/wE+KeLJId5a+YMcPNiNO1tHPJA5M+CFYqIBkm9gnpX1f9uknZdX2RW6MHUfHJGj/yfmCc/myBP4WLdlAK3v1XAKLVbkQzuuvo5ra9ZTH2nKlBQH1l5D7bdOwelbE1Vl x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: ee581332-e705-4c5f-bd3c-08d5d5cd480f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2688; x-ms-traffictypediagnostic: VI1PR0501MB2688: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2688; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2688; x-forefront-prvs: 07083FF734 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(366004)(396003)(39380400002)(199004)(189003)(316002)(76176011)(6506007)(59450400001)(14454004)(68736007)(55016002)(6436002)(8676002)(478600001)(81166006)(8936002)(229853002)(110136005)(33656002)(86362001)(99286004)(7696005)(5660300001)(102836004)(81156014)(5250100002)(186003)(6246003)(25786009)(39060400002)(486006)(6116002)(3846002)(26005)(476003)(74316002)(2906002)(7736002)(66066001)(446003)(3280700002)(11346002)(2900100001)(106356001)(105586002)(9686003)(305945005)(2501003)(97736004)(53936002)(3660700001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2688; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ZM7LKEtBPfy8/pDA6Ts4iK35+SWjGiHHggI80PRJZwYI1puttLC5iCC1tpXqeyzFgIgEoTWbQpCYA5bCN3XEIjew4jEqirPKXX1mzAW46ZOXyQHAh/zS9jP9bLsVIfuqGgDDeK/LwWByVecx7KW6BNdJAu8cs3PPzNXHKTbN2RFSSqXuJWyzfhlXjRjyEN4m8G6SZMTCpwGPP11ECdSs8EbYRPV1pg38Jeb8UKpQv/NUhD4wdfZFbN2S/1XbBpSH/+Pr1xWGRRFmlulflPi2/ZE0ema9WVexH9tFfBYy5SqMnBQyyddmV82f3iwf/ii8CeuPuF2Y7hqHuUouDfaRXg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee581332-e705-4c5f-bd3c-08d5d5cd480f X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2018 10:13:19.5485 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2688 Subject: Re: [dpdk-dev] [PATCH v3] net/bonding: add add/remove mac addrs 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: , X-List-Received-Date: Tue, 19 Jun 2018 10:13:21 -0000 From: Alex Kiselev > Hi Matan. >=20 > > Hi Alex >=20 > > Please see comments below. >=20 >=20 > >> + > >> + ret =3D rte_eth_dev_mac_addr_add(slave_port_id, mac_addr= , 0); > >> + if (ret < 0) { > >> + /* rollback */ > >> + for (i--; i > 0; i--) > >> + >=20 > > In case of failure in the first mac address(i=3D1) you are going to > > remove the default mac address(i=3D0) from the slave. > In that case i will be incremented first and will be equal to 0, then for= condition > will fail and the loop body will not be executed. >=20 Yes, my mistake. >=20 > >> rte_eth_dev_mac_addr_remove(slave_port_id, > >> + &bonded_eth_dev->data- > >> >mac_addrs[i]); > >> + return ret; > >> + } > >> + } > >> + > >> + return 0; > >> +} > >> + > >> +/* > >> + * Remove additional MAC addresses from the slave */ int > >> +slave_remove_mac_addresses(struct rte_eth_dev *bonded_eth_dev, > >> + uint16_t slave_port_id) { > >> + int i, ret =3D 0; > >> + struct ether_addr *mac_addr; > >> + > >> + for (i =3D 1; i < BOND_MAX_MAC_ADDRS; i++) { > >> + mac_addr =3D &bonded_eth_dev->data->mac_addrs[i]; > >> + if (is_same_ether_addr(mac_addr, &null_mac_addr)) > >> + break; > >> + > >> + ret =3D rte_eth_dev_mac_addr_remove(slave_port_id, > >> mac_addr); > >> + } >=20 > > I suggest to return the first error, also in case of all success with > > last failure, the code here wrongly returns success. > Yeah, you are right. I'll fix it. >=20 > >> + > >> + for (i =3D 0; i < internals->slave_count; i++) { > >> + ret =3D rte_eth_dev_mac_addr_add(internals->slaves[i].po= rt_id, > >> + mac_addr, vmdq); > >> + if (ret < 0) { > >> + /* rollback */ > >> + for (i--; i >=3D 0; i--) >=20 > > In case of failure in the first slave(i=3D0) you are going probably to = get memory > error (i=3D-1). > The same logic apply here. When i =3D=3D-1 the condition will fail and th= e loop body > will not be executed; Yes, my mistake. >=20 >=20 >=20 >=20 > -- > Alex