Re: [PATCH v3 net-next 5/8] sctp: Use sk_clone() in sctp_accept().
Xin Long <[email protected]>
| Newsgroups | org.kernel.vger.linux-sctp,org.kernel.vger.netdev |
|---|---|
| Message-ID | <CADvbK_fnzXPNiLTQ9fV0P8ZYaw1au8iwMoijsmgHmcGbyS=0dg@mail.gmail.com> |
On Thu, Oct 23, 2025 at 7:18 PM Kuniyuki Iwashima <[email protected]> wrote: > > sctp_accept() calls sctp_v[46]_create_accept_sk() to allocate a new > socket and calls sctp_sock_migrate() to copy fields from the parent > socket to the new socket. > > sctp_v4_create_accept_sk() allocates sk by sk_alloc(), initialises > it by sock_init_data(), and copy a bunch of fields from the parent > socekt by sctp_copy_sock(). > > sctp_sock_migrate() calls sctp_copy_descendant() to copy most fields > in sctp_sock from the parent socket by memcpy(). > > These can be simply replaced by sk_clone(). > > Let's consolidate sctp_v[46]_create_accept_sk() to sctp_clone_sock() > with sk_clone(). > > We will reuse sctp_clone_sock() for sctp_do_peeloff() and then remove > sctp_copy_descendant(). > > Note that sock_reset_flag(newsk, SOCK_ZAPPED) is not copied to > sctp_clone_sock() as sctp does not use SOCK_ZAPPED at all. > > Signed-off-by: Kuniyuki Iwashima <[email protected]> Nice patch for the dup sk copy code cleanup. Thanks. Acked-by: Xin Long <[email protected]>