netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kaber@trash.net
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [PATCH 03/11] netfilter: nf_tables: move hgenerator from chain to table
Date: Wed, 12 Dec 2012 19:47:33 +0100	[thread overview]
Message-ID: <1355338061-5517-4-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1355338061-5517-1-git-send-email-kaber@trash.net>

From: Patrick McHardy <kaber@trash.net>

With 48 bits rule handles, there's no risk of overflowing even when the
handles are unique per table and not per chain. Save a few bytes in the
chain structure and move the hgenerator to the table.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 include/net/netfilter/nf_tables.h | 4 ++--
 net/netfilter/nf_tables_api.c     | 8 ++++----
 2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 99c500f..86fd951 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -349,7 +349,6 @@ enum nft_chain_flags {
  *	@flags: bitmask of enum nft_chain_flags
  *	@use: number of jump references to this chain
  *	@level: length of longest path to this chain
- *	@hgenerator: handle generator state
  *	@name: name of the chain
  */
 struct nft_chain {
@@ -359,7 +358,6 @@ struct nft_chain {
 	u8				policy;
 	u16				use;
 	u16				level;
-	u64				hgenerator;
 	char				name[NFT_CHAIN_MAXNAMELEN];
 };
 
@@ -400,12 +398,14 @@ extern unsigned int nft_do_chain(const struct nf_hook_ops *ops,
  *	@chains: chains in the table
  *	@sets: sets in the table
  *	@flags: table flag (see enum nft_table_flags)
+ *	@hgenerator: handle generator state
  *	@name: name of the table
  */
 struct nft_table {
 	struct list_head		list;
 	struct list_head		chains;
 	struct list_head		sets;
+	u64				hgenerator;
 	u16				flags;
 	char				name[];
 };
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 63d71e7..9768881 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1116,9 +1116,9 @@ static struct nft_rule *nf_tables_rule_lookup(const struct nft_chain *chain,
 	return __nf_tables_rule_lookup(chain, be64_to_cpu(nla_get_be64(nla)));
 }
 
-static inline u64 nf_tables_rule_alloc_handle(struct nft_chain *chain)
+static inline u64 nf_tables_rule_alloc_handle(struct nft_table *table)
 {
-	return ++chain->hgenerator;
+	return ++table->hgenerator;
 }
 
 static const struct nla_policy nft_rule_policy[NFTA_RULE_MAX + 1] = {
@@ -1338,7 +1338,7 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
 {
 	const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
 	const struct nft_af_info *afi;
-	const struct nft_table *table;
+	struct nft_table *table;
 	struct nft_chain *chain;
 	struct nft_rule *rule, *old_rule = NULL;
 	struct nft_expr_info info[NFT_RULE_MAXEXPRS];
@@ -1383,7 +1383,7 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
 				return 0;
 		}
 	} else
-		handle = nf_tables_rule_alloc_handle(chain);
+		handle = nf_tables_rule_alloc_handle(table);
 
 	if (handle == 0)
 		return -EINVAL;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-12-12 18:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 18:47 [PATCH 00/11] netfilter: nf_tables: small cleanups and netlink fixes kaber
2012-12-12 18:47 ` [PATCH 01/11] netfilter: nf_tables: rename pid variables to portid kaber
2012-12-12 18:47 ` [PATCH 02/11] netfilter: nf_tables: revert commit 2a3c360f kaber
2012-12-12 18:47 ` kaber [this message]
2012-12-12 18:47 ` [PATCH 04/11] netfilter: nf_tables: move policy to struct nft_base_chain kaber
2012-12-12 18:47 ` [PATCH 05/11] netfilter: nf_tables: send notifications for base chain policy changes kaber
2012-12-12 18:47 ` [PATCH 06/11] netfilter: nf_tables: introduce chain handles and fix chain rename kaber
2012-12-12 18:47 ` [PATCH 07/11] netfilter: nf_tables: fix invalid event type in nf_tables_getrule() kaber
2012-12-12 18:47 ` [PATCH 08/11] netfilter: nf_tables: remove ability to specify handles for new rules kaber
2012-12-12 18:47 ` [PATCH 09/11] netfilter: nf_tables: return error for rule change request kaber
2012-12-12 18:47 ` [PATCH 10/11] netfilter: nf_tables: return error for NLM_F_REPLACE without rule handle kaber
2012-12-12 18:47 ` [PATCH 11/11] netfilter: nf_tables: include NLM_F_APPEND/NLM_F_REPLACE flags in rule notification kaber
2012-12-14  7:16 ` [PATCH 00/11] netfilter: nf_tables: small cleanups and netlink fixes Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355338061-5517-4-git-send-email-kaber@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).