diff mbox

[ovs-dev,3/4] datapath-windows: return netlink error for read operation

Message ID 1442343149-52881-3-git-send-email-nithin@vmware.com
State Superseded
Headers show

Commit Message

Nithin Raju Sept. 15, 2015, 6:52 p.m. UTC
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 <nithin@vmware.com>
---
 datapath-windows/ovsext/Datapath.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Sairam Venugopal Sept. 19, 2015, 12:42 a.m. UTC | #1
Acked-by: Sairam Venugopal <vsairam@vmware.com>


On 9/15/15, 11:52 AM, "Nithin Raju" <nithin@vmware.com> wrote:

>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 <nithin@vmware.com>
>---
> 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;
>-- 
>1.8.5.6
>
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
>n_listinfo_dev&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Dc
>ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ&m=fVZ2fP_SDXKNCKrglHfU-wgr_QVTUe
>I8IqoPOpOTbNc&s=ZE2Nxv2llugjT6mzOnB7bWqonbHf6ywDl5gXPmBUfSs&e=
Alin Serdean Sept. 23, 2015, 3:23 p.m. UTC | #2
You could probably use NlFillNlHdr to prepare the netlink message.

Shouldn't this be apply to OVS_IOCTL_READ also?

Alin.

> -----Mesaj original-----

> De la: dev [mailto:dev-bounces@openvswitch.org] În numele Nithin Raju

> Trimis: Tuesday, September 15, 2015 9:52 PM

> Către: dev@openvswitch.org

> Subiect: [ovs-dev] [PATCH 3/4] datapath-windows: return netlink error for

> read operation

> 

> 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 <nithin@vmware.com>

> ---

>  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;

> --

> 1.8.5.6

> 

> _______________________________________________

> dev mailing list

> dev@openvswitch.org

> http://openvswitch.org/mailman/listinfo/dev
Nithin Raju Sept. 23, 2015, 3:55 p.m. UTC | #3
> On Sep 23, 2015, at 8:23 AM, Alin Serdean <aserdean@cloudbasesolutions.com> wrote:

> 

> You could probably use NlFillNlHdr to prepare the netlink message.


Done in the v2.

> 

> Shouldn't this be apply to OVS_IOCTL_READ also?


OVS_IOCTL_READ is used for dump operations, in which case we’d have cached the msgIn from the dump state message, and use it in all of the subsequent reads, until the dump is complete.

-- Nithin
diff mbox

Patch

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;