From: Leon Romanovsky <leon@kernel.org>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
netdev@vger.kernel.org, Raed Salem <raeds@nvidia.com>,
ipsec-devel <devel@linux-ipsec.org>
Subject: Re: [PATCH ipsec-next 5/6] xfrm: add RX datapath protection for IPsec full offload mode
Date: Mon, 16 May 2022 08:29:03 +0300 [thread overview]
Message-ID: <YoHhH++2sBvyy+8d@unreal> (raw)
In-Reply-To: <20220513150254.GM680067@gauss3.secunet.de>
On Fri, May 13, 2022 at 05:02:54PM +0200, Steffen Klassert wrote:
> On Tue, May 10, 2022 at 01:36:56PM +0300, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> >
> > Traffic received by device with enabled IPsec full offload should be
> > forwarded to the stack only after decryption, packet headers and
> > trailers removed.
> >
> > Such packets are expected to be seen as normal (non-XFRM) ones, while
> > not-supported packets should be dropped by the HW.
> >
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> > include/net/xfrm.h | 55 +++++++++++++++++++++++++++-------------------
> > 1 file changed, 32 insertions(+), 23 deletions(-)
> >
> > diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> > index 21be19ece4f7..9f9250fe1c4d 100644
> > --- a/include/net/xfrm.h
> > +++ b/include/net/xfrm.h
> > @@ -1094,6 +1094,29 @@ xfrm_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, un
> > return !0;
> > }
> >
> > +#ifdef CONFIG_XFRM
> > +static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb)
> > +{
> > + struct sec_path *sp = skb_sec_path(skb);
> > +
> > + return sp->xvec[sp->len - 1];
> > +}
> > +#endif
> > +
> > +static inline struct xfrm_offload *xfrm_offload(struct sk_buff *skb)
> > +{
> > +#ifdef CONFIG_XFRM
> > + struct sec_path *sp = skb_sec_path(skb);
> > +
> > + if (!sp || !sp->olen || sp->len != sp->olen)
> > + return NULL;
> > +
> > + return &sp->ovec[sp->olen - 1];
> > +#else
> > + return NULL;
> > +#endif
> > +}
> > +
> > #ifdef CONFIG_XFRM
> > int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb,
> > unsigned short family);
> > @@ -1113,6 +1136,15 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir,
> > {
> > struct net *net = dev_net(skb->dev);
> > int ndir = dir | (reverse ? XFRM_POLICY_MASK + 1 : 0);
> > + struct xfrm_offload *xo = xfrm_offload(skb);
> > + struct xfrm_state *x;
> > +
> > + if (xo) {
> > + x = xfrm_input_state(skb);
> > + if (x->xso.type == XFRM_DEV_OFFLOAD_FULL)
> > + return (xo->flags & CRYPTO_DONE) &&
> > + (xo->status & CRYPTO_SUCCESS);
> > + }
>
> We can not exit without doing the policy check here. The inner
> packet could still match a block policy in software. Maybe
> we can reset the secpath and do the policy check.
We checked that both policy and state were offloaded. In such case,
driver returned that everything ok and the packet is handled.
SW policy will be in lower priority, so we won't catch it.
Thanks
next prev parent reply other threads:[~2022-05-16 5:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 10:36 [PATCH ipsec-next 0/6] Extend XFRM core to allow full offload configuration Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 1/6] xfrm: add new full offload flag Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 2/6] xfrm: allow state full offload mode Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 3/6] xfrm: add an interface to offload policy Leon Romanovsky
2022-05-13 14:44 ` Steffen Klassert
2022-05-16 5:18 ` Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 4/6] xfrm: add TX datapath support for IPsec full offload mode Leon Romanovsky
2022-05-13 14:56 ` Steffen Klassert
2022-05-16 5:44 ` Leon Romanovsky
2022-05-18 7:49 ` Steffen Klassert
2022-05-24 18:30 ` Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 5/6] xfrm: add RX datapath protection " Leon Romanovsky
2022-05-13 15:02 ` Steffen Klassert
2022-05-16 5:29 ` Leon Romanovsky [this message]
2022-05-18 8:02 ` Steffen Klassert
2022-05-10 10:36 ` [PATCH ipsec-next 6/6] xfrm: enforce separation between priorities of HW/SW policies Leon Romanovsky
2022-05-13 15:07 ` Steffen Klassert
2022-05-16 5:17 ` Leon Romanovsky
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=YoHhH++2sBvyy+8d@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=devel@linux-ipsec.org \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=raeds@nvidia.com \
--cc=steffen.klassert@secunet.com \
/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).