Commit 728e87b4 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nat: fix cmp return value

The comparator works like memcmp, i.e. 0 means objects are equal.
In other words, when objects are distinct they are treated as identical,
when they are distinct they are allegedly the same.

The first case is rare (distinct objects are unlikely to get hashed to
same bucket).

The second case results in unneeded port conflict resolutions attempts.

Fixes: 870190a9 ("netfilter: nat: convert nat bysrc hash to rhashtable")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent abd66e9f
...@@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg, ...@@ -193,9 +193,12 @@ static int nf_nat_bysource_cmp(struct rhashtable_compare_arg *arg,
const struct nf_nat_conn_key *key = arg->key; const struct nf_nat_conn_key *key = arg->key;
const struct nf_conn *ct = obj; const struct nf_conn *ct = obj;
return same_src(ct, key->tuple) && if (!same_src(ct, key->tuple) ||
net_eq(nf_ct_net(ct), key->net) && !net_eq(nf_ct_net(ct), key->net) ||
nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL); !nf_ct_zone_equal(ct, key->zone, IP_CT_DIR_ORIGINAL))
return 1;
return 0;
} }
static struct rhashtable_params nf_nat_bysource_params = { static struct rhashtable_params nf_nat_bysource_params = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment