From patchwork Tue Sep 15 18:52:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Raju X-Patchwork-Id: 518084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id E515D1402D6 for ; Wed, 16 Sep 2015 04:52:46 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 0EB0D10A5E; Tue, 15 Sep 2015 11:52:41 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id EB5A810A5B for ; Tue, 15 Sep 2015 11:52:39 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 6995942006A for ; Tue, 15 Sep 2015 12:52:39 -0600 (MDT) X-ASG-Debug-ID: 1442343158-09eadd48f919d280001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id WQR6DyJpjbTTFIrR (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Sep 2015 12:52:38 -0600 (MDT) X-Barracuda-Envelope-From: nithin@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO smtp-outbound-2.vmware.com) (208.91.2.13) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 15 Sep 2015 18:52:38 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf.vmware.com designates 208.91.2.13 as permitted sender) X-Barracuda-Apparent-Source-IP: 208.91.2.13 X-Barracuda-RBL-IP: 208.91.2.13 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id A1ADB28208 for ; Tue, 15 Sep 2015 11:52:37 -0700 (PDT) Received: from pa-dbc1122.eng.vmware.com (unknown [10.162.210.22]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 700911899D; Tue, 15 Sep 2015 11:52:32 -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-914078134 X-CudaMail-DTE: 091515 X-CudaMail-Originating-IP: 208.91.2.13 Date: Tue, 15 Sep 2015 11:52:28 -0700 X-ASG-Orig-Subj: [##CM-E2-914078134##][PATCH 3/4] datapath-windows: return netlink error for read operation Message-Id: <1442343149-52881-3-git-send-email-nithin@vmware.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1442343149-52881-1-git-send-email-nithin@vmware.com> References: <1442343149-52881-1-git-send-email-nithin@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1442343158 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] 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 --- datapath-windows/ovsext/Datapath.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c index 409c4bb..8dce97d 100644 --- a/datapath-windows/ovsext/Datapath.c +++ b/datapath-windows/ovsext/Datapath.c @@ -1020,10 +1020,25 @@ 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. */ + msgInTmp.nlMsg.nlmsgLen = 0; + msgInTmp.nlMsg.nlmsgType = nlFamilyOps->id; + msgInTmp.nlMsg.nlmsgFlags = 0; + msgInTmp.nlMsg.nlmsgSeq = 0; + msgInTmp.nlMsg.nlmsgPid = usrParamsCtx->ovsInstance->pid; + msgIn = &msgInTmp; + } else { + msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer; + } + + ASSERT(msgIn); ASSERT(msgError); NlBuildErrorMsg(msgIn, msgError, nlError); *replyLen = msgError->nlMsg.nlmsgLen;