aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNithin Raju <nithin@vmware.com>2014-12-03 07:56:00 -0800
committerBen Pfaff <blp@nicira.com>2014-12-05 10:30:20 -0800
commitfa8266a805b46891854d1fd48827514c7a1f0b55 (patch)
treeb4ffc673a7f648e08fd2358df86b013b77324a80
parent3100516ad790b20e449b67a848e071dc5bd3f8d3 (diff)
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@vmware.com> Acked-by: Eitan Eliahu <eliahue@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--datapath-windows/ovsext/Datapath.h14
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.c37
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.h13
-rw-r--r--datapath-windows/ovsext/Vport.c47
4 files changed, 55 insertions, 56 deletions
diff --git a/datapath-windows/ovsext/Datapath.h b/datapath-windows/ovsext/Datapath.h
index e4366994c..2e3bac58f 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 ae10a870d..7633f2ff1 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 438d8571a..18e40b133 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 fc905b1c8..35f95bc98 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);