From patchwork Wed Sep 13 17:58:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 13383647 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0308F200C3 for ; Wed, 13 Sep 2023 17:58:48 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 369C919AE for ; Wed, 13 Sep 2023 10:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694627927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qawn5ppsw1vm2xxtX3RUrgq9U34E1jYZhJD2HrMAzsc=; b=K0MYzyZdLkqMt7dMJEa4hhNdgqbYRTvwCdOqcs0Z4RByjL8FvzHh08xBWmYL6Kv22kWkpe +uOYG7x6+HtXKSAlJchvtneRa0McsJmdY7X+68EQCS7eyxKZmbxJ5JbfM+3lEHBUBj5yTh tsoplMvp8PxgBsDtdZYQYzca4uyFl3o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-DCPnJ2wGOrmQPM9phsFezA-1; Wed, 13 Sep 2023 13:58:44 -0400 X-MC-Unique: DCPnJ2wGOrmQPM9phsFezA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7A33101B456; Wed, 13 Sep 2023 17:58:43 +0000 (UTC) Received: from renaissance-vector.redhat.com (unknown [10.39.193.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id A76A040C6EA8; Wed, 13 Sep 2023 17:58:41 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: Roopa Prabhu , Nikolay Aleksandrov , bridge@lists.linux-foundation.org, Stephen Hemminger , David Ahern Subject: [PATCH iproute2-next 1/2] configure: add the --color option Date: Wed, 13 Sep 2023 19:58:25 +0200 Message-ID: <844947000ac7744a3b40b10f9cf971fd15572195.1694625043.git.aclaudi@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Patchwork-Delegate: dsahern@gmail.com This commit allows users/packagers to choose a default for the color output feature provided by some iproute2 tools. The configure script option is documented in the script itself and it is pretty much self-explanatory. The default value is set to "never" to avoid changes to the current ip, tc, and bridge behaviour. Signed-off-by: Andrea Claudi --- Makefile | 3 ++- configure | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7d1819ce..a24844cf 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,8 @@ endif DEFINES+=-DCONF_USR_DIR=\"$(CONF_USR_DIR)\" \ -DCONF_ETC_DIR=\"$(CONF_ETC_DIR)\" \ -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \ - -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" + -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\" \ + -DCONF_COLOR=$(CONF_COLOR) #options for AX.25 ADDLIB+=ax25_ntop.o diff --git a/configure b/configure index 18be5a03..eb689341 100755 --- a/configure +++ b/configure @@ -5,6 +5,7 @@ INCLUDE="$PWD/include" PREFIX="/usr" LIBDIR="\${prefix}/lib" +COLOR="never" # Output file which is input to Makefile CONFIG=config.mk @@ -479,6 +480,24 @@ check_cap() fi } +check_color() +{ + case "$COLOR" in + never) + echo 'CONF_COLOR:=COLOR_OPT_NEVER' >> $CONFIG + echo 'never' + ;; + auto) + echo 'CONF_COLOR:=COLOR_OPT_AUTO' >> $CONFIG + echo 'auto' + ;; + always) + echo 'CONF_COLOR:=COLOR_OPT_ALWAYS' >> $CONFIG + echo 'always' + ;; + esac +} + quiet_config() { cat < Default color output configuration. Available options: + never: color output is disabled (default) + auto: color output is enabled if stdout is a terminal + always: color output is enabled regardless of stdout state --include_dir Path to iproute2 include dir --libdir Path to iproute2 lib dir --libbpf_dir Path to libbpf DESTDIR @@ -527,6 +550,11 @@ if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then else while [ "$#" -gt 0 ]; do case "$1" in + --color) + shift + COLOR="$1" ;; + --color=*) + COLOR="${1#*=}" ;; --include_dir) shift INCLUDE="$1" ;; @@ -563,6 +591,12 @@ else done fi +case "$COLOR" in + never) ;; + auto) ;; + always) ;; + *) usage 1 ;; +esac [ -d "$INCLUDE" ] || usage 1 if [ "${LIBBPF_DIR-unused}" != "unused" ]; then [ -d "$LIBBPF_DIR" ] || usage 1 @@ -634,6 +668,9 @@ check_strlcpy echo -n "libcap support: " check_cap +echo -n "color output: " +check_color + echo >> $CONFIG echo "%.o: %.c" >> $CONFIG echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG From patchwork Wed Sep 13 17:58:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Claudi X-Patchwork-Id: 13383648 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4905200C3 for ; Wed, 13 Sep 2023 17:58:52 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66A3619AE for ; Wed, 13 Sep 2023 10:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694627931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LEtiwNiM9PzpjRqi6jakAaaVv0eVpRImxmmfOJbw9+M=; b=SUdx+cTdg+47HmYDdeHwHc1CD1Sz0j32ZxJeyO5GSMx/9YAGYk8D4PJfWRSWA7pZzpfAr9 mWwBmefpl4kEjZLpiT134tN8EJ58lkNBT8niiImverB0HaYi0WNgE4H21J6F7xZsac2OJ9 ZnQedE8zLtTQ9U1PY+1xEOj5fzsY6bU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-NaXQbMMjPkOpPhfNncG2hg-1; Wed, 13 Sep 2023 13:58:47 -0400 X-MC-Unique: NaXQbMMjPkOpPhfNncG2hg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 222B681B08C; Wed, 13 Sep 2023 17:58:47 +0000 (UTC) Received: from renaissance-vector.redhat.com (unknown [10.39.193.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A97740C6EA8; Wed, 13 Sep 2023 17:58:44 +0000 (UTC) From: Andrea Claudi To: netdev@vger.kernel.org Cc: Roopa Prabhu , Nikolay Aleksandrov , bridge@lists.linux-foundation.org, Stephen Hemminger , David Ahern Subject: [PATCH iproute2-next 2/2] treewide: use configured value as the default color output Date: Wed, 13 Sep 2023 19:58:26 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Patchwork-Delegate: dsahern@gmail.com With Makefile providing -DCONF_COLOR, we can use its value as the default color output. This effectively allow users and packagers to define a default for the color output feature without using shell aliases, and with minimum code impact. Signed-off-by: Andrea Claudi --- bridge/bridge.c | 3 ++- ip/ip.c | 2 +- tc/tc.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bridge/bridge.c b/bridge/bridge.c index 704be50c..339101a8 100644 --- a/bridge/bridge.c +++ b/bridge/bridge.c @@ -23,7 +23,6 @@ int preferred_family = AF_UNSPEC; int oneline; int show_stats; int show_details; -static int color; int compress_vlans; int json; int timestamp; @@ -103,6 +102,8 @@ static int batch(const char *name) int main(int argc, char **argv) { + int color = CONF_COLOR; + while (argc > 1) { const char *opt = argv[1]; diff --git a/ip/ip.c b/ip/ip.c index 8c046ef1..860ff957 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -168,7 +168,7 @@ int main(int argc, char **argv) const char *libbpf_version; char *batch_file = NULL; char *basename; - int color = 0; + int color = CONF_COLOR; /* to run vrf exec without root, capabilities might be set, drop them * if not needed as the first thing. diff --git a/tc/tc.c b/tc/tc.c index 25820500..082c6677 100644 --- a/tc/tc.c +++ b/tc/tc.c @@ -35,7 +35,6 @@ int use_iec; int force; bool use_names; int json; -int color; int oneline; int brief; @@ -254,6 +253,7 @@ int main(int argc, char **argv) { const char *libbpf_version; char *batch_file = NULL; + int color = CONF_COLOR; int ret; while (argc > 1) {