From mboxrd@z Thu Jan 1 00:00:00 1970 From: Slava Ovsiienko Subject: [PATCH 2/4] net/mlx5: fix Netlink communication routine Date: Mon, 12 Nov 2018 20:01:40 +0000 Message-ID: <1542052877-41512-3-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh Return-path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80089.outbound.protection.outlook.com [40.107.8.89]) by dpdk.org (Postfix) with ESMTP id 96CF04CA5 for ; Mon, 12 Nov 2018 21:01:41 +0100 (CET) In-Reply-To: <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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; =20 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) { + 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; --=20 1.8.3.1