From 1cc0e1e5efe5583eb9fd0fa0efec9d66c418ecd4 Mon Sep 17 00:00:00 2001
From: Timothy Redaelli <tredaelli@redhat.com>
Date: Mon, 4 Sep 2017 18:33:51 +0200
Subject: [PATCH] Update to Open vSwitch 2.8.0 and DPDK 17.05.1

Resolves: #1487971
---
 .gitignore       |  2 ++
 openvswitch.spec | 61 ++++++++++++++++++++++++++++++++++++++++++++----
 sources          |  4 ++--
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index aea09db..827155f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,5 @@
 /dpdk-16.11.2.tar.gz
 /openvswitch-2.7.1.tar.gz
 /openvswitch-2.7.2.tar.gz
+/openvswitch-2.8.0.tar.gz
+/dpdk-17.05.1.tar.gz
diff --git a/openvswitch.spec b/openvswitch.spec
index c0531ea..7623e20 100644
--- a/openvswitch.spec
+++ b/openvswitch.spec
@@ -21,16 +21,19 @@
 %bcond_with check
 %endif
 
+# option to build with libcap-ng, needed for running OVS as regular user
+%bcond_without libcapng
+
 # Enable PIE, bz#955181
 %global _hardened_build 1
 
-%define dpdkver 16.11.2
+%define dpdkver 17.05.1
 %define dpdkdir dpdk-stable
 %define dpdksver %(echo %{dpdkver} | cut -d. -f-2)
 
 Name: openvswitch
-Version: 2.7.2
-Release: 3%{?snapshot}%{?dist}
+Version: 2.8.0
+Release: 1%{?snapshot}%{?dist}
 Summary: Open vSwitch daemon/database/utilities
 
 # Nearly all of openvswitch is ASL 2.0.  The bugtool is LGPLv2+, and the
@@ -74,6 +77,7 @@ Source2: ovs-snapshot.sh
 %endif
 ExcludeArch: ppc
 
+BuildRequires: python-sphinx
 BuildRequires: autoconf automake libtool
 BuildRequires: systemd-units openssl openssl-devel
 BuildRequires: python2-devel python2-six
@@ -92,10 +96,19 @@ BuildRequires: libpcap-devel numactl-devel
 %endif
 %endif
 
+%if %{with libcapng}
+BuildRequires: libcap-ng libcap-ng-devel
+%endif
+
 Requires: openssl iproute module-init-tools
 #Upstream kernel commit 4f647e0a3c37b8d5086214128614a136064110c3
 #Requires: kernel >= 3.15.0-0
 
+Requires(post): /usr/bin/getent
+Requires(post): /usr/sbin/useradd
+Requires(post): /usr/bin/sed
+Requires(post): /usr/sbin/usermod
+Requires(post): /usr/sbin/groupadd
 Requires(post): systemd-units
 Requires(preun): systemd-units
 Requires(postun): systemd-units
@@ -304,6 +317,11 @@ sed -i.old -e "s/^AC_INIT(openvswitch,.*,/AC_INIT(openvswitch, %{version},/" con
 %endif
 
 %configure \
+%if %{with libcapng}
+        --enable-libcapng \
+%else
+        --disable-libcapng \
+%endif
   --enable-ssl \
 %if %{with dpdk}
 %ifarch %{dpdkarches}
@@ -311,15 +329,23 @@ sed -i.old -e "s/^AC_INIT(openvswitch,.*,/AC_INIT(openvswitch, %{version},/" con
 %endif
 %endif
   --with-pkidir=%{_sharedstatedir}/openvswitch/pki
-
+/usr/bin/perl build-aux/dpdkstrip.pl \
+        --dpdk \
+        < rhel/usr_lib_systemd_system_ovs-vswitchd.service.in \
+        > rhel/usr_lib_systemd_system_ovs-vswitchd.service
 make %{?_smp_mflags}
 
 %install
 rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
 
+install -d -m 0755 $RPM_BUILD_ROOT%{_rundir}/openvswitch
+install -d -m 0750 $RPM_BUILD_ROOT%{_localstatedir}/log/openvswitch
 install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
 
+install -p -D -m 0644 rhel/usr_lib_udev_rules.d_91-vfio.rules \
+        $RPM_BUILD_ROOT%{_udevrulesdir}/91-vfio.rules
+
 install -p -D -m 0644 \
         rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
@@ -333,6 +359,9 @@ done
 install -m 0755 rhel/etc_init.d_openvswitch \
         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
 
+install -p -D -m 0644 rhel/etc_openvswitch_default.conf \
+        $RPM_BUILD_ROOT/%{_sysconfdir}/openvswitch/default.conf
+
 install -p -D -m 0644 rhel/etc_logrotate.d_openvswitch \
         $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/openvswitch
 
@@ -434,6 +463,23 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %post
+if [ $1 -eq 1 ]; then
+    getent passwd openvswitch >/dev/null || \
+        useradd -r -d / -s /sbin/nologin -c "Open vSwitch Daemons" openvswitch
+
+    sed -i 's:^#OVS_USER_ID=:OVS_USER_ID=:' /etc/sysconfig/openvswitch
+
+    getent group hugetlbfs >/dev/null || \
+        groupadd hugetlbfs
+    usermod -a -G hugetlbfs openvswitch
+    sed -i \
+        's@OVS_USER_ID="openvswitch:openvswitch"@OVS_USER_ID="openvswitch:hugetlbfs"@'\
+        /etc/sysconfig/openvswitch
+
+    # In the case of upgrade, this is not needed.
+    chown -R openvswitch:openvswitch /etc/openvswitch
+fi
+
 %if 0%{?systemd_post:1}
     %systemd_post %{name}.service
 %else
@@ -553,6 +599,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash
 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
 %dir %{_sysconfdir}/openvswitch
+%{_sysconfdir}/openvswitch/default.conf
 %config %ghost %{_sysconfdir}/openvswitch/conf.db
 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
@@ -603,6 +650,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man8/ovs-vswitchd.8*
 %{_mandir}/man8/ovs-parse-backtrace.8*
 %{_mandir}/man8/ovs-testcontroller.8*
+%{_udevrulesdir}/91-vfio.rules
 %doc COPYING NOTICE README.rst NEWS rhel/README.RHEL.rst
 /var/lib/openvswitch
 /var/log/openvswitch
@@ -613,6 +661,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ovn-docker-underlay-driver
 
 %files ovn-common
+%{_bindir}/ovn-detrace
 %{_bindir}/ovn-nbctl
 %{_bindir}/ovn-sbctl
 %{_bindir}/ovn-trace
@@ -621,6 +670,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_datadir}/openvswitch/scripts/ovn-bugtool-nbctl-show
 %{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-lflow-list
 %{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-show
+%{_mandir}/man1/ovn-detrace.1*
 %{_mandir}/man8/ovn-ctl.8*
 %{_mandir}/man8/ovn-nbctl.8*
 %{_mandir}/man8/ovn-trace.8*
@@ -650,6 +700,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_unitdir}/ovn-controller-vtep.service
 
 %changelog
+* Mon Sep 04 2017 Timothy Redaelli <tredaelli@redhat.com> - 2.8.0-1
+- Update to Open vSwitch 2.8.0 and DPDK 17.05.1 (#1487971)
+
 * Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.2-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
 
diff --git a/sources b/sources
index 1542be4..980ca01 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
-SHA512 (openvswitch-2.7.2.tar.gz) = 790a715dd31729893a1c21af4197400b7362569d15cb763cbbab82830c5f5168d2dea0cb40282faa17734a2ad967bc40d02b8f4f92ea585164386d2aa0719470
-SHA512 (dpdk-16.11.2.tar.gz) = b0b103f7f45620e7e4e4601ac57781104e6764cdb1d31ece29162c9588e0cd6de0cf4be5e1988bb7493ca43fdd476bc100e6c42edc6763dcf9c77475c3ac7317
+SHA512 (openvswitch-2.8.0.tar.gz) = f490eec99fb4868e809e462ea28453d900857c6e830f8dce2aaf27bba037eb4b4fd2944eb063a289657b8260ba3d1473e585d0c3bd386836b9682a91bee74300
+SHA512 (dpdk-17.05.1.tar.gz) = 6e2b23902cc9449fb853dd94a8b051608a4528281956d42d5145d7e1df7485ce1cfc8e62ab0f578553ee295251609dac9402e72ba19f2ae6f10f8db7432c40e2