summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2001-10-04 13:11:48 +0000
committerdwmalone <dwmalone@FreeBSD.org>2001-10-04 13:11:48 +0000
commit86cf053ae0113e103de743ed432880fb2b462149 (patch)
tree6615cc44c88feefec804ce8ebb7cd6284b4483b6 /sys/netgraph
parenta41aa2f6cfba0d70cf320783974b86c4bb644eda (diff)
downloadFreeBSD-src-86cf053ae0113e103de743ed432880fb2b462149.zip
FreeBSD-src-86cf053ae0113e103de743ed432880fb2b462149.tar.gz
Hopefully improve control message passing over Unix domain sockets.
1) Allow the sending of more than one control message at a time over a unix domain socket. This should cover the PR 29499. 2) This requires that unp_{ex,in}ternalize and unp_scan understand mbufs with more than one control message at a time. 3) Internalize and externalize used to work on the mbuf in-place. This made life quite complicated and the code for sizeof(int) < sizeof(file *) could end up doing the wrong thing. The patch always create a new mbuf/cluster now. This resulted in the change of the prototype for the domain externalise function. 4) You can now send SCM_TIMESTAMP messages. 5) Always use CMSG_DATA(cm) to determine the start where the data in unp_{ex,in}ternalize. It was using ((struct cmsghdr *)cm + 1) in some places, which gives the wrong alignment on the alpha. (NetBSD made this fix some time ago). This results in an ABI change for discriptor passing and creds passing on the alpha. (Probably on the IA64 and Spare ports too). 6) Fix userland programs to use CMSG_* macros too. 7) Be more careful about freeing mbufs containing (file *)s. This is made possible by the prototype change of externalise. PR: 29499 MFC after: 6 weeks
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/ng_socket.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index a7e7e20..87924ce 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -583,7 +583,7 @@ ng_internalize(struct mbuf *control, struct thread *td)
}
/* Check there is only one FD. XXX what would more than one signify? */
- oldfds = (cm->cmsg_len - sizeof(*cm)) / sizeof(int);
+ oldfds = ((caddr_t)cm + cm->cmsg_len - (caddr_t)data) / sizeof (int);
if (oldfds != 1) {
TRAP_ERROR;
return (EINVAL);
@@ -591,7 +591,7 @@ ng_internalize(struct mbuf *control, struct thread *td)
/* Check that the FD given is legit. and change it to a pointer to a
* struct file. */
- fd = *(int *) (cm + 1);
+ fd = CMSG_DATA(cm);
if ((unsigned) fd >= fdp->fd_nfiles
|| (fp = fdp->fd_ofiles[fd]) == NULL) {
return (EBADF);
OpenPOWER on IntegriCloud