How to Build the Kernel module & userspace daemons for Windows

Autoconf, Automake and Visual C++:

Open vSwitch on Linux uses autoconf and automake for generating Makefiles. It will be useful to maintain the same build system while compiling on Windows too. One approach is to compile Open vSwitch in a MinGW environment that contains autoconf and automake utilities and then use Visual C++ as a compiler and linker.

The following explains the steps in some detail.

This should install mingw at C:\Mingw and msys at C:\Mingw\msys. Add "C:\MinGW\bin" and "C:\Mingw\msys\1.0\bin" to PATH environment variable of Windows.

You can either use the MinGW installer or the command line utility 'mingw-get' to install both the base packages and additional packages like automake and autoconf(version 2.68).

Also make sure that /mingw mount point exists. If its not, please add/create the following entry in /etc/fstab - 'C:/MinGW /mingw'.

It is important to get the Visual Studio related environment variables and to have the $PATH inside the bash to point to the proper compiler and linker. One easy way to achieve this for VS2013 is to get into the "VS2013 x86 Native Tools Command Prompt" (in a default installation of Visual Studio 2013 this can be found under the following location: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts) and through it enter into the bash shell available from msys by typing 'bash --login'.

There is support for generating 64 bit binaries too. To compile under x64, open the "VS2013 x64 Native Tools Command Prompt" (if your current running OS is 64 bit) or "VS2013 x64 Cross Tools Command Prompt" (if your current running OS is not 64 bit) instead of opening its x86 variant. This will point the compiler and the linker to their 64 bit equivalent.

If after the above step, a 'which link' inside MSYS's bash says, "/bin/link.exe", rename /bin/link.exe to something else so that the Visual studio's linker is used. You should also see a 'which sort' report "/bin/sort.exe".

OpenSSL, Open vSwitch and Visual C++

To get SSL support for Open vSwitch on Windows, do the following:

Note down the directory where OpenSSL is installed (e.g.: C:/OpenSSL-Win32).

Building the Kernel datapath module

Installing the Kernel module

Once you have built the solution, you can copy the following files to the target Hyper-V machines.


The above path assumes that the kernel module has been built using Windows DDK 8.1 in Debug mode. Change the path appropriately, if a different WDK has been used.

Steps to install the module

01> Run ./uninstall.cmd to remove the old extension.

02> Run ./install.cmd to insert the new one. For this to work you will have to turn on TESTSIGNING boot option or 'Disable Driver Signature Enforcement' during boot. The following commands can be used: % bcdedit /set LOADOPTIONS DISABLEINTEGRITYCHECKS % bcdedit /set TESTSIGNING ON % bcdedit /set nointegritychecks ON

Note: you may have to restart the machine for the settings to take effect.

03> In the Virtual Switch Manager configuration you can enable the Open vSwitch Extension on an existing switch or create a new switch. If you are using an existing switch, make sure to enable the "Allow Management OS" option for VXLAN to work (covered later).

The command to create a new switch named 'OVS-Extended-Switch' using a physical NIC named 'Ethernet 1' is: % New-VMSwitch "OVS-Extended-Switch" -AllowManagementOS $true \ -NetAdapterName "Ethernet 1"

Note: you can obtain the list of physical NICs on the host using 'Get-NetAdapter' command.

04> In the properties of any switch, you should should now see "Open vSwitch Extension" under 'Extensions'. Click the check box to enable the extension. An alternative way to do the same is to run the following command: % Enable-VMSwitchExtension "Open vSwitch Extension" OVS-Extended-Switch

Note: If you enabled the extension using the command line, a delay of a few seconds has been observed for the change to be reflected in the UI. This is not a bug in Open vSwitch.

Steps to run the user processes & configure ports

The following steps assume that you have installed the Open vSwitch utilities in the local machine via 'make install'.

01> Create the database. % ovsdb-tool create C:\openvswitch\etc\openvswitch\conf.db \ C:\openvswitch\usr\share\openvswitch\vswitch.ovsschema

02> Start the ovsdb-server and initialize the database. % ovsdb-server -vfile:info --remote=punix:db.sock --log-file --pidfile \ --detach % ovs-vsctl --no-wait init

If you would like to terminate the started ovsdb-server, run:
% ovs-appctl -t ovsdb-server exit

(Note that the logfile is created at C:/openvswitch/var/log/openvswitch/)

03> Start ovs-vswitchd. % ovs-vswitchd -vfile:info --log-file --pidfile --detach

If you would like to terminate the started ovs-vswitchd, run:
% ovs-appctl exit

(Note that the logfile is created at C:/openvswitch/var/log/openvswitch/)

04> Create integration bridge & pif bridge % ovs-vsctl add-br br-int % ovs-vsctl add-br br-pif

NOTE: There's a known bug that running the ovs-vsctl command does not terminate. This is generally solved by having ovs-vswitchd running. If you face the issue despite that, hit Ctrl-C to terminate ovs-vsctl and check the output to see if your command succeeded.

NOTE: There's a known bug that the ports added to OVSDB via ovs-vsctl don't get to the kernel datapath immediately, ie. they don't show up in the output of "ovs-dpctl show" even though they show up in output of "ovs-vsctl show". In order to workaround this issue, restart ovs-vswitchd. (You can terminate ovs-vswitchd by running 'ovs-appctl exit'.)

05> Dump the ports in the kernel datapath % ovs-dpctl show

06> Dump the ports in the OVSDB % ovs-vsctl show

07> Add the physical NIC and the internal port to br-pif.

In OVS for Hyper-V, we use the name of the adapter on top of which the Hyper-V virtual switch was created, as a special name to refer to the physical NICs connected to the Hyper-V switch. I.e. let us suppose we created the Hyper-V virtual switch on top of the adapter named 'Ethernet0'. In OVS for Hyper-V, we use that name('Ethernet0') as a special name to refer to that adapter.

Note: Currently, we assume that the Hyper-V switch on which OVS extension is enabled has a single physical NIC connected to it.

Internal port is the virtual adapter created on the Hyper-V switch using the 'AllowManagementOS' setting. This has already been setup while creating the switch using the instructions above. In OVS for Hyper-V, we use a the name of that specific adapter as a special name to refer to that adapter. By default it is created under the following rule "vEthernet ()".

As a whole example, if we issue the following in a powershell console: PS C:\package\binaries> Get-NetAdapter | select Name,MacAddress,InterfaceDescription

Name MacAddress InterfaceDescription ---- ---------- -------------------- Ethernet1 00-0C-29-94-05-65 Intel(R) PRO/1000 MT Network Connection vEthernet (external) 00-0C-29-94-05-5B Hyper-V Virtual Ethernet Adapter #2 Ethernet0 00-0C-29-94-05-5B Intel(R) PRO/1000 MT Network Connection #2

PS C:\package\binaries> Get-VMSwitch

Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ external External Intel(R) PRO/1000 MT Network Connection #2

We can see that we have a switch(external) created upon adapter name 'Ethernet0' with an internal port under name 'vEthernet (external)'. Thus resulting into the following ovs-vsctl commands

% ovs-vsctl add-port br-pif Ethernet0
% ovs-vsctl add-port br-pif "vEthernet (external)"

08> Add the VIFs to br-int

Adding VIFs to openvswitch is a two step procedure. The first step is to assign a 'OVS port name' which is a unique name across all VIFs on this Hyper-V. The next step is to add the VIF to the ovsdb using its 'OVS port name' as key.

08a> Assign a unique 'OVS port name' to the VIF

Note that the VIF needs to have been disconnected from the Hyper-V switch before assigning a 'OVS port name' to it. In the example below, we assign a 'OVS port name' called 'ovs-port-a' to a VIF on a VM by name 'VM1'. By using index 0 for '$vnic', the first VIF of the VM is being addressed. After assigning the name 'ovs-port-a', the VIF is connected back to the Hyper-V switch with name 'OVS-HV-Switch', which is assumed to be the Hyper-V switch with OVS extension enabled.

% import-module .\datapath-windows\misc\OVS.psm1
% $vnic = Get-VMNetworkAdapter <Name of the VM>
% Disconnect-VMNetworkAdapter -VMNetworkAdapter $vnic[0]
% $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-a
% Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] \
                           -SwitchName OVS-Extended-Switch

08b> Add the VIFs to br-int in ovsdb

% ovs-vsctl add-port br-int ovs-port-a

09> Verify the status % ovs-dpctl show system@ovs-system: lookups: hit:0 missed:0 lost:0 flows: 0 port 4: vEthernet (external) (internal) port 5: ovs-port-a port 2: br-pif (internal) port 1: br-int (internal port 3: Ethernet0

% ovs-vsctl show
    Bridge br-pif
        Port "vEthernet (external)"
            Interface "vEthernet (external)"
        Port "Ethernet0"
            Interface "Ethernet0"
        Port br-pif
            Interface br-pif
                type: internal
    Bridge br-int
        Port br-int
            Interface br-int
                type: internal
        Port "ovs-port-a"
            Interface "ovs-port-a"

Steps to configure patch ports and switch VLAN tagging

The Windows Open vSwitch implementation support VLAN tagging in the switch. Switch VLAN tagging along with patch ports between 'br-int' and 'br-pif' is used to configure VLAN tagging functionality between two VMs on different Hyper-Vs. The following examples demonstrate how it can be done:

01> Add a patch port from br-int to br-pif % ovs-vsctl add-port br-int patch-to-pif % ovs-vsctl set interface patch-to-pif type=patch \ options:peer=patch-to-int

02> Add a patch port from br-pif to br-int % ovs-vsctl add-port br-pif patch-to-int % ovs-vsctl set interface patch-to-int type=patch \ options:peer=patch-to-pif

03> Re-Add the VIF ports with the VLAN tag % ovs-vsctl add-port br-int ovs-port-a tag=900 % ovs-vsctl add-port br-int ovs-port-b tag=900

Steps to add tunnels

The Windows Open vSwitch implementation support VXLAN and STT tunnels. To add tunnels, the following steps serve as examples.

Note that, any patch ports created between br-int and br-pif MUST be beleted prior to adding tunnels.

01> Add the tunnel port between <-> % ovs-vsctl add-port br-int tun-1 % ovs-vsctl set Interface tun-1 type=port-type % ovs-vsctl set Interface tun-1 options:localip= % ovs-vsctl set Interface tun-1 options:remoteip= % ovs-vsctl set Interface tun-1 options:inkey=flow % ovs-vsctl set Interface tun-1 options:outkey=flow

02> Add the tunnel port between <-> % ovs-vsctl add-port br-int tun-2 % ovs-vsctl set Interface tun-2 type=port-type % ovs-vsctl set Interface tun-2 options:localip= % ovs-vsctl set Interface tun-2 options:remoteip= % ovs-vsctl set Interface tun-2 options:inkey=flow % ovs-vsctl set Interface tun-2 options:outkey=flow

Where port-type is the string stt or vxlan


Windows Services

Open vSwitch daemons come with support to run as a Windows service. The instructions here assume that you have installed the Open vSwitch utilities and daemons via 'make install'. The commands shown here can be run from MSYS bash or Windows command prompt.

Windows autobuild service

AppVeyor ( provides a free Windows autobuild service for opensource projects. Open vSwitch has integration with AppVeyor for continuous build. A developer can build test his changes for Windows by logging into using a github account, creating a new project by linking it to his development repository in github and triggering a new build.