From nobody Fri May 3 21:02:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505835681925838.8852134516968; Tue, 19 Sep 2017 08:41:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC7C1C0050C5; Tue, 19 Sep 2017 15:41:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DD705C88F; Tue, 19 Sep 2017 15:41:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 082411806104; Tue, 19 Sep 2017 15:41:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8JFFWLX002442 for ; Tue, 19 Sep 2017 11:15:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B8105C541; Tue, 19 Sep 2017 15:15:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4FD217529 for ; Tue, 19 Sep 2017 15:15:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC7C1C0050C5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 11:15:28 -0400 Message-Id: <20170919151528.28998-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] util: Fix configure.ac check for DEVLINK_CMD_ESWITCH_GET X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 19 Sep 2017 15:41:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Turns out the mechanism of providing multiple definitions to check via AC_CHECK_DECLS in order to determine whether HAVE_DECL_DEVLINK should be set resulted in a false positive since as long as one of the defs was true, then the HAVE_DECL_DEVLINK got defined. But we cannot just check for the symbol we most care about due to a complication in a kernel 4.11 change that altered the name of the symbol from DEVLINK_CMD_ESWITCH_MODE_GET to DEVLINK_CMD_ESWITCH_GET in the newer kernel and added a #define for the former name with an ominous comment/caveat that the old format is obsolete should never be used. However, if we only looked for the new symbol, that would leave kernels 4.8 through 4.10 unable to use the command even though it exists under an old name. So, rather than checking for whether the devlink.h on the system has multiple symbols, let's only check for whether the command we want is defined. This patch checks for both symbol names in order to allow usage and then adds a check to see if the new name doesn't exist after linux/devlink.h is include, then to use #define of the new name to the old name - essentially the reverse logic that the 4.11 header file has. Note that we do not need to check for other symbols as well since they already existed prior to when the various ESWITCH symbols were added. Other defintions include DEVLINK_GENL_VERSION, DEVLINK_GENL_NAME, DEVLINK_ATTR_MAX, DEVLINK_ATTR_BUS_NAME, and DEVLINK_ATTR_DEV_NAME. The DEVLINK_ATTR_ESWITCH_MODE and DEVLINK_ESWITCH_MODE_SWITCHDEV were added at the same time as DEVLINK_CMD_ESWITCH_MODE_GET, but it's only DEVLINK_CMD_ESWITCH_MODE_GET that changed in 4.11. Signed-off-by: John Ferlan --- v1: https://www.redhat.com/archives/libvir-list/2017-September/msg00543.ht= ml Just to make it official - here's what I described in the v1 followup which got the ACK if comment from Andrea: https://www.redhat.com/archives/libvir-list/2017-September/msg00591.html Still, I won't push this yet until it too gets an official blessing. configure.ac | 8 ++++++-- src/util/virnetdev.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c9509c7f9..73ae7fdd5 100644 --- a/configure.ac +++ b/configure.ac @@ -630,12 +630,16 @@ fi dnl dnl check for kernel headers required by devlink dnl +dnl kernel 4.8 introduced DEVLINK_CMD_ESWITCH_MODE_GET, but that was +dnl later changed in kernel 4.11 to be just DEVLINK_CMD_ESWITCH_GET, so +dnl for "completeness" let's allow HAVE_DECL_DEVLINK to be define if +dnl either is defined. if test "$with_linux" =3D "yes"; then AC_CHECK_HEADERS([linux/devlink.h]) - AC_CHECK_DECLS([DEVLINK_GENL_VERSION, DEVLINK_GENL_NAME, DEVLINK_ATTR_= MAX, DEVLINK_CMD_ESWITCH_GET, DEVLINK_ATTR_BUS_NAME, DEVLINK_ATTR_DEV_NAME,= DEVLINK_ATTR_ESWITCH_MODE, DEVLINK_ESWITCH_MODE_SWITCHDEV], + AC_CHECK_DECLS([DEVLINK_CMD_ESWITCH_GET, DEVLINK_CMD_ESWITCH_MODE_GET], [AC_DEFINE([HAVE_DECL_DEVLINK], [1], - [whether devlink declarations are available]= )], + [whether devlink CMD_ESWITCH_GET is availabl= e])], [], [[#include ]]) fi diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 040693925..435ca5562 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -61,6 +61,9 @@ =20 #if HAVE_DECL_DEVLINK # include +# ifndef DEVLINK_CMD_ESWITCH_GET +# define DEVLINK_CMD_ESWITCH_GET DEVLINK_CMD_ESWITCH_MODE_GET +# endif #endif =20 #ifndef IFNAMSIZ --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list