From patchwork Sat May 5 12:55:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 909145 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40dTRs30S8z9s2t for ; Sat, 5 May 2018 22:57:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751747AbeEEM5N (ORCPT ); Sat, 5 May 2018 08:57:13 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:53028 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbeEEM5M (ORCPT ); Sat, 5 May 2018 08:57:12 -0400 Received: from localhost ([::1]:40072 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.90_1) (envelope-from ) id 1fEwkR-00087K-Fl; Sat, 05 May 2018 14:57:11 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [nft PATCH v2 04/14] libnftables: Make some functions globally accessible Date: Sat, 5 May 2018 14:55:56 +0200 Message-Id: <20180505125606.1909-5-phil@nwl.cc> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180505125606.1909-1-phil@nwl.cc> References: <20180505125606.1909-1-phil@nwl.cc> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This removes static flag and adds header prototype for the following functions: * must_print_eq_op() from src/expression.c * fib_result_str() from src/fib.c * set_policy2str() and chain_policy2str from src/rule.c In fib.h, include linux/netfilter/nf_tables.h to make sure enum nft_fib_result is known when including this file. Signed-off-by: Phil Sutter --- include/expression.h | 2 ++ include/fib.h | 3 +++ include/rule.h | 2 ++ include/statement.h | 2 ++ src/expression.c | 2 +- src/fib.c | 2 +- src/rule.c | 4 ++-- src/statement.c | 4 ++-- 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/expression.h b/include/expression.h index f0ba6fc112601..23d6bd23cff29 100644 --- a/include/expression.h +++ b/include/expression.h @@ -366,6 +366,8 @@ extern struct expr *unary_expr_alloc(const struct location *loc, extern struct expr *binop_expr_alloc(const struct location *loc, enum ops op, struct expr *left, struct expr *right); +extern bool must_print_eq_op(const struct expr *expr); + extern struct expr *relational_expr_alloc(const struct location *loc, enum ops op, struct expr *left, struct expr *right); diff --git a/include/fib.h b/include/fib.h index 9ce681cc1ecf3..67edccfea0d57 100644 --- a/include/fib.h +++ b/include/fib.h @@ -1,6 +1,9 @@ #ifndef NFTABLES_FIB_H #define NFTABLES_FIB_H +#include + +extern const char *fib_result_str(enum nft_fib_result result); extern struct expr *fib_expr_alloc(const struct location *loc, unsigned int flags, unsigned int result); diff --git a/include/rule.h b/include/rule.h index ab7f45fd0aba4..91076fde4c9a1 100644 --- a/include/rule.h +++ b/include/rule.h @@ -183,6 +183,7 @@ extern struct chain *chain_lookup(const struct table *table, extern const char *family2str(unsigned int family); extern const char *hooknum2str(unsigned int family, unsigned int hooknum); +extern const char *chain_policy2str(uint32_t policy); extern void chain_print_plain(const struct chain *chain, struct output_ctx *octx); @@ -263,6 +264,7 @@ extern void set_add_hash(struct set *set, struct table *table); extern struct set *set_lookup(const struct table *table, const char *name); extern struct set *set_lookup_global(uint32_t family, const char *table, const char *name, struct nft_cache *cache); +extern const char *set_policy2str(uint32_t policy); extern void set_print(const struct set *set, struct output_ctx *octx); extern void set_print_plain(const struct set *s, struct output_ctx *octx); diff --git a/include/statement.h b/include/statement.h index 5987b18170f94..fc80dbd518b35 100644 --- a/include/statement.h +++ b/include/statement.h @@ -21,6 +21,7 @@ struct objref_stmt { struct expr *expr; }; +const char *objref_type_name(uint32_t type); struct stmt *objref_stmt_alloc(const struct location *loc); struct counter_stmt { @@ -75,6 +76,7 @@ struct log_stmt { uint32_t flags; }; +extern const char *log_level(uint32_t level); extern struct stmt *log_stmt_alloc(const struct location *loc); diff --git a/src/expression.c b/src/expression.c index e698b14c969c7..e8b30b4857de0 100644 --- a/src/expression.c +++ b/src/expression.c @@ -558,7 +558,7 @@ static void binop_arg_print(const struct expr *op, const struct expr *arg, nft_print(octx, ")"); } -static bool must_print_eq_op(const struct expr *expr) +bool must_print_eq_op(const struct expr *expr) { return expr->left->ops->type == EXPR_BINOP; } diff --git a/src/fib.c b/src/fib.c index 21bc69a9f0a38..069411f0131f2 100644 --- a/src/fib.c +++ b/src/fib.c @@ -52,7 +52,7 @@ const struct datatype fib_addr_type = { .sym_tbl = &addrtype_tbl, }; -static const char *fib_result_str(enum nft_fib_result result) +const char *fib_result_str(enum nft_fib_result result) { if (result <= NFT_FIB_RESULT_MAX) return fib_result[result]; diff --git a/src/rule.c b/src/rule.c index e348b847b4954..b392032390cd8 100644 --- a/src/rule.c +++ b/src/rule.c @@ -287,7 +287,7 @@ struct print_fmt_options { const char *stmt_separator; }; -static const char *set_policy2str(uint32_t policy) +const char *set_policy2str(uint32_t policy) { switch (policy) { case NFT_SET_POL_PERFORMANCE: @@ -732,7 +732,7 @@ const char *hooknum2str(unsigned int family, unsigned int hooknum) return "unknown"; } -static const char *chain_policy2str(uint32_t policy) +const char *chain_policy2str(uint32_t policy) { switch (policy) { case NF_DROP: diff --git a/src/statement.c b/src/statement.c index a5ef7d7dfd2eb..6537bbbd9a20b 100644 --- a/src/statement.c +++ b/src/statement.c @@ -178,7 +178,7 @@ static const char *objref_type[NFT_OBJECT_MAX + 1] = { [NFT_OBJECT_LIMIT] = "limit", }; -static const char *objref_type_name(uint32_t type) +const char *objref_type_name(uint32_t type) { if (type > NFT_OBJECT_MAX) return "unknown"; @@ -225,7 +225,7 @@ static const char *syslog_level[LOG_DEBUG + 1] = { [LOG_DEBUG] = "debug", }; -static const char *log_level(uint32_t level) +const char *log_level(uint32_t level) { if (level > LOG_DEBUG) return "unknown";