netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antony Antony <antony@phenome.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: Antony Antony <antony.antony@secunet.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	devel@linux-ipsec.org, Leon Romanovsky <leon@kernel.org>,
	Eyal Birger <eyal.birger@gmail.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: Re: [PATCH ipsec-next v12 1/4] xfrm: Add Direction to the SA in or out
Date: Fri, 26 Apr 2024 09:47:31 +0200	[thread overview]
Message-ID: <ZitcE8dJnwLi5bYx@Antony2201.local> (raw)
In-Reply-To: <ZijTAN_ns1gRU9hz@hog>

On Wed, Apr 24, 2024 at 11:38:08AM +0200, Sabrina Dubroca via Devel wrote:
> 2024-04-23, 14:49:17 +0200, Antony Antony wrote:
> > diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> > index 0c306473a79d..c8c5fc47c431 100644
> > --- a/net/xfrm/xfrm_state.c
> > +++ b/net/xfrm/xfrm_state.c
> > @@ -1292,6 +1292,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
> >  		if (km_query(x, tmpl, pol) == 0) {
> >  			spin_lock_bh(&net->xfrm.xfrm_state_lock);
> >  			x->km.state = XFRM_STATE_ACQ;
> > +			x->dir = XFRM_SA_DIR_OUT;
> 
> Would that make updates fail if userspace isn't setting SA_DIR
> afterwards?

Not in typical, operation of IKE daemons. I haven't update acquire state.
I don't think iproute2 supports that.
UPDSA is called for input where there is no acquire; acquire is for output.  
For output SA, added using NEWSA, will find the output acquire and delete it 
if p->seq matches. It won't update.

May be some other userspace update acquire? I extend the code to accomodate 
this possible case, in v13.

> > diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> > index 810b520493f3..d34ac467a219 100644
> > --- a/net/xfrm/xfrm_user.c
> > +++ b/net/xfrm/xfrm_user.c
> [...]
> > @@ -176,6 +200,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
> >  			     struct netlink_ext_ack *extack)
> >  {
> >  	int err;
> > +	u8 sa_dir = attrs[XFRMA_SA_DIR] ?  nla_get_u8(attrs[XFRMA_SA_DIR]) : 0;
> 
> nit: extra ' ' after '?', only one is needed.

fixed.

> > @@ -358,6 +383,64 @@ static int verify_newsa_info(struct 
> > xfrm_usersa_info *p,
> >  			err = -EINVAL;
> >  			goto out;
> >  		}
> > +
> > +		if (sa_dir == XFRM_SA_DIR_OUT) {
> > +			NL_SET_ERR_MSG(extack,
> > +				       "MTIMER_THRESH attribute should not be set on output SA");
> > +			err = -EINVAL;
> > +			goto out;
> > +		}
> > +	}
> > +
> > +	if (sa_dir == XFRM_SA_DIR_OUT) {
> > +		if (p->flags & XFRM_STATE_DECAP_DSCP) {
> > +			NL_SET_ERR_MSG(extack, "Flag NDECAP_DSCP should not be set for output SA");
> 
> That typo in the error string is still here (extra N in flag name).

sorry.Fixed. I will send v13 soon.

-antony

  reply	other threads:[~2024-04-26  7:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 12:48 [PATCH ipsec-next v12 0/4] xfrm: Introduce direction attribute for SA Antony Antony
2024-04-23 12:49 ` [PATCH ipsec-next v12 1/4] xfrm: Add Direction to the SA in or out Antony Antony
2024-04-24  9:38   ` Sabrina Dubroca
2024-04-26  7:47     ` Antony Antony [this message]
2024-04-23 12:49 ` [PATCH ipsec-next v12 2/4] xfrm: Add dir validation to "out" data path lookup Antony Antony
2024-04-23 12:50 ` [PATCH ipsec-next v12 3/4] xfrm: Add dir validation to "in" " Antony Antony
2024-04-23 15:27   ` Nicolas Dichtel
2024-04-24  8:40     ` Sabrina Dubroca
2024-04-24 10:04       ` Nicolas Dichtel
2024-04-26  8:11         ` Antony Antony
2024-04-23 12:51 ` [PATCH ipsec-next v12 4/4] xfrm: Restrict SA direction attribute to specific netlink message types Antony Antony
2024-04-26  4:49   ` Steffen Klassert
2024-04-26  7:50     ` Antony Antony

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=ZitcE8dJnwLi5bYx@Antony2201.local \
    --to=antony@phenome.org \
    --cc=antony.antony@secunet.com \
    --cc=davem@davemloft.net \
    --cc=devel@linux-ipsec.org \
    --cc=edumazet@google.com \
    --cc=eyal.birger@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --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).