Skip to content

Commit

Permalink
Merge pull request #23 from dbosoft/dbosoft-mods
Browse files Browse the repository at this point in the history
* Windows build for master branch (#8)
* merged windows build
* Update build-and-test.yml
Removed windows steps from build-and-test workflow
* Update build-windows.yml
rename windows build workflow (no tests active)

* fix json inlining (#9)
restored ovs upstream json inline

* remove pthreads code after build (#10)

* improved windows build workflow (#12)

* generate artificats for windows

* fix install step in windows workflow

* copy pthreads

* added TargetVersion for Analyze configurations (#11)

* Update README.rst

* driver branding (#13)

* Revert "driver branding (#13)" (#14)

This reverts commit 8f437fd.

* dbosoft branding (#15)

* branding
* branding: fixed check for extension

* Update build-windows.yml (#16)

* fixed version variable (#17)

* Build with SSL enabled (#18)

- Update build-windows.yml to download openssl
- openssl 1.1 renamed libraries
* update appveyor openssl download to openssl 1.1

* OpenSSL DLLs are missing in build output (#19)
copy DLLs of openssl 1.1 to c:\openvswitch

* fix BSOD in kernel driver (#20)

In case OVS_KEY_ATTR_IN_PORT is not in netlink attributes
a BSOD will occur.

* Driver: windows server 2016 compatibility (#21)

* lower driver build version for server 2016
* use ExAllocatePoolPriorityUninitialized

* Update build-windows.yml

* disable SSL build

disable ssl to build server issue - cannot find headers

* disable parallel build on windows
option -j sometimes cause build errors currently
  • Loading branch information
fw2568 authored Feb 5, 2024
2 parents 6bdca15 + 797ede1 commit 5a9c218
Show file tree
Hide file tree
Showing 19 changed files with 282 additions and 78 deletions.
30 changes: 30 additions & 0 deletions .ci/windows-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -o errexit
set -x

CFLAGS_FOR_OVS="-g -O2"
EXTRA_OPTS="--with-pthread=`realpath ./PTHREADS-BUILT | xargs cygpath -m`"

function configure_ovs()
{
./boot.sh
./configure CC="./build-aux/cccl" LD="`which link`" \
LIBS="-lws2_32 -lShlwapi -liphlpapi -lwbemuuid -lole32 -loleaut32" \
CFLAGS="${CFLAGS_FOR_OVS}" $* || { cat config.log; exit 1; }
}


OPTS="${EXTRA_OPTS} ${OPTS} $*"
configure_ovs $OPTS
make || { cat config.log; exit 1; }

if [ "$TESTSUITE" ]; then
if ! make check RECHECK=yes; then
# testsuite.log is necessary for debugging.
cat ./tests/testsuite.log
exit 1
fi
fi

exit 0
9 changes: 9 additions & 0 deletions .ci/windows-prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ev

# clone and build pthreads4w
git clone https://git.code.sf.net/p/pthreads4w/code pthreads4w-code
cd pthreads4w-code
nmake all install
cd ..
rm -rf pthreads4w-code
100 changes: 100 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build for Windows

on: [push, pull_request]

jobs:
build-windows:
name: windows ${{ join(matrix.*, ' ') }}
env:
OPTS: --with-vstudiotarget=${{ matrix.target }} --with-vstudiotargetver=Win10 --prefix=C:/openvswitch/usr --localstatedir=C:/ProgramData/openvswitch/var --sysconfdir=C:/ProgramData/openvswitch/etc --disable-ssl ${{ matrix.opts }}
TESTSUITE: ${{ matrix.testsuite }}

runs-on: windows-latest
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
include:
# run only one job for windows, as more than one be enough currently to verify
# PRs
# tests are not enabled as they take very long and a lot of them will fail
- target: Release

defaults:
run:
shell: msys2 {0}

steps:
- name: checkout
uses: actions/checkout@v2
- name: install msys
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: base-devel git mingw-w64-ucrt-x86_64-toolchain autotools
- name: set up python
uses: actions/setup-python@v2
with:
python-version: '3.x'

# pypiwin32 has to be installed with a Windows python version therefore
# this step will configure python first on Windows and exports
# its location for MSYS bash.
- name: configure python in Windows cmdline
shell: cmd
run: |
python -m pip install --upgrade pip
pip install pypiwin32
echo export pythonLocation="%pythonLocation%" > %RUNNER_TEMP%\msys64\home\%USERNAME%\.pythonenv.sh
echo export PYTHONPATH="%pythonLocation%\Lib;%pythonLocation%\DLLs;%pythonLocation%\Lib\lib-tk" >> %RUNNER_TEMP%\msys64\home\%USERNAME%\.pythonenv.sh
echo ".pythonenv.sh was generated in %RUNNER_TEMP%\msys64\home\%USERNAME%"
- name: generate Visual Studio environment
shell: cmd
run: |
powershell -c ./build-aux/envdiff.ps1
@call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
powershell -c ./build-aux/envdiff.ps1 > %RUNNER_TEMP%\msys64\home\%USERNAME%\.visualstudio.sh
echo ".visualstudio.sh was generated in %RUNNER_TEMP%\msys64\home\%USERNAME%"
- name: configure python for MSYS
run: |
source ~/.pythonenv.sh
echo "using python from path $pythonLocation"
mv /ucrt64/bin/python /ucrt64/bin/python_off
mv /ucrt64/bin/python3 /ucrt64/bin/python3_off
ln -s "$pythonLocation\python" /ucrt64/bin/python3
- name: prepare
run: |
[[ -f /usr/bin/link ]] && mv /usr/bin/link /usr/bin/link_off
source ~/.visualstudio.sh
./.ci/windows-prepare.sh
- name: build
run: |
source ~/.visualstudio.sh
source ~/.pythonenv.sh
echo $PYTHONPATH
./.ci/windows-build.sh
- name: upload logs on failure
if: failure()
uses: actions/upload-artifact@v2
with:
name: logs-windows-${{ join(matrix.*, '-') }}
path: config.log
- name: install
run: |
source ~/.visualstudio.sh
source ~/.pythonenv.sh
make install
cp ./PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/sbin
cp ./PTHREADS-BUILT/bin/pthreadVC3.dll /C/openvswitch/usr/bin
mkdir /C/openvswitch/driver
cp ./datapath-windows/x64/Win10${{ matrix.target }}/package/* /C/openvswitch/driver
cp ./datapath-windows/x64/Win10${{ matrix.target }}/package.cer /C/openvswitch/driver
cp ./datapath-windows/misc/* /C/openvswitch/driver
cp ./datapath-windows/ovsext/x64/Win10${{ matrix.target }}/DBO_OVSE.pdb /C/openvswitch/driver
- name: upload build artifacts
uses: actions/upload-artifact@v2
with:
name: openvswitch-windows-${{ join(matrix.*, '-') }}
path: c:\openvswitch
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ testsuite.tmp.orig
/Documentation/_build
/.venv
/cxx-check
snapshot.env
PTHREADS-BUILT/bin/pthreadVC3.dll
PTHREADS-BUILT/bin/pthreadVC3d.dll
PTHREADS-BUILT/bin/pthreadVCE3.dll
PTHREADS-BUILT/bin/pthreadVCE3d.dll
PTHREADS-BUILT/bin/pthreadVSE3.dll
PTHREADS-BUILT/bin/pthreadVSE3d.dll
PTHREADS-BUILT/include/_ptw32.h
PTHREADS-BUILT/include/pthread.h
PTHREADS-BUILT/include/sched.h
PTHREADS-BUILT/include/semaphore.h
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ EXTRA_DIST = \
.ci/dpdk-prepare.sh \
.ci/linux-build.sh \
.ci/linux-prepare.sh \
.ci/windows-build.sh \
.ci/windows-prepare.sh \
.ci/osx-build.sh \
.ci/osx-prepare.sh \
.cirrus.yml \
.editorconfig \
.github/workflows/build-and-test.yml \
.github/workflows/build-windows.yml \
.readthedocs.yaml \
appveyor.yml \
boot.sh \
Expand Down
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
are kept up-to-date.
============
Open vSwitch
Open vSwitch (dbosoft fork)
============

.. image:: https://github.com/dbosoft/ovs/workflows/Build%20and%20Test/badge.svg
:target: https://github.com/dbosoft/ovs/actions
.. image:: https://github.com/openvswitch/ovs/workflows/Build%20and%20Test/badge.svg
:target: https://github.com/openvswitch/ovs/actions
.. image:: https://ci.appveyor.com/api/projects/status/github/openvswitch/ovs?branch=master&svg=true&retina=true
Expand Down Expand Up @@ -49,6 +51,10 @@ the kernel-based switch. OVS in userspace can access Linux or DPDK devices.
Note Open vSwitch with userspace datapath and non DPDK devices is considered
experimental and comes with a cost in performance.

What is the dbosoft fork?
-------------------------
We have forked openvswitch to build it for windows and to work on upstream patches.

What's here?
------------

Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ init:
mkdir C:\openvswitch\driver
$source = "https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe"
$source = "https://slproweb.com/download/Win64OpenSSL-1_1_1s.exe"
$destination = "C:\ovs-build-downloads\Win64OpenSSL-1_0_2u.exe"
$destination = "C:\ovs-build-downloads\Win64OpenSSL-1_1_1s.exe"
Invoke-WebRequest $source -OutFile $destination
cd C:\ovs-build-downloads
.\Win64OpenSSL-1_0_2u.exe /silent /verysilent /sp- /suppressmsgboxes
.\Win64OpenSSL-1_1_1s.exe /silent /verysilent /sp- /suppressmsgboxes
Start-Sleep -s 30
Expand Down
3 changes: 2 additions & 1 deletion build-aux/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ EXTRA_DIST += \
build-aux/sodepends.py \
build-aux/soexpand.py \
build-aux/text2c \
build-aux/xml2nroff
build-aux/xml2nroff \
build-aux/envdiff.ps1

FLAKE8_PYFILES += \
build-aux/dpdkstrip.py \
Expand Down
44 changes: 44 additions & 0 deletions build-aux/envdiff.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# script to export windows environment variables to bash shell
# This is useful to create bash environments from vcvars64.bat
# based on the solution from this article https://anadoxin.org/blog/bringing-visual-studio-compiler-into-msys2-environment.html/

if((Test-Path "snapshot.env") -eq $false){

Get-ChildItem env: | Select-Object Key,Value | ConvertTo-Json | Set-Content "snapshot.env"
Write-Host "Stored snapshot.env"
return
}

$snapshotEnv = Get-Content "snapshot.env" | ConvertFrom-Json

foreach($e in Get-ChildItem env:){
if($e.Key -contains '/') {
# Sometimes Windows uses environment variables like i.e.
# ProgramFiles(x86)=c:\...
# but let's just skip this.
continue;
}
$key = $e.Key
$keyUpperCase = $e.Key.ToUpperInvariant()

if($keyUpperCase -eq "PATH") {
$path = $e.Value.Replace("c:", "/c").Replace("C:", "/c").Replace("\", "/").Replace(";", ":")
Write-Output "export PATH=""`$PATH:$path"""
continue
}
$valueEscaped = $e.value.replace("\", "\\");

$snapShotEntry = $snapshotEnv | Where-Object -Property Key -eq $key | Select-Object -First 1

if($null -ne $snapShotEntry){
Write-Output "# debug: key=$keyUpperCase"
$oldValue = $snapShotEntry.Value
if($oldValue -ne $e.Value) {
Write-Output "export $key=""$valueEscaped"" #changed"
}
}
else{
Write-Output "export $key=""$valueEscaped"" #new"

}
}
8 changes: 3 additions & 5 deletions datapath-windows/Package/package.VcxProj
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 Debug|x64'" Label="Configuration">
<TargetVersion>
</TargetVersion>
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == ''">10.0</PlatformToolsetVer>
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
<DriverTargetPlatform>Desktop</DriverTargetPlatform>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10Analyze|x64'" Label="Configuration">
<TargetVersion />
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == ''">10.0</PlatformToolsetVer>
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
Expand All @@ -95,8 +94,7 @@
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 Release|x64'" Label="Configuration">
<TargetVersion>
</TargetVersion>
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == ''">10.0</PlatformToolsetVer>
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
Expand Down
6 changes: 3 additions & 3 deletions datapath-windows/include/OvsDpInterfaceExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#define OVS_DATAPATH_EXT_VERSION 1

/* Name of the device. */
#define OVS_DEVICE_NAME_NT L"\\Device\\OpenvSwitchDevice"
#define OVS_DEVICE_NAME_DOS L"\\DosDevices\\OpenvSwitchDevice"
#define OVS_DEVICE_NAME_USER TEXT("\\\\.\\OpenvSwitchDevice")
#define OVS_DEVICE_NAME_NT L"\\Device\\DbosoftOVSD"
#define OVS_DEVICE_NAME_DOS L"\\DosDevices\\DbosoftOVSD"
#define OVS_DEVICE_NAME_USER TEXT("\\\\.\\DbosoftOVSD")

#define OVS_IOCTL_DEVICE_TYPE 45000

Expand Down
14 changes: 7 additions & 7 deletions datapath-windows/ovsext/Driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ NDIS_HANDLE gOvsExtDriverHandle;
*/
extern POVS_SWITCH_CONTEXT gOvsSwitchContext;

static PWCHAR ovsExtFriendlyName = L"Open vSwitch Extension";
static PWCHAR ovsExtServiceName = L"OVSExt";
static PWCHAR ovsExtFriendlyName = L"dbosoft Open vSwitch Extension";
static PWCHAR ovsExtServiceName = L"DBO_OVSE";
NDIS_STRING ovsExtGuidUC;
NDIS_STRING ovsExtFriendlyNameUC;

static PWCHAR ovsExtGuidStr = L"{583CC151-73EC-4A6A-8B47-578297AD7623}";
static PWCHAR ovsExtGuidStr = L"{63E968D9-754E-4704-A5CE-6E3BF7DDF59B}";
static const GUID ovsExtGuid = {
0x583cc151,
0x73ec,
0x4a6a,
{0x8b, 0x47, 0x57, 0x82, 0x97, 0xad, 0x76, 0x23}
0x63e968d9,
0x754e,
0x4704,
{0xa5, 0xce, 0x6e, 0x3b, 0xf7, 0xdd, 0xf5, 0x9b}
};

DRIVER_INITIALIZE DriverEntry;
Expand Down
5 changes: 4 additions & 1 deletion datapath-windows/ovsext/User.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ _MapNlAttrToOvsPktExec(PNL_MSG_HDR nlMsgHdr, PNL_ATTR *nlAttrs,
execute->actionsLen = NlAttrGetSize(nlAttrs[OVS_PACKET_ATTR_ACTIONS]);

ASSERT(keyAttrs[OVS_KEY_ATTR_IN_PORT]);
execute->inPort = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_IN_PORT]);
if (keyAttrs[OVS_KEY_ATTR_IN_PORT]) {
execute->inPort = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_IN_PORT]);
}

execute->keyAttrs = keyAttrs;

if (nlAttrs[OVS_PACKET_ATTR_MRU]) {
Expand Down
Loading

0 comments on commit 5a9c218

Please sign in to comment.