Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sctp: Remove sctp_copy_sock() and sctp_copy_descendant().

Now, sctp_accept() and sctp_do_peeloff() use sk_clone(), and
we no longer need sctp_copy_sock() and sctp_copy_descendant().

Let's remove them.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20251023231751.4168390-9-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
71068e2e b7ddb55f

+1 -81
-8
include/net/inet_sock.h
··· 355 355 356 356 #define inet_sk(ptr) container_of_const(ptr, struct inet_sock, sk) 357 357 358 - static inline void __inet_sk_copy_descendant(struct sock *sk_to, 359 - const struct sock *sk_from, 360 - const int ancestor_size) 361 - { 362 - memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, 363 - sk_from->sk_prot->obj_size - ancestor_size); 364 - } 365 - 366 358 int inet_sk_rebuild_header(struct sock *sk); 367 359 368 360 /**
+1 -2
include/net/sctp/sctp.h
··· 94 94 __poll_t sctp_poll(struct file *file, struct socket *sock, 95 95 poll_table *wait); 96 96 void sctp_sock_rfree(struct sk_buff *skb); 97 - void sctp_copy_sock(struct sock *newsk, struct sock *sk, 98 - struct sctp_association *asoc); 97 + 99 98 extern struct percpu_counter sctp_sockets_allocated; 100 99 int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *); 101 100 struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int *);
-71
net/sctp/socket.c
··· 9491 9491 sctp_skb_set_owner_r(skb, sk); 9492 9492 } 9493 9493 9494 - void sctp_copy_sock(struct sock *newsk, struct sock *sk, 9495 - struct sctp_association *asoc) 9496 - { 9497 - struct inet_sock *inet = inet_sk(sk); 9498 - struct inet_sock *newinet; 9499 - struct sctp_sock *sp = sctp_sk(sk); 9500 - 9501 - newsk->sk_type = sk->sk_type; 9502 - newsk->sk_bound_dev_if = sk->sk_bound_dev_if; 9503 - newsk->sk_flags = sk->sk_flags; 9504 - newsk->sk_tsflags = sk->sk_tsflags; 9505 - newsk->sk_no_check_tx = sk->sk_no_check_tx; 9506 - newsk->sk_no_check_rx = sk->sk_no_check_rx; 9507 - newsk->sk_reuse = sk->sk_reuse; 9508 - sctp_sk(newsk)->reuse = sp->reuse; 9509 - 9510 - newsk->sk_shutdown = sk->sk_shutdown; 9511 - newsk->sk_destruct = sk->sk_destruct; 9512 - newsk->sk_family = sk->sk_family; 9513 - newsk->sk_protocol = IPPROTO_SCTP; 9514 - newsk->sk_backlog_rcv = sk->sk_prot->backlog_rcv; 9515 - newsk->sk_sndbuf = sk->sk_sndbuf; 9516 - newsk->sk_rcvbuf = sk->sk_rcvbuf; 9517 - newsk->sk_lingertime = sk->sk_lingertime; 9518 - newsk->sk_rcvtimeo = READ_ONCE(sk->sk_rcvtimeo); 9519 - newsk->sk_sndtimeo = READ_ONCE(sk->sk_sndtimeo); 9520 - newsk->sk_rxhash = sk->sk_rxhash; 9521 - newsk->sk_gso_type = sk->sk_gso_type; 9522 - 9523 - newinet = inet_sk(newsk); 9524 - 9525 - /* Initialize sk's sport, dport, rcv_saddr and daddr for 9526 - * getsockname() and getpeername() 9527 - */ 9528 - newinet->inet_sport = inet->inet_sport; 9529 - newinet->inet_saddr = inet->inet_saddr; 9530 - newinet->inet_rcv_saddr = inet->inet_rcv_saddr; 9531 - newinet->inet_dport = htons(asoc->peer.port); 9532 - newinet->pmtudisc = inet->pmtudisc; 9533 - atomic_set(&newinet->inet_id, get_random_u16()); 9534 - 9535 - newinet->uc_ttl = inet->uc_ttl; 9536 - inet_set_bit(MC_LOOP, newsk); 9537 - newinet->mc_ttl = 1; 9538 - newinet->mc_index = 0; 9539 - newinet->mc_list = NULL; 9540 - 9541 - if (newsk->sk_flags & SK_FLAGS_TIMESTAMP) 9542 - net_enable_timestamp(); 9543 - 9544 - /* Set newsk security attributes from original sk and connection 9545 - * security attribute from asoc. 9546 - */ 9547 - security_sctp_sk_clone(asoc, sk, newsk); 9548 - } 9549 - 9550 - static inline void sctp_copy_descendant(struct sock *sk_to, 9551 - const struct sock *sk_from) 9552 - { 9553 - size_t ancestor_size = sizeof(struct inet_sock); 9554 - 9555 - ancestor_size += sk_from->sk_prot->obj_size; 9556 - ancestor_size -= offsetof(struct sctp_sock, pd_lobby); 9557 - __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size); 9558 - } 9559 - 9560 9494 /* Populate the fields of the newsk from the oldsk and migrate the assoc 9561 9495 * and its messages to the newsk. 9562 9496 */ ··· 9506 9572 struct sctp_ulpevent *event; 9507 9573 struct sctp_bind_hashbucket *head; 9508 9574 int err; 9509 - 9510 - /* Migrate all the socket level options to the new socket. 9511 - * Brute force copy old sctp opt. 9512 - */ 9513 - sctp_copy_descendant(newsk, oldsk); 9514 9575 9515 9576 /* Restore the ep value that was overwritten with the above structure 9516 9577 * copy.