From d62c4607e8a3613253d613c0d3417cccd02b2c57 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 18 Mar 2024 08:50:30 -0700 Subject: [PATCH] sockets: remove unused KPIs to manipulate sockets These KPIs were added in dd0e6c383a9f0 and through 15 years had zero use. They slightly remind what IfAPI does for struct ifnet. But IfAPI does that for the sake of large collection of NIC drivers not being aware of struct ifnet. For the sockets it is unclear what could be a large collection of externally written kernel modules that need extensively use sockets and not be aware of their internals at the same time. This isolation of a structure knowledge requires a lot of work, and just throwing in a few KPIs isn't helpful. Reviewed by: kib, olce, markj Differential Revision: https://reviews.freebsd.org/D44311 --- sys/kern/uipc_socket.c | 101 ------------------------------------- sys/netinet/in_pcb.c | 7 --- sys/netinet/tcp_fastopen.h | 1 + sys/netinet/tcp_offload.h | 2 + sys/sys/socket.h | 23 --------- 5 files changed, 3 insertions(+), 131 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 18ecf1409fd7..9a29df8b0340 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4254,34 +4254,6 @@ sotoxsocket(struct socket *so, struct xsocket *xso) } } -struct sockbuf * -so_sockbuf_rcv(struct socket *so) -{ - - return (&so->so_rcv); -} - -struct sockbuf * -so_sockbuf_snd(struct socket *so) -{ - - return (&so->so_snd); -} - -int -so_state_get(const struct socket *so) -{ - - return (so->so_state); -} - -void -so_state_set(struct socket *so, int val) -{ - - so->so_state = val; -} - int so_options_get(const struct socket *so) { @@ -4309,76 +4281,3 @@ so_error_set(struct socket *so, int val) so->so_error = val; } - -int -so_linger_get(const struct socket *so) -{ - - return (so->so_linger); -} - -void -so_linger_set(struct socket *so, int val) -{ - - KASSERT(val >= 0 && val <= USHRT_MAX && val <= (INT_MAX / hz), - ("%s: val %d out of range", __func__, val)); - - so->so_linger = val; -} - -struct protosw * -so_protosw_get(const struct socket *so) -{ - - return (so->so_proto); -} - -void -so_protosw_set(struct socket *so, struct protosw *val) -{ - - so->so_proto = val; -} - -void -so_sorwakeup(struct socket *so) -{ - - sorwakeup(so); -} - -void -so_sowwakeup(struct socket *so) -{ - - sowwakeup(so); -} - -void -so_sorwakeup_locked(struct socket *so) -{ - - sorwakeup_locked(so); -} - -void -so_sowwakeup_locked(struct socket *so) -{ - - sowwakeup_locked(so); -} - -void -so_lock(struct socket *so) -{ - - SOCK_LOCK(so); -} - -void -so_unlock(struct socket *so) -{ - - SOCK_UNLOCK(so); -} diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 16a3707e7c89..d966f8e386fe 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2847,13 +2847,6 @@ inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, *fp = inp->inp_fport; } -struct inpcb * -so_sotoinpcb(struct socket *so) -{ - - return (sotoinpcb(so)); -} - /* * Create an external-format (``xinpcb'') structure using the information in * the kernel-format in_pcb structure pointed to by inp. This is done to diff --git a/sys/netinet/tcp_fastopen.h b/sys/netinet/tcp_fastopen.h index ee860941fdb8..f70de4bb8947 100644 --- a/sys/netinet/tcp_fastopen.h +++ b/sys/netinet/tcp_fastopen.h @@ -79,6 +79,7 @@ struct tcp_fastopen_ccache { uint32_t secret; }; +struct tcpcb; #ifdef TCP_RFC7413 void tcp_fastopen_init(void); void tcp_fastopen_destroy(void); diff --git a/sys/netinet/tcp_offload.h b/sys/netinet/tcp_offload.h index b397336ab487..c76408ccd07f 100644 --- a/sys/netinet/tcp_offload.h +++ b/sys/netinet/tcp_offload.h @@ -38,6 +38,8 @@ extern int registered_toedevs; +struct tcpcb; + int tcp_offload_connect(struct socket *, struct sockaddr *); void tcp_offload_listen_start(struct tcpcb *); void tcp_offload_listen_stop(struct tcpcb *); diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 3e24db552618..91fafdec672a 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -713,33 +713,10 @@ __END_DECLS #ifdef _KERNEL struct socket; -struct inpcb *so_sotoinpcb(struct socket *so); -struct sockbuf *so_sockbuf_snd(struct socket *); -struct sockbuf *so_sockbuf_rcv(struct socket *); - -int so_state_get(const struct socket *); -void so_state_set(struct socket *, int); - int so_options_get(const struct socket *); void so_options_set(struct socket *, int); int so_error_get(const struct socket *); void so_error_set(struct socket *, int); - -int so_linger_get(const struct socket *); -void so_linger_set(struct socket *, int); - -struct protosw *so_protosw_get(const struct socket *); -void so_protosw_set(struct socket *, struct protosw *); - -void so_sorwakeup_locked(struct socket *so); -void so_sowwakeup_locked(struct socket *so); - -void so_sorwakeup(struct socket *so); -void so_sowwakeup(struct socket *so); - -void so_lock(struct socket *so); -void so_unlock(struct socket *so); - #endif /* _KERNEL */ #endif /* !_SYS_SOCKET_H_ */