Introduction

Purpose

This is a functional specification of the Open vSwitch (OVS) controller within CloudStack

References

Document History

Glossary

Use Cases

  1. Cloud operator downloads CloudStack release and installs CloudStack. She wishes to use the GRE tunnel method of isolation. She enables this flag in the configuration database and restarts CloudStack management servers. When she creates a zone with Advanced Networking and creates a physical network within the zone, she is presented with a choice to use GRE isolation
  2. Cloud operator wants to enable firewall and load balancing service on top of the GRE-isolated network. She adds a public VLAN and a public IP range to this network. She creates a network offering with these services. End-users now use this offering to create networks.
  3. Cloud operator wants to enable firewall services using Juniper SRX on top of the GRE-isolated network. Not supported
  4. Cloud operator wants to enable both VLANs and GRE tunnels as isolation methods. Not supported

Feature Specifications

Goals

The goal of this feature is to broadly support all of CloudStack's virtual networking functions while removing the limitations associated with VLANs. Among the limitations are:

Unsupported/ToDo items

Known issues

Failure modes

Failures in setting up the bridge, or configuring the GRE tunnels will not cause a failure of the VM startup process. The VM will be started anyway, even if networking might be compromised. When starting a subsequent VM, the tunnel manager will try again to create the tunnels which previously failed.

NOTE: This is the behaviour as currently implemented, but not yet committed. The alternative approach would be to fail VM startup if an error occurs while setting up either the OVS bridge, the tunnels, or the broadcast storm prevention rules. Alternately, a synchronization framework (like the one used by the SecurityGroupManager) can use eventual consistency to (re)create the tunnels.

Logging and Debugging

Useful tips for debugging the OVS controller:

Configuration Characteristics

The OVS tunnel manager is disabled by default, and should be explicitly enabled in the configuration.
To this aim, the sdn.ovs.controller configuration flag should be set to true.
After enabling it, the management server should be restarted. 

Also, a Vnet range should be configured. Vnet identifiers are used as GRE keys for tunnel networks. The network manager implementation has a check for validating the maximum vnet id. By default this maximum is 4096, unless GRE is explicitly specified as the isolation mode for the physical network on top of which the OVS controller operates.

Deployment requirements

The implemented full mesh topology ensures each VM can be reached with at most 1 hop across different hosts. This means that bottleneck issues which are common in star or ring topologies do not occur in this case.
We deliberately avoided using STP for avoiding loops in the traffic. Instead, we prevent issues such as broadcast storm ensuring that broadcast on ingress tunnels are not forwarded on egress tunnels.

This solution scales much better than a traditional VLAN approach, as the GRE key is a 32-bit field whereas the VLAN id is a 12-bit field. It also scales better than approaches based on Q-in-Q as there's no constraint associated with the physical topology of the data center network, such as Top-of-Rack/Core switches.

The following factors however impact performance and scalability of virtual networks built using the GRE encapsulation technique:

Security considerations

Preamble: I am not a security expert, nor any security experts has performed a security assessment for this feature.

In the current implementation, for each network a distinct Open vSwitch bridge is created on each host; also, each network is assigned a distinct GRE key. This means that accidental traffic snooping is avoided at the edge of the network; malicious traffic snooping would require attackers to compromise, in the XenServer case, the dom0 where the vSwitch instances are running. Malicious users cannot influence the way in which bridges are created and GRE keys assigned. 

We assume the physical infrastructure to be under exclusive control of the admin of the data center. Cloudstack does not encrypt or perform any operation for protecting the traffic once it has left the host.

Architecture and Design description

Software design and architecture:

Network design and architecture:

  1. Creating a sort of framework for pluggins alternative network managers, possibly provided by 3rd parties, adding a 'service provider' for basic network connectivity, and then have OVS tunnel networks as a network offering. This is something interesting but rather orthogonal to the subject of this FS. We are separetely working on it;
  2. Using programmatic interfaces exposed by Open vSwitch (OvsDB and Openflow) for manipulating virtual networks. This would have probably extended the timeline for the implementation of this feature, and therefore we decided to stay with xenapi plugins for this release. We are currently working with the XenServer engineering team on exposing the above mentioned interfaces in the hypervisor layer.
    Database Changes

