summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Vport.c
diff options
context:
space:
mode:
authorNithin Raju <nithin@vmware.com>2016-06-17 10:51:52 -0700
committerGurucharan Shetty <guru@ovn.org>2016-06-17 14:16:41 -0700
commit885b8265d682a9736bb0db98c48a811bfd9de6cf (patch)
treef01fdd9a5f20e5690dde0702635d2c900f43f44b /datapath-windows/ovsext/Vport.c
parentf69f713bb032e8c31c05477f32e92f0f235a30e2 (diff)
downloadopenvswitch-885b8265d682a9736bb0db98c48a811bfd9de6cf.tar.gz
datapath-windows: use ip proto for tunnel port lookup
In Actions.c, based on the IP Protocol type and L4 port of the outer packet, we lookup the tunnel port. The function that made this happen took the tunnel type as an argument. Semantically, is is better to pass the IP protocol type and let the lookup code map IP protocol type to tunnel type. In the vport add code, we make sure that we block tunnel port addition if there's already a tunnel port that uses the same IP protocol type and L4 port number. Signed-off-by: Nithin Raju <nithin@vmware.com> Acked-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Yin Lin <linyi@vmware.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Diffstat (limited to 'datapath-windows/ovsext/Vport.c')
-rw-r--r--datapath-windows/ovsext/Vport.c64
1 files changed, 61 insertions, 3 deletions
diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index b4234e963..fbab61b70 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -689,9 +689,9 @@ OvsFindVportByPortNo(POVS_SWITCH_CONTEXT switchContext,
POVS_VPORT_ENTRY
-OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,
- UINT16 dstPort,
- OVS_VPORT_TYPE ovsPortType)
+OvsFindTunnelVportByDstPortAndType(POVS_SWITCH_CONTEXT switchContext,
+ UINT16 dstPort,
+ OVS_VPORT_TYPE ovsPortType)
{
POVS_VPORT_ENTRY vport;
PLIST_ENTRY head, link;
@@ -709,6 +709,41 @@ OvsFindTunnelVportByDstPort(POVS_SWITCH_CONTEXT switchContext,
}
POVS_VPORT_ENTRY
+OvsFindTunnelVportByDstPortAndNWProto(POVS_SWITCH_CONTEXT switchContext,
+ UINT16 dstPort,
+ UINT8 nwProto)
+{
+ POVS_VPORT_ENTRY vport;
+ PLIST_ENTRY head, link;
+ UINT32 hash = OvsJhashBytes((const VOID *)&dstPort, sizeof(dstPort),
+ OVS_HASH_BASIS);
+ head = &(switchContext->tunnelVportsArray[hash & OVS_VPORT_MASK]);
+ LIST_FORALL(head, link) {
+ vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, tunnelVportLink);
+ if (GetPortFromPriv(vport) == dstPort) {
+ switch (nwProto) {
+ case IPPROTO_UDP:
+ if (vport->ovsType != OVS_VPORT_TYPE_VXLAN) {
+ continue;
+ }
+ break;
+ case IPPROTO_TCP:
+ if (vport->ovsType != OVS_VPORT_TYPE_STT) {
+ continue;
+ }
+ break;
+ case IPPROTO_GRE:
+ break;
+ default:
+ continue;
+ }
+ return vport;
+ }
+ }
+ return NULL;
+}
+
+POVS_VPORT_ENTRY
OvsFindTunnelVportByPortType(POVS_SWITCH_CONTEXT switchContext,
OVS_VPORT_TYPE ovsPortType)
{
@@ -2220,15 +2255,20 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
if (OvsIsTunnelVportType(portType)) {
UINT16 transportPortDest = 0;
+ UINT8 nwProto;
+ POVS_VPORT_ENTRY dupVport;
switch (portType) {
case OVS_VPORT_TYPE_GRE:
+ nwProto = IPPROTO_GRE;
break;
case OVS_VPORT_TYPE_VXLAN:
transportPortDest = VXLAN_UDP_PORT;
+ nwProto = IPPROTO_UDP;
break;
case OVS_VPORT_TYPE_STT:
transportPortDest = STT_TCP_PORT;
+ nwProto = IPPROTO_TCP;
break;
default:
nlError = NL_ERROR_INVAL;
@@ -2243,6 +2283,22 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
}
}
+ /*
+ * We don't allow two tunnel ports on identical N/W protocol and
+ * L4 port number. This is applicable even if the two ports are of
+ * different tunneling types.
+ */
+ dupVport =
+ OvsFindTunnelVportByDstPortAndNWProto(gOvsSwitchContext,
+ transportPortDest,
+ nwProto);
+ if (dupVport) {
+ OVS_LOG_ERROR("Vport for N/W proto and port already exists,"
+ " type: %u, dst port: %u, name: %s", dupVport->ovsType,
+ transportPortDest, dupVport->ovsName);
+ goto Cleanup;
+ }
+
status = OvsInitTunnelVport(usrParamsCtx,
vport,
portType,
@@ -2317,6 +2373,8 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
gOvsSwitchContext->dpNo);
*replyLen = msgOut->nlMsg.nlmsgLen;
+ OVS_LOG_INFO("Created new vport, name: %s, type: %u", vport->ovsName,
+ vport->ovsType);
Cleanup:
NdisReleaseRWLock(gOvsSwitchContext->dispatchLock, &lockState);