Current flow commands: new, set, get, del need to respond with a NETLINK error in the case OVS_FLOW_ATTR_KEY is missing.
OVS_FLOW_ATTR_KEY is now an optional attribute. Also add OVS_FLOW_ATTR_UFID attribute to the kernel for further use. Signed-off-by: Alin Gabriel Serdean <aserd...@cloudbasesolutions.com> --- datapath-windows/ovsext/Flow.c | 26 +++++++++++++++++++++++--- datapath-windows/ovsext/Flow.h | 6 ++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/datapath-windows/ovsext/Flow.c b/datapath-windows/ovsext/Flow.c index d3de8cc..b849666 100644 --- a/datapath-windows/ovsext/Flow.c +++ b/datapath-windows/ovsext/Flow.c @@ -95,7 +95,7 @@ static NTSTATUS OvsDoDumpFlows(OvsFlowDumpInput *dumpInput, /* For Parsing attributes in FLOW_* commands */ const NL_POLICY nlFlowPolicy[] = { - [OVS_FLOW_ATTR_KEY] = {.type = NL_A_NESTED, .optional = FALSE}, + [OVS_FLOW_ATTR_KEY] = {.type = NL_A_NESTED, .optional = TRUE}, [OVS_FLOW_ATTR_MASK] = {.type = NL_A_NESTED, .optional = TRUE}, [OVS_FLOW_ATTR_ACTIONS] = {.type = NL_A_NESTED, .optional = TRUE}, [OVS_FLOW_ATTR_STATS] = {.type = NL_A_UNSPEC, @@ -103,7 +103,9 @@ const NL_POLICY nlFlowPolicy[] = { .maxLen = sizeof(struct ovs_flow_stats), .optional = TRUE}, [OVS_FLOW_ATTR_TCP_FLAGS] = {NL_A_U8, .optional = TRUE}, - [OVS_FLOW_ATTR_USED] = {NL_A_U64, .optional = TRUE} + [OVS_FLOW_ATTR_USED] = {NL_A_U64, .optional = TRUE}, + [OVS_FLOW_ATTR_UFID] = { .type = NL_A_UNSPEC, .optional = TRUE, + .minLen = sizeof(OvsU128) } }; /* For Parsing nested OVS_FLOW_ATTR_KEY attributes. @@ -308,6 +310,11 @@ OvsFlowNlCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, goto done; } + if (nlAttrs[OVS_FLOW_ATTR_KEY] == NULL) { + nlError = NL_ERROR_INVAL; + goto done; + } + if ((rc = _MapNlToFlowPut(msgIn, nlAttrs[OVS_FLOW_ATTR_KEY], nlAttrs[OVS_FLOW_ATTR_ACTIONS], nlAttrs[OVS_FLOW_ATTR_CLEAR], &mappedFlow)) @@ -420,7 +427,7 @@ _FlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, PNL_MSG_HDR nlMsgOutHdr = NULL; UINT32 attrOffset = NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN; PNL_ATTR nlAttrs[__OVS_FLOW_ATTR_MAX]; - + NL_ERROR nlError = NL_ERROR_SUCCESS; OvsFlowGetInput getInput; OvsFlowGetOutput getOutput; NL_BUFFER nlBuf; @@ -455,6 +462,11 @@ _FlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, goto done; } + if (nlAttrs[OVS_FLOW_ATTR_KEY] == NULL) { + nlError = NL_ERROR_INVAL; + goto done; + } + keyAttrOffset = (UINT32)((PCHAR) nlAttrs[OVS_FLOW_ATTR_KEY] - (PCHAR)nlMsgHdr); @@ -532,6 +544,14 @@ _FlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, *replyLen += NlMsgSize(nlMsgOutHdr); done: + if (nlError != NL_ERROR_SUCCESS) { + POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR) + usrParamsCtx->outputBuffer; + NlBuildErrorMsg(msgIn, msgError, nlError); + *replyLen = msgError->nlMsg.nlmsgLen; + rc = STATUS_SUCCESS; + } + return rc; } diff --git a/datapath-windows/ovsext/Flow.h b/datapath-windows/ovsext/Flow.h index e817bcf..02a72de 100644 --- a/datapath-windows/ovsext/Flow.h +++ b/datapath-windows/ovsext/Flow.h @@ -37,6 +37,12 @@ typedef struct _OvsFlow { NL_ATTR actions[1]; } OvsFlow; +typedef union _OvsU128{ + uint32_t u32[4]; + struct { + uint64_t lo, hi; + } u64; +} OvsU128; typedef struct _OvsLayers { UINT32 l3Ofs; // IPv4, IPv6, ARP, or other L3 header. -- 1.9.5.msysgit.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev