Skip to content

Commit

Permalink
datapath-windows: Update port property.
Browse files Browse the repository at this point in the history
Update Hyper-V port properties on NDIS property port set callback.
Driver update the port friendly name in its internal table.
Since the NIC Create callback won't be called after we need to maintain the
NIC and THE OVS states of the Vport.

Setting a new friendly name was tested in the following states:
[1] The port is disconnected
[2] The port is connected but not OVS user mode counter port
[3] The port is connected and an OCS port associated with it

Signed-off-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
EitanEliahu authored and blp committed Nov 12, 2014
1 parent a22a952 commit b5af03d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datapath-windows/ovsext/Oid.c
Expand Up @@ -171,6 +171,9 @@ OvsProcessSetOidPort(POVS_SWITCH_CONTEXT switchObject,
case OID_SWITCH_PORT_CREATE:
status = HvCreatePort(switchObject, portParam);
break;
case OID_SWITCH_PORT_UPDATED:
status = HvUpdatePort(switchObject, portParam);
break;
case OID_SWITCH_PORT_TEARDOWN:
HvTeardownPort(switchObject, portParam);
break;
Expand Down
57 changes: 57 additions & 0 deletions datapath-windows/ovsext/Vport.c
Expand Up @@ -102,6 +102,63 @@ HvCreatePort(POVS_SWITCH_CONTEXT switchContext,
return status;
}


/*
* Function updating the port properties
*/
NDIS_STATUS
HvUpdatePort(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_PORT_PARAMETERS portParam)
{
POVS_VPORT_ENTRY vport;
LOCK_STATE_EX lockState;
OVS_VPORT_STATE ovsState;
NDIS_SWITCH_NIC_STATE nicState;

VPORT_PORT_ENTER(portParam);

NdisAcquireRWLockWrite(switchContext->dispatchLock, &lockState, 0);
vport = OvsFindVportByPortIdAndNicIndex(switchContext,
portParam->PortId, 0);
/*
* Update properties only for NETDEV ports for supprting PS script
* We don't allow changing the names of the internal or external ports
*/
if (vport == NULL || ( vport->portType != NdisSwitchPortTypeSynthetic) ||
( vport->portType != NdisSwitchPortTypeEmulated)) {
goto update_port_done;
}

/* Store the nic and the OVS states as Nic Create won't be called */
ovsState = vport->ovsState;
nicState = vport->nicState;

/*
* Currently only the port friendly name is being updated
* Make sure that no other properties are changed
*/
ASSERT(portParam->PortId == vport->portId);
ASSERT(portParam->PortState == vport->portState);
ASSERT(portParam->PortType == vport->portType);

/*
* Call the set parameters function the handle all properties
* change in a single place in case future version supports change of
* other properties
*/
OvsInitVportWithPortParam(vport, portParam);
/* Retore the nic and OVS states */
vport->nicState = nicState;
vport->ovsState = ovsState;

update_port_done:
NdisReleaseRWLock(switchContext->dispatchLock, &lockState);
VPORT_PORT_EXIT(portParam);

/* Must always return success */
return NDIS_STATUS_SUCCESS;
}

VOID
HvTeardownPort(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_PORT_PARAMETERS portParam)
Expand Down
2 changes: 2 additions & 0 deletions datapath-windows/ovsext/Vport.h
Expand Up @@ -158,6 +158,8 @@ NDIS_STATUS HvCreateNic(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_NIC_PARAMETERS nicParam);
NDIS_STATUS HvCreatePort(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_PORT_PARAMETERS portParam);
NDIS_STATUS HvUpdatePort(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_PORT_PARAMETERS portParam);
VOID HvTeardownPort(POVS_SWITCH_CONTEXT switchContext,
PNDIS_SWITCH_PORT_PARAMETERS portParam);
VOID HvDeletePort(POVS_SWITCH_CONTEXT switchContext,
Expand Down

0 comments on commit b5af03d

Please sign in to comment.