From patchwork Mon Jul 6 17:06:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 491712 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AB712140D5E for ; Tue, 7 Jul 2015 03:01:21 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753495AbbGFRBT (ORCPT ); Mon, 6 Jul 2015 13:01:19 -0400 Received: from mail.us.es ([193.147.175.20]:58986 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753506AbbGFRBS (ORCPT ); Mon, 6 Jul 2015 13:01:18 -0400 Received: (qmail 21183 invoked from network); 6 Jul 2015 19:01:15 +0200 Received: from unknown (HELO us.es) (192.168.2.13) by us.es with SMTP; 6 Jul 2015 19:01:15 +0200 Received: (qmail 5361 invoked by uid 507); 6 Jul 2015 17:01:14 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus3 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.7/20651. spamassassin: 3.4.0. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 4.246479 secs); 06 Jul 2015 17:01:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on antivirus3 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, USER_IN_WHITELIST autolearn=disabled version=3.4.0 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pablo@netfilter.org Received: from unknown (HELO antivirus3) (127.0.0.1) by us.es with SMTP; 6 Jul 2015 17:01:10 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus3 (F-Secure/fsigk_smtp/412/antivirus3); Mon, 06 Jul 2015 19:01:10 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus3) Received: (qmail 998 invoked from network); 6 Jul 2015 19:01:10 +0200 Received: from 129.166.216.87.static.jazztel.es (HELO salvia.here) (pneira@us.es@87.216.166.129) by mail.us.es with SMTP; 6 Jul 2015 19:01:10 +0200 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net Subject: [PATCH nft 2/3] src: set chain->hookstr from delinearization Date: Mon, 6 Jul 2015 19:06:45 +0200 Message-Id: <1436202406-14059-2-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1436202406-14059-1-git-send-email-pablo@netfilter.org> References: <1436202406-14059-1-git-send-email-pablo@netfilter.org> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Set human readable hookname chain->hookstr field from delinearize. Signed-off-by: Pablo Neira Ayuso --- include/rule.h | 1 + src/netlink.c | 2 ++ src/rule.c | 8 +++----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/rule.h b/include/rule.h index 5d44599..8ec7f91 100644 --- a/include/rule.h +++ b/include/rule.h @@ -138,6 +138,7 @@ extern struct chain *chain_lookup(const struct table *table, const struct handle *h); extern const char *family2str(unsigned int family); +extern const char *hooknum2str(unsigned int family, unsigned int hooknum); extern void chain_print_plain(const struct chain *chain); /** diff --git a/src/netlink.c b/src/netlink.c index 429eed4..d11d82f 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -691,6 +691,8 @@ static struct chain *netlink_delinearize_chain(struct netlink_ctx *ctx, nft_chain_attr_is_set(nlc, NFT_CHAIN_ATTR_POLICY)) { chain->hooknum = nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_HOOKNUM); + chain->hookstr = + hooknum2str(chain->handle.family, chain->hooknum); chain->priority = nft_chain_attr_get_s32(nlc, NFT_CHAIN_ATTR_PRIO); chain->type = diff --git a/src/rule.c b/src/rule.c index 39b4d9a..993f970 100644 --- a/src/rule.c +++ b/src/rule.c @@ -408,7 +408,7 @@ const char *family2str(unsigned int family) return "unknown"; } -static const char *hooknum2str(unsigned int family, unsigned int hooknum) +const char *hooknum2str(unsigned int family, unsigned int hooknum) { switch (family) { case NFPROTO_IPV4: @@ -466,8 +466,7 @@ static void chain_print(const struct chain *chain) printf("\tchain %s {\n", chain->handle.chain); if (chain->flags & CHAIN_F_BASECHAIN) { printf("\t\ttype %s hook %s priority %d; policy %s;\n", - chain->type, - hooknum2str(chain->handle.family, chain->hooknum), + chain->type, chain->hookstr, chain->priority, chain_policy2str(chain->policy)); } list_for_each_entry(rule, &chain->rules, list) { @@ -488,8 +487,7 @@ void chain_print_plain(const struct chain *chain) if (chain->flags & CHAIN_F_BASECHAIN) { printf(" { type %s hook %s priority %d; policy %s; }", - chain->type, - hooknum2str(chain->handle.family, chain->hooknum), + chain->type, chain->hookstr, chain->priority, chain_policy2str(chain->policy)); }