From patchwork Wed Aug 1 20:51:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Xu X-Patchwork-Id: 952385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UwiUjblZ"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41glpv4Cbyz9s2g for ; Thu, 2 Aug 2018 06:51:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E9288D24; Wed, 1 Aug 2018 20:51:47 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AF529D21 for ; Wed, 1 Aug 2018 20:51:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EEEBFCF for ; Wed, 1 Aug 2018 20:51:46 +0000 (UTC) Received: by mail-pl0-f68.google.com with SMTP id w3-v6so9332585plq.2 for ; Wed, 01 Aug 2018 13:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DT1NGnQggAugLOnftz173Y7tqV2X8afLty0pFbmut2g=; b=UwiUjblZQaGSWNdog3kJEQVTLrPzY1JNkNMlX3uxhKnaPnbkjD0+eU4yOsWrgIbRdV GU8u3DVwp9l84DCnjQbFFukIkYS0+yjTSMKSqVyA3XZ6QlVqpvkTtFSO1qGjAokxw02O Q11gjtn5KqBJ4nztYxP0DhZN1SXy+CTsg5iUNOYPb5TLCPp8JMOCVvPxdmgSbKYpJzbS kF8N8CEw6a+OpWJw4Hy/sqpa/B9Q1wR4i8MjMrLe/nTEqIueA8+BlvLk7LCDLRMD9D19 jMQTMP2UsQHmVsqFFEHsoTkXrr8qmUxNvVM1E2BX16WZkkiEZsQWoCwBRsUdcLApr37H 2pbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DT1NGnQggAugLOnftz173Y7tqV2X8afLty0pFbmut2g=; b=BHHNHW7+pwjVTVt8pUvyBZjWVuDzyzj28V+qLSgOnpX3+UCllm3YgrnuKBoMFKmkXi S43QevM1Xr+VsAFuymWDlv0z47lYyvt/wTlatqlN7MIOf/pw0Tz74lK8J3qzgsBAYcFo Me1FT0cnJicDkA10BjauBs6+UFxE+b0p0e95yq3tNcbP/KJBEn9hy3q5H28p6v5GTXML KrMXC+bx+2PnkyLYYdlnEhUvElAiEhDwXSCnqzLDMdIbBOifkarBiQ84KkKPoG0oK4jU HDc+GnUlnyycMYZqPuv1H3+Vm2f4CKzD6znlutHM5i6rpQ4Sd0pHc9UbfnnXM3l12rgp dltQ== X-Gm-Message-State: AOUpUlGIXfWRxZSHmsPAKST/+X3o9Ze28DgcSwqLtYZdlfnyxTYtJ0pS wWxN/aJsOmPJsOKy1ak2Q60HMCxR X-Google-Smtp-Source: AAOMgpfyAfcMDv0fOVld8LLrMdQ3xx72qz6vjoJ4aJ1NsrRG0YwQiCEZEti8Eq1cR1nh0/wMQCP3UQ== X-Received: by 2002:a17:902:8f8e:: with SMTP id z14-v6mr25776482plo.139.1533156706113; Wed, 01 Aug 2018 13:51:46 -0700 (PDT) Received: from vm1-rhel74-local.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id l79-v6sm8788390pfb.111.2018.08.01.13.51.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 13:51:45 -0700 (PDT) From: Martin Xu To: dev@openvswitch.org Date: Wed, 1 Aug 2018 13:51:42 -0700 Message-Id: <1533156702-117479-1-git-send-email-martinxu9.ovs@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Flavio Leitner Subject: [ovs-dev] [PATCH v3] rhel: support kmod build against multiple 7.2 kernels, rhel6 X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch extends commit 89dd5819cf18 (rhel: support kmod-openvswitch build against multiple kernels, rhel6) to support building kmod RPMs with multiple minor revisions within 3.10.0-327 kernels. It was discovered for RHEL 7.2 that 41.3 minor revision introduced backward incompatible changes. Also fixes a scenario not working for RHEL7.3 in commit 89dd5819cf18. When multiple versions passed into the kversion for the spec file, the variable is used as is for the kernel module paths for command weak-modules --add-modules. Then the modules cannot be found. Fixes: 89dd5819cf18 (rhel: support kmod-openvswitch build against multiple kernels, rhel6) VMware-BZ: #2170334 Signed-off-by: Martin Xu CC: Greg Rose CC: Ben Pfaff CC: Flavio Leitner CC: Yi-Hung Wei --- rhel/kmod-openvswitch-rhel6.spec.in | 13 ++--- ...sr_share_openvswitch_scripts_ovs-kmod-manage.sh | 67 +++++++++++++++++++--- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/rhel/kmod-openvswitch-rhel6.spec.in b/rhel/kmod-openvswitch-rhel6.spec.in index f18802d..afbad96 100644 --- a/rhel/kmod-openvswitch-rhel6.spec.in +++ b/rhel/kmod-openvswitch-rhel6.spec.in @@ -31,7 +31,8 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) # for specified kernel version. # Use -D 'kversion 3.10.0-693.1.1.el7.x86_64 3.10.0-693.17.1.el7.x86_64' # to build package for mulitple kernel versions in the same package -# This only works for kernel 3.10.0 major revision 693 +# This only works for kernel 3.10.0 major revision 693 (RHEL 7.4) +# and major revision 327 (RHEL 7.2) # By default, build against the latest installed kernel-devel %{!?kversion:%global kversion %(rpm -qa | egrep "^kernel(-rt|-aarch64)?-devel" | /usr/lib/rpm/redhat/rpmsort -r | head -n 1| sed "s/^kernel.*-devel-//")} @@ -86,8 +87,8 @@ install -p -m 0755 rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh \ current_kernel=$(uname -r) IFS=. read installed_major installed_minor installed_micro installed_arch \ installed_build <<<"${current_kernel##*-}" -if [ "$installed_major" = "693" ]; then - # Workaround for RHEL 7.4 +if [ "$installed_major" = "327" ] || [ "$installed_major" = "693" ]; then + # Workaround for RHEL 7.2 and 7.4 if [ -x "/usr/share/%{oname}/scripts/ovs-kmod-manage.sh" ]; then /usr/share/%{oname}/scripts/ovs-kmod-manage.sh fi @@ -97,10 +98,8 @@ else [ -d "/lib/modules/$k/kernel/" ] && depmod -a "$k" done if [ -x "/sbin/weak-modules" ]; then - for m in openvswitch vport-gre vport-stt vport-geneve \ - vport-lisp vport-vxlan; do - echo "/lib/modules/%{kversion}/extra/%{oname}/$m.ko" - done | /sbin/weak-modules --add-modules + rpm -ql kmod-%{oname} | grep '\.ko$' | \ + /sbin/weak-modules --add-modules fi fi diff --git a/rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh b/rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh index a6c738f..254fad6 100644 --- a/rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh +++ b/rhel/usr_share_openvswitch_scripts_ovs-kmod-manage.sh @@ -14,23 +14,39 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This version of the script is intended to be used on kernel version -# 3.10.0 major revision 693 only. It is packaged in the openvswitch kmod RPM -# built using the rhel6 spec file, and run in the post-install for minor -# revision 693 kernels. +# This version of the script is intended to be used on kernel version 3.10.0 +# major revision 327 and 693 only. It is packaged in the openvswitch kmod RPM +# built using the rhel6 spec file, and run in the post-install for major +# revision 327/693 kernels. # -# Due to some backward incompatible changes introduced in minor revision 17.1, +# For kernel 3.10.0-693, +# due to some backward incompatible changes introduced in minor revision 17.1, # kernel modules built against kernels newer than 17.1 cannot be loaded on # system running kernels older than 17.1, vice versa. # +# For kernel 3.10.0-327, +# due to some backward incompatible changes introduced in minor revision 41.3, +# kernel modules built against kernels newer than 41.3 cannot be loaded on +# system running kernels older than 41.3, vice versa. +# # This script checks the current running kernel version, and update symlinks # for the openvswitch kernel modules in the appropriate kernel directory, # provided the kmod RPM has installed kernel modules files built from both -# 1.1 and 17.1 minor revisions. +# minor revisions. # # In case of a kernel minor revision change after the openvswitch kmod package # is installed, this script shall be run manually after system reboots and # switches to a different kernel +if [ -n "$(rpm -qa kmod-openvswitch)" ]; then + rpmname="kmod-openvswitch" +elif [ -n "$(rpm -qa openvswitch-kmod)" ]; then + rpmname="openvswitch-kmod" +else + echo "openvswitch kmod package not installed, existing" + exit 1 +fi +#echo $rpmname + script_name=$(basename -- "$0") current_kernel=$(uname -r) echo current kernel is $current_kernel @@ -42,7 +58,40 @@ IFS=. read installed_major installed_minor installed_micro \ # installed_build=$installed_build expected_base_minor="el7" -expected_minor=11 +if [ "$installed_major" = "327" ]; then + expected_minor=36 +elif [ "$installed_major" = "693" ]; then + expected_minor=11 +else + echo "This script is not intended to run on kernel $(uname -r)" + exit 1 +fi + +kmod_minor_versions=() +kversion=$(rpm -ql ${rpmname} | grep '\.ko$' | \ + sed -n -e 's/^\/lib\/modules\/\(.*\)\/extra\/.*$/\1/p' | sort | uniq) +for kv in $kversion; do + IFS=. read kmod_major kmod_minor kmod_micro kmod_arch \ + kmod_build <<<"${kv##*-}" + echo kmod_major=$kmod_major kmod_minor=$kmod_minor \ + kmod_micro=$kmod_micro kmod_arch=$kmod_arch \ + kmod_build=$kmod_build + kmod_minor_versions+=($kmod_minor) +done +sorted_kmod_minor_versions=$(printf "%s\n" "${kmod_minor_versions[@]}" | \ + sort -n) +#echo "$sorted_kmod_minor_versions" + +if [ ! -n "$sorted_kmod_minor_versions" ]; then + echo "No kernel modules found from package $rpmname, exiting" + exit 1 +else + # first line for kmod_minor_low_ver, last for kmod_minor_high_ver + kmod_minor_low_ver=$(echo "$sorted_kmod_minor_versions" | head -1) + kmod_minor_high_ver=$(echo "$sorted_kmod_minor_versions" | tail -1) +fi +#echo "Installing KMOD with minor revisions $kmod_minor_low_ver and \ +# $kmod_minor_high_ver" found_match=false for kname in `ls -d /lib/modules/*` @@ -51,14 +100,14 @@ do # echo major=$major minor=$minor micro=$micro arch=$arch build=$build if [ "$installed_minor" = "$expected_base_minor" ] || [ "$installed_minor" -le "$expected_minor" ]; then - if [ "$minor" = "1" ]; then + if [ "$minor" = "$kmod_minor_low_ver" ]; then requested_kernel=$kname found_match="true" echo "Installing Openvswitch KMOD from kernel $kname" break fi else - if [ "$minor" = "17" ]; then + if [ "$minor" = "$kmod_minor_high_ver" ]; then requested_kernel=$kname found_match="true" echo "Installing Openvswitch KMOD from kernel $kname"