From 7e7c8bfb30b76009faea450d0ecbb8691d85b154 Mon Sep 17 00:00:00 2001 From: yushaogui Date: Tue, 27 Jul 2021 16:01:49 +0800 Subject: [PATCH] 1.update python package to python3; 2.fix tcpdump error --- 0002-fix-dict-change-during-iteration.patch | 13 ++++++ ...llback-to-read-proc-net-dev-on-linux.patch | 41 +++++++++++++++++++ openvswitch.spec | 39 ++++++++++-------- 3 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 0002-fix-dict-change-during-iteration.patch create mode 100644 0003-Fallback-to-read-proc-net-dev-on-linux.patch diff --git a/0002-fix-dict-change-during-iteration.patch b/0002-fix-dict-change-during-iteration.patch new file mode 100644 index 0000000..3b64ab9 --- /dev/null +++ b/0002-fix-dict-change-during-iteration.patch @@ -0,0 +1,13 @@ +diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in +index 40fef39..22d0a4e 100755 +--- a/ovsdb/ovsdb-idlc.in ++++ b/ovsdb/ovsdb-idlc.in +@@ -176,7 +176,7 @@ def replace_cplusplus_keyword(schema): + 'wchar_t', 'while', 'xor', 'xor_eq'} + + for tableName, table in schema.tables.items(): +- for columnName in table.columns: ++ for columnName in list(table.columns): + if columnName in keywords: + table.columns[columnName + '_'] = table.columns.pop(columnName) + diff --git a/0003-Fallback-to-read-proc-net-dev-on-linux.patch b/0003-Fallback-to-read-proc-net-dev-on-linux.patch new file mode 100644 index 0000000..12b0b07 --- /dev/null +++ b/0003-Fallback-to-read-proc-net-dev-on-linux.patch @@ -0,0 +1,41 @@ +diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in +index 11624c5..cdba1d5 100755 +--- a/utilities/ovs-tcpdump.in ++++ b/utilities/ovs-tcpdump.in +@@ -24,7 +24,21 @@ import subprocess + import sys + import time + +-import netifaces ++try: ++ from netifaces import interfaces ++except ImportError: ++ if sys.platform in ['linux', 'linux2']: ++ def interfaces(): ++ devices = [] ++ with open("/proc/net/dev", "r") as f_netdev: ++ for line in f_netdev: ++ if ":" not in line: ++ continue ++ devices.append(line.split(":")[0].strip()) ++ return devices ++ else: ++ print("ERROR: Please install netifaces Python library.") ++ sys.exit(1) + + try: + from ovs.db import idl +@@ -438,11 +452,11 @@ def main(): + mirror_interface = _make_mirror_name[sys.platform](interface) + + if sys.platform in _make_taps and \ +- mirror_interface not in netifaces.interfaces(): ++ mirror_interface not in interfaces(): + _make_taps[sys.platform](mirror_interface, + ovsdb.interface_mtu(interface)) + +- if mirror_interface not in netifaces.interfaces(): ++ if mirror_interface not in interfaces(): + print("ERROR: Please create an interface called `%s`" % + mirror_interface) + print("See your OS guide for how to do this.") diff --git a/openvswitch.spec b/openvswitch.spec index 4bde8bb..ea66a9f 100644 --- a/openvswitch.spec +++ b/openvswitch.spec @@ -3,19 +3,21 @@ Summary: Production Quality, Multilayer Open Virtual Switch URL: http://www.openvswitch.org/ Version: 2.12.0 License: ASL 2.0 and ISC -Release: 11 +Release: 12 Source: https://www.openvswitch.org/releases/openvswitch-%{version}.tar.gz Buildroot: /tmp/openvswitch-rpm Patch0000: 0000-openvswitch-add-stack-protector-strong.patch Patch0001: 0001-Remove-unsupported-permission-names.patch -Patch0002: CVE-2020-35498-pre.patch -Patch0003: CVE-2020-35498.patch -Patch0004: CVE-2020-27827.patch -Patch0005: CVE-2015-8011.patch +Patch0002: 0002-fix-dict-change-during-iteration.patch +Patch0003: 0003-Fallback-to-read-proc-net-dev-on-linux.patch +Patch0004: CVE-2020-35498-pre.patch +Patch0005: CVE-2020-35498.patch +Patch0006: CVE-2020-27827.patch +Patch0007: CVE-2015-8011.patch Requires: %{name}-help -Requires: logrotate hostname python >= 2.7 python2-six selinux-policy-targeted -BuildRequires: python2-six, openssl-devel checkpolicy selinux-policy-devel autoconf automake libtool python-sphinx unbound-devel +Requires: logrotate hostname python >= 3.7 python3-six selinux-policy-targeted +BuildRequires: python3-six, openssl-devel checkpolicy selinux-policy-devel autoconf automake libtool python-sphinx unbound-devel Provides: openvswitch-selinux-policy = %{version}-%{release} Obsoletes: openvswitch-selinux-policy < %{version}-%{release} @@ -51,7 +53,7 @@ autoreconf --enable-ssl \ --enable-shared \ --with-pkidir=%{_sharedstatedir}/openvswitch/pki \ - PYTHON=%{__python2} + PYTHON=%{__python3} build-aux/dpdkstrip.py \ --nodpdk \ @@ -89,8 +91,6 @@ install -p -m 644 -D selinux/openvswitch-custom.pp \ rm \ $RPM_BUILD_ROOT/usr/bin/ovs-testcontroller \ $RPM_BUILD_ROOT/usr/share/man/man8/ovs-testcontroller.8 \ - $RPM_BUILD_ROOT/usr/bin/ovs-test \ - $RPM_BUILD_ROOT/usr/bin/ovs-l3ping \ $RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8 \ $RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \ $RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \ @@ -126,6 +126,10 @@ install -m 0644 lib/*.h $RPM_BUILD_ROOT/%{_includedir}/openvs install -D -m 0644 lib/.libs/libopenvswitch.a \ $RPM_BUILD_ROOT/%{_libdir}/libopenvswitch.a +install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib} +cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \ + $RPM_BUILD_ROOT%{python3_sitelib} + install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db @@ -138,6 +142,8 @@ install -p -D -m 0755 \ rhel/usr_share_openvswitch_scripts_ovs-systemd-reload \ $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-systemd-reload +rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ + %clean rm -rf $RPM_BUILD_ROOT @@ -193,26 +199,21 @@ exit 0 /etc/sysconfig/network-scripts/ifdown-ovs /usr/bin/ovs-appctl /usr/bin/ovs-dpctl -/usr/bin/ovs-dpctl-top /usr/bin/ovs-docker /usr/bin/ovs-ofctl -/usr/bin/ovs-parse-backtrace /usr/bin/ovs-pcap /usr/bin/ovs-pki /usr/bin/ovs-tcpdump /usr/bin/ovs-tcpundump -/usr/bin/ovs-vlan-test /usr/bin/ovs-vsctl /usr/bin/ovsdb-client /usr/bin/ovsdb-tool /usr/bin/vtep-ctl %{_libdir}/lib*.so.* -/usr/sbin/ovs-bugtool /usr/sbin/ovs-vswitchd /usr/sbin/ovsdb-server -/usr/share/openvswitch/bugtool-plugins/ -/usr/share/openvswitch/python/ -/usr/share/openvswitch/scripts/ovs-bugtool-* +%{python3_sitelib}/ovs +%{python3_sitelib}/ovstest /usr/share/openvswitch/scripts/ovs-check-dead-ifs /usr/share/openvswitch/scripts/ovs-ctl /usr/share/openvswitch/scripts/ovs-kmod-ctl @@ -253,6 +254,10 @@ exit 0 %doc README.rst NEWS rhel/README.RHEL.rst %changelog +* Tue Jul 27 2021 yushaogui - 2.12.0-12 +- Change the dependent python package from python2 to python3 + Fix ovs-tcpdump import error + * Mon Apr 12 2021 liuyiguo - 2.12.0-11 - Change the OVS startup mode to service startup. -- Gitee