[ovs-dev] [PATCH v2 6/7] datapath-windows: Update OvsReadEventCmdHandler in Datapath.c to support different events

Sairam Venugopal vsairam at vmware.com
Tue Jul 26 00:04:42 UTC 2016


OvsReadEventCmdHandler must now reflect the right event being read. If the
event is a Conntrack related event, then convert the entry to netlink
format and send it to userspace. If it's Vport event, retain the existing
workflow.

v2: Address review comments from Alin Serdean (Not default values to 0 and
instead read from msgIn). Added Acked-By

Signed-off-by: Sairam Venugopal <vsairam at vmware.com>
Acked-by: Paul Boca <pboca at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Datapath.c | 66 +++++++++++++++++++++++++++++---------
 1 file changed, 50 insertions(+), 16 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
index f9f965c..745cdb6 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -1672,14 +1672,12 @@ static NTSTATUS
 OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                        UINT32 *replyLen)
 {
-#ifdef DBG
     POVS_MESSAGE msgOut = (POVS_MESSAGE)usrParamsCtx->outputBuffer;
+    POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
     POVS_OPEN_INSTANCE instance =
         (POVS_OPEN_INSTANCE)usrParamsCtx->ovsInstance;
-#endif
     NL_BUFFER nlBuf;
     NTSTATUS status;
-    OVS_VPORT_EVENT_ENTRY eventEntry;
 
     ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP);
 
@@ -1692,21 +1690,57 @@ OvsReadEventCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
     /* Output buffer has been validated while validating read dev op. */
     ASSERT(msgOut != NULL && usrParamsCtx->outputLength >= sizeof *msgOut);
 
-    NlBufInit(&nlBuf, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength);
+    if (instance->protocol == NETLINK_NETFILTER) {
+        if (!instance->mcastMask) {
+            status = STATUS_SUCCESS;
+            *replyLen = 0;
+            goto cleanup;
+        }
 
-    /* remove an event entry from the event queue */
-    status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
-                                      &eventEntry);
-    if (status != STATUS_SUCCESS) {
-        /* If there were not elements, read should return no data. */
-        status = STATUS_SUCCESS;
-        *replyLen = 0;
-        goto cleanup;
-    }
+        OVS_CT_EVENT_ENTRY ctEventEntry;
+        status = OvsRemoveCtEventEntry(usrParamsCtx->ovsInstance,
+                                       &ctEventEntry);
 
-    status = OvsPortFillInfo(usrParamsCtx, &eventEntry, &nlBuf);
-    if (status == NDIS_STATUS_SUCCESS) {
-        *replyLen = NlBufSize(&nlBuf);
+        if (status != STATUS_SUCCESS) {
+            /* If there were not elements, read should return no data. */
+            status = STATUS_SUCCESS;
+            *replyLen = 0;
+            goto cleanup;
+        }
+
+        status = OvsCreateNlMsgFromCtEntry(&ctEventEntry.entry,
+                                           usrParamsCtx->outputBuffer,
+                                           usrParamsCtx->outputLength,
+                                           ctEventEntry.type,
+                                           msgIn->nlMsg.nlmsgSeq,
+                                           usrParamsCtx->ovsInstance->pid,
+                                           NFNETLINK_V0,
+                                           gOvsSwitchContext->dpNo);
+        if (status == NDIS_STATUS_SUCCESS) {
+            *replyLen = msgOut->nlMsg.nlmsgLen;
+        }
+    } else if (instance->protocol == NETLINK_GENERIC) {
+        NlBufInit(&nlBuf,
+                  usrParamsCtx->outputBuffer,
+                  usrParamsCtx->outputLength);
+
+        OVS_VPORT_EVENT_ENTRY eventEntry;
+        /* remove vport event entry from the vport event queue */
+        status = OvsRemoveVportEventEntry(usrParamsCtx->ovsInstance,
+                                          &eventEntry);
+        if (status != STATUS_SUCCESS) {
+            /* If there were not elements, read should return no data. */
+            status = STATUS_SUCCESS;
+            *replyLen = 0;
+            goto cleanup;
+        }
+
+        status = OvsPortFillInfo(usrParamsCtx, &eventEntry, &nlBuf);
+        if (status == NDIS_STATUS_SUCCESS) {
+            *replyLen = NlBufSize(&nlBuf);
+        }
+    } else {
+        status = STATUS_INVALID_PARAMETER;
     }
 
 cleanup:
-- 
2.9.0.windows.1




More information about the dev mailing list