POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
rc = NlAttrParse(&msgIn->nlMsg, sizeof (*msgIn),
- NlMsgAttrsLen((PNL_MSG_HDR)msgIn), policy, attrs, ARRAY_SIZE(attrs));
+ NlMsgAttrsLen((PNL_MSG_HDR)msgIn), policy, ARRAY_SIZE(policy),
+ attrs, ARRAY_SIZE(attrs));
if (!rc) {
status = STATUS_INVALID_PARAMETER;
goto done;
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsDatapathSetPolicy, dpAttrs, ARRAY_SIZE(dpAttrs))) {
+ ovsDatapathSetPolicy,
+ ARRAY_SIZE(ovsDatapathSetPolicy),
+ dpAttrs, ARRAY_SIZE(dpAttrs))) {
return STATUS_INVALID_PARAMETER;
}
POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
rc = NlAttrParse(&msgIn->nlMsg, sizeof (*msgIn),
- NlMsgAttrsLen((PNL_MSG_HDR)msgIn), policy, attrs, ARRAY_SIZE(attrs));
+ NlMsgAttrsLen((PNL_MSG_HDR)msgIn), policy, ARRAY_SIZE(policy),
+ attrs, ARRAY_SIZE(attrs));
if (!rc) {
status = STATUS_INVALID_PARAMETER;
goto done;
.maxLen = 4, .optional = TRUE},
[OVS_KEY_ATTR_MPLS] = {.type = NL_A_VAR_LEN, .optional = TRUE}
};
+const UINT32 nlFlowKeyPolicyLen = ARRAY_SIZE(nlFlowKeyPolicy);
/* For Parsing nested OVS_KEY_ATTR_TUNNEL attributes */
const NL_POLICY nlFlowTunnelKeyPolicy[] = {
/* Get all the top level Flow attributes */
if ((NlAttrParse(nlMsgHdr, attrOffset, NlMsgAttrsLen(nlMsgHdr),
- nlFlowPolicy, nlAttrs, ARRAY_SIZE(nlAttrs)))
+ nlFlowPolicy, ARRAY_SIZE(nlFlowPolicy),
+ nlAttrs, ARRAY_SIZE(nlAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Attr Parsing failed for msg: %p",
nlMsgHdr);
/* Get all the top level Flow attributes */
if ((NlAttrParse(nlMsgHdr, attrOffset, NlMsgAttrsLen(nlMsgHdr),
- nlFlowPolicy, nlAttrs, ARRAY_SIZE(nlAttrs)))
+ nlFlowPolicy, ARRAY_SIZE(nlFlowPolicy),
+ nlAttrs, ARRAY_SIZE(nlAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Attr Parsing failed for msg: %p",
nlMsgHdr);
/* Get flow keys attributes */
if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset,
NlAttrLen(nlAttrs[OVS_FLOW_ATTR_KEY]),
- nlFlowKeyPolicy, keyAttrs, ARRAY_SIZE(keyAttrs)))
+ nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy),
+ keyAttrs, ARRAY_SIZE(keyAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p",
nlMsgHdr);
/* Get tunnel keys attributes */
if ((NlAttrParseNested(nlMsgHdr, tunnelKeyAttrOffset,
NlAttrLen(keyAttrs[OVS_KEY_ATTR_TUNNEL]),
- nlFlowTunnelKeyPolicy,
+ nlFlowTunnelKeyPolicy,
+ ARRAY_SIZE(nlFlowTunnelKeyPolicy),
tunnelAttrs, ARRAY_SIZE(tunnelAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p",
/* Get flow keys attributes */
if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset, NlAttrLen(keyAttr),
- nlFlowKeyPolicy, keyAttrs, ARRAY_SIZE(keyAttrs)))
+ nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy),
+ keyAttrs, ARRAY_SIZE(keyAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p",
nlMsgHdr);
if ((NlAttrParseNested(nlMsgHdr, tunnelKeyAttrOffset,
NlAttrLen(keyAttrs[OVS_KEY_ATTR_TUNNEL]),
nlFlowTunnelKeyPolicy,
+ ARRAY_SIZE(nlFlowTunnelKeyPolicy),
tunnelAttrs, ARRAY_SIZE(tunnelAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p",
BOOLEAN
NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen,
- const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs)
+ const NL_POLICY policy[], const UINT32 numPolicy,
+ PNL_ATTR attrs[], UINT32 numAttrs)
{
PNL_ATTR nla;
UINT32 left;
UINT32 iter;
BOOLEAN ret = FALSE;
+ UINT32 numPolicyAttr = MIN(numPolicy, numAttrs);
- RtlZeroMemory(attrs, n_attrs * sizeof *attrs);
+ RtlZeroMemory(attrs, numAttrs * sizeof *attrs);
/* There is nothing to parse */
totalAttrLen)
{
UINT16 type = NlAttrType(nla);
- if (type < n_attrs && policy[type].type != NL_A_NO_ATTR) {
+ if (type < numPolicyAttr && policy[type].type != NL_A_NO_ATTR) {
/* Typecasting to keep the compiler happy */
const PNL_POLICY e = (const PNL_POLICY)(&policy[type]);
if (!NlAttrValidate(nla, e)) {
goto done;
}
- for (iter = 0; iter < n_attrs; iter++) {
+ for (iter = 0; iter < numPolicyAttr; iter++) {
const PNL_POLICY e = (const PNL_POLICY)(&policy[iter]);
if (!e->optional && e->type != NL_A_NO_ATTR && !attrs[iter]) {
OVS_LOG_ERROR("Required attr:%d missing", iter);
BOOLEAN
NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen,
- const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs)
+ const NL_POLICY policy[], const UINT32 numPolicy,
+ PNL_ATTR attrs[], UINT32 numAttrs)
{
return NlAttrParse(nlMsg, attrOffset + NLA_HDRLEN,
- totalAttrLen - NLA_HDRLEN, policy, attrs, n_attrs);
+ totalAttrLen - NLA_HDRLEN, policy, numPolicy,
+ attrs, numAttrs);
}
UINT16 type);
BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs);
+ const UINT32 numPolicy, PNL_ATTR attrs[],
+ UINT32 numAttrs);
BOOLEAN NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
- PNL_ATTR attrs[], UINT32 n_attrs);
+ const UINT32 numPolicy, PNL_ATTR attrs[],
+ UINT32 numAttrs);
/*
* --------------------------------------------------------------------------
* Returns the length of attribute.
static VOID _MapNlAttrToOvsPktExec(PNL_ATTR *nlAttrs, PNL_ATTR *keyAttrs,
OvsPacketExecute *execute);
extern NL_POLICY nlFlowKeyPolicy[];
+extern UINT32 nlFlowKeyPolicyLen;
static __inline VOID
OvsAcquirePidHashLock()
/* Get all the top level Flow attributes */
if ((NlAttrParse(nlMsgHdr, attrOffset, NlMsgAttrsLen(nlMsgHdr),
- nlPktExecPolicy, nlAttrs, ARRAY_SIZE(nlAttrs)))
+ nlPktExecPolicy, ARRAY_SIZE(nlPktExecPolicy),
+ nlAttrs, ARRAY_SIZE(nlAttrs)))
!= TRUE) {
OVS_LOG_ERROR("Attr Parsing failed for msg: %p",
nlMsgHdr);
/* Get flow keys attributes */
if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset,
NlAttrLen(nlAttrs[OVS_PACKET_ATTR_KEY]),
- nlFlowKeyPolicy, keyAttrs,
- ARRAY_SIZE(keyAttrs))) != TRUE) {
+ nlFlowKeyPolicy, nlFlowKeyPolicyLen,
+ keyAttrs, ARRAY_SIZE(keyAttrs))) != TRUE) {
OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p", nlMsgHdr);
status = STATUS_UNSUCCESSFUL;
goto done;
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsNetdevPolicy, netdevAttrs, ARRAY_SIZE(netdevAttrs))) {
+ ovsNetdevPolicy, ARRAY_SIZE(ovsNetdevPolicy),
+ netdevAttrs, ARRAY_SIZE(netdevAttrs))) {
return STATUS_INVALID_PARAMETER;
}
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsVportPolicy, vportAttrs, ARRAY_SIZE(vportAttrs))) {
+ ovsVportPolicy, ARRAY_SIZE(ovsVportPolicy),
+ vportAttrs, ARRAY_SIZE(vportAttrs))) {
return STATUS_INVALID_PARAMETER;
}
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsVportPolicy, vportAttrs, ARRAY_SIZE(vportAttrs))) {
+ ovsVportPolicy, ARRAY_SIZE(ovsVportPolicy),
+ vportAttrs, ARRAY_SIZE(vportAttrs))) {
return STATUS_INVALID_PARAMETER;
}
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsVportPolicy, vportAttrs, ARRAY_SIZE(vportAttrs))) {
+ ovsVportPolicy, ARRAY_SIZE(ovsVportPolicy),
+ vportAttrs, ARRAY_SIZE(vportAttrs))) {
return STATUS_INVALID_PARAMETER;
}
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsVportPolicy, vportAttrs, ARRAY_SIZE(vportAttrs))) {
+ ovsVportPolicy, ARRAY_SIZE(ovsVportPolicy),
+ vportAttrs, ARRAY_SIZE(vportAttrs))) {
return STATUS_INVALID_PARAMETER;
}
if (!NlAttrParse((PNL_MSG_HDR)msgIn,
NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN,
NlMsgAttrsLen((PNL_MSG_HDR)msgIn),
- ovsVportPolicy, vportAttrs, ARRAY_SIZE(vportAttrs))) {
+ ovsVportPolicy, ARRAY_SIZE(ovsVportPolicy),
+ vportAttrs, ARRAY_SIZE(vportAttrs))) {
nlError = NL_ERROR_INVAL;
break;
}