From patchwork Sat Jun 11 10:07:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1642282 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=oIZaTblo; dkim-atps=neutral Authentication-Results: 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=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4LKtnC0K4Cz9sFk for ; Sat, 11 Jun 2022 20:07:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbiFKKH4 (ORCPT ); Sat, 11 Jun 2022 06:07:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiFKKH4 (ORCPT ); Sat, 11 Jun 2022 06:07:56 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D0C7C08 for ; Sat, 11 Jun 2022 03:07:55 -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:Cc:To:From:Sender:Reply-To: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=fBM9JNPyYNTfif3jYrsKEZF+KJBwn27fzoqJ/hvvz4A=; b=oIZaTblodHqY0R8AvkhKns7lA6 kg4C204/jaa7AE4VQWCPSKr446COELPR2qmkC4m8pCrkobIhljWCDfqskuVec5ecY41munWJmvq87 5AJLQxfT2ypKzPfSxm4rzIWEpoUM0nUdml6L7T05P34TE19ZbfS+Xy0mRCkIpMrp8li+XUnUCxEJU SMY14YykkscZ7+muC+Jhulg7JXl31WoxKn6UntgOh1+d1kgbN3leBUiTXPVsgD+u8qGJyCDnweS9J 5pGM/bs/Sd9eXcWj2BGJHNn0xYK3duIS6fPJbo23u4JK4X2RWzj+mK9qS7WV6F1Uly+Dw12yC/rPC hlWvFOjw==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1nzy23-00061e-46; Sat, 11 Jun 2022 12:07:51 +0200 From: Phil Sutter To: Pablo Neira Ayuso , Jan Engelhardt Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 1/2] libxtables: Move struct xtables_afinfo into xtables.h Date: Sat, 11 Jun 2022 12:07:41 +0200 Message-Id: <20220611100742.4888-2-phil@nwl.cc> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220611100742.4888-1-phil@nwl.cc> References: <20220611100742.4888-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, T_SCC_BODY_TEXT_LINE 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 The library "owns" this structure and maintains 'afinfo' pointer to instances of it. With libxt_set, there's even an extension making use of the data. To avoid impact on library users, guard it by XTABLES_INTERNAL. To eliminate the xshared.h include by libxt_set, DEBUGP has to be redefined. Other extensions have similar defines, fix this later. Signed-off-by: Phil Sutter --- extensions/libxt_set.c | 6 ++++++ extensions/libxt_set.h | 1 - include/xtables.h | 22 ++++++++++++++++++++++ iptables/xshared.h | 22 ---------------------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/extensions/libxt_set.c b/extensions/libxt_set.c index 16921023a22f8..a2137ab1eb180 100644 --- a/extensions/libxt_set.c +++ b/extensions/libxt_set.c @@ -22,6 +22,12 @@ #include #include "libxt_set.h" +#ifdef DEBUG +#define DEBUGP(x, args...) fprintf(stderr, x, ## args) +#else +#define DEBUGP(x, args...) +#endif + /* Revision 0 */ static void diff --git a/extensions/libxt_set.h b/extensions/libxt_set.h index ad895a7504d9d..597bf7ebe575a 100644 --- a/extensions/libxt_set.h +++ b/extensions/libxt_set.h @@ -6,7 +6,6 @@ #include #include #include -#include "../iptables/xshared.h" static int get_version(unsigned *version) diff --git a/include/xtables.h b/include/xtables.h index f1937f3ea0530..b8d8372d0e498 100644 --- a/include/xtables.h +++ b/include/xtables.h @@ -665,6 +665,28 @@ void xtables_announce_chain(const char *name); extern void _init(void); +/** + * xtables_afinfo - protocol family dependent information + * @kmod: kernel module basename (e.g. "ip_tables") + * @proc_exists: file which exists in procfs when module already loaded + * @libprefix: prefix of .so library name (e.g. "libipt_") + * @family: nfproto family + * @ipproto: used by setsockopt (e.g. IPPROTO_IP) + * @so_rev_match: optname to check revision support of match + * @so_rev_target: optname to check revision support of target + */ +struct xtables_afinfo { + const char *kmod; + const char *proc_exists; + const char *libprefix; + uint8_t family; + uint8_t ipproto; + int so_rev_match; + int so_rev_target; +}; + +extern const struct xtables_afinfo *afinfo; + #endif /* XTABLES_INTERNAL */ #ifdef __cplusplus diff --git a/iptables/xshared.h b/iptables/xshared.h index 1d6b9bf4ee9b7..1fdc760a32442 100644 --- a/iptables/xshared.h +++ b/iptables/xshared.h @@ -75,26 +75,6 @@ struct xtables_target; #define IPT_INV_ARPOP 0x0400 #define IPT_INV_ARPHRD 0x0800 -/** - * xtables_afinfo - protocol family dependent information - * @kmod: kernel module basename (e.g. "ip_tables") - * @proc_exists: file which exists in procfs when module already loaded - * @libprefix: prefix of .so library name (e.g. "libipt_") - * @family: nfproto family - * @ipproto: used by setsockopt (e.g. IPPROTO_IP) - * @so_rev_match: optname to check revision support of match - * @so_rev_target: optname to check revision support of target - */ -struct xtables_afinfo { - const char *kmod; - const char *proc_exists; - const char *libprefix; - uint8_t family; - uint8_t ipproto; - int so_rev_match; - int so_rev_target; -}; - /* trick for ebtables-compat, since watchers are targets */ struct ebt_match { struct ebt_match *next; @@ -187,8 +167,6 @@ int parse_counters(const char *string, struct xt_counters *ctr); bool tokenize_rule_counters(char **bufferp, char **pcnt, char **bcnt, int line); bool xs_has_arg(int argc, char *argv[]); -extern const struct xtables_afinfo *afinfo; - #define MAX_ARGC 255 struct argv_store { int argc; From patchwork Sat Jun 11 10:07:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1642283 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=jY0TaKkq; dkim-atps=neutral Authentication-Results: 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=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4LKtnF348Jz9sGC for ; Sat, 11 Jun 2022 20:08:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbiFKKIA (ORCPT ); Sat, 11 Jun 2022 06:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiFKKH7 (ORCPT ); Sat, 11 Jun 2022 06:07:59 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB3BC16 for ; Sat, 11 Jun 2022 03:07:58 -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:Cc:To:From:Sender:Reply-To: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=Ax64YxzISIvtDVzbvI66PxM8gbyRl8FaCxomypLILfY=; b=jY0TaKkqsL6yXMA5RZLJobNF65 p9yer+RrRpLlinCk9J7Hy5KxRvAqbUoeAxsoLvT8BuEm60wczypS/8zBQpGRsaVFR8bcXjhMlZ1OZ auwKd+3mI7S2LJdUGsNWDItNACsYtwOA8yg+UmoeWj3mwuT4oAd6dA4OTHYDysC0jCNv4VFZLpIKJ 92FeZrNTOfpk54ALMIVkQlHUEmc+uN9JCY97CXYxDAZod5Fu0C3NsDIDOe48ltjFKlOczXMfBBqaS Il3mKB5WjPebbK/jfqD8eBNfkFl6phwseZiFH5D8HiHErk3pil3P6+9FEM6dB+KUvVKUN7Y2ww1/a IZ9Yn79Q==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1nzy28-00061l-FQ; Sat, 11 Jun 2022 12:07:56 +0200 From: Phil Sutter To: Pablo Neira Ayuso , Jan Engelhardt Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 2/2] libxtables: Define XT_OPTION_OFFSET_SCALE in xtables.h Date: Sat, 11 Jun 2022 12:07:42 +0200 Message-Id: <20220611100742.4888-3-phil@nwl.cc> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220611100742.4888-1-phil@nwl.cc> References: <20220611100742.4888-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, T_SCC_BODY_TEXT_LINE 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 This is the last symbol in xshared.h used by libxtables, move it over. Again, treat this as "implementation detail" and hence put it behind XTABLES_INTERNAL-curtains. Signed-off-by: Phil Sutter --- include/xtables.h | 3 +++ iptables/xshared.h | 4 ---- libxtables/xtables.c | 1 - libxtables/xtoptions.c | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/xtables.h b/include/xtables.h index b8d8372d0e498..9eba4f619d351 100644 --- a/include/xtables.h +++ b/include/xtables.h @@ -687,6 +687,9 @@ struct xtables_afinfo { extern const struct xtables_afinfo *afinfo; +/* base offset of merged extensions' consecutive options */ +#define XT_OPTION_OFFSET_SCALE 256 + #endif /* XTABLES_INTERNAL */ #ifdef __cplusplus diff --git a/iptables/xshared.h b/iptables/xshared.h index 1fdc760a32442..1a019a7c04882 100644 --- a/iptables/xshared.h +++ b/iptables/xshared.h @@ -132,10 +132,6 @@ struct subcommand { mainfunc_t main; }; -enum { - XT_OPTION_OFFSET_SCALE = 256, -}; - extern int subcmd_main(int, char **, const struct subcommand *); extern void xs_init_target(struct xtables_target *); extern void xs_init_match(struct xtables_match *); diff --git a/libxtables/xtables.c b/libxtables/xtables.c index 0638f9271c601..dc645162973f0 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -64,7 +64,6 @@ #endif #include #include "iptables/internal.h" -#include "xshared.h" #define NPROTO 255 diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c index 9d3ac5c8066cb..8174a560ec4df 100644 --- a/libxtables/xtoptions.c +++ b/libxtables/xtoptions.c @@ -21,7 +21,6 @@ #include #include #include "xtables.h" -#include "xshared.h" #ifndef IPTOS_NORMALSVC # define IPTOS_NORMALSVC 0 #endif