CREATE TABLE `cloud`.`ovs_tunnel_interface` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,
   `ip` varchar(16) DEFAULT NULL,
   `netmask` varchar(16) DEFAULT NULL,
  `mac` varchar(18) DEFAULT NULL,
  `host_id` bigint(20) DEFAULT NULL,
  `label` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

INSERT INTO `cloud`.`ovs_tunnel_interface` (`ip`, `netmask`, `mac`, `host_id`, `label`) VALUES ('0', '0', '0', 0, 'lock');

CREATE TABLE `cloud`.`ovs_tunnel_network`(
  `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
  `from` bigint unsigned COMMENT 'from host id',
  `to` bigint unsigned COMMENT 'to host id',
  `network_id` bigint unsigned COMMENT 'network identifier',
  `key` int unsigned COMMENT 'gre key',
  `port_name` varchar(32) COMMENT 'in port on open vswitch',
  `state` varchar(16) default 'FAILED' COMMENT 'result of tunnel creatation',
  PRIMARY KEY(`from`, `to`, `account`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `cloud`.`ovs_tunnel_network` (`from`, `to`, `network_id`, `key`, `port_name`, `state`) VALUES (0, 0, 0, 0, 'lock', 'SUCCESS');

Code changes: 

api/src/com/cloud/network/Network.java
api/src/com/cloud/network/NetworkService.java
api/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java
api/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
api/src/com/cloud/network/ovs/OvsDestroyBridgeCommand.java
api/src/com/cloud/network/ovs/OvsDestroyTunnelCommand.java
api/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java
api/src/com/cloud/network/ovs/OvsFetchInterfaceCommand.java
api/src/com/cloud/network/ovs/OvsSetupBridgeCommand.java
api/src/com/cloud/offering/NetworkOffering.java
core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
scripts/vm/hypervisor/xenserver/cloudstack_pluginlib.py
scripts/vm/hypervisor/xenserver/cloudstack_plugins.conf
scripts/vm/hypervisor/xenserver/ovs-vif-flows.py
scripts/vm/hypervisor/xenserver/ovstunnel
scripts/vm/hypervisor/xenserver/vmops
scripts/vm/hypervisor/xenserver/xen-ovs-vif-flows.rules
scripts/vm/hypervisor/xenserver/xenserver56fp1/ovs-vif-flows.py
scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
scripts/vm/hypervisor/xenserver/xenserver60/ovs-vif-flows.py
scripts/vm/hypervisor/xenserver/xenserver60/patch
server/src/com/cloud/network/NetworkManager.java
server/src/com/cloud/network/NetworkManagerImpl.java
server/src/com/cloud/network/element/OvsElement.java
server/src/com/cloud/network/guru/GuestNetworkGuru.java
server/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
server/src/com/cloud/network/ovs/OvsTunnelManager.java
server/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
server/src/com/cloud/network/ovs/dao/OvsTunnelInterfaceDao.java
server/src/com/cloud/network/ovs/dao/OvsTunnelInterfaceDaoImpl.java
server/src/com/cloud/network/ovs/dao/OvsTunnelInterfaceVO.java
server/src/com/cloud/network/ovs/dao/OvsTunnelNetworkDao.java
server/src/com/cloud/network/ovs/dao/OvsTunnelNetworkDaoImpl.java
server/src/com/cloud/network/ovs/dao/OvsTunnelNetworkVO.java
server/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java
setup/db/create-schema.sql

Code is available in the salvatore-ovs-tunnel-mgr branch on git.cloud.com

NOTE: A prototype for this feature was originally developed by Chiradeep; the proposed implementation has been developed starting from that prototype. Not all code relevant to that prototype has been removed, even though it is not anymore in use. When looking at the branch on the git server, please disregard all classes pertaining to OVS not included in the list above.

Web services APIs

No changes introduced to the API

UI flow

Exactly the same as the flow for starting a VM instance.