[ovs-dev] [PATCH v1 04/10] datapath-windows/Netlink: Allow support for NESTED Attributes in NlAttrValidate

Ankur Sharma ankursharma at vmware.com
Fri Sep 26 16:53:26 UTC 2014


Hi Sam,

Thanks a lot for the review.

The usage of NlAttrValidate is to validate a give attribute against a given policy. I think adding a recursive check is going to complicate it.  

Thanks.

Regards,
Ankur
________________________________________
From: Samuel Ghinet <sghinet at cloudbasesolutions.com>
Sent: Thursday, September 25, 2014 8:13 AM
To: dev at openvswitch.org
Cc: Ankur Sharma
Subject: RE: [ovs-dev] [PATCH v1 04/10] datapath-windows/Netlink: Allow         support for NESTED Attributes in NlAttrValidate

In the future it might be useful if we could do recursive validation checks in NlAttrValidate when we have nested attributes.
Because I am not sure we can currently validate the netlink attributes nested in parent netlink attributes, using functions like NlAttrValidate.

Acked-by: Samuel Ghinet <sghinet at cloudbasesolutions.com>
________________________________________
Date: Wed, 24 Sep 2014 00:15:38 -0700
From: Ankur Sharma <ankursharma at vmware.com>
To: dev at openvswitch.org
Subject: [ovs-dev] [PATCH v1 04/10] datapath-windows/Netlink: Allow
        support for NESTED Attributes in NlAttrValidate
Message-ID: <1411542944-19374-4-git-send-email-ankursharma at vmware.com>

---
 datapath-windows/ovsext/Netlink/Netlink.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index 5f07451..5c74ec0 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -870,12 +870,13 @@ NlAttrValidate(const PNL_ATTR nla, const PNL_POLICY policy)
     UINT32 minLen;
     UINT32 maxLen;
     UINT32 len;
-    BOOLEAN ret = TRUE;
+    BOOLEAN ret = FALSE;

     if ((policy->type == NL_A_NO_ATTR) ||
-        (policy->type == NL_A_VAR_LEN)) {
+        (policy->type == NL_A_VAR_LEN) ||
+        (policy->type == NL_A_NESTED)) {
         /* Do not validate anything for attributes of type var length */
-        ret = FALSE;
+        ret = TRUE;
         goto done;
     }

@@ -894,7 +895,6 @@ NlAttrValidate(const PNL_ATTR nla, const PNL_POLICY policy)
     if (len < minLen || len > maxLen) {
         OVS_LOG_WARN("Attribute: %p, len: %d, not in valid range, "
                      "min: %d, max: %d", nla, len, minLen, maxLen);
-        ret = FALSE;
         goto done;
     }

@@ -902,17 +902,17 @@ NlAttrValidate(const PNL_ATTR nla, const PNL_POLICY policy)
     if (policy->type == NL_A_STRING) {
         if (((PCHAR) nla)[nla->nlaLen - 1]) {
             OVS_LOG_WARN("Attributes %p lacks null at the end", nla);
-            ret = FALSE;
             goto done;
         }

         if (memchr(nla + 1, '\0', len - 1) != NULL) {
             OVS_LOG_WARN("Attributes %p has bad length", nla);
-            ret = FALSE;
             goto done;
         }
     }

+    ret = TRUE;
+
 done:
     return ret;
 }
--
1.9.1



More information about the dev mailing list