summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Vxlan.c
diff options
context:
space:
mode:
authorNithin Raju <nithin@vmware.com>2014-10-12 20:56:14 -0700
committerBen Pfaff <blp@nicira.com>2014-10-13 14:01:21 -0700
commit8d9f1e0c0150b0cfa71275e93e2b663129703985 (patch)
treecdd8300f6a01ad26cddf0622b11a12f579843243 /datapath-windows/ovsext/Vxlan.c
parent9189184d09bfb742149b878d6b9e0194979b3dbb (diff)
downloadopenvswitch-8d9f1e0c0150b0cfa71275e93e2b663129703985.tar.gz
datapath-windows: Add netlink command: vport new
Does the following: a. before creating the vport, makes sure there is no existing vport with the same ovs (datapath) port name. If this is not so, it means that the specified port already exists: it returns NL_ERROR_EXIST. b. looks up the vport: o) if the vport type is "internal", then the internal vport of the hyper-v switch is yielded. o) if the vport type is "netdev" and the vport ovs (datapath) name is "external", then the external vport is yielded. The switch can have only one "external" vport. The method of looking up the "external" port can be changed later, if a better method is found. o) if the vport type is "netdev" but the name is not "external", then a VM VNic is assumed, so the vport is looked up by hyper-v switch port friendly name. o) if none of the above, a tunneling vport type is expected, which in our case, at the moment, can only be the one vxlan vport. Only one vxlan vport is allowed, and it's saved in switchContext->vxlanVport. The tunneling vport is the only kind which is created in the netlink command vport new, because it does not have a hyper-v switch port counterpart. c. if the vport could not be found (non-tunneling vports), then the NL_ERROR_INVAL is returned to the userspace. d. if the vport was found, but it has a valid ovs (datapath) port number, it means that this port was already created by a netlink command vport new. Therefore, NL_ERROR_EXIST is returned to the userspace. e. if the netlink command vport new specified an ovs (datapath) port number, then it means that the userspace is trying to re-create a vport: that specified port number will be used. Otherwise, a new ovs (datapath) port number is computed and assigned to the vport. f. the ovsName field of the vport is set to the name given by the OVS_VPORT_ATTR_NAME netlink attribute. The ovsNameLen is no longer stored in the OVS_VPORT_ENTRY struct, because ovsName is null-terminated. g. the "portOptions" are set to the vport, if the attribute OVS_VPORT_ATTR_OPTIONS was given. Otherwise, it is set to NULL. portOptions is a PNL_ATTR, which is yet to be implemented. The only option available for now would be vxlan udp destination port, but we have a constant value there, so this option is not yet needed. h. the upcall pid is set to the vport. i. if the vport type is vxlan, then the vport pointer is also saved to switchContext->vxlanVport. j. Now that the ovs (datapath) port number and the ovs name were set, the vport can be added to the hash array of vports, hashed on ovs name and to the hash array of vports hashed by ovs (datapath) port number. k. the reply is yielded to the userspace. Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com> Acked-by: Nithin Raju <nithin@vmware.com> Acked-by: Ankur Sharma <ankursharma@vmware.com> Acked-by: Eitan Eliahu <eliahue@vmware.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/Vxlan.c')
-rw-r--r--datapath-windows/ovsext/Vxlan.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/datapath-windows/ovsext/Vxlan.c b/datapath-windows/ovsext/Vxlan.c
index 7f94634f9..f5f3c0818 100644
--- a/datapath-windows/ovsext/Vxlan.c
+++ b/datapath-windows/ovsext/Vxlan.c
@@ -26,7 +26,6 @@
#include "PacketIO.h"
#include "Flow.h"
#include "PacketParser.h"
-#include "Checksum.h"
#pragma warning( push )
#pragma warning( disable:4127 )
@@ -50,30 +49,43 @@
/* Move to a header file */
extern POVS_SWITCH_CONTEXT gOvsSwitchContext;
-NTSTATUS
+/*
+ * udpDestPort: the vxlan is set as payload to a udp frame. If the destination
+ * port of an udp frame is udpDestPort, we understand it to be vxlan.
+*/
+NL_ERROR
OvsInitVxlanTunnel(POVS_VPORT_ENTRY vport,
- POVS_VPORT_ADD_REQUEST addReq)
+ UINT16 udpDestPort)
{
POVS_VXLAN_VPORT vxlanPort;
- NTSTATUS status = STATUS_SUCCESS;
-
- ASSERT(addReq->type == OVS_VPORT_TYPE_VXLAN);
+ NTSTATUS status;
vxlanPort = OvsAllocateMemory(sizeof (*vxlanPort));
if (vxlanPort == NULL) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- } else {
- RtlZeroMemory(vxlanPort, sizeof (*vxlanPort));
- vxlanPort->dstPort = addReq->dstPort;
- /*
- * since we are installing the WFP filter before the port is created
- * We need to check if it is the same number
- * XXX should be removed later
- */
- ASSERT(vxlanPort->dstPort == VXLAN_UDP_PORT);
- vport->priv = (PVOID)vxlanPort;
+ return NL_ERROR_NOMEM;
}
- return status;
+
+ RtlZeroMemory(vxlanPort, sizeof(*vxlanPort));
+ vxlanPort->dstPort = udpDestPort;
+ /*
+ * since we are installing the WFP filter before the port is created
+ * We need to check if it is the same number
+ * XXX should be removed later
+ */
+ ASSERT(vxlanPort->dstPort == VXLAN_UDP_PORT);
+ vport->priv = (PVOID)vxlanPort;
+
+ status = OvsInitVportCommon(gOvsSwitchContext, vport);
+ ASSERT(status == NDIS_STATUS_SUCCESS);
+
+ vport->ovsState = OVS_STATE_CONNECTED;
+ vport->nicState = NdisSwitchNicStateConnected;
+ /*
+ * allow the vport to be deleted, because there is no hyper-v switch part
+ */
+ vport->hvDeleted = TRUE;
+
+ return NL_ERROR_SUCCESS;
}