提交 e562d860 编写于 作者: P Patrick McHardy 提交者: Pablo Neira Ayuso

netfilter: nf_tables: kill nft_data_cmp()

Only needlessly complicates things due to requiring specific argument
types. Use memcmp directly.
Signed-off-by: NPatrick McHardy <kaber@trash.net>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 fad136ea
...@@ -69,13 +69,6 @@ struct nft_regs { ...@@ -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, static inline void nft_data_copy(struct nft_data *dst,
const struct nft_data *src) const struct nft_data *src)
{ {
......
...@@ -31,7 +31,7 @@ static void nft_cmp_eval(const struct nft_expr *expr, ...@@ -31,7 +31,7 @@ static void nft_cmp_eval(const struct nft_expr *expr,
const struct nft_cmp_expr *priv = nft_expr_priv(expr); const struct nft_cmp_expr *priv = nft_expr_priv(expr);
int d; int d;
d = nft_data_cmp(&regs->data[priv->sreg], &priv->data, priv->len); d = memcmp(&regs->data[priv->sreg], &priv->data, priv->len);
switch (priv->op) { switch (priv->op) {
case NFT_CMP_EQ: case NFT_CMP_EQ:
if (d != 0) if (d != 0)
......
...@@ -62,7 +62,7 @@ static inline int nft_hash_cmp(struct rhashtable_compare_arg *arg, ...@@ -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_cmp_arg *x = arg->key;
const struct nft_hash_elem *he = ptr; 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; return 1;
if (nft_set_elem_expired(&he->ext)) if (nft_set_elem_expired(&he->ext))
return 1; return 1;
......
...@@ -45,7 +45,7 @@ static bool nft_rbtree_lookup(const struct nft_set *set, ...@@ -45,7 +45,7 @@ static bool nft_rbtree_lookup(const struct nft_set *set,
while (parent != NULL) { while (parent != NULL) {
rbe = rb_entry(parent, struct nft_rbtree_elem, node); 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) { if (d < 0) {
parent = parent->rb_left; parent = parent->rb_left;
interval = rbe; interval = rbe;
...@@ -91,9 +91,9 @@ static int __nft_rbtree_insert(const struct nft_set *set, ...@@ -91,9 +91,9 @@ static int __nft_rbtree_insert(const struct nft_set *set,
while (*p != NULL) { while (*p != NULL) {
parent = *p; parent = *p;
rbe = rb_entry(parent, struct nft_rbtree_elem, node); rbe = rb_entry(parent, struct nft_rbtree_elem, node);
d = nft_data_cmp(nft_set_ext_key(&rbe->ext), d = memcmp(nft_set_ext_key(&rbe->ext),
nft_set_ext_key(&new->ext), nft_set_ext_key(&new->ext),
set->klen); set->klen);
if (d < 0) if (d < 0)
p = &parent->rb_left; p = &parent->rb_left;
else if (d > 0) else if (d > 0)
...@@ -153,8 +153,7 @@ static void *nft_rbtree_deactivate(const struct nft_set *set, ...@@ -153,8 +153,7 @@ static void *nft_rbtree_deactivate(const struct nft_set *set,
while (parent != NULL) { while (parent != NULL) {
rbe = rb_entry(parent, struct nft_rbtree_elem, node); rbe = rb_entry(parent, struct nft_rbtree_elem, node);
d = nft_data_cmp(nft_set_ext_key(&rbe->ext), &elem->key, d = memcmp(nft_set_ext_key(&rbe->ext), &elem->key, set->klen);
set->klen);
if (d < 0) if (d < 0)
parent = parent->rb_left; parent = parent->rb_left;
else if (d > 0) else if (d > 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册