]> Gentwo Git Trees - linux/.git/commit
sctp: Use sk_clone() in sctp_accept().
authorKuniyuki Iwashima <kuniyu@google.com>
Thu, 23 Oct 2025 23:16:54 +0000 (23:16 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 28 Oct 2025 01:04:58 +0000 (18:04 -0700)
commit16942cf4d3e31b6246b7d000dd823f7b0b38bf8c
tree2ff3c151daae714a0cc0ffdaab2e030c1102a061
parent151b98d10ef7c3174465e409b99d8762e7e8de60
sctp: Use sk_clone() in sctp_accept().

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 <kuniyu@google.com>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20251023231751.4168390-6-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/af_inet.c
net/sctp/socket.c