datapath-windows: Move Build*Msg() to Netlink.c
authorNithin Raju <nithin@vmware.com>
Wed, 3 Dec 2014 15:56:00 +0000 (07:56 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 5 Dec 2014 18:30:20 +0000 (10:30 -0800)
Moving the functions that build netlink messages to Netlink.c from
Vport.c

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/Datapath.h
datapath-windows/ovsext/Netlink/Netlink.c
datapath-windows/ovsext/Netlink/Netlink.h
datapath-windows/ovsext/Vport.c

index e436699..2e3bac5 100644 (file)
 #ifndef __DATAPATH_H_
 #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
@@ -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.
index ae10a87..7633f2f 100644 (file)
@@ -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.
index 438d857..18e40b1 100644 (file)
@@ -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);
index fc905b1..35f95bc 100644 (file)
@@ -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);