From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00082.outbound.protection.outlook.com [40.107.0.82]) by dpdk.org (Postfix) with ESMTP id 232A1695D for ; Wed, 14 Nov 2018 13:57:32 +0100 (CET) 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=v1NEABDLrUV0yKUXzDCLUPxnKFDO66dBip/WarcuOqY=; b=i/5hosmzqlY6swtktc1LMKTqnzzbjdbXTlaVcdxJumi4ZCSfAFT30+EhqKU3quFOI5r2s5EjrWpPq21SO/ekqr14qgCwwwz0svrgPN2KPv1SvdGviVyHJ0Rudb1NDGt5dpQVd7oX6abKORWSdJR0qU/TtPfkio8DM2FtGNLm1LY= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3188.eurprd05.prod.outlook.com (10.171.186.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Wed, 14 Nov 2018 12:57:31 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e%2]) with mapi id 15.20.1294.045; Wed, 14 Nov 2018 12:57:31 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [PATCH 2/4] net/mlx5: fix Netlink communication routine Thread-Index: AQHUesKGE1AKtqM02Uml+gaw0faa8aVNshMAgAGJsuA= Date: Wed, 14 Nov 2018 12:57:30 +0000 Message-ID: References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-3-git-send-email-viacheslavo@mellanox.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [95.67.35.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3188; 6:9a1iCvG4GFjCmlkMCSI3TZswpdHbbWWLKsAD08/JeGFuaRh22Et93scsOu0H+hW/UkQrCCa3r4yq8GfWTkDwSgByO2nemxHkmfbrSuB1fdxO4m3l/0tilWZn0DUbbp7fngLHD51Rd7Hb8rBlQhFYtQuT2LXx5GgYTiBZpK8ua5KWPCNigxF+ChZ8FKPFQROB03V71SudemvQVLi+ZeZE5i4oLJf9kke+TWs0rDdzYpYdcAb83oce6afmOR7JIlWOr1pFje6abBbTjOHA/xDeyHHuwmN5TwRMX+4eKld7k8RQkr+g0/0Yf3xeJlbV1rjqL3w/H4MuTtkNj1Y1GFLE0C19jtdjcRUYJxsTnFu4YBsd4Z3Pr/xm+JpvluN1m20GEUHZqDg421gL4CF8lE94BlI2XwW3hLSs008VfqOPizTw/Bcmk7Dji7QEQh9fXAlg5Re1R1kTtOnqtEFeEf03rg==; 5:HMGXNLI5huWHRSOofkTE8ZvVujfJnXoR+m4lHNLqqooMydf+TWjeuU5dPMyyd1TxfJ5lk1Bx5aiC0odE0UPfkZIt6ZZyTVM2EIhcI/CrmzqLsN/YpcGuoRT1289EItH8NqiiQ6URaW8wVHvEBtdhpctWqOEh81V/U9dmBZWLc2o=; 7:KH/ED6AP5v3lelTej1hREh84FqpfR+O3RC93NMwtqaDoR52N6bF4ytSuSvOmmKke7MX9p28f47wyhNQpoEf/igMpP4xhHKkY/OMSbJoRoDLDqXWfMGi85HAb5HZ7/jYhaPqEQpGb6sQQUCYMNGpaVQ== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: b5854660-a668-48e8-1ba1-08d64a30bd16 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3188; x-ms-traffictypediagnostic: AM4PR05MB3188: authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@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)(3231410)(944501410)(52105112)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3188; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3188; x-forefront-prvs: 085634EFF4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(136003)(366004)(39860400002)(199004)(189003)(13464003)(476003)(68736007)(446003)(25786009)(11346002)(86362001)(6636002)(8676002)(97736004)(486006)(5660300001)(14454004)(110136005)(71190400001)(106356001)(81166006)(81156014)(71200400001)(105586002)(8936002)(93886005)(316002)(478600001)(186003)(33656002)(6436002)(2906002)(2900100001)(6116002)(3846002)(229853002)(26005)(305945005)(76176011)(7736002)(256004)(14444005)(7696005)(102836004)(9686003)(6246003)(4326008)(53936002)(74316002)(66066001)(53546011)(6506007)(55016002)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3188; H:AM4PR05MB3265.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: DlkgSFb45mViTLPnuV8BByylBeIIVWihWePRwl/ymFJNG03IyzpRhf5LUoTwBwGFRkPHoED7fk4yDXVrvtr7ey1/nh9cIRcyJZN0rqr9nscFS3Cy5vGmuAsjDPg2sWxTKR90mOj76BOFGkQ6yDO/NcJG+v4y/vSyyjoikq5XzqI0HBLC4Ml69lNHz6WOWTNMPujaLfUZzxrrk+FSR/WH24c5OMR6noepb373OBw8bljVlSKXsjqKZItsppR2AFhj9bWWp42JJ2H+uhkHfNpJGwGaYUDNErU3Y9N1lsWnIWYRXuWADMmlo82FG464AZoS6/uv5MC39f8WkUD8pNw85FzRn9ZApgoHRBKvMLU9smE= 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: b5854660-a668-48e8-1ba1-08d64a30bd16 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Nov 2018 12:57:30.9010 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3188 Subject: Re: [dpdk-dev] [PATCH 2/4] net/mlx5: fix Netlink communication routine 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: Wed, 14 Nov 2018 12:57:32 -0000 > -----Original Message----- > From: Shahaf Shuler > Sent: Tuesday, November 13, 2018 15:22 > To: Slava Ovsiienko ; Yongseok Koh > > Cc: dev@dpdk.org > Subject: RE: [PATCH 2/4] net/mlx5: fix Netlink communication routine >=20 > Monday, November 12, 2018 10:02 PM, Slava Ovsiienko: > > Subject: [PATCH 2/4] net/mlx5: fix Netlink communication routine > > > > While receiving the Netlink reply messages we should stop at DONE or > > ACK message. The existing implementation stops at DONE message or if > > no multiple message flag set ( NLM_F_MULTI). It prevents the single > > query requests from working, these requests send the single reply > > message without multi-message flag followed by ACK message. This patch > > fixes receiving part of Netlink communication routine. > > > > Fixes: 6e74990b3463 ("net/mlx5: update E-Switch VXLAN netlink > > routines") > > > > Signed-off-by: Viacheslav Ovsiienko > > --- > > drivers/net/mlx5/mlx5_flow_tcf.c | 58 +++++++++++++++++++++++++----- > > ---------- > > 1 file changed, 37 insertions(+), 21 deletions(-) > > > > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c > > b/drivers/net/mlx5/mlx5_flow_tcf.c > > index 5a38940..4d154b6 100644 > > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > > @@ -3732,44 +3732,60 @@ struct pedit_parser { { > > unsigned int portid =3D mnl_socket_get_portid(tcf->nl); > > uint32_t seq =3D tcf->seq++; > > - int err, ret; > > + int ret, err =3D 0; > > > > assert(tcf->nl); > > assert(tcf->buf); > > - if (!seq) > > + if (!seq) { > > /* seq 0 is reserved for kernel event-driven notifications. */ > > seq =3D tcf->seq++; > > + } > > nlh->nlmsg_seq =3D seq; > > nlh->nlmsg_flags |=3D NLM_F_ACK; > > ret =3D mnl_socket_sendto(tcf->nl, nlh, nlh->nlmsg_len); > > - err =3D (ret <=3D 0) ? errno : 0; > > + if (ret <=3D 0) { > > + /* Message send error occurres. */ > > + rte_errno =3D errno; > > + return -rte_errno; > > + } > > nlh =3D (struct nlmsghdr *)(tcf->buf); > > /* > > * The following loop postpones non-fatal errors until multipart > > * messages are complete. > > */ > > - if (ret > 0) > > - while (true) { > > - ret =3D mnl_socket_recvfrom(tcf->nl, tcf->buf, > > - tcf->buf_size); > > + while (true) { >=20 > This while(true) is a bit disturbing (I know it exists also before). >=20 > Can't we bound it to some limit, e.g. is there any multiply of tcf->buf_s= ize > that if we receive more than that it is for sure an error? >=20 We receive the reply messages in the loop - one for each iteration. Yes, it is expected the each message is smaller than tcf->buf_size, but the= number of messages is not limited theoretically. We query the dump, dump can be se= nt by kernel in any number of reply messages, depending on size of dump, we ca= n't make any assumptions regarding the number of reply messages, we should rece= ive all of them until DONE or ACK message is encountered. WBR, Slava > > + ret =3D mnl_socket_recvfrom(tcf->nl, tcf->buf, tcf->buf_size); > > + if (ret < 0) { > > + err =3D errno; > > + /* > > + * In case of overflow Will receive till > > + * end of multipart message. We may lost part > > + * of reply messages but mark and return an error. > > + */ > > + if (err !=3D ENOSPC || > > + !(nlh->nlmsg_flags & NLM_F_MULTI) || > > + nlh->nlmsg_type =3D=3D NLMSG_DONE) > > + break; > > + } else { > > + ret =3D mnl_cb_run(nlh, ret, seq, portid, cb, arg); > > + if (!ret) { > > + /* > > + * libmnl returns 0 if DONE or > > + * success ACK message found. > > + */ > > + break; > > + } > > if (ret < 0) { > > + /* > > + * ACK message with error found > > + * or some error occurred. > > + */ > > err =3D errno; > > - if (err !=3D ENOSPC) > > - break; > > - } > > - if (!err) { > > - ret =3D mnl_cb_run(nlh, ret, seq, portid, > > - cb, arg); > > - if (ret < 0) { > > - err =3D errno; > > - break; > > - } > > - } > > - /* Will receive till end of multipart message */ > > - if (!(nlh->nlmsg_flags & NLM_F_MULTI) || > > - nlh->nlmsg_type =3D=3D NLMSG_DONE) > > break; > > + } > > + /* We should continue receiving. */ > > } > > + } > > if (!err) > > return 0; > > rte_errno =3D err; > > -- > > 1.8.3.1