From patchwork Sat Oct 1 23:39:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1685296 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nwl.cc header.i=@nwl.cc header.a=rsa-sha256 header.s=mail2022 header.b=BxOvdAJV; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Mg3Tr0crMz20Zd for ; Sun, 2 Oct 2022 10:39:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbiJAXjX (ORCPT ); Sat, 1 Oct 2022 19:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiJAXjW (ORCPT ); Sat, 1 Oct 2022 19:39:22 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36C02CE35 for ; Sat, 1 Oct 2022 16:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc; s=mail2022; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: To:From:Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6zHBykh5Iuxc64Mz7XFTejex3CjuBDMZa5olLZMG0Es=; b=BxOvdAJVHzyXWpxIT1X6v1TotI 4L9Rptwt/MI54ASRsSKiZ+nXaPw3scMxM3j0/dfSaixem1xt3i6GgWUX/1FUJ7RYeEGLwxaf8faCl KwKHUaaAeChbRW+wM9nWcj4B7Tf31zyeP7DRFG4lkv9/VB9fSxtK2ibXBkjMTQrs5Bd+/Gd1mI1/2 n84C4cp6Mj65hGWkh6Sbo1pkvtQ5fptmZQmhR/Qrks2gz//cMtTMxETOgoAUbDOzTHqhiX26Hfi1E krBo+dvdkkcALqCNpa3oWQbp4YJp3h/4DLaUi+/ptq+Yb0kYq5UucIIE05+cYOu9Vx0rt7OnBE9oR 9lnuUsEA==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1oem4m-0004qL-4Q for netfilter-devel@vger.kernel.org; Sun, 02 Oct 2022 01:39:20 +0200 From: Phil Sutter To: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output Date: Sun, 2 Oct 2022 01:39:04 +0200 Message-Id: <20221001233906.5386-1-phil@nwl.cc> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org No need for print_range() to print a trailing whitespace, caller does this already. Fixes: fd8d7d7e5d911 ("ebtables-nft: add stp match") Signed-off-by: Phil Sutter --- extensions/libebt_stp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/libebt_stp.c b/extensions/libebt_stp.c index 3e9e24474eb61..41059baae7078 100644 --- a/extensions/libebt_stp.c +++ b/extensions/libebt_stp.c @@ -146,9 +146,9 @@ static int parse_range(const char *portstring, void *lower, void *upper, static void print_range(unsigned int l, unsigned int u) { if (l == u) - printf("%u ", l); + printf("%u", l); else - printf("%u:%u ", l, u); + printf("%u:%u", l, u); } static int From patchwork Sat Oct 1 23:39:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1685298 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nwl.cc header.i=@nwl.cc header.a=rsa-sha256 header.s=mail2022 header.b=geCNbbff; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Mg3Tv3x90z20Zd for ; Sun, 2 Oct 2022 10:39:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiJAXj2 (ORCPT ); Sat, 1 Oct 2022 19:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiJAXj1 (ORCPT ); Sat, 1 Oct 2022 19:39:27 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C1772CE35 for ; Sat, 1 Oct 2022 16:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc; s=mail2022; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jufXAelwRvswf1jCGfzuuE0qgFcKLiTXyNB5kWH+yic=; b=geCNbbffCKh8WhPmucY5ZgClDN FPBFWPfViw6kZmvlgiqMMgDuShDuJL64TcnAkfpga9NS2oe6oOY7Xnsbsjw80L4pQwNV4DcZzHEa2 jK/LjIHWlR17/XJEzj5KpbyVg4KGZp/i7yZZP2GL5snVUxSmaDjk1Eraz1c43h0ciX3aMINyN9dkB gYVf2E0NE+lzSWPluHMD4KaHz1rRcMgEocLLjfn5UkHuqs+XyzXGuQmREQpXSrc72aRd6O6KkGDoZ 78adn+PNel/z/rWwSj5qRORpAU0Hty0+2DCKzr8DV0osZjyg2FPI+YPsnZW6ouyTiFAU9/rk1HF1x sw6TDGhQ==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1oem4r-0004qQ-Cp for netfilter-devel@vger.kernel.org; Sun, 02 Oct 2022 01:39:25 +0200 From: Phil Sutter To: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options Date: Sun, 2 Oct 2022 01:39:05 +0200 Message-Id: <20221001233906.5386-2-phil@nwl.cc> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221001233906.5386-1-phil@nwl.cc> References: <20221001233906.5386-1-phil@nwl.cc> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org If no --dst-opts were given, print_options() would print just a whitespace. Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces") Signed-off-by: Phil Sutter --- extensions/libip6t_dst.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c index bf0e3e436665d..baa010f56ac22 100644 --- a/extensions/libip6t_dst.c +++ b/extensions/libip6t_dst.c @@ -125,15 +125,15 @@ static void print_options(unsigned int optsnr, uint16_t *optsp) { unsigned int i; + char sep = ' '; - printf(" "); for(i = 0; i < optsnr; i++) { - printf("%d", (optsp[i] & 0xFF00) >> 8); + printf("%c%d", sep, (optsp[i] & 0xFF00) >> 8); if ((optsp[i] & 0x00FF) != 0x00FF) printf(":%d", (optsp[i] & 0x00FF)); - printf("%c", (i != optsnr - 1) ? ',' : ' '); + sep = ','; } } From patchwork Sat Oct 1 23:39:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1685297 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nwl.cc header.i=@nwl.cc header.a=rsa-sha256 header.s=mail2022 header.b=Zdr3MWcz; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Mg3Ts1DYSz20cn for ; Sun, 2 Oct 2022 10:39:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbiJAXjU (ORCPT ); Sat, 1 Oct 2022 19:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiJAXjT (ORCPT ); Sat, 1 Oct 2022 19:39:19 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12C5D2CE35 for ; Sat, 1 Oct 2022 16:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc; s=mail2022; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=280J40IPWuN4C8MA4kdsGHFF9Je2oDx2zy9Gpq0eJ4g=; b=Zdr3MWczt6lXdQSX/E9I0a+IbB 7Ttsq00GJ1CaLPT4RWcNQn4QABcZ0hwSoJYbLGLotA0XvYxVc+KRI0zmiSsjxv7h/tmeC33I5Bgxc FUjSTkkdESBBLMY2OLox5dHnP3lvj9NMn+8O8HXlcOJWN5rI9aAjzoReQ61FfLBHEcHi++Opv2Oaf Q1VxFAOMquMngQwGsX8wJpHMm/SkBU5jWtP3RNH52Pk/w6MLmfe3EUhdO3SNLiGdWIAVjtVJZwqI8 lRbCyhFvaLWhyEmK3R2gKHLzpiqh/JcoITpSOjEjvPGsq141RxQ/Y1UlFHFYzttHlwM2FNa/seeOP PxyFgkBA==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1oem4g-0004qD-Rb for netfilter-devel@vger.kernel.org; Sun, 02 Oct 2022 01:39:14 +0200 From: Phil Sutter To: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print empty options Date: Sun, 2 Oct 2022 01:39:06 +0200 Message-Id: <20221001233906.5386-3-phil@nwl.cc> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221001233906.5386-1-phil@nwl.cc> References: <20221001233906.5386-1-phil@nwl.cc> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org No point in printing anything if none of the bits are set. Fixes: aef4c1e727563 ("libxt_TCPOPTSTRIP") Signed-off-by: Phil Sutter --- extensions/libxt_TCPOPTSTRIP.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extensions/libxt_TCPOPTSTRIP.c b/extensions/libxt_TCPOPTSTRIP.c index 6ea3489224602..ff873f98b3aaa 100644 --- a/extensions/libxt_TCPOPTSTRIP.c +++ b/extensions/libxt_TCPOPTSTRIP.c @@ -142,6 +142,13 @@ tcpoptstrip_print_list(const struct xt_tcpoptstrip_target_info *info, } } +static bool tcpoptstrip_empty(const struct xt_tcpoptstrip_target_info *info) +{ + static const struct xt_tcpoptstrip_target_info empty = {}; + + return memcmp(info, &empty, sizeof(empty)) == 0; +} + static void tcpoptstrip_tg_print(const void *ip, const struct xt_entry_target *target, int numeric) @@ -149,6 +156,9 @@ tcpoptstrip_tg_print(const void *ip, const struct xt_entry_target *target, const struct xt_tcpoptstrip_target_info *info = (const void *)target->data; + if (tcpoptstrip_empty(info)) + return; + printf(" TCPOPTSTRIP options "); tcpoptstrip_print_list(info, numeric); } @@ -159,6 +169,9 @@ tcpoptstrip_tg_save(const void *ip, const struct xt_entry_target *target) const struct xt_tcpoptstrip_target_info *info = (const void *)target->data; + if (tcpoptstrip_empty(info)) + return; + printf(" --strip-options "); tcpoptstrip_print_list(info, true); }