git: 97958f5d5c67 - main - netlink: simplify socket destruction

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 27 Dec 2023 04:24:54 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=97958f5d5c674de5d05a6b547cb1c45f8c58791b

commit 97958f5d5c674de5d05a6b547cb1c45f8c58791b
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-12-27 04:22:12 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-12-27 04:22:12 +0000

    netlink: simplify socket destruction
    
    Destroy the socket at the file descriptor close(2).  There is no
    reason to linger for any longer, there are no external references.
    Remove pr_detach method as nothing left to do after pr_close.
    Remove pr_abort method as it shall never be executed for this type
    of socket.
    
    Reviewed by:            melifaro
    Differential Revision:  https://reviews.freebsd.org/D42521
---
 sys/netlink/netlink_domain.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/sys/netlink/netlink_domain.c b/sys/netlink/netlink_domain.c
index 1b48ac65cec1..38f4a2dfed94 100644
--- a/sys/netlink/netlink_domain.c
+++ b/sys/netlink/netlink_domain.c
@@ -360,14 +360,6 @@ nl_pru_attach(struct socket *so, int proto, struct thread *td)
 	return (0);
 }
 
-static void
-nl_pru_abort(struct socket *so)
-{
-	NL_LOG(LOG_DEBUG3, "socket %p, PID %d", so, curproc->p_pid);
-	MPASS(sotonlpcb(so) != NULL);
-	soisdisconnected(so);
-}
-
 static int
 nl_pru_bind(struct socket *so, struct sockaddr *sa, struct thread *td)
 {
@@ -494,7 +486,7 @@ destroy_nlpcb_epoch(epoch_context_t ctx)
 
 
 static void
-nl_pru_detach(struct socket *so)
+nl_close(struct socket *so)
 {
 	struct nl_control *ctl = atomic_load_ptr(&V_nl_ctl);
 	MPASS(sotonlpcb(so) != NULL);
@@ -563,14 +555,6 @@ nl_sockaddr(struct socket *so, struct sockaddr *sa)
 	return (0);
 }
 
-static void
-nl_pru_close(struct socket *so)
-{
-	NL_LOG(LOG_DEBUG3, "socket %p, PID %d", so, curproc->p_pid);
-	MPASS(sotonlpcb(so) != NULL);
-	soisdisconnected(so);
-}
-
 static int
 nl_pru_output(struct mbuf *m, struct socket *so, ...)
 {
@@ -766,17 +750,15 @@ nl_setsbopt(struct socket *so, struct sockopt *sopt)
 	.pr_flags = PR_ATOMIC | PR_ADDR | PR_WANTRCVD,		\
 	.pr_ctloutput = nl_ctloutput,				\
 	.pr_setsbopt = nl_setsbopt,				\
-	.pr_abort = nl_pru_abort,				\
 	.pr_attach = nl_pru_attach,				\
 	.pr_bind = nl_pru_bind,					\
 	.pr_connect = nl_pru_connect,				\
-	.pr_detach = nl_pru_detach,				\
 	.pr_disconnect = nl_pru_disconnect,			\
 	.pr_send = nl_pru_send,					\
 	.pr_rcvd = nl_pru_rcvd,					\
 	.pr_shutdown = nl_pru_shutdown,				\
 	.pr_sockaddr = nl_sockaddr,				\
-	.pr_close = nl_pru_close
+	.pr_close = nl_close
 
 static struct protosw netlink_raw_sw = {
 	.pr_type = SOCK_RAW,