From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 09/14] netfilter: nf_tables: kill nft_data_cmp()
Date: Sat, 11 Apr 2015 02:27:34 +0100 [thread overview]
Message-ID: <1428715659-31358-10-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1428715659-31358-1-git-send-email-kaber@trash.net>
Only needlessly complicates things due to requiring specific argument
types. Use memcmp directly.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/net/netfilter/nf_tables.h | 7 -------
net/netfilter/nft_cmp.c | 2 +-
net/netfilter/nft_hash.c | 2 +-
net/netfilter/nft_rbtree.c | 11 +++++------
4 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 81cd816..fca0b5d 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -69,13 +69,6 @@ struct nft_regs {
};
};
-static inline int nft_data_cmp(const struct nft_data *d1,
- const struct nft_data *d2,
- unsigned int len)
-{
- return memcmp(d1->data, d2->data, len);
-}
-
static inline void nft_data_copy(struct nft_data *dst,
const struct nft_data *src)
{
diff --git a/net/netfilter/nft_cmp.c b/net/netfilter/nft_cmp.c
index 59391e6..b7e1c58 100644
--- a/net/netfilter/nft_cmp.c
+++ b/net/netfilter/nft_cmp.c
@@ -31,7 +31,7 @@ static void nft_cmp_eval(const struct nft_expr *expr,
const struct nft_cmp_expr *priv = nft_expr_priv(expr);
int d;
- d = nft_data_cmp(®s->data[priv->sreg], &priv->data, priv->len);
+ d = memcmp(®s->data[priv->sreg], &priv->data, priv->len);
switch (priv->op) {
case NFT_CMP_EQ:
if (d != 0)
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index bbbe87c..c26844d 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -62,7 +62,7 @@ static inline int nft_hash_cmp(struct rhashtable_compare_arg *arg,
const struct nft_hash_cmp_arg *x = arg->key;
const struct nft_hash_elem *he = ptr;
- if (nft_data_cmp(nft_set_ext_key(&he->ext), x->key, x->set->klen))
+ if (memcmp(nft_set_ext_key(&he->ext), x->key, x->set->klen))
return 1;
if (nft_set_elem_expired(&he->ext))
return 1;
diff --git a/net/netfilter/nft_rbtree.c b/net/netfilter/nft_rbtree.c
index 42d0ca4..b398f1a 100644
--- a/net/netfilter/nft_rbtree.c
+++ b/net/netfilter/nft_rbtree.c
@@ -45,7 +45,7 @@ static bool nft_rbtree_lookup(const struct nft_set *set,
while (parent != NULL) {
rbe = rb_entry(parent, struct nft_rbtree_elem, node);
- d = nft_data_cmp(nft_set_ext_key(&rbe->ext), key, set->klen);
+ d = memcmp(nft_set_ext_key(&rbe->ext), key, set->klen);
if (d < 0) {
parent = parent->rb_left;
interval = rbe;
@@ -91,9 +91,9 @@ static int __nft_rbtree_insert(const struct nft_set *set,
while (*p != NULL) {
parent = *p;
rbe = rb_entry(parent, struct nft_rbtree_elem, node);
- d = nft_data_cmp(nft_set_ext_key(&rbe->ext),
- nft_set_ext_key(&new->ext),
- set->klen);
+ d = memcmp(nft_set_ext_key(&rbe->ext),
+ nft_set_ext_key(&new->ext),
+ set->klen);
if (d < 0)
p = &parent->rb_left;
else if (d > 0)
@@ -153,8 +153,7 @@ static void *nft_rbtree_deactivate(const struct nft_set *set,
while (parent != NULL) {
rbe = rb_entry(parent, struct nft_rbtree_elem, node);
- d = nft_data_cmp(nft_set_ext_key(&rbe->ext), &elem->key,
- set->klen);
+ d = memcmp(nft_set_ext_key(&rbe->ext), &elem->key, set->klen);
if (d < 0)
parent = parent->rb_left;
else if (d > 0)
--
2.1.0
next prev parent reply other threads:[~2015-04-11 1:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-11 1:27 [PATCH 00/14] netfilter: nf_tables: concatenation support Patrick McHardy
2015-04-11 1:27 ` [PATCH 01/14] netfilter: nf_tables: validate len in nft_validate_data_load() Patrick McHardy
2015-04-11 1:27 ` [PATCH 02/14] netfilter: nf_tables: rename nft_validate_data_load() Patrick McHardy
2015-04-11 1:27 ` [PATCH 03/14] netfilter: nft_lookup: use nft_validate_register_store() to validate types Patrick McHardy
2015-04-11 1:27 ` [PATCH 04/14] netfilter: nf_tables: kill nft_validate_output_register() Patrick McHardy
2015-04-11 1:27 ` [PATCH 05/14] netfilter: nf_tables: introduce nft_validate_register_load() Patrick McHardy
2015-04-11 1:27 ` [PATCH 06/14] netfilter: nf_tables: get rid of NFT_REG_VERDICT usage Patrick McHardy
2015-04-11 1:27 ` [PATCH 07/14] netfilter: nf_tables: use struct nft_verdict within struct nft_data Patrick McHardy
2015-04-11 1:27 ` [PATCH 08/14] netfilter: nf_tables: convert expressions to u32 register pointers Patrick McHardy
2015-04-11 1:27 ` Patrick McHardy [this message]
2015-04-11 1:27 ` [PATCH 10/14] netfilter: nf_tables: convert sets to u32 data pointers Patrick McHardy
2015-04-11 1:27 ` [PATCH 11/14] netfilter: nf_tables: add register parsing/dumping helpers Patrick McHardy
2015-04-11 1:27 ` [PATCH 12/14] netfilter: nf_tables: switch registers to 32 bit addressing Patrick McHardy
2015-04-11 1:27 ` [PATCH 13/14] netfilter: nf_tables: support variable sized data in nft_data_init() Patrick McHardy
2015-04-11 1:27 ` [PATCH 14/14] netfilter: nf_tables: variable sized set element keys / data Patrick McHardy
2015-04-11 13:47 ` [PATCH 00/14] netfilter: nf_tables: concatenation support Pablo Neira Ayuso
2015-04-11 13:47 ` Patrick McHardy
2015-04-13 18:07 ` 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=1428715659-31358-10-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).