datapath-windows: NUL character should be left out during VPORT hash lookup
authorNithin Raju <nithin@vmware.com>
Sat, 27 Sep 2014 01:38:16 +0000 (18:38 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 29 Sep 2014 15:40:14 +0000 (08:40 -0700)
While calculating the hash on a VPORT name, we don't include the NUL character.
We should be doing the same while doing lookup as well.

We set the required minimum length of the name to be 2 so that the string has
at least one valid character.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/Datapath.c

index 2091777..b6dc55e 100644 (file)
@@ -1440,6 +1440,7 @@ OvsGetVport(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
     static const NL_POLICY ovsVportPolicy[] = {
         [OVS_VPORT_ATTR_PORT_NO] = { .type = NL_A_U32, .optional = TRUE },
         [OVS_VPORT_ATTR_NAME] = { .type = NL_A_STRING,
+                                  .minLen = 2,
                                   .maxLen = IFNAMSIZ,
                                   .optional = TRUE},
     };
@@ -1468,7 +1469,7 @@ OvsGetVport(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
     if (vportAttrs[OVS_VPORT_ATTR_NAME] != NULL) {
         vport = OvsFindVportByOvsName(gOvsSwitchContext,
             NlAttrGet(vportAttrs[OVS_VPORT_ATTR_NAME]),
-            NlAttrGetSize(vportAttrs[OVS_VPORT_ATTR_NAME]));
+            NlAttrGetSize(vportAttrs[OVS_VPORT_ATTR_NAME]) - 1);
     } else if (vportAttrs[OVS_VPORT_ATTR_PORT_NO] != NULL) {
         vport = OvsFindVportByPortNo(gOvsSwitchContext,
             NlAttrGetU32(vportAttrs[OVS_VPORT_ATTR_PORT_NO]));