Subject: Re: [PATCH ipsec-next v12 3/4] xfrm: Add dir validation to "in" data path lookup

From: Sabrina Dubroca <[email-masked]>
Date: Wed, 24 Apr 2024 10:40:56 +0200

2024-04-23, 17:27:37 +0200, Nicolas Dichtel wrote:
> Le 23/04/2024 à 14:50, Antony Antony a écrit :
> > Introduces validation for the x->dir attribute within the XFRM input
> > data lookup path. If the configured direction does not match the
> > expected direction, input, increment the XfrmInStateDirError counter
> > and drop the packet to ensure data integrity and correct flow handling.
> > 
> > grep -vw 0 /proc/net/xfrm_stat
> > XfrmInStateDirError     	1
> > 
> > Signed-off-by: Antony Antony <[email-masked]>
> > ---
> > v11 -> 12
> >  - add documentation to xfrm_proc.rst
> > 
> > v10->v11
> >  - rename error s/XfrmInDirError/XfrmInStateDirError/
> > ---
> >  Documentation/networking/xfrm_proc.rst |  3 +++
> >  include/uapi/linux/snmp.h              |  1 +
> >  net/ipv6/xfrm6_input.c                 |  7 +++++++
> >  net/xfrm/xfrm_input.c                  | 11 +++++++++++
> >  net/xfrm/xfrm_proc.c                   |  1 +
> >  5 files changed, 23 insertions(+)
> > 
> > diff --git a/Documentation/networking/xfrm_proc.rst b/Documentation/networking/xfrm_proc.rst
> > index c237bef03fb6..b4f4d9552dea 100644
> > --- a/Documentation/networking/xfrm_proc.rst
> > +++ b/Documentation/networking/xfrm_proc.rst
> > @@ -73,6 +73,9 @@ XfrmAcquireError:
> >  XfrmFwdHdrError:
> >  	Forward routing of a packet is not allowed
> > 
> > +XfrmInStateDirError:
> > +        State direction input mismatched with lookup path direction
> It's a bit confusing because when this error occurs, the state direction is not
> 'input'.

Agree.

> This statistic is under 'Inbound errors', so may something like this is enough:
> 'State direction is output.'

Maybe something like:

State direction mismatch (lookup found an output state on the input path, expected input or no direction)

It's a bit verbose, but I think those extra details would help users
understand what went wrong.

-- 
Sabrina