UINT32 *replyLen)
{
NTSTATUS rc = STATUS_SUCCESS;
+ BOOLEAN ok;
POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
POVS_MESSAGE msgOut = (POVS_MESSAGE)usrParamsCtx->outputBuffer;
PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg);
OvsFlowStats stats;
struct ovs_flow_stats replyStats;
NL_ERROR nlError = NL_ERROR_SUCCESS;
-
NL_BUFFER nlBuf;
RtlZeroMemory(&mappedFlow, sizeof(OvsFlowPut));
usrParamsCtx->outputLength);
/* Prepare nl Msg headers */
- rc = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
+ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid,
genlMsgHdr->cmd, OVS_FLOW_VERSION,
ovsHdr->dp_ifindex);
-
- if (rc == STATUS_SUCCESS) {
+ if (ok) {
*replyLen = msgOut->nlMsg.nlmsgLen;
+ } else {
+ rc = STATUS_INVALID_BUFFER_SIZE;
}
}
usrParamsCtx->outputLength);
/* Prepare nl Msg headers */
- rc = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
+ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid,
genlMsgHdr->cmd, OVS_FLOW_VERSION,
ovsHdr->dp_ifindex);
-
- if (rc != STATUS_SUCCESS) {
+ if (!ok) {
+ rc = STATUS_INVALID_BUFFER_SIZE;
goto done;
+ } else {
+ rc = STATUS_SUCCESS;
}
/* Append OVS_FLOW_ATTR_STATS attribute */
/* Done with Dump, send NLMSG_DONE */
if (!(dumpOutput.n)) {
+ BOOLEAN ok;
+
OVS_LOG_INFO("Dump Done");
nlMsgOutHdr = (PNL_MSG_HDR)(NlBufAt(&nlBuf, NlBufSize(&nlBuf), 0));
- rc = NlFillNlHdr(&nlBuf, NLMSG_DONE, NLM_F_MULTI,
+ ok = NlFillNlHdr(&nlBuf, NLMSG_DONE, NLM_F_MULTI,
nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid);
- if (rc != STATUS_SUCCESS) {
+ if (!ok) {
+ rc = STATUS_INVALID_BUFFER_SIZE;
OVS_LOG_ERROR("Unable to prepare DUMP_DONE reply.");
break;
+ } else {
+ rc = STATUS_SUCCESS;
}
NlMsgAlignSize(nlMsgOutHdr);
FreeUserDumpState(instance);
break;
} else {
+ BOOLEAN ok;
hdrOffset = NlBufSize(&nlBuf);
nlMsgOutHdr = (PNL_MSG_HDR)(NlBufAt(&nlBuf, hdrOffset, 0));
/* Netlink header */
- rc = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, NLM_F_MULTI,
+ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, NLM_F_MULTI,
nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid,
genlMsgHdr->cmd, genlMsgHdr->version,
ovsHdr->dp_ifindex);
- if (rc != STATUS_SUCCESS) {
+ if (!ok) {
/* Reset rc to success so that we can
* send already added messages to user space. */
rc = STATUS_SUCCESS;
* Attributes should be added by caller.
* ---------------------------------------------------------------------------
*/
-NTSTATUS
+BOOLEAN
NlFillOvsMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
UINT16 nlmsgFlags, UINT32 nlmsgSeq,
UINT32 nlmsgPid, UINT8 genlCmd,
writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut),
sizeof (struct _OVS_MESSAGE));
- return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE;
+ return writeOk;
}
/*
* input NlBuf.
* ---------------------------------------------------------------------------
*/
-NTSTATUS
+BOOLEAN
NlFillNlHdr(PNL_BUFFER nlBuf, UINT16 nlmsgType,
UINT16 nlmsgFlags, UINT32 nlmsgSeq,
UINT32 nlmsgPid)
writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut),
sizeof(struct _NL_MSG_HDR));
- return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE;
+ return writeOk;
}
/*
#define NL_ATTR_GET_AS(NLA, TYPE) \
(*(TYPE*) NlAttrGetUnspec(nla, sizeof(TYPE)))
-NTSTATUS NlFillOvsMsg(PNL_BUFFER nlBuf,
- UINT16 nlmsgType, UINT16 nlmsgFlags,
- UINT32 nlmsgSeq, UINT32 nlmsgPid,
- UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);
-NTSTATUS NlFillNlHdr(PNL_BUFFER nlBuf,
+BOOLEAN NlFillOvsMsg(PNL_BUFFER nlBuf,
UINT16 nlmsgType, UINT16 nlmsgFlags,
- UINT32 nlmsgSeq, UINT32 nlmsgPid);
+ UINT32 nlmsgSeq, UINT32 nlmsgPid,
+ UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);
+BOOLEAN NlFillNlHdr(PNL_BUFFER nlBuf,
+ UINT16 nlmsgType, UINT16 nlmsgFlags,
+ UINT32 nlmsgSeq, UINT32 nlmsgPid);
VOID NlBuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut,
UINT errorCode);
/* Default reply that we want to send */
if (status == STATUS_SUCCESS) {
+ BOOLEAN ok;
+
NlBufInit(&nlBuf, usrParamsCtx->outputBuffer,
usrParamsCtx->outputLength);
/* Prepare nl Msg headers */
- status = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
+ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0,
nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid,
genlMsgHdr->cmd, OVS_PACKET_VERSION,
ovsHdr->dp_ifindex);
- if (status == STATUS_SUCCESS) {
+ if (ok) {
*replyLen = msgOut->nlMsg.nlmsgLen;
+ } else {
+ status = STATUS_INVALID_BUFFER_SIZE;
}
} else {
/* Map NTSTATUS to NL_ERROR */
* Since we are pre allocating memory for the NL buffer
* the attribute settings should not fail
*/
- if (NlFillOvsMsg(&nlBuf, OVS_WIN_NL_PACKET_FAMILY_ID, 0,
+ if (!NlFillOvsMsg(&nlBuf, OVS_WIN_NL_PACKET_FAMILY_ID, 0,
0, pid, (UINT8)cmd, OVS_PACKET_VERSION,
- gOvsSwitchContext->dpNo) != STATUS_SUCCESS) {
+ gOvsSwitchContext->dpNo)) {
goto fail;
}
ok = NlFillOvsMsg(&nlBuffer, msgIn->nlMsg.nlmsgType, NLM_F_MULTI,
msgIn->nlMsg.nlmsgSeq, msgIn->nlMsg.nlmsgPid,
msgIn->genlMsg.cmd, msgIn->genlMsg.version,
- dpIfIndex) == STATUS_SUCCESS ? TRUE : FALSE;
+ dpIfIndex);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_PORT_NO,
info->portNo);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_TYPE, info->type);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailString(&nlBuffer, OVS_WIN_NETDEV_ATTR_NAME,
info->name);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailUnspec(&nlBuffer, OVS_WIN_NETDEV_ATTR_MAC_ADDR,
(PCHAR)info->macAddress, sizeof (info->macAddress));
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_MTU, info->mtu);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
if (info->status != OVS_EVENT_CONNECT) {
ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_IF_FLAGS,
netdevFlags);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
/*
ok = NlFillOvsMsg(&nlBuffer, msgIn->nlMsg.nlmsgType, NLM_F_MULTI,
msgIn->nlMsg.nlmsgSeq, msgIn->nlMsg.nlmsgPid,
msgIn->genlMsg.cmd, msgIn->genlMsg.version,
- dpIfIndex) == STATUS_SUCCESS ? TRUE : FALSE;
+ dpIfIndex);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailU32(&nlBuffer, OVS_VPORT_ATTR_PORT_NO, vport->portNo);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailU32(&nlBuffer, OVS_VPORT_ATTR_TYPE, vport->ovsType);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
ok = NlMsgPutTailString(&nlBuffer, OVS_VPORT_ATTR_NAME, vport->ovsName);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
/*
ok = NlMsgPutTailU32(&nlBuffer, OVS_VPORT_ATTR_UPCALL_PID,
vport->upcallPid);
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
/*stats*/
(PCHAR)&vportStats,
sizeof(OVS_VPORT_FULL_STATS));
if (!ok) {
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INVALID_BUFFER_SIZE;
}
/*