[ovs-dev] [PATCH 1/3] datapath-windows: Move Build*Msg() to Netlink.c

Eitan Eliahu eliahue at vmware.com
Wed Dec 3 17:58:58 UTC 2014


Acked-by: Eitan Eliahu <eliahue at vmware.com>
Thanks,
Eitan

-----Original Message-----
From: dev [mailto:dev-bounces at openvswitch.org] On Behalf Of Nithin Raju
Sent: Wednesday, December 03, 2014 7:56 AM
To: dev at openvswitch.org
Subject: [ovs-dev] [PATCH 1/3] datapath-windows: Move Build*Msg() to Netlink.c

Moving the functions that build netlink messages to Netlink.c from Vport.c

Signed-off-by: Nithin Raju <nithin at vmware.com>
---
 datapath-windows/ovsext/Datapath.h        |   14 --------
 datapath-windows/ovsext/Netlink/Netlink.c |   37 ++++++++++++++++++++++
 datapath-windows/ovsext/Netlink/Netlink.h |   13 ++++++++
 datapath-windows/ovsext/Vport.c           |   47 +++-------------------------
 4 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.h b/datapath-windows/ovsext/Datapath.h
index e436699..2e3bac5 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -25,14 +25,6 @@
 #define __DATAPATH_H_ 1
 
 /*
- * Structure of an error message sent as a reply from kernel.
- */
-typedef struct _OVS_MESSAGE_ERROR {
-    NL_MSG_HDR nlMsg;
-    NL_MSG_ERR errorMsg;
-} OVS_MESSAGE_ERROR, *POVS_MESSAGE_ERROR;
-
-/*
  * Device operations to tag netlink commands with. This is a bitmask since it
  * is possible that a particular command can be invoked via different device
  * operations.
@@ -98,12 +90,6 @@ NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);  VOID OvsAcquireCtrlLock();  VOID OvsReleaseCtrlLock();
 
-/* XXX: Move this to netlink.[ch] eventually. */ -VOID BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut,
-                            UINT16 flags);
-VOID BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut,
-                   UINT errorCode);
-
 /*
  * Utility structure and functions to collect in one place all the parameters
  * passed during a call from userspace.
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index ae10a87..7633f2f 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -102,6 +102,43 @@ NlFillNlHdr(PNL_BUFFER nlBuf, UINT16 nlmsgType,
     return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE;  }
 
+static VOID
+BuildMsgOut(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 type,
+            UINT32 length, UINT16 flags) {
+    msgOut->nlMsg.nlmsgType = type;
+    msgOut->nlMsg.nlmsgFlags = flags;
+    msgOut->nlMsg.nlmsgSeq = msgIn->nlMsg.nlmsgSeq;
+    msgOut->nlMsg.nlmsgPid = msgIn->nlMsg.nlmsgPid;
+    msgOut->nlMsg.nlmsgLen = length;
+
+    msgOut->genlMsg.cmd = msgIn->genlMsg.cmd;
+    msgOut->genlMsg.version = msgIn->genlMsg.version;
+    msgOut->genlMsg.reserved = 0;
+}
+
+/*
+ * XXX: should move out these functions to a Netlink.c or to a 
+OvsMessage.c
+ * or even make them inlined functions in Datapath.h. Can be done after 
+the
+ * first sprint once we have more code to refactor.
+ */
+VOID
+BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 
+flags) {
+    BuildMsgOut(msgIn, msgOut, msgIn->nlMsg.nlmsgType, sizeof(OVS_MESSAGE),
+                flags);
+}
+
+VOID
+BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut, UINT 
+errorCode) {
+    BuildMsgOut(msgIn, (POVS_MESSAGE)msgOut, NLMSG_ERROR,
+                sizeof(OVS_MESSAGE_ERROR), 0);
+
+    msgOut->errorMsg.error = errorCode;
+    msgOut->errorMsg.nlMsg = msgIn->nlMsg; }
+
 /*
  * ---------------------------------------------------------------------------
  * Adds Netlink Header to the NL_BUF.
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index 438d857..18e40b1 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -32,6 +32,14 @@ typedef struct _OVS_MESSAGE {
     /* Variable length nl_attrs follow. */  } OVS_MESSAGE, *POVS_MESSAGE;
 
+/*
+ * Structure of an error message sent as a reply from kernel.
+ */
+typedef struct _OVS_MESSAGE_ERROR {
+    NL_MSG_HDR nlMsg;
+    NL_MSG_ERR errorMsg;
+} OVS_MESSAGE_ERROR, *POVS_MESSAGE_ERROR;
+
 /* Netlink attribute types. */
 typedef enum
 {
@@ -86,6 +94,11 @@ NTSTATUS NlFillNlHdr(PNL_BUFFER nlBuf,
                      UINT16 nlmsgType, UINT16 nlmsgFlags,
                      UINT32 nlmsgSeq, UINT32 nlmsgPid);
 
+VOID BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut,
+                            UINT16 flags); VOID 
+BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut,
+                   UINT errorCode);
+
 /* Netlink message accessing the payload */  PVOID NlMsgAt(const PNL_MSG_HDR nlh, UINT32 offset);
 UINT32 NlMsgSize(const PNL_MSG_HDR nlh); diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c index fc905b1..35f95bc 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -1631,44 +1631,6 @@ OvsWaitActivate(POVS_SWITCH_CONTEXT switchContext, ULONG sleepMicroSec)
     }
 }
 
-
-static VOID
-BuildMsgOut(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 type,
-            UINT32 length, UINT16 flags)
-{
-    msgOut->nlMsg.nlmsgType = type;
-    msgOut->nlMsg.nlmsgFlags = flags;
-    msgOut->nlMsg.nlmsgSeq = msgIn->nlMsg.nlmsgSeq;
-    msgOut->nlMsg.nlmsgPid = msgIn->nlMsg.nlmsgPid;
-    msgOut->nlMsg.nlmsgLen = length;
-
-    msgOut->genlMsg.cmd = msgIn->genlMsg.cmd;
-    msgOut->genlMsg.version = msgIn->genlMsg.version;
-    msgOut->genlMsg.reserved = 0;
-}
-
-/*
- * XXX: should move out these functions to a Netlink.c or to a OvsMessage.c
- * or even make them inlined functions in Datapath.h. Can be done after the
- * first sprint once we have more code to refactor.
- */
-VOID
-BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 flags) -{
-    BuildMsgOut(msgIn, msgOut, msgIn->nlMsg.nlmsgType, sizeof(OVS_MESSAGE),
-                flags);
-}
-
-VOID
-BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut, UINT errorCode) -{
-    BuildMsgOut(msgIn, (POVS_MESSAGE)msgOut, NLMSG_ERROR,
-                sizeof(OVS_MESSAGE_ERROR), 0);
-
-    msgOut->errorMsg.error = errorCode;
-    msgOut->errorMsg.nlMsg = msgIn->nlMsg;
-}
-
 static NTSTATUS
 OvsCreateMsgFromVport(POVS_VPORT_ENTRY vport,
                       POVS_MESSAGE msgIn, @@ -1948,8 +1910,10 @@ Cleanup:
 
 /*
  * --------------------------------------------------------------------------
- *  Handler for the get vport command. The function handles the initial call to
- *  setup the dump state, as well as subsequent calls to continue dumping data.
+ *  Command Handler for 'OVS_VPORT_CMD_NEW'.
+ *
+ *  The function handles the initial call to setup the dump state, as 
+ well as
+ *  subsequent calls to continue dumping data.
  * --------------------------------------------------------------------------
 */
 NTSTATUS
@@ -1958,8 +1922,7 @@ OvsGetVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,  {
     *replyLen = 0;
 
-    switch (usrParamsCtx->devOp)
-    {
+    switch (usrParamsCtx->devOp) {
     case OVS_WRITE_DEV_OP:
         return OvsSetupDumpStart(usrParamsCtx);
 
--
1.7.4.1

_______________________________________________
dev mailing list
dev at openvswitch.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailman_listinfo_dev&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=CWsgHUxi6ExLXY798tmo3LJ4e3geGYp56lkcH-5cLCY&m=_pNrJOaUKOew_uwqUnGTYclPSoAyh1DmMgj8iqGVaNg&s=BEwrNseBe89Bu-zZ5-YjWZ0tB7ieLD8VB_3qYbbx5OA&e= 


More information about the dev mailing list