diff mbox

[ovs-dev,v2] datapath-windows: Updating an External Adapter causes flow lookup failure

Message ID 1446513427-8644-1-git-send-email-vsairam@vmware.com
State Accepted
Headers show

Commit Message

Sairam Venugopal Nov. 3, 2015, 1:17 a.m. UTC
This patch fixes an issue with updating the propeties of an external
adapter in Windows. The issue causes flow lookups to fail until the
kernel is reinstalled.

Associated bug - https://github.com/openvswitch/ovs-issues/issues/102

Signed-off-by: Sairam Venugopal <vsairam@vmware.com>
---
 datapath-windows/ovsext/Vport.c | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

Comments

Ben Pfaff Nov. 3, 2015, 5:46 p.m. UTC | #1
On Mon, Nov 02, 2015 at 05:17:07PM -0800, Sairam Venugopal wrote:
> This patch fixes an issue with updating the propeties of an external
> adapter in Windows. The issue causes flow lookups to fail until the
> kernel is reinstalled.
> 
> Associated bug - https://github.com/openvswitch/ovs-issues/issues/102

I converted this to a Reported-by:.

> Signed-off-by: Sairam Venugopal <vsairam@vmware.com>

I added Nithin's ack and applied this to master.  Thank you!
diff mbox

Patch

diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index 4ade842..7de42d7 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -322,19 +322,51 @@  HvCreateNic(POVS_SWITCH_CONTEXT switchContext,
         POVS_VPORT_ENTRY virtExtVport =
             (POVS_VPORT_ENTRY)switchContext->virtualExternalVport;
 
-        vport = (POVS_VPORT_ENTRY)OvsAllocateVport();
+        vport = OvsFindVportByPortIdAndNicIndex(switchContext,
+                                                nicParam->PortId,
+                                                nicParam->NicIndex);
         if (vport == NULL) {
-            status = NDIS_STATUS_RESOURCES;
-            goto add_nic_done;
+            /* Find by interface name */
+            WCHAR interfaceName[IF_MAX_STRING_SIZE] = { 0 };
+            NET_LUID interfaceLuid = { 0 };
+            size_t len = 0;
+            status = ConvertInterfaceGuidToLuid(&nicParam->NetCfgInstanceId,
+                                                &interfaceLuid);
+            if (status == STATUS_SUCCESS) {
+                status = ConvertInterfaceLuidToAlias(&interfaceLuid,
+                                                     interfaceName,
+                                                     IF_MAX_STRING_SIZE + 1);
+                if (status == STATUS_SUCCESS) {
+                    RtlStringCbLengthW(interfaceName,
+                                       IF_MAX_STRING_SIZE,
+                                       &len);
+                    vport = OvsFindVportByHvNameW(switchContext,
+                                                  interfaceName,
+                                                  len);
+                }
+            }
+
+            if (vport == NULL) {
+                /* XXX: Handle this event appropriately */
+                vport = (POVS_VPORT_ENTRY)OvsAllocateVport();
+                if (vport == NULL) {
+                    status = NDIS_STATUS_RESOURCES;
+                    goto add_nic_done;
+                }
+            }
         }
+
         OvsInitPhysNicVport(vport, virtExtVport, nicParam->NicIndex);
+        OvsInitVportWithNicParam(switchContext, vport, nicParam);
         status = InitHvVportCommon(switchContext, vport, TRUE);
+        vport->isAbsentOnHv = FALSE;
         if (status != NDIS_STATUS_SUCCESS) {
             OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
             goto add_nic_done;
         }
+    } else {
+        OvsInitVportWithNicParam(switchContext, vport, nicParam);
     }
-    OvsInitVportWithNicParam(switchContext, vport, nicParam);
     portNo = vport->portNo;
     if (vport->ovsState == OVS_STATE_CONNECTED) {
         event = OVS_EVENT_CONNECT | OVS_EVENT_LINK_UP;