summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-04-01 15:42:02 +0000
committerrwatson <rwatson@FreeBSD.org>2006-04-01 15:42:02 +0000
commit5479e5d69217e0a6876338fc7cde604067b679ca (patch)
tree7431f8c0d78c14bc446d524dcda6a00888732015 /sys/netinet
parent68ff3be0b395955e8feac72262824b90a155a710 (diff)
downloadFreeBSD-src-5479e5d69217e0a6876338fc7cde604067b679ca.zip
FreeBSD-src-5479e5d69217e0a6876338fc7cde604067b679ca.tar.gz
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or the protocol flags SS_PROTOREF to take ownership of the socket. soclose() no longer looks at so_pcb to see if it's NULL, relying entirely on the protocol to decide whether it's time to free the socket or not using SS_PROTOREF. so_pcb is now entirely owned and managed by the protocol code. Likewise, no longer test so_pcb in other socket functions, such as soreceive(), which have no business digging into protocol internals. Protocol detach routines no longer try to free the socket on detach, this is performed in the socket code if the protocol permits it. In rts_detach(), no longer test for rp != NULL in detach, and likewise in other protocols that don't permit a NULL so_pcb, reduce the incidence of testing for it during detach. netinet and netinet6 are not fully updated to this change, which will be in an upcoming commit. In their current state they may leak memory or panic. MFC after: 3 months
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_divert.c5
-rw-r--r--sys/netinet/raw_ip.c5
-rw-r--r--sys/netinet/tcp_usrreq.c6
-rw-r--r--sys/netinet/udp_usrreq.c6
4 files changed, 8 insertions, 14 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index b3b1a7c..bb31630 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -424,7 +424,7 @@ div_attach(struct socket *so, int proto, struct thread *td)
return 0;
}
-static int
+static void
div_detach(struct socket *so)
{
struct inpcb *inp;
@@ -433,12 +433,11 @@ div_detach(struct socket *so)
inp = sotoinpcb(so);
if (inp == 0) {
INP_INFO_WUNLOCK(&divcbinfo);
- return EINVAL;
+ return;
}
INP_LOCK(inp);
in_pcbdetach(inp);
INP_INFO_WUNLOCK(&divcbinfo);
- return 0;
}
static int
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index b39e693..b6cf708 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -635,7 +635,7 @@ rip_pcbdetach(struct socket *so, struct inpcb *inp)
in_pcbdetach(inp);
}
-static int
+static void
rip_detach(struct socket *so)
{
struct inpcb *inp;
@@ -645,12 +645,11 @@ rip_detach(struct socket *so)
if (inp == 0) {
/* XXX counter, printf */
INP_INFO_WUNLOCK(&ripcbinfo);
- return EINVAL;
+ return;
}
INP_LOCK(inp);
rip_pcbdetach(so, inp);
INP_INFO_WUNLOCK(&ripcbinfo);
- return 0;
}
static void
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index ff4bd47..902cab6 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -148,10 +148,9 @@ out:
* which may finish later; embryonic TCB's can just
* be discarded here.
*/
-static int
+static void
tcp_usr_detach(struct socket *so)
{
- int error = 0;
struct inpcb *inp;
struct tcpcb *tp;
TCPDEBUG0;
@@ -160,7 +159,7 @@ tcp_usr_detach(struct socket *so)
inp = sotoinpcb(so);
if (inp == NULL) {
INP_INFO_WUNLOCK(&tcbinfo);
- return error;
+ return;
}
INP_LOCK(inp);
tp = intotcpcb(inp);
@@ -171,7 +170,6 @@ tcp_usr_detach(struct socket *so)
if (tp)
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
- return error;
}
#define INI_NOLOCK 0
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 69ba6fe..23d4301 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -125,7 +125,7 @@ SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
static void udp_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
int off, struct sockaddr_in *udp_in);
-static int udp_detach(struct socket *so);
+static void udp_detach(struct socket *so);
static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, struct thread *);
@@ -1027,7 +1027,7 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
return error;
}
-static int
+static void
udp_detach(struct socket *so)
{
struct inpcb *inp;
@@ -1036,12 +1036,10 @@ udp_detach(struct socket *so)
inp = sotoinpcb(so);
if (inp == 0) {
INP_INFO_WUNLOCK(&udbinfo);
- return EINVAL;
}
INP_LOCK(inp);
in_pcbdetach(inp);
INP_INFO_WUNLOCK(&udbinfo);
- return 0;
}
static int
OpenPOWER on IntegriCloud