[ovs-dev] [PATCH v3 3/3] datapath-windows/Netlink: Add optional flag in policy.

Ankur Sharma ankursharma at vmware.com
Tue Sep 16 01:18:05 UTC 2014


Added the optional flag in policy structure. This would allow
caller to avoid checks for mandatory attributes if parsing
succeeds.

Signed-off-by: Ankur Sharma <ankursharma at vmware.com>
Acked-by: Nithin Raju <nithin at vmware.com>
---
 datapath-windows/ovsext/Netlink/Netlink.c | 2 +-
 datapath-windows/ovsext/Netlink/Netlink.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index cfbc73a..1ceb5e3 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -945,7 +945,7 @@ NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
 
     for (iter = 0; iter < n_attrs; iter++) {
         const PNL_POLICY e = (const PNL_POLICY)(&policy[iter]);
-        if (e->type != NL_A_NO_ATTR && !attrs[iter]) {
+        if (!e->optional && e->type != NL_A_NO_ATTR && !attrs[iter]) {
             OVS_LOG_ERROR("Required attr:%d missing", iter);
             goto done;
         }
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index a9f62bc..6ecbdc5 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -47,6 +47,7 @@ typedef struct _NL_POLICY
     NL_ATTR_TYPE type;
     UINT32 minLen;
     UINT32 maxLen;
+    BOOLEAN optional;
 } NL_POLICY, *PNL_POLICY;
 
 /* This macro is careful to check for attributes with bad lengths. */
-- 
1.9.1




More information about the dev mailing list