Skip to content

Commit

Permalink
Windows: Add internal switch port per OVS bridge
Browse files Browse the repository at this point in the history
This patch updates the following commands in the vswitch:
 ovs-vsctl add-br br-test
 ovs-vsctl del-br br-test

ovs-vsctl add-br br-test:
    This command will now create an internal port on the MSFT virtual switch
  using the WMI interface from Msvm_VirtualEthernetSwitchManagementService
  leveraging the method AddResourceSettings.
    Before creating the actual port, the switch will be queried to see if there
  is not a port already created (good for restarts when restarting the
  vswitch daemon). If there is a port defined it will return success and log
  a message.
    After checking if the port already exists the command will also verify
  if the forwarding extension (windows datapath) is enabled and on a single
  switch. If it is not activated or if it is activated on multiple switches
  it will return an error and a message will be logged.
    After the port was created on the switch, we will disable the adapter on
  the host and rename to the corresponding OVS bridge name for consistency.
    The user will enable and set the values he wants after creation.

ovs-vsctl del-br br-test
    This command will remove an internal port on the MSFT virtual switch
  using the Msvm_VirtualEthernetSwitchManagementService class and executing
  the method RemoveResourceSettings.

Both commands will be blocking until the WMI job is finished, this allows us
to guarantee that the ports are created and their name are set before issuing
a netlink message to the windows datapath.

This patch also includes helpers for normal WMI retrievals and initializations.
Appveyor and documentation has been modified to include the libraries needed
for COM objects.

This patch was tested individually using IMallocSpy and CRT heap checks
to ensure no new memory leaks are introduced.

Tested on the following OS's:
Windows 2012, Windows 2012r2, Windows 2016

Signed-off-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Paul Boca <[email protected]>
Acked-by: Sairam Venugopal <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
Alin Serdean authored and shettyg committed Dec 20, 2016
1 parent 7532fef commit da46789
Show file tree
Hide file tree
Showing 5 changed files with 1,353 additions and 2 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ build_script:
- C:\MinGW\msys\1.0\bin\bash -lc "cp /c/pthreads-win32/Pre-built.2/dll/x86/*.dll /c/openvswitch/."
- C:\MinGW\msys\1.0\bin\bash -lc "mv /bin/link.exe /bin/link_copy.exe"
- C:\MinGW\msys\1.0\bin\bash -lc "cd /c/openvswitch && ./boot.sh"
- C:\MinGW\msys\1.0\bin\bash -lc "cd /c/openvswitch && ./configure CC=build-aux/cccl LD=\"`which link`\" LIBS=\"-lws2_32 -liphlpapi\" --with-pthread=C:/pthreads-win32/Pre-built.2 --with-openssl=C:/OpenSSL-Win32 --with-vstudiotarget=\"Debug\""
- C:\MinGW\msys\1.0\bin\bash -lc "cd /c/openvswitch && ./configure CC=build-aux/cccl LD=\"`which link`\" LIBS=\"-lws2_32 -liphlpapi -lwbemuuid -lole32 -loleaut32\" --with-pthread=C:/pthreads-win32/Pre-built.2 --with-openssl=C:/OpenSSL-Win32 --with-vstudiotarget=\"Debug\""
- C:\MinGW\msys\1.0\bin\bash -lc "cd /c/openvswitch && make"
4 changes: 3 additions & 1 deletion lib/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ lib_libopenvswitch_la_SOURCES += \
lib/netlink-notifier.h \
lib/netlink-protocol.h \
lib/netlink-socket.c \
lib/netlink-socket.h
lib/netlink-socket.h \
lib/wmi.c \
lib/wmi.h
endif

if HAVE_POSIX_AIO
Expand Down
21 changes: 21 additions & 0 deletions lib/dpif-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

VLOG_DEFINE_THIS_MODULE(dpif_netlink);
#ifdef _WIN32
#include "wmi.h"
enum { WINDOWS = 1 };
#else
enum { WINDOWS = 0 };
Expand Down Expand Up @@ -849,6 +850,16 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif, struct netdev *netdev,
#endif
}

#ifdef _WIN32
if (request.type == OVS_VPORT_TYPE_INTERNAL) {
if (!create_wmi_port(name)){
VLOG_ERR("Could not create wmi internal port with name:%s", name);
vport_del_socksp(dpif, socksp);
return EINVAL;
};
}
#endif

tnl_cfg = netdev_get_tunnel_config(netdev);
if (tnl_cfg && (tnl_cfg->dst_port != 0 || tnl_cfg->exts)) {
ofpbuf_use_stack(&options, options_stub, sizeof options_stub);
Expand Down Expand Up @@ -940,6 +951,16 @@ dpif_netlink_port_del__(struct dpif_netlink *dpif, odp_port_t port_no)
vport.cmd = OVS_VPORT_CMD_DEL;
vport.dp_ifindex = dpif->dp_ifindex;
vport.port_no = port_no;
#ifdef _WIN32
struct dpif_port temp_dpif_port;
dpif_netlink_port_query__(dpif, port_no, NULL, &temp_dpif_port);
if (!strcmp(temp_dpif_port.type, "internal")) {
if (!delete_wmi_port(temp_dpif_port.name)){
VLOG_ERR("Could not delete wmi port with name: %s",
temp_dpif_port.name);
};
}
#endif
error = dpif_netlink_vport_transact(&vport, NULL, NULL);

vport_del_channels(dpif, port_no);
Expand Down
Loading

0 comments on commit da46789

Please sign in to comment.