From patchwork Wed Sep 23 16:15:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Raju X-Patchwork-Id: 521761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 7B6971401AF for ; Thu, 24 Sep 2015 02:15:58 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 3497D22C39C; Wed, 23 Sep 2015 09:15:46 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 6411F22C39B for ; Wed, 23 Sep 2015 09:15:44 -0700 (PDT) Received: from bar2.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id DBCF51E0261 for ; Wed, 23 Sep 2015 10:15:43 -0600 (MDT) X-ASG-Debug-ID: 1443024936-03dc537fe152b260001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id 8LY8putH5lEKeqoH (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Sep 2015 10:15:36 -0600 (MDT) X-Barracuda-Envelope-From: nithin@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO smtp-outbound-1.vmware.com) (208.91.2.12) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 23 Sep 2015 16:15:36 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf.vmware.com designates 208.91.2.12 as permitted sender) X-Barracuda-Apparent-Source-IP: 208.91.2.12 X-Barracuda-RBL-IP: 208.91.2.12 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id DCB5C2876C for ; Wed, 23 Sep 2015 09:18:02 -0700 (PDT) Received: from pa-dbc1122.eng.vmware.com (unknown [10.162.210.22]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 62E6B18584; Wed, 23 Sep 2015 09:15:34 -0700 (PDT) X-CudaMail-Envelope-Sender: nithin@vmware.com From: Nithin Raju To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-922050558 X-CudaMail-DTE: 092315 X-CudaMail-Originating-IP: 208.91.2.12 Date: Wed, 23 Sep 2015 09:15:32 -0700 X-ASG-Orig-Subj: [##CM-E2-922050558##][PATCH 3/4 v2] datapath-windows: return netlink error for read operation Message-Id: <1443024933-47622-3-git-send-email-nithin@vmware.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1443024933-47622-1-git-send-email-nithin@vmware.com> References: <1443024933-47622-1-git-send-email-nithin@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1443024936 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Subject: [ovs-dev] [PATCH 3/4 v2] datapath-windows: return netlink error for read operation X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" The kernel datapath returns a NL error message upon any errors during read operations, and returns STATUS_SUCCESS as the return code. We reply on the input NL request to get the family ID, and the PID. However, when the request is of type OVS_CTRL_CMD_EVENT_NOTIFY and OVS_CTRL_CMD_READ_NOTIFY, there's no input buffer associated with the request. So, we use a temporary input buffer to be able to call the Netlink APIs for constructing the output NL error message. Signed-off-by: Nithin Raju Acked-by: Sairam Venugopal Acked-by: Alin Gabriel Serdean --- v2: addressed ALin's review comments --- datapath-windows/ovsext/Datapath.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c index 1e16604..b3dbd71 100644 --- a/datapath-windows/ovsext/Datapath.c +++ b/datapath-windows/ovsext/Datapath.c @@ -1020,10 +1020,24 @@ InvokeNetlinkCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, if (status != STATUS_SUCCESS && status != STATUS_PENDING) { if (usrParamsCtx->devOp != OVS_WRITE_DEV_OP && *replyLen == 0) { NL_ERROR nlError = NlMapStatusToNlErr(status); - POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer; + OVS_MESSAGE msgInTmp = { 0 }; + POVS_MESSAGE msgIn = NULL; POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR) usrParamsCtx->outputBuffer; + if (usrParamsCtx->ovsMsg->genlMsg.cmd == OVS_CTRL_CMD_EVENT_NOTIFY || + usrParamsCtx->ovsMsg->genlMsg.cmd == OVS_CTRL_CMD_READ_NOTIFY) { + /* There's no input buffer associated with such requests. */ + NL_BUFFER nlBuffer; + msgIn = &msgInTmp; + NlBufInit(&nlBuffer, (PCHAR)msgIn, sizeof *msgIn); + NlFillNlHdr(&nlBuffer, nlFamilyOps->id, 0, 0, + usrParamsCtx->ovsInstance->pid); + } else { + msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer; + } + + ASSERT(msgIn); ASSERT(msgError); NlBuildErrorMsg(msgIn, msgError, nlError); *replyLen = msgError->nlMsg.nlmsgLen;