From 63ef7247552afa28db7a4316e928b9b18eb61a97 Mon Sep 17 00:00:00 2001 From: Timothy Redaelli Date: May 24 2022 21:17:06 +0000 Subject: Create openvswitch-dpdk subpackage, install it by default (weak dependency), but enable it only if the CPU is new enough Resolves: #2081665 --- diff --git a/openvswitch.spec b/openvswitch.spec index ce37a66..d675bc0 100644 --- a/openvswitch.spec +++ b/openvswitch.spec @@ -45,7 +45,7 @@ Name: openvswitch Summary: Open vSwitch daemon/database/utilities URL: https://www.openvswitch.org/ Version: 2.17.0 -Release: 3%{?dist} +Release: 4%{?dist} # Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the # lib/sflow*.[ch] files are SISSL @@ -111,6 +111,8 @@ Requires: openssl iproute module-init-tools %{?sysusers_requires_compat} Requires(post): /bin/sed +Requires(post): %{_sbindir}/update-alternatives +Requires(postun): %{_sbindir}/update-alternatives Obsoletes: openvswitch-controller <= 0:2.1.0-1 %description @@ -178,6 +180,18 @@ Requires: python3-openvswitch = %{?epoch:%{epoch}:}%{version}-%{release} %description ipsec This package provides IPsec tunneling support for OVS tunnels. +%if %{with dpdk} +%ifarch %{dpdkarches} +%package dpdk +Summary: Open vSwitch OpenFlow development package (switch, linked with DPDK) +License: ASL 2.0 +Supplements: %{name} + +%description dpdk +This provides ovs-vswitchd linked with DPDK library. +%endif +%endif + %prep %if 0%{?commit0:1} %autosetup -n ovs-%{commit0} -p 1 @@ -195,6 +209,9 @@ sed -i.old -e "s/^AC_INIT(openvswitch,.*,/AC_INIT(openvswitch, %{version},/" con rm -f python/ovs/dirs.py ./boot.sh +mkdir build build-dpdk +pushd build +ln -s ../configure %configure \ %if %{with libcapng} --enable-libcapng \ @@ -204,22 +221,53 @@ rm -f python/ovs/dirs.py --disable-static \ --enable-shared \ --enable-ssl \ + --with-pkidir=%{_sharedstatedir}/openvswitch/pki +make %{?_smp_mflags} +popd %if %{with dpdk} %ifarch %{dpdkarches} - --with-dpdk=shared \ +pushd build-dpdk +ln -s ../configure +%configure \ +%if %{with libcapng} + --enable-libcapng \ +%else + --disable-libcapng \ +%endif + --disable-static \ + --enable-shared \ + --enable-ssl \ + --with-dpdk=shared \ + --with-pkidir=%{_sharedstatedir}/openvswitch/pki \ + --libdir=%{_libdir}/openvswitch-dpdk \ + --program-suffix=.dpdk +make %{?_smp_mflags} +popd %endif %endif - --with-pkidir=%{_sharedstatedir}/openvswitch/pki /usr/bin/python3 build-aux/dpdkstrip.py \ --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 + +%if %{with dpdk} +%ifarch %{dpdkarches} +make -C build-dpdk install-exec DESTDIR=$RPM_BUILD_ROOT + +# We only need ovs-vswitchd-dpdk and some libraries for dpdk subpackage +rm -rf $RPM_BUILD_ROOT%{_bindir} +find $RPM_BUILD_ROOT%{_sbindir} -mindepth 1 -maxdepth 1 -not -name ovs-vswitchd.dpdk -delete +find $RPM_BUILD_ROOT%{_libdir}/openvswitch-dpdk -mindepth 1 -maxdepth 1 -not -name "libofproto*.so.*" -not -name "libopenvswitch*.so.*" -delete +%endif +%endif + +make -C build install DESTDIR=$RPM_BUILD_ROOT +mv $RPM_BUILD_ROOT%{_sbindir}/ovs-vswitchd $RPM_BUILD_ROOT%{_sbindir}/ovs-vswitchd.nodpdk +touch $RPM_BUILD_ROOT%{_sbindir}/ovs-vswitchd install -d -m 0755 $RPM_BUILD_ROOT%{_rundir}/openvswitch install -d -m 0750 $RPM_BUILD_ROOT%{_localstatedir}/log/openvswitch @@ -306,6 +354,14 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovn* rm -f $RPM_BUILD_ROOT%{_includedir}/ovn/* %check +for dir in build \ +%if %{with dpdk} +%ifarch %{dpdkarches} +build-dpdk \ +%endif +%endif +; do +pushd $dir %if %{with check} touch resolv.conf export OVS_RESOLV_CONF=$(pwd)/resolv.conf @@ -324,6 +380,8 @@ rm -f $RPM_BUILD_ROOT%{_includedir}/ovn/* exit 1 fi %endif +popd +done %preun %if 0%{?systemd_preun:1} @@ -340,6 +398,8 @@ rm -f $RPM_BUILD_ROOT%{_includedir}/ovn/* %sysusers_create_compat %{SOURCE1} %post +%{_sbindir}/update-alternatives --install %{_sbindir}/ovs-vswitchd \ + ovs-vswitchd %{_sbindir}/ovs-vswitchd.nodpdk 10 if [ $1 -eq 1 ]; then sed -i 's:^#OVS_USER_ID=:OVS_USER_ID=:' /etc/sysconfig/openvswitch @@ -359,12 +419,29 @@ chown -R openvswitch:openvswitch /etc/openvswitch %endif %postun +if [ $1 -eq 0 ] ; then + %{_sbindir}/update-alternatives --remove ovs-vswitchd %{_sbindir}/ovs-vswitchd.nodpdk +fi %if 0%{?systemd_postun:1} %systemd_postun %{name}.service %else /bin/systemctl daemon-reload >/dev/null 2>&1 || : %endif +%post dpdk +if fgrep -qw sse4_1 /proc/cpuinfo; then + priority=20 +else + echo "Warning: the CPU doesn't support SSE 4.1, dpdk support is not enabled." >&2 + priority=5 +fi +%{_sbindir}/update-alternatives --install %{_sbindir}/ovs-vswitchd \ + ovs-vswitchd %{_sbindir}/ovs-vswitchd.dpdk $priority + +%postun dpdk +if [ $1 -eq 0 ] ; then + %{_sbindir}/update-alternatives --remove ovs-vswitchd %{_sbindir}/ovs-vswitchd.dpdk +fi %files -n python3-openvswitch %{python3_sitearch}/ovs @@ -416,6 +493,15 @@ chown -R openvswitch:openvswitch /etc/openvswitch %{_datadir}/openvswitch/scripts/ovs-monitor-ipsec %{_unitdir}/openvswitch-ipsec.service +%if %{with dpdk} +%ifarch %{dpdkarches} +%files dpdk +%{_libdir}/openvswitch-dpdk/ +%ghost %{_sbindir}/ovs-vswitchd +%{_sbindir}/ovs-vswitchd.dpdk +%endif +%endif + %files %defattr(-,openvswitch,openvswitch) %dir %{_sysconfdir}/openvswitch @@ -449,7 +535,8 @@ chown -R openvswitch:openvswitch /etc/openvswitch %{_bindir}/ovs-pki %{_bindir}/vtep-ctl %{_libdir}/*.so.* -%{_sbindir}/ovs-vswitchd +%ghost %{_sbindir}/ovs-vswitchd +%{_sbindir}/ovs-vswitchd.nodpdk %{_sbindir}/ovsdb-server %{_mandir}/man1/ovsdb-client.1* %{_mandir}/man1/ovsdb-server.1* @@ -484,6 +571,10 @@ chown -R openvswitch:openvswitch /etc/openvswitch %{_sysusersdir}/openvswitch.conf %changelog +* Tue May 24 2022 Timothy Redaelli - 2.17.0-4 +- Create openvswitch-dpdk subpackage, install it by default (weak dependency), + but enable it only if the CPU is new enough (#2081665) + * Mon Mar 28 2022 Timothy Redaelli - 2.17.0-3 - Be sure dirs.py is updated (#2055576)