From: Leon Romanovsky <leon@kernel.org>
To: Chiachang Wang <chiachangwang@google.com>
Cc: netdev@vger.kernel.org, steffen.klassert@secunet.com,
stanleyjhu@google.com, yumike@google.com
Subject: Re: [PATCH ipsec-next v4 2/2] xfrm: Refactor migration setup during the cloning process
Date: Wed, 12 Mar 2025 15:00:54 +0200 [thread overview]
Message-ID: <20250312130054.GB1322339@unreal> (raw)
In-Reply-To: <CAOb+sWFi+8df32zdAL5AmkfCpFBMG6hU=_+S3U-X_Zd6386r6g@mail.gmail.com>
On Mon, Mar 10, 2025 at 08:20:39PM +0800, Chiachang Wang wrote:
> While the xfrm_state_migrate() is the only caller for this method
> currently, this check can be removed indeed.
> I add this for the feasibility of other callers without performing the
> validation. If you have a strong opinion on this. I can update to
> remove this.
> Please let me know if you prefer to do so.
Sure, please remove. We are adding code when it is actually needed.
Thanks
>
> Thank you!
>
> Leon Romanovsky <leon@kernel.org> 於 2025年3月10日 週一 下午7:52寫道:
> >
> > On Mon, Mar 10, 2025 at 09:16:20AM +0000, Chiachang Wang wrote:
> > > Previously, migration related setup, such as updating family,
> > > destination address, and source address, was performed after
> > > the clone was created in `xfrm_state_migrate`. This change
> > > moves this setup into the cloning function itself, improving
> > > code locality and reducing redundancy.
> > >
> > > The `xfrm_state_clone_and_setup` function now conditionally
> > > applies the migration parameters from struct xfrm_migrate
> > > if it is provided. This allows the function to be used both
> > > for simple cloning and for cloning with migration setup.
> > >
> > > Test: Tested with kernel test in the Android tree located
> > > in https://android.googlesource.com/kernel/tests/
> > > The xfrm_tunnel_test.py under the tests folder in
> > > particular.
> > > Signed-off-by: Chiachang Wang <chiachangwang@google.com>
> > > ---
> > > net/xfrm/xfrm_state.c | 18 ++++++++++--------
> > > 1 file changed, 10 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> > > index 9cd707362767..0365daedea32 100644
> > > --- a/net/xfrm/xfrm_state.c
> > > +++ b/net/xfrm/xfrm_state.c
> > > @@ -1958,8 +1958,9 @@ static inline int clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *secu
> > > return 0;
> > > }
> > >
> > > -static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
> > > - struct xfrm_encap_tmpl *encap)
> > > +static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig,
> > > + struct xfrm_encap_tmpl *encap,
> > > + struct xfrm_migrate *m)
> > > {
> > > struct net *net = xs_net(orig);
> > > struct xfrm_state *x = xfrm_state_alloc(net);
> > > @@ -2058,6 +2059,12 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
> > > goto error;
> > > }
> > >
> > > + if (m) {
> >
> > Why do you need this "if (m)"? "m" should be valid at this stage.
> >
> > Thanks
> >
> > > + x->props.family = m->new_family;
> > > + memcpy(&x->id.daddr, &m->new_daddr, sizeof(x->id.daddr));
> > > + memcpy(&x->props.saddr, &m->new_saddr, sizeof(x->props.saddr));
> > > + }
> > > +
> > > return x;
>
prev parent reply other threads:[~2025-03-12 13:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 9:16 [PATCH ipsec-next v4 0/2] Update offload configuration with SA Chiachang Wang
2025-03-10 9:16 ` [PATCH ipsec-next v4 1/2] xfrm: Migrate offload configuration Chiachang Wang
2025-03-10 11:54 ` Leon Romanovsky
2025-03-10 9:16 ` [PATCH ipsec-next v4 2/2] xfrm: Refactor migration setup during the cloning process Chiachang Wang
2025-03-10 11:52 ` Leon Romanovsky
2025-03-10 12:20 ` Chiachang Wang
2025-03-12 13:00 ` Leon Romanovsky [this message]
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=20250312130054.GB1322339@unreal \
--to=leon@kernel.org \
--cc=chiachangwang@google.com \
--cc=netdev@vger.kernel.org \
--cc=stanleyjhu@google.com \
--cc=steffen.klassert@secunet.com \
--cc=yumike@google.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).