netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / INSTALL.Windows.md
index cd6ba40..6b0f5d8 100644 (file)
@@ -28,16 +28,25 @@ the following entry in /etc/fstab - 'C:/MinGW /mingw'.
 * Install the latest Python 2.x from python.org and verify that its path is
 part of Windows' PATH environment variable.
 
-* You will need at least Visual Studio 2013 to compile userspace binaries. In
-addition to that, if you want to compile the kernel module you will also need to
-install Windows Driver Kit (WDK) 8.1 Update.
+* You will need at least Visual Studio 2013 (update 4) to compile userspace
+binaries.  In addition to that, if you want to compile the kernel module you
+will also need to install Windows Driver Kit (WDK) 8.1 Update.
 
 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 is to get into the "Developer Command prompt for visual
-studio" and through it enter into the bash shell available from msys by typing
+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
@@ -46,7 +55,8 @@ Visual studio's linker is used. You should also see a 'which sort' report
 * For pthread support, install the library, dll and includes of pthreads-win32
 project from
 ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-9-1-release to a
-directory (e.g.: C:/pthread).
+directory (e.g.: C:/pthread). You should add the pthread-win32's dll
+path (e.g.: C:\pthread\dll\x86) to the Windows' PATH environment variable.
 
 * Get the Open vSwitch sources from either cloning the repo using git
 or from a distribution tar ball.
@@ -61,9 +71,10 @@ or from a distribution tar ball.
   the right compiler, linker, libraries, Open vSwitch component installation
   directories, etc. For example,
 
-    % ./configure CC=./build-aux/cccl LD="`which link`" LIBS="-lws2_32" \
-      --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
-      --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread"
+    % ./configure CC=./build-aux/cccl LD="`which link`" \
+      LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
+      --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
+       --with-pthread="C:/pthread"
 
     By default, the above enables compiler optimization for fast code.
     For default compiler optimization, pass the "--with-debug" configure
@@ -73,10 +84,32 @@ or from a distribution tar ball.
 
     % make
 
-* To run all the unit tests:
+  For faster compilation, you can pass the '-j' argument to make.  For
+  example, to run 4 jobs simultaneously, run 'make -j4'.
+
+  Note: MSYS 1.0.18 has a bug that causes parallel make to hang. You
+  can overcome this by downgrading to MSYS 1.0.17.  A simple way to
+  downgrade is to exit all MinGW sessions and then run the command
+  'mingw-get upgrade msys-core-bin=1.0.17-1' from MSVC developers command
+  prompt.
+
+* To run all the unit tests in Open vSwitch, one at a time:
 
     % make check
 
+  To run all the unit tests in Open vSwitch, up to 8 in parallel:
+
+    % make check TESTSUITEFLAGS="-j8"
+
+* To install all the compiled executables on the local machine, run:
+
+    % make install
+
+  The above command will install the Open vSwitch executables in
+  C:/openvswitch.  You can add 'C:\openvswitch\usr\bin' and
+  'C:\openvswitch\usr\sbin' to Windows' PATH environment variable
+  for easy access.
+
 OpenSSL, Open vSwitch and Visual C++
 ------------------------------------
 To get SSL support for Open vSwitch on Windows, do the following:
@@ -91,10 +124,10 @@ Note down the directory where OpenSSL is installed (e.g.: C:/OpenSSL-Win32).
 * While configuring the package, specify the OpenSSL directory path.
 For example,
 
-    % ./configure CC=./build-aux/cccl LD="`which link`" LIBS="-lws2_32" \
-    --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
-    --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread" \
-    --enable-ssl --with-openssl="C:/OpenSSL-Win32"
+    % ./configure CC=./build-aux/cccl LD="`which link`"  \
+    LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
+    --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
+    --with-pthread="C:/pthread" --enable-ssl --with-openssl="C:/OpenSSL-Win32"
 
 * Run make for the ported executables.
 
@@ -105,17 +138,17 @@ You can open the extensions.sln file in the IDE and build the solution.
 
 * The kernel datapath can be compiled from command line as well.  The top
 level 'make' will invoke building the kernel datapath, if the
-'--with-vstudioddk' argument is specified while configuring the package.
+'--with-vstudiotarget' argument is specified while configuring the package.
 For example,
 
-    % ./configure CC=./build-aux/cccl LD="`which link`" LIBS="-lws2_32" \
-    --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
-    --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread" \
-    --enable-ssl --with-openssl="C:/OpenSSL-Win32" \
-    --with-vstudioddk="<WDK to use>"
+    % ./configure CC=./build-aux/cccl LD="`which link`" \
+    LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
+    --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
+    --with-pthread="C:/pthread" --enable-ssl \
+    --with-openssl="C:/OpenSSL-Win32" --with-vstudiotarget="<target type>"
 
-    Possible values for "<WDK to use>" are:
-    "Win8.1 Debug", "Win8.1 Release", "Win8 Debug" and "Win8 Release".
+    Possible values for "<target type>" are:
+    "Debug" and "Release"
 
 Installing the Kernel module
 ----------------------------
@@ -139,7 +172,12 @@ Steps to install the module
 
 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.
+during boot.  The following commands can be used:
+    % bcdedit /set LOADOPTIONS DISABLE_INTEGRITY_CHECKS
+    % 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
@@ -165,45 +203,52 @@ not a bug in Open vSwitch.
 
 Steps to run the user processes & configure ports
 -------------------------------------------------
-NOTE: The userspace executables built in Open vSwitch for Hyper-V links
-statically with the pthread library mentioned above.  However, the pthread
-library has been found to have a dependency on a DLL file called
-"pthreadVC2.dll" which is part of the pthread package and typically resides in
-"C:\pthread\dll\x86".  In order to resolve the dependency, add the location of
-the DLL file to Windows environment variable %Path%.  An alternative is to copy
-the DLL file into each of the directories where the OVS executables are
-located.  Without having this DLL dependency resolved, the OVS executables will
-not run.  They exit without showing any error/output.
+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
 
-01> Create the OVSDB file
-    % ovsdb\ovsdb-tool.exe create conf.db .\vswitchd\vswitch.ovsschema
+    If you would like to terminate the started ovsdb-server, run:
+    % ovs-appctl -t ovsdb-server exit
 
-02> Start ovsdb-server [IN A NEW CONSOLE]
-    % ovsdb\ovsdb-server.exe -v --remote=punix:db.sock conf.db
+    (Note that the logfile is created at C:/openvswitch/var/log/openvswitch/)
 
-03> Start ovs-vswitchd [IN A NEW CONSOLE]
-    % vswitchd\ovs-vswitchd.exe -v
+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
-    % utilities\ovs-vsctl.exe add-br br-int
-    % utilities\ovs-vsctl.exe add-br br-pif
+    % ovs-vsctl add-br br-int
+    % ovs-vsctl add-br br-pif
 
-NOTE: There's a known bug that running the ovs-vsctl.exe command does not
-terminate.  This is generally solved by having ovs-vswitchd.exe running.  If
-you face the issue despite that, hit Ctrl-C to terminate ovs-vsctl.exe and
+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.exe don't
-get to the kernel datapath immediately, ie. they don't whow up in the output of
-"ovs-dpctl.exe show" even though they show up in output of "ovs-vsctl.exe
-show".  In order to workaround this issue, restart ovs-vswitchd.exe.
+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
-.\    % utilities\ovs-dpctl.exe show
+    % ovs-dpctl show
 
 * Sample output is as follows:
 
-    % utilities\ovs-dpctl.exe show
+    % ovs-dpctl show
     system@ovs-system:
             lookups: hit:0 missed:0 lost:0
             flows: 0
@@ -211,10 +256,10 @@ show".  In order to workaround this issue, restart ovs-vswitchd.exe.
             port 1: br-int (internal)     <<< internal port on 'br-int' bridge
 
 06> Dump the ports in the OVSDB
-    % utilities\ovs-vsctl.exe show
+    % ovs-vsctl show
 
 * Sample output is as follows:
-    % .\ovs-vsctl.exe show
+    % ovs-vsctl show
     a56ec7b5-5b1f-49ec-a795-79f6eb63228b
         Bridge br-pif
             Port br-pif
@@ -227,46 +272,69 @@ show".  In order to workaround this issue, restart ovs-vswitchd.exe.
 
 07> Add the physical NIC and the internal port to br-pif.
 
-In OVS for Hyper-V, we use 'external' as a special name to refer to the
-physical NICs connected to the Hyper-V switch.  An index is added to this
-special name to refer to the particular physical NIC. Eg. 'external.1' refers
-to the first physical NIC on the Hyper-V switch.
+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.
 
-Interal port is the virtual adapter created on the Hyper-V switch using the
+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 'internal'
-as a special name to refer to that adapter.
+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 (<name of the switch>)".
+
+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
 
-    % utilities\ovs-vsctl.exe add-port br-pif external.1
-    % utilities\ovs-vsctl.exe add-port br-pif internal
+
+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)"
 
 * Dumping the ports should show the additional ports that were just added.
   Sample output shows up as follows:
 
-    % utilities\ovs-dpctl.exe show
+    % ovs-dpctl show
     system@ovs-system:
             lookups: hit:0 missed:0 lost:0
             flows: 0
-            port 4: internal (internal)   <<< 'AllowManagementOS' adapter on
-                                              Hyper-V switch
+            port 4: vEthernet (external) (internal) <<< 'AllowManagementOS'
+                                                         adapter on
+                                                         Hyper-V switch
             port 2: br-pif (internal)
-            port 1: br-int (internal
-            port 3: external.1            <<< Physical NIC
+            port 1: br-int (internal)
+            port 3: Ethernet0                       <<< Physical NIC
 
-    % .\ovs-vsctl.exe show
+    % ovs-vsctl show
     a56ec7b5-5b1f-49ec-a795-79f6eb63228b
         Bridge br-pif
-            Port internal
-                Interface internal
+            Port "vEthernet (external)"
+                Interface "vEthernet (external)"
             Port br-pif
                 Interface br-pif
                     type: internal
+            Port "Ethernet0"
+                Interface "Ethernet0"
         Bridge br-int
-            Port "external.1"
-                Interface "external.1"
             Port br-int
                 Interface br-int
                     type: internal
@@ -299,26 +367,26 @@ with OVS extension enabled.
 08b> Add the VIFs to br-int in ovsdb
 
     Eg:
-    % utilities\ovs-vsctl.exe add-port br-int ovs-port-a
+    % ovs-vsctl add-port br-int ovs-port-a
 
 09> Verify the status
-    % utilities\ovs-dpctl.exe show
+    % ovs-dpctl show
     system@ovs-system:
             lookups: hit:0 missed:0 lost:0
             flows: 0
-            port 4: internal (internal)
+            port 4: vEthernet (external) (internal)
             port 5: ovs-port-a
             port 2: br-pif (internal)
             port 1: br-int (internal
-            port 3: external.1
+            port 3: Ethernet0
 
-    % utilities\ovs-vsctl.exe show
+    % ovs-vsctl show
     4cd86499-74df-48bd-a64d-8d115b12a9f2
         Bridge br-pif
-            Port internal
-                Interface internal
-            Port "external.1"
-                Interface "external.1"
+            Port "vEthernet (external)"
+                Interface "vEthernet (external)"
+            Port "Ethernet0"
+                Interface "Ethernet0"
             Port br-pif
                 Interface br-pif
                     type: internal
@@ -337,46 +405,44 @@ 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
-    % utilities/ovs-vsctl.exe -- add-port br-int patch-to-pif
-    % utilities/ovs-vsctl.exe -- set interface patch-to-pif type=patch \
+    % 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
-    % utilities/ovs-vsctl.exe -- add-port br-pif patch-to-int
-    % utilities/ovs-vsctl.exe -- set interface patch-to-int type=patch \
+    % 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
-    % utilities\ovs-vsctl.exe add-port br-int ovs-port-a tag=900
-    % utilities\ovs-vsctl.exe add-port br-int ovs-port-b tag=900
+    % 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 VXLAN tunnels
+Steps to add tunnels
 --------------------------
-The Windows Open vSwitch implementation support VXLAN tunnels.  To add VXLAN
+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 VXLAN tunnels.
-
-01> Add the vxlan port between 172.168.201.101 <-> 172.168.201.102
-    % utilities\ovs-vsctl.exe add-port br-int vxlan-1
-    % utilities\ovs-vsctl.exe set Interface vxlan-1 type=vxlan
-    % utilities\ovs-vsctl.exe set Interface vxlan-1 \
-                                  options:local_ip=172.168.201.101
-    % utilities\ovs-vsctl.exe set Interface vxlan-1 \
-                                  options:remote_ip=172.168.201.102
-    % utilities\ovs-vsctl.exe set Interface vxlan-1 options:in_key=flow
-    % utilities\ovs-vsctl.exe set Interface vxlan-1 options:out_key=flow
-
-02> Add the vxlan port between 172.168.201.101 <-> 172.168.201.105
-    % utilities\ovs-vsctl.exe add-port br-int vxlan-2
-    % utilities\ovs-vsctl.exe set Interface vxlan-2 type=vxlan
-    % utilities\ovs-vsctl.exe set Interface vxlan-2 \
-                                  options:local_ip=172.168.201.102
-    % utilities\ovs-vsctl.exe set Interface vxlan-2 \
-                                  options:remote_ip=172.168.201.105
-    % utilities\ovs-vsctl.exe set Interface vxlan-2 options:in_key=flow
-    % utilities\ovs-vsctl.exe set Interface vxlan-2 options:out_key=flow
+prior to adding tunnels.
+
+01> Add the tunnel port between 172.168.201.101 <-> 172.168.201.102
+    % ovs-vsctl add-port br-int tun-1
+    % ovs-vsctl set Interface tun-1 type=port-type
+    % ovs-vsctl set Interface tun-1 options:local_ip=172.168.201.101
+    % ovs-vsctl set Interface tun-1 options:remote_ip=172.168.201.102
+    % ovs-vsctl set Interface tun-1 options:in_key=flow
+    % ovs-vsctl set Interface tun-1 options:out_key=flow
+
+02> Add the tunnel port between 172.168.201.101 <-> 172.168.201.105
+    % ovs-vsctl add-port br-int tun-2
+    % ovs-vsctl set Interface tun-2 type=port-type
+    % ovs-vsctl set Interface tun-2 options:local_ip=172.168.201.102
+    % ovs-vsctl set Interface tun-2 options:remote_ip=172.168.201.105
+    % ovs-vsctl set Interface tun-2 options:in_key=flow
+    % ovs-vsctl set Interface tun-2 options:out_key=flow
+
+    Where port-type is the string stt or vxlan
 
 
 Requirements
@@ -390,6 +456,57 @@ type: External network', in the HyperV virtual network switch configuration.
 this is still a work in progress. Till the support is complete we recommend
 disabling TX/RX offloads for both the VM's as well as the HyperV.
 
+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.
+
+* Create the database.
+
+  % ovsdb-tool create C:/openvswitch/etc/openvswitch/conf.db \
+        "C:/openvswitch/usr/share/openvswitch/vswitch.ovsschema"
+
+* Create the ovsdb-server service and start it.
+
+  % sc create ovsdb-server binpath="C:/openvswitch/usr/sbin/ovsdb-server.exe C:/openvswitch/etc/openvswitch/conf.db -vfile:info --log-file --pidfile --remote=punix:db.sock --service --service-monitor"
+
+  One of the common issues with creating a Windows service is with mungled
+  paths. You can make sure that the correct path has been registered with
+  the Windows services manager by running:
+
+  % sc qc ovsdb-server
+
+  Start the service.
+
+  % sc start ovsdb-server
+
+  Check that the service is healthy by running:
+
+  % sc query ovsdb-server
+
+* Initialize the database.
+
+  % ovs-vsctl --no-wait init
+
+* Create the ovs-vswitchd service and start it.
+
+  % sc create ovs-vswitchd binpath="C:/openvswitch/usr/sbin/ovs-vswitchd.exe --pidfile -vfile:info --log-file  --service --service-monitor"
+
+  % sc start ovs-vswitchd
+
+  Check that the service is healthy by running:
+
+  % sc query ovs-vswitchd
+
+* To stop and delete the services, run:
+
+  % sc stop ovs-vswitchd
+  % sc stop ovsdb-server
+  % sc delete ovs-vswitchd
+  % sc delete ovsdb-server
+
 Windows autobuild service
 -------------------------
 AppVeyor (appveyor.com) provides a free Windows autobuild service for