mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
b7ddb55f31
commit
71068e2e1b
|
|
@ -355,14 +355,6 @@ static inline struct sock *skb_to_full_sk(const struct sk_buff *skb)
|
|||
|
||||
#define inet_sk(ptr) container_of_const(ptr, struct inet_sock, sk)
|
||||
|
||||
static inline void __inet_sk_copy_descendant(struct sock *sk_to,
|
||||
const struct sock *sk_from,
|
||||
const int ancestor_size)
|
||||
{
|
||||
memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1,
|
||||
sk_from->sk_prot->obj_size - ancestor_size);
|
||||
}
|
||||
|
||||
int inet_sk_rebuild_header(struct sock *sk);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ void sctp_data_ready(struct sock *sk);
|
|||
__poll_t sctp_poll(struct file *file, struct socket *sock,
|
||||
poll_table *wait);
|
||||
void sctp_sock_rfree(struct sk_buff *skb);
|
||||
void sctp_copy_sock(struct sock *newsk, struct sock *sk,
|
||||
struct sctp_association *asoc);
|
||||
|
||||
extern struct percpu_counter sctp_sockets_allocated;
|
||||
int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *);
|
||||
struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int *);
|
||||
|
|
|
|||
|
|
@ -9491,72 +9491,6 @@ static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk)
|
|||
sctp_skb_set_owner_r(skb, sk);
|
||||
}
|
||||
|
||||
void sctp_copy_sock(struct sock *newsk, struct sock *sk,
|
||||
struct sctp_association *asoc)
|
||||
{
|
||||
struct inet_sock *inet = inet_sk(sk);
|
||||
struct inet_sock *newinet;
|
||||
struct sctp_sock *sp = sctp_sk(sk);
|
||||
|
||||
newsk->sk_type = sk->sk_type;
|
||||
newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
|
||||
newsk->sk_flags = sk->sk_flags;
|
||||
newsk->sk_tsflags = sk->sk_tsflags;
|
||||
newsk->sk_no_check_tx = sk->sk_no_check_tx;
|
||||
newsk->sk_no_check_rx = sk->sk_no_check_rx;
|
||||
newsk->sk_reuse = sk->sk_reuse;
|
||||
sctp_sk(newsk)->reuse = sp->reuse;
|
||||
|
||||
newsk->sk_shutdown = sk->sk_shutdown;
|
||||
newsk->sk_destruct = sk->sk_destruct;
|
||||
newsk->sk_family = sk->sk_family;
|
||||
newsk->sk_protocol = IPPROTO_SCTP;
|
||||
newsk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
|
||||
newsk->sk_sndbuf = sk->sk_sndbuf;
|
||||
newsk->sk_rcvbuf = sk->sk_rcvbuf;
|
||||
newsk->sk_lingertime = sk->sk_lingertime;
|
||||
newsk->sk_rcvtimeo = READ_ONCE(sk->sk_rcvtimeo);
|
||||
newsk->sk_sndtimeo = READ_ONCE(sk->sk_sndtimeo);
|
||||
newsk->sk_rxhash = sk->sk_rxhash;
|
||||
newsk->sk_gso_type = sk->sk_gso_type;
|
||||
|
||||
newinet = inet_sk(newsk);
|
||||
|
||||
/* Initialize sk's sport, dport, rcv_saddr and daddr for
|
||||
* getsockname() and getpeername()
|
||||
*/
|
||||
newinet->inet_sport = inet->inet_sport;
|
||||
newinet->inet_saddr = inet->inet_saddr;
|
||||
newinet->inet_rcv_saddr = inet->inet_rcv_saddr;
|
||||
newinet->inet_dport = htons(asoc->peer.port);
|
||||
newinet->pmtudisc = inet->pmtudisc;
|
||||
atomic_set(&newinet->inet_id, get_random_u16());
|
||||
|
||||
newinet->uc_ttl = inet->uc_ttl;
|
||||
inet_set_bit(MC_LOOP, newsk);
|
||||
newinet->mc_ttl = 1;
|
||||
newinet->mc_index = 0;
|
||||
newinet->mc_list = NULL;
|
||||
|
||||
if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
|
||||
net_enable_timestamp();
|
||||
|
||||
/* Set newsk security attributes from original sk and connection
|
||||
* security attribute from asoc.
|
||||
*/
|
||||
security_sctp_sk_clone(asoc, sk, newsk);
|
||||
}
|
||||
|
||||
static inline void sctp_copy_descendant(struct sock *sk_to,
|
||||
const struct sock *sk_from)
|
||||
{
|
||||
size_t ancestor_size = sizeof(struct inet_sock);
|
||||
|
||||
ancestor_size += sk_from->sk_prot->obj_size;
|
||||
ancestor_size -= offsetof(struct sctp_sock, pd_lobby);
|
||||
__inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
|
||||
}
|
||||
|
||||
/* Populate the fields of the newsk from the oldsk and migrate the assoc
|
||||
* and its messages to the newsk.
|
||||
*/
|
||||
|
|
@ -9573,11 +9507,6 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
|
|||
struct sctp_bind_hashbucket *head;
|
||||
int err;
|
||||
|
||||
/* Migrate all the socket level options to the new socket.
|
||||
* Brute force copy old sctp opt.
|
||||
*/
|
||||
sctp_copy_descendant(newsk, oldsk);
|
||||
|
||||
/* Restore the ep value that was overwritten with the above structure
|
||||
* copy.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue