From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796061430; b=ZuMnRBtrHgdwr8R4HGDbE9dXk/t19Ku0AoJfo595BN2uh5Tb1EcRlolexuoYX0VOIGtf 64IC4wsDUzakFiLLzBsXm/8ciVfbUQ4x9k0QopcGLDekBPxfyOtK2ZJbk7SJyE3+gjcJy kP445BCcEBLTpGw2wWM6fpIodpL2XPFfKbiv1U7jtty9DYxmWio/TB0RlyXjG/MFSJFZB Koj765WEyT/cBv3dwTx6IjaF+QFDnbIGT23gJ9p8fGm0A61/q6dp6BMP6x48jseHsG4xU AiIZ+snY4S4Ix71D4yjHSHLd7JCwJR/9MwBQzvYoLNIWLfmW+r1syx1ghbih1dC8KwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796061430; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=ZnK+eJwN15E64qSfJoKkIx0eXosHEJGz8eCq8YV2ris=; b=qVVx7MhvK5Twwhc18ywV18f4VY7cvdDjoJBBeJfqi0hpgFnqGOWaKgvkhkmqDp9A9aZq pRO7uhjz0zBrFeeYiiEMXWzVvoMpJaeN0o7bDmxbi5u7y3WzESl8vgmXjBLQ3eTMq95Uh 2BjuiIknhJt3V58Zu1hYgPVSPKbcKjLRck4v271qEDNDq+Oci9nNV0mXMLmJVomyyQ35o SvUzpAQLU1vyr/La/q8Xxg4CnAadn8AivOdL9z+FxQ5pxrmP5ON26q+wJEYK46/X90kfe fPeVqYJXLr7oAgt9Y9FEI3k0A9htlK+HzPqm9CKhL9lLf+n0zu/yshY85icK2yxjfHQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=sFzQtiyS; arc=none smtp.remote-ip=209.85.214.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61D6D606A332 for ; Mon, 30 Nov 2026 17:57:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61D6D606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=sFzQtiyS Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f04e3bf46dso80754015ad.2 for ; Mon, 30 Nov 2026 09:57:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796061430; x=1796666230; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZnK+eJwN15E64qSfJoKkIx0eXosHEJGz8eCq8YV2ris=; b=sFzQtiySRqi+wRAm6M3aZ0HpecYxjjAylqehe62C4ZBpw9z8zV/JnyRmHJ+K7Hb7Uw nxUQkrXABFqkOpHzf848Cy+QkSVswuuIcUnZB7DpkZmaBPZJ1DiDtn6LNxhdvBbtB/QM Gm6QDQ6lUFCUu3uMtNbiE3Olf4up/ff6L4/udF7HueAUxIbJPS+5QTdtJUww8pKXrE8r LO/nYp8FCZ3sT4vQy1Nc1CqWhhmqDu5jPNSNFS7usb2jtCsCSC7nWbOktB4kQHVFxo6L 0tTLxm9p8eEfyef0/SjN5dECTVdIMAmkYJEd3mPtB8Up8x9V6d1V3OxRSqFtuN9m16rL YTGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796061430; x=1796666230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZnK+eJwN15E64qSfJoKkIx0eXosHEJGz8eCq8YV2ris=; b=CREpmZrnizWOhEoRfITjMf+hV76JVfNx8wpz64QAMVd/uxCxn+HFheuZBF9FBfh3ZG SYXemtORQQ6PHDWdIHVJ53EMGCcys9gPhLJxcXxXQ3IrV5dhCO2lsmGR61A00fpg71hK I6oFUBxWvM0cSM3cuwTZvAi0F5Fo5/1VrP3iG2mqQ9RwcWHyrpCZ1U2f0/OCslfGOXsZ omKZLPKNf9dP3AIjoGWRTUl7pNU6gaUJACU54SvtP3iHtE/dDGGSEtqK0bGhWxFsV7+d t0Dy+Wwxxqrgrvyl00bPscCpoETfb6nylDH0uPcKB30mde6VhXAnXB8OagFZi107PsSb lzBw== X-Gm-Message-State: APuU4Z83DBuTgnzF/llxIHxBwQ4ai9nsXwSk/TwAlxOUqi9UgTuC+s5N f7r3gX14mVR3KIccj3pekrDlo5JoXt7mZUJsemZmJk+puFjY2v9iM9NbQYg0+sQ8mqNLnx+2D5o i4pZy X-Gm-Gg: AZFdTZcZRYbi8W6QxWaP7r/dXWc4NhQNZ7FIlpTOkz7lZIT0kg3v6U28wZctYXTCf3V 0NO80ZzklMm5ZHemMLS7QSXXXKBYVTuiSKac/wOBkb9NUuWZ1GxeIviXFQMNifdntFvA6L4eyph H3bTcu9Z6HZ35SfmgF/4BJkiFPzXwjhHtTpM/Tq/JPM0FHUtDZtA9RyXa/nvs324aRtMpzt7D9L 1pO83A1//qf4aPc3cOlS08Ka5wz44STxu30AroDWXOytqAXPPtpdB6P0khFpT30q/wG57p9Q2Hv ann9JrxNM8EG52ALHzIY+5ICTllMPRLF0820fKCh1yJF6ehY9IrPJUsr2C2sA33INAJFqxeCBXy NFVShs63Z/XUcPjIcoukiTj3IjorJMxV12X6gbHjIYI/jeuQzczEEZ5W/VudDZVhObU1s8jmP39 v9vtOP4Z3dhR7GDZMN2yA8Bh+QXHqqeLjaf215++ETZZ8kUjI3eFt7M4ke1aJsF5J49jjUdITKd +3dvrmxUwSVF0UJV3EWexI/XB+6alawSnMV/K1DBM/hDWAvhZCywHOL6VycNHTombX8irHU2zEA 2plbmp0iM5q95uXUzksjLrGOTpsY9xU97MsO3Sj5e5bfMJG291UD+uHnacXvJ0ixw2oe X-Received: by 2002:a17:902:ce85:b0:2f0:3e44:4761 with SMTP id d9443c01a7336-2f03f25e801mr366894185ad.54.1796061429665; Mon, 30 Nov 2026 09:57:09 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f0f5a31dcasm72384895ad.66.2026.11.30.09.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:57:09 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: dsahern@kernel.org, jhs@mojatatu.com, Stephen Hemminger Subject: [PATCH iproute2-next v2 3/3] configure: use pkg-config instead of hand-rolled probes Date: Mon, 30 Nov 2026 09:57:05 -0800 Message-ID: <20261130175706.336492-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130175706.336492-1-stephen@networkplumber.org> References: <20261130175706.336492-1-stephen@networkplumber.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit libselinux, libtirpc, libmnl and libcap each had their own copy of the same pkg-config block, and the copies had drifted: two wrote LDLIBS before CFLAGS, two after. Add check_pkg() and use it for all four. The libbpf version test compiled a program that only existed to fail on LIBBPF_MAJOR_VERSION < 1. pkg-config --atleast-version=1.0 answers that without running the compiler. check_xtables() wrote TC_CONFIG_NO_XT so the caller could grep config.mk to decide whether to run check_xt(). The symbol never changed anything: tc/Makefile tested it as the outer guard around an inner TC_CONFIG_XT test, and without the .pc file the compile test cannot set TC_CONFIG_XT anyway. Fold the existence test into check_xt(), which now also prints yes/no like the other probes. The setns, name_to_handle_at and strlcpy probes stay as compile tests since libc has no .pc file, check_ipset() reads kernel headers, and mnl_attr_get_uint() is in no released libmnl so there is no version to compare against. Signed-off-by: Stephen Hemminger --- configure | 146 ++++++++++++++++++---------------------------------- tc/Makefile | 10 ++-- 2 files changed, 53 insertions(+), 103 deletions(-) diff --git a/configure b/configure index ef155ab3..bb965538 100755 --- a/configure +++ b/configure @@ -26,16 +26,15 @@ check_toolchain() echo "YACC:=${YACC}" >>$CONFIG } -check_xtables() -{ - if ! ${PKG_CONFIG} xtables --exists; then - echo "TC_CONFIG_NO_XT:=y" >>$CONFIG - fi -} - check_xt() { - #check that the xtables library is usable + # The xtables .pc file can be present while the headers are not + # usable, so compile against it rather than trusting --exists. + if ! ${PKG_CONFIG} xtables --exists; then + echo "no" + return + fi + cat >$TMPDIR/ipttest.c < #include @@ -58,7 +57,9 @@ EOF if $CC -I$INCLUDE -o $TMPDIR/ipttest $TMPDIR/ipttest.c \ $(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1; then echo "TC_CONFIG_XT:=y" >>$CONFIG - echo "using xtables" + echo "yes" + else + echo "no" fi rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest } @@ -72,6 +73,26 @@ check_lib_dir() echo "LIBDIR:=$LIBDIR" >> $CONFIG } +# check_pkg +# +# Most optional libraries follow the same shape: if pkg-config knows the +# module, export a HAVE_ make variable for the Makefiles, add -DHAVE_ for +# the sources, and append the module's cflags and libs. +check_pkg() +{ + local mod="$1" var="$2" def="$3" + + if ! ${PKG_CONFIG} "$mod" --exists; then + echo "no" + return 1 + fi + + echo "yes" + echo "$var:=y" >>$CONFIG + echo "CFLAGS += -D$def" "$(${PKG_CONFIG} "$mod" --cflags)" >>$CONFIG + echo 'LDLIBS +=' "$(${PKG_CONFIG} "$mod" --libs)" >>$CONFIG +} + check_setns() { cat >$TMPDIR/setnstest.c <>$CONFIG - else - echo "no" - fi -} - -check_tirpc() -{ - if ${PKG_CONFIG} libtirpc --exists; then - echo "HAVE_RPC:=y" >>$CONFIG - echo "yes" - - echo 'LDLIBS +=' "$(${PKG_CONFIG} --libs libtirpc)" >>$CONFIG - echo 'CFLAGS += -DHAVE_RPC' "$(${PKG_CONFIG} --cflags libtirpc)" >>$CONFIG - else - echo "no" - fi -} - have_mnl_attr_get_uint() { cat >$TMPDIR/mnl_attr_get_uint_test.c <>$CONFIG - echo "yes" - - echo 'CFLAGS += -DHAVE_LIBMNL' "$(${PKG_CONFIG} libmnl --cflags)" >>$CONFIG - echo 'LDLIBS +=' "$(${PKG_CONFIG} libmnl --libs)" >> $CONFIG + check_pkg libmnl HAVE_MNL HAVE_LIBMNL || return - if have_mnl_attr_get_uint; then - echo "CFLAGS += -DHAVE_MNL_ATTR_GET_UINT" >>$CONFIG - fi - else - echo "no" + # mnl_attr_get_uint() is not in any released libmnl, so there is no + # version to test for; lib/mnl_utils.c carries a fallback. + if have_mnl_attr_get_uint; then + echo "CFLAGS += -DHAVE_MNL_ATTR_GET_UINT" >>$CONFIG fi } @@ -291,19 +256,6 @@ EOF rm -f $TMPDIR/strtest.c $TMPDIR/strtest } -check_cap() -{ - if ${PKG_CONFIG} libcap --exists; then - echo "HAVE_CAP:=y" >>$CONFIG - echo "yes" - - echo 'CFLAGS += -DHAVE_LIBCAP' "$(${PKG_CONFIG} libcap --cflags)" >>$CONFIG - echo 'LDLIBS +=' "$(${PKG_CONFIG} libcap --libs)" >> $CONFIG - else - echo "no" - fi -} - check_color() { case "$COLOR" in @@ -424,11 +376,10 @@ check_toolchain echo "TC schedulers" -check_xtables -if ! grep -q TC_CONFIG_NO_XT $CONFIG; then - echo -n " IPT " - check_xt +echo -n " IPT " +check_xt +if grep -q TC_CONFIG_XT $CONFIG; then echo -n " IPSET " check_ipset fi @@ -442,11 +393,12 @@ check_setns echo -n "libc has name_to_handle_at: " check_name_to_handle_at +# SELinux is a compile time option in the ss utility echo -n "SELinux support: " -check_selinux +check_pkg libselinux HAVE_SELINUX HAVE_SELINUX echo -n "libtirpc support: " -check_tirpc +check_pkg libtirpc HAVE_RPC HAVE_RPC echo -n "libbpf support: " check_libbpf @@ -461,7 +413,7 @@ echo -n "need for strlcpy: " check_strlcpy echo -n "libcap support: " -check_cap +check_pkg libcap HAVE_CAP HAVE_LIBCAP echo -n "color output: " check_color diff --git a/tc/Makefile b/tc/Makefile index 0e48ba38..062a5102 100644 --- a/tc/Makefile +++ b/tc/Makefile @@ -81,12 +81,10 @@ TCMODULES += q_ets.o TCSO := -ifneq ($(TC_CONFIG_NO_XT),y) - ifeq ($(TC_CONFIG_XT),y) - TCMODULES += em_ipt.o - ifeq ($(TC_CONFIG_IPSET),y) - TCMODULES += em_ipset.o - endif +ifeq ($(TC_CONFIG_XT),y) + TCMODULES += em_ipt.o + ifeq ($(TC_CONFIG_IPSET),y) + TCMODULES += em_ipset.o endif endif -- 2.53.0