summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_usrreq.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-10-03 13:01:56 +0000
committerrwatson <rwatson@FreeBSD.org>2008-10-03 13:01:56 +0000
commitbbe0e181656adf606748968f5803bb8cbc7d83c8 (patch)
tree6df1e9f9441c9e8cdfb916b2b5f8ce8b0a928b0e /sys/kern/uipc_usrreq.c
parentfa40502272affacff314b996f52032651539d2cd (diff)
downloadFreeBSD-src-bbe0e181656adf606748968f5803bb8cbc7d83c8.zip
FreeBSD-src-bbe0e181656adf606748968f5803bb8cbc7d83c8.tar.gz
Further minor cleanups to UNIX domain sockets:
- Staticize and locally prototype functions uipc_ctloutput(), unp_dispose(), unp_init(), and unp_externalize(), none of which have been required outside of uipc_usrreq.c since uipc_proto.c was removed. - Remove stale prototype for uipc_usrreq(), which has not existed in the code since 1997 - Forward declare and staticize uipc_usrreqs structure in uipc_usrreq.c and not un.h. - Comment on why uipc_connect2() is still non-static -- it is used directly by fifofs. - Remove stale comments, tidy up whitespace. MFC after: 3 days (where applicable)
Diffstat (limited to 'sys/kern/uipc_usrreq.c')
-rw-r--r--sys/kern/uipc_usrreq.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 2ecb4b9..544ab60 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -225,18 +225,22 @@ static struct rwlock unp_global_rwlock;
#define UNP_PCB_UNLOCK(unp) mtx_unlock(&(unp)->unp_mtx)
#define UNP_PCB_LOCK_ASSERT(unp) mtx_assert(&(unp)->unp_mtx, MA_OWNED)
+static int uipc_ctloutput(struct socket *, struct sockopt *);
static int unp_connect(struct socket *, struct sockaddr *,
struct thread *);
static int unp_connect2(struct socket *so, struct socket *so2, int);
static void unp_disconnect(struct unpcb *unp, struct unpcb *unp2);
+static void unp_dispose(struct mbuf *);
static void unp_shutdown(struct unpcb *);
static void unp_drop(struct unpcb *, int);
static void unp_gc(__unused void *, int);
static void unp_scan(struct mbuf *, void (*)(struct file *));
static void unp_discard(struct file *);
static void unp_freerights(struct file **, int);
+static void unp_init(void);
static int unp_internalize(struct mbuf **, struct thread *);
static void unp_internalize_fp(struct file *);
+static int unp_externalize(struct mbuf *, struct mbuf **);
static void unp_externalize_fp(struct file *);
static struct mbuf *unp_addsockcred(struct thread *, struct mbuf *);
@@ -244,6 +248,7 @@ static struct mbuf *unp_addsockcred(struct thread *, struct mbuf *);
* Definitions of protocols supported in the LOCAL domain.
*/
static struct domain localdomain;
+static struct pr_usrreqs uipc_usrreqs;
static struct protosw localsw[] = {
{
.pr_type = SOCK_STREAM,
@@ -523,6 +528,9 @@ uipc_close(struct socket *so)
UNP_GLOBAL_WUNLOCK();
}
+/*
+ * uipc_connect2() is not static as it is invoked directly by fifofs.
+ */
int
uipc_connect2(struct socket *so1, struct socket *so2)
{
@@ -543,8 +551,6 @@ uipc_connect2(struct socket *so1, struct socket *so2)
return (error);
}
-/* control is EOPNOTSUPP */
-
static void
uipc_detach(struct socket *so)
{
@@ -989,7 +995,7 @@ uipc_sockaddr(struct socket *so, struct sockaddr **nam)
return (0);
}
-struct pr_usrreqs uipc_usrreqs = {
+static struct pr_usrreqs uipc_usrreqs = {
.pru_abort = uipc_abort,
.pru_accept = uipc_accept,
.pru_attach = uipc_attach,
@@ -1008,7 +1014,7 @@ struct pr_usrreqs uipc_usrreqs = {
.pru_close = uipc_close,
};
-int
+static int
uipc_ctloutput(struct socket *so, struct sockopt *sopt)
{
struct unpcb *unp;
@@ -1498,7 +1504,6 @@ unp_drop(struct unpcb *unp, int errno)
unp2 = unp->unp_conn;
if (unp2 == NULL)
return;
-
UNP_PCB_LOCK(unp2);
unp_disconnect(unp, unp2);
UNP_PCB_UNLOCK(unp2);
@@ -1523,7 +1528,7 @@ unp_freerights(struct file **rp, int fdcount)
}
}
-int
+static int
unp_externalize(struct mbuf *control, struct mbuf **controlp)
{
struct thread *td = curthread; /* XXX */
@@ -1543,16 +1548,13 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp)
error = 0;
if (controlp != NULL) /* controlp == NULL => free control messages */
*controlp = NULL;
-
while (cm != NULL) {
if (sizeof(*cm) > clen || cm->cmsg_len > clen) {
error = EINVAL;
break;
}
-
data = CMSG_DATA(cm);
datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data;
-
if (cm->cmsg_level == SOL_SOCKET
&& cm->cmsg_type == SCM_RIGHTS) {
newfds = datalen / sizeof(struct file *);
@@ -1613,7 +1615,6 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp)
CMSG_DATA(mtod(*controlp, struct cmsghdr *)),
datalen);
}
-
controlp = &(*controlp)->m_next;
next:
@@ -1628,7 +1629,6 @@ next:
}
m_freem(control);
-
return (error);
}
@@ -1639,7 +1639,7 @@ unp_zone_change(void *tag)
uma_zone_set_max(unp_zone, maxsockets);
}
-void
+static void
unp_init(void)
{
@@ -1677,14 +1677,12 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
error = 0;
*controlp = NULL;
-
while (cm != NULL) {
if (sizeof(*cm) > clen || cm->cmsg_level != SOL_SOCKET
|| cm->cmsg_len > clen) {
error = EINVAL;
goto out;
}
-
data = CMSG_DATA(cm);
datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data;
@@ -1699,7 +1697,6 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
error = ENOBUFS;
goto out;
}
-
cmcred = (struct cmsgcred *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
cmcred->cmcred_pid = p->p_pid;
@@ -1707,7 +1704,7 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
cmcred->cmcred_gid = td->td_ucred->cr_rgid;
cmcred->cmcred_euid = td->td_ucred->cr_uid;
cmcred->cmcred_ngroups = MIN(td->td_ucred->cr_ngroups,
- CMGROUP_MAX);
+ CMGROUP_MAX);
for (i = 0; i < cmcred->cmcred_ngroups; i++)
cmcred->cmcred_groups[i] =
td->td_ucred->cr_groups[i];
@@ -1739,8 +1736,8 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
}
/*
- * Now replace the integer FDs with pointers to
- * the associated global file table entry..
+ * Now replace the integer FDs with pointers to the
+ * associated global file table entry..
*/
newlen = oldfds * sizeof(struct file *);
*controlp = sbcreatecontrol(NULL, newlen,
@@ -1750,7 +1747,6 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
error = E2BIG;
goto out;
}
-
fdp = data;
rp = (struct file **)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
@@ -1780,7 +1776,6 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
}
controlp = &(*controlp)->m_next;
-
if (CMSG_SPACE(datalen) < clen) {
clen -= CMSG_SPACE(datalen);
cm = (struct cmsghdr *)
@@ -1793,7 +1788,6 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
out:
m_freem(control);
-
return (error);
}
@@ -1807,7 +1801,6 @@ unp_addsockcred(struct thread *td, struct mbuf *control)
int i;
ngroups = MIN(td->td_ucred->cr_ngroups, CMGROUP_MAX);
-
m = sbcreatecontrol(NULL, SOCKCREDSIZE(ngroups), SCM_CREDS, SOL_SOCKET);
if (m == NULL)
return (control);
@@ -1844,7 +1837,6 @@ unp_addsockcred(struct thread *td, struct mbuf *control)
/* Prepend it to the head. */
m->m_next = control;
-
return (m);
}
@@ -2047,7 +2039,7 @@ unp_gc(__unused void *arg, int pending)
free(unref, M_TEMP);
}
-void
+static void
unp_dispose(struct mbuf *m)
{
OpenPOWER on IntegriCloud