From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 04/10] netfilter: nft_xfrm: use state family, not hook one
Date: Sat, 20 Oct 2018 11:43:11 +0200 [thread overview]
Message-ID: <20181020094317.16011-5-pablo@netfilter.org> (raw)
In-Reply-To: <20181020094317.16011-1-pablo@netfilter.org>
From: Florian Westphal <fw@strlen.de>
Eyal says:
doesn't the use of nft_pf(pkt) in this context limit the matching of
encapsulated packets to the same family?
IIUC when an e.g. IPv6-in-IPv4 packet is matched, the nft_pf(pkt) will
be the decapsulated packet family - IPv6 - whereas the state may be
IPv4. So this check would not allow matching the 'underlay' address in
such cases.
I know this was a limitation in xt_policy. but is this intentional in
this matcher? or is it possible to use state->props.family when
validating the match instead of nft_pf(pkt)?
Userspace already tells us which address family it expects to match, so
we can just use the real state family rather than the hook family.
so change it as suggested above.
Reported-by: Eyal Birger <eyal.birger@gmail.com>
Suggested-by: Eyal Birger <eyal.birger@gmail.com>
Fixes: 6c47260250fc6 ("netfilter: nf_tables: add xfrm expression")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_xfrm.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/nft_xfrm.c b/net/netfilter/nft_xfrm.c
index 3cf71a2e375b..5322609f7662 100644
--- a/net/netfilter/nft_xfrm.c
+++ b/net/netfilter/nft_xfrm.c
@@ -118,12 +118,13 @@ static bool xfrm_state_addr_ok(enum nft_xfrm_keys k, u8 family, u8 mode)
static void nft_xfrm_state_get_key(const struct nft_xfrm *priv,
struct nft_regs *regs,
- const struct xfrm_state *state,
- u8 family)
+ const struct xfrm_state *state)
{
u32 *dest = ®s->data[priv->dreg];
- if (!xfrm_state_addr_ok(priv->key, family, state->props.mode)) {
+ if (!xfrm_state_addr_ok(priv->key,
+ state->props.family,
+ state->props.mode)) {
regs->verdict.code = NFT_BREAK;
return;
}
@@ -169,7 +170,7 @@ static void nft_xfrm_get_eval_in(const struct nft_xfrm *priv,
}
state = sp->xvec[priv->spnum];
- nft_xfrm_state_get_key(priv, regs, state, nft_pf(pkt));
+ nft_xfrm_state_get_key(priv, regs, state);
}
static void nft_xfrm_get_eval_out(const struct nft_xfrm *priv,
@@ -184,7 +185,7 @@ static void nft_xfrm_get_eval_out(const struct nft_xfrm *priv,
if (i < priv->spnum)
continue;
- nft_xfrm_state_get_key(priv, regs, dst->xfrm, nft_pf(pkt));
+ nft_xfrm_state_get_key(priv, regs, dst->xfrm);
return;
}
--
2.11.0
next prev parent reply other threads:[~2018-10-20 9:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-20 9:43 [PATCH 00/10] Netfilter updates for net-next Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 01/10] netfilter: Replace spin_is_locked() with lockdep Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 02/10] netfilter: cttimeout: remove set but not used variable 'l3num' Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 03/10] netfilter: nft_osf: Add ttl option support Pablo Neira Ayuso
2018-10-20 9:43 ` Pablo Neira Ayuso [this message]
2018-10-20 9:43 ` [PATCH 05/10] netfilter: xt_osf: simplify xt_osf_match_packet() Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 06/10] netfilter: nf_nat_snmp_basic: add missing helper alias name Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 07/10] netfilter: nf_flow_table: remove unnecessary parameter of nf_flow_table_cleanup() Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 08/10] netfilter: remove two unused variables Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 09/10] netfilter: nfnetlink_log: remove empty nfnetlink_log.h header file Pablo Neira Ayuso
2018-10-20 9:43 ` [PATCH 10/10] Revert "netfilter: xt_quota: fix the behavior of xt_quota module" Pablo Neira Ayuso
2018-10-20 19:33 ` [PATCH 00/10] Netfilter updates for net-next David Miller
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=20181020094317.16011-5-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.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).