Deleted Added
full compact
uipc_syscalls.c (98849) uipc_syscalls.c (98995)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
37 * $FreeBSD: head/sys/kern/uipc_syscalls.c 98849 2002-06-26 03:37:47Z ken $
37 * $FreeBSD: head/sys/kern/uipc_syscalls.c 98995 2002-06-28 23:48:23Z alfred $
38 */
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

--- 24 unchanged lines hidden (view full) ---

70#include <vm/vm_page.h>
71#include <vm/vm_pageout.h>
72#include <vm/vm_kern.h>
73#include <vm/vm_extern.h>
74
75static void sf_buf_init(void *arg);
76SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL)
77struct sf_buf *sf_buf_alloc(void);
38 */
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>

--- 24 unchanged lines hidden (view full) ---

70#include <vm/vm_page.h>
71#include <vm/vm_pageout.h>
72#include <vm/vm_kern.h>
73#include <vm/vm_extern.h>
74
75static void sf_buf_init(void *arg);
76SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL)
77struct sf_buf *sf_buf_alloc(void);
78void sf_buf_free(caddr_t addr, void *args);
78void sf_buf_free(void *addr, void *args);
79
80static int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
79
80static int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
81static int recvit(struct thread *td, int s, struct msghdr *mp,
82 caddr_t namelenp);
81static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp);
83
84static int accept1(struct thread *td, struct accept_args *uap, int compat);
85static int getsockname1(struct thread *td, struct getsockname_args *uap,
86 int compat);
87static int getpeername1(struct thread *td, struct getpeername_args *uap,
88 int compat);
89
90/*

--- 47 unchanged lines hidden (view full) ---

138 if (error) {
139 if (fdp->fd_ofiles[fd] == fp) {
140 fdp->fd_ofiles[fd] = NULL;
141 FILEDESC_UNLOCK(fdp);
142 fdrop(fp, td);
143 } else
144 FILEDESC_UNLOCK(fdp);
145 } else {
82
83static int accept1(struct thread *td, struct accept_args *uap, int compat);
84static int getsockname1(struct thread *td, struct getsockname_args *uap,
85 int compat);
86static int getpeername1(struct thread *td, struct getpeername_args *uap,
87 int compat);
88
89/*

--- 47 unchanged lines hidden (view full) ---

137 if (error) {
138 if (fdp->fd_ofiles[fd] == fp) {
139 fdp->fd_ofiles[fd] = NULL;
140 FILEDESC_UNLOCK(fdp);
141 fdrop(fp, td);
142 } else
143 FILEDESC_UNLOCK(fdp);
144 } else {
146 fp->f_data = (caddr_t)so; /* already has ref count */
145 fp->f_data = so; /* already has ref count */
147 fp->f_flag = FREAD|FWRITE;
148 fp->f_ops = &socketops;
149 fp->f_type = DTYPE_SOCKET;
150 FILEDESC_UNLOCK(fdp);
151 td->td_retval[0] = fd;
152 }
153 fdrop(fp, td);
154done2:

--- 76 unchanged lines hidden (view full) ---

231 int namelen, error, s;
232 struct socket *head, *so;
233 int fd;
234 u_int fflag;
235
236 mtx_lock(&Giant);
237 fdp = td->td_proc->p_fd;
238 if (uap->name) {
146 fp->f_flag = FREAD|FWRITE;
147 fp->f_ops = &socketops;
148 fp->f_type = DTYPE_SOCKET;
149 FILEDESC_UNLOCK(fdp);
150 td->td_retval[0] = fd;
151 }
152 fdrop(fp, td);
153done2:

--- 76 unchanged lines hidden (view full) ---

230 int namelen, error, s;
231 struct socket *head, *so;
232 int fd;
233 u_int fflag;
234
235 mtx_lock(&Giant);
236 fdp = td->td_proc->p_fd;
237 if (uap->name) {
239 error = copyin((caddr_t)uap->anamelen, (caddr_t)&namelen,
240 sizeof (namelen));
238 error = copyin(uap->anamelen, &namelen, sizeof (namelen));
241 if(error)
242 goto done2;
243 }
244 error = fgetsock(td, uap->s, &head, &fflag);
245 if (error)
246 goto done2;
247 s = splnet();
248 if ((head->so_options & SO_ACCEPTCONN) == 0) {

--- 6 unchanged lines hidden (view full) ---

255 error = EWOULDBLOCK;
256 goto done;
257 }
258 while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) {
259 if (head->so_state & SS_CANTRCVMORE) {
260 head->so_error = ECONNABORTED;
261 break;
262 }
239 if(error)
240 goto done2;
241 }
242 error = fgetsock(td, uap->s, &head, &fflag);
243 if (error)
244 goto done2;
245 s = splnet();
246 if ((head->so_options & SO_ACCEPTCONN) == 0) {

--- 6 unchanged lines hidden (view full) ---

253 error = EWOULDBLOCK;
254 goto done;
255 }
256 while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) {
257 if (head->so_state & SS_CANTRCVMORE) {
258 head->so_error = ECONNABORTED;
259 break;
260 }
263 error = tsleep((caddr_t)&head->so_timeo, PSOCK | PCATCH,
261 error = tsleep(&head->so_timeo, PSOCK | PCATCH,
264 "accept", 0);
265 if (error) {
266 splx(s);
267 goto done;
268 }
269 }
270 if (head->so_error) {
271 error = head->so_error;

--- 35 unchanged lines hidden (view full) ---

307
308 so->so_state &= ~SS_COMP;
309 so->so_head = NULL;
310 if (head->so_sigio != NULL)
311 fsetown(fgetown(head->so_sigio), &so->so_sigio);
312
313 FILE_LOCK(nfp);
314 soref(so); /* file descriptor reference */
262 "accept", 0);
263 if (error) {
264 splx(s);
265 goto done;
266 }
267 }
268 if (head->so_error) {
269 error = head->so_error;

--- 35 unchanged lines hidden (view full) ---

305
306 so->so_state &= ~SS_COMP;
307 so->so_head = NULL;
308 if (head->so_sigio != NULL)
309 fsetown(fgetown(head->so_sigio), &so->so_sigio);
310
311 FILE_LOCK(nfp);
312 soref(so); /* file descriptor reference */
315 nfp->f_data = (caddr_t)so; /* nfp has ref count from falloc */
313 nfp->f_data = so; /* nfp has ref count from falloc */
316 nfp->f_flag = fflag;
317 nfp->f_ops = &socketops;
318 nfp->f_type = DTYPE_SOCKET;
319 FILE_UNLOCK(nfp);
320 sa = 0;
321 error = soaccept(so, &sa);
322 if (error) {
323 /*
324 * return a namelen of zero for older code which might
325 * ignore the return value from accept.
326 */
327 if (uap->name != NULL) {
328 namelen = 0;
314 nfp->f_flag = fflag;
315 nfp->f_ops = &socketops;
316 nfp->f_type = DTYPE_SOCKET;
317 FILE_UNLOCK(nfp);
318 sa = 0;
319 error = soaccept(so, &sa);
320 if (error) {
321 /*
322 * return a namelen of zero for older code which might
323 * ignore the return value from accept.
324 */
325 if (uap->name != NULL) {
326 namelen = 0;
329 (void) copyout((caddr_t)&namelen,
330 (caddr_t)uap->anamelen, sizeof(*uap->anamelen));
327 (void) copyout(&namelen,
328 uap->anamelen, sizeof(*uap->anamelen));
331 }
332 goto noconnection;
333 }
334 if (sa == NULL) {
335 namelen = 0;
336 if (uap->name)
337 goto gotnoname;
338 splx(s);

--- 4 unchanged lines hidden (view full) ---

343 /* check sa_len before it is destroyed */
344 if (namelen > sa->sa_len)
345 namelen = sa->sa_len;
346#ifdef COMPAT_OLDSOCK
347 if (compat)
348 ((struct osockaddr *)sa)->sa_family =
349 sa->sa_family;
350#endif
329 }
330 goto noconnection;
331 }
332 if (sa == NULL) {
333 namelen = 0;
334 if (uap->name)
335 goto gotnoname;
336 splx(s);

--- 4 unchanged lines hidden (view full) ---

341 /* check sa_len before it is destroyed */
342 if (namelen > sa->sa_len)
343 namelen = sa->sa_len;
344#ifdef COMPAT_OLDSOCK
345 if (compat)
346 ((struct osockaddr *)sa)->sa_family =
347 sa->sa_family;
348#endif
351 error = copyout(sa, (caddr_t)uap->name, (u_int)namelen);
349 error = copyout(sa, uap->name, (u_int)namelen);
352 if (!error)
353gotnoname:
350 if (!error)
351gotnoname:
354 error = copyout((caddr_t)&namelen,
355 (caddr_t)uap->anamelen, sizeof (*uap->anamelen));
352 error = copyout(&namelen,
353 uap->anamelen, sizeof (*uap->anamelen));
356 }
357noconnection:
358 if (sa)
359 FREE(sa, M_SONAME);
360
361 /*
362 * close the new descriptor, assuming someone hasn't ripped it
363 * out from under us.

--- 80 unchanged lines hidden (view full) ---

444 goto bad;
445 if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
446 FREE(sa, M_SONAME);
447 error = EINPROGRESS;
448 goto done1;
449 }
450 s = splnet();
451 while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
354 }
355noconnection:
356 if (sa)
357 FREE(sa, M_SONAME);
358
359 /*
360 * close the new descriptor, assuming someone hasn't ripped it
361 * out from under us.

--- 80 unchanged lines hidden (view full) ---

442 goto bad;
443 if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
444 FREE(sa, M_SONAME);
445 error = EINPROGRESS;
446 goto done1;
447 }
448 s = splnet();
449 while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
452 error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH, "connec", 0);
450 error = tsleep(&so->so_timeo, PSOCK | PCATCH, "connec", 0);
453 if (error)
454 break;
455 }
456 if (error == 0) {
457 error = so->so_error;
458 so->so_error = 0;
459 }
460 splx(s);

--- 36 unchanged lines hidden (view full) ---

497 td->td_ucred, td);
498 if (error)
499 goto free1;
500 error = falloc(td, &fp1, &fd);
501 if (error)
502 goto free2;
503 fhold(fp1);
504 sv[0] = fd;
451 if (error)
452 break;
453 }
454 if (error == 0) {
455 error = so->so_error;
456 so->so_error = 0;
457 }
458 splx(s);

--- 36 unchanged lines hidden (view full) ---

495 td->td_ucred, td);
496 if (error)
497 goto free1;
498 error = falloc(td, &fp1, &fd);
499 if (error)
500 goto free2;
501 fhold(fp1);
502 sv[0] = fd;
505 fp1->f_data = (caddr_t)so1; /* so1 already has ref count */
503 fp1->f_data = so1; /* so1 already has ref count */
506 error = falloc(td, &fp2, &fd);
507 if (error)
508 goto free3;
509 fhold(fp2);
504 error = falloc(td, &fp2, &fd);
505 if (error)
506 goto free3;
507 fhold(fp2);
510 fp2->f_data = (caddr_t)so2; /* so2 already has ref count */
508 fp2->f_data = so2; /* so2 already has ref count */
511 sv[1] = fd;
512 error = soconnect2(so1, so2);
513 if (error)
514 goto free4;
515 if (uap->type == SOCK_DGRAM) {
516 /*
517 * Datagram socket connection is asymmetric.
518 */

--- 6 unchanged lines hidden (view full) ---

525 fp1->f_ops = &socketops;
526 fp1->f_type = DTYPE_SOCKET;
527 FILE_UNLOCK(fp1);
528 FILE_LOCK(fp2);
529 fp2->f_flag = FREAD|FWRITE;
530 fp2->f_ops = &socketops;
531 fp2->f_type = DTYPE_SOCKET;
532 FILE_UNLOCK(fp2);
509 sv[1] = fd;
510 error = soconnect2(so1, so2);
511 if (error)
512 goto free4;
513 if (uap->type == SOCK_DGRAM) {
514 /*
515 * Datagram socket connection is asymmetric.
516 */

--- 6 unchanged lines hidden (view full) ---

523 fp1->f_ops = &socketops;
524 fp1->f_type = DTYPE_SOCKET;
525 FILE_UNLOCK(fp1);
526 FILE_LOCK(fp2);
527 fp2->f_flag = FREAD|FWRITE;
528 fp2->f_ops = &socketops;
529 fp2->f_type = DTYPE_SOCKET;
530 FILE_UNLOCK(fp2);
533 error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
531 error = copyout(sv, uap->rsv, 2 * sizeof (int));
534 fdrop(fp1, td);
535 fdrop(fp2, td);
536 goto done2;
537free4:
538 FILEDESC_LOCK(fdp);
539 if (fdp->fd_ofiles[sv[1]] == fp2) {
540 fdp->fd_ofiles[sv[1]] = NULL;
541 FILEDESC_UNLOCK(fdp);

--- 91 unchanged lines hidden (view full) ---

633#endif
634 } else {
635 control = 0;
636 }
637#ifdef KTRACE
638 if (KTRPOINT(td, KTR_GENIO)) {
639 iovlen = auio.uio_iovcnt * sizeof (struct iovec);
640 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
532 fdrop(fp1, td);
533 fdrop(fp2, td);
534 goto done2;
535free4:
536 FILEDESC_LOCK(fdp);
537 if (fdp->fd_ofiles[sv[1]] == fp2) {
538 fdp->fd_ofiles[sv[1]] = NULL;
539 FILEDESC_UNLOCK(fdp);

--- 91 unchanged lines hidden (view full) ---

631#endif
632 } else {
633 control = 0;
634 }
635#ifdef KTRACE
636 if (KTRPOINT(td, KTR_GENIO)) {
637 iovlen = auio.uio_iovcnt * sizeof (struct iovec);
638 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
641 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
639 bcopy(auio.uio_iov, ktriov, iovlen);
642 ktruio = auio;
643 }
644#endif
645 len = auio.uio_resid;
646 error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
647 flags, td);
648 if (error) {
649 if (auio.uio_resid != len && (error == ERESTART ||

--- 104 unchanged lines hidden (view full) ---

754 int flags;
755 } */ *uap;
756{
757 struct msghdr msg;
758 struct iovec aiov[UIO_SMALLIOV], *iov;
759 int error;
760
761 mtx_lock(&Giant);
640 ktruio = auio;
641 }
642#endif
643 len = auio.uio_resid;
644 error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
645 flags, td);
646 if (error) {
647 if (auio.uio_resid != len && (error == ERESTART ||

--- 104 unchanged lines hidden (view full) ---

752 int flags;
753 } */ *uap;
754{
755 struct msghdr msg;
756 struct iovec aiov[UIO_SMALLIOV], *iov;
757 int error;
758
759 mtx_lock(&Giant);
762 error = copyin(uap->msg, (caddr_t)&msg, sizeof (struct omsghdr));
760 error = copyin(uap->msg, &msg, sizeof (struct omsghdr));
763 if (error)
764 goto done2;
765 if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
766 if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) {
767 error = EMSGSIZE;
768 goto done2;
769 }
770 MALLOC(iov, struct iovec *,
771 sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
772 M_WAITOK);
773 } else {
774 iov = aiov;
775 }
761 if (error)
762 goto done2;
763 if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
764 if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) {
765 error = EMSGSIZE;
766 goto done2;
767 }
768 MALLOC(iov, struct iovec *,
769 sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
770 M_WAITOK);
771 } else {
772 iov = aiov;
773 }
776 error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
774 error = copyin(msg.msg_iov, iov,
777 (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
778 if (error)
779 goto done;
780 msg.msg_flags = MSG_COMPAT;
781 msg.msg_iov = iov;
782 error = sendit(td, uap->s, &msg, uap->flags);
783done:
784 if (iov != aiov)

--- 16 unchanged lines hidden (view full) ---

801 int flags;
802 } */ *uap;
803{
804 struct msghdr msg;
805 struct iovec aiov[UIO_SMALLIOV], *iov;
806 int error;
807
808 mtx_lock(&Giant);
775 (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
776 if (error)
777 goto done;
778 msg.msg_flags = MSG_COMPAT;
779 msg.msg_iov = iov;
780 error = sendit(td, uap->s, &msg, uap->flags);
781done:
782 if (iov != aiov)

--- 16 unchanged lines hidden (view full) ---

799 int flags;
800 } */ *uap;
801{
802 struct msghdr msg;
803 struct iovec aiov[UIO_SMALLIOV], *iov;
804 int error;
805
806 mtx_lock(&Giant);
809 error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg));
807 error = copyin(uap->msg, &msg, sizeof (msg));
810 if (error)
811 goto done2;
812 if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
813 if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) {
814 error = EMSGSIZE;
815 goto done2;
816 }
817 MALLOC(iov, struct iovec *,
818 sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
819 M_WAITOK);
820 } else {
821 iov = aiov;
822 }
823 if (msg.msg_iovlen &&
808 if (error)
809 goto done2;
810 if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
811 if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) {
812 error = EMSGSIZE;
813 goto done2;
814 }
815 MALLOC(iov, struct iovec *,
816 sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
817 M_WAITOK);
818 } else {
819 iov = aiov;
820 }
821 if (msg.msg_iovlen &&
824 (error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
822 (error = copyin(msg.msg_iov, iov,
825 (unsigned)(msg.msg_iovlen * sizeof (struct iovec)))))
826 goto done;
827 msg.msg_iov = iov;
828#ifdef COMPAT_OLDSOCK
829 msg.msg_flags = 0;
830#endif
831 error = sendit(td, uap->s, &msg, uap->flags);
832done:

--- 4 unchanged lines hidden (view full) ---

837 return (error);
838}
839
840static int
841recvit(td, s, mp, namelenp)
842 register struct thread *td;
843 int s;
844 register struct msghdr *mp;
823 (unsigned)(msg.msg_iovlen * sizeof (struct iovec)))))
824 goto done;
825 msg.msg_iov = iov;
826#ifdef COMPAT_OLDSOCK
827 msg.msg_flags = 0;
828#endif
829 error = sendit(td, uap->s, &msg, uap->flags);
830done:

--- 4 unchanged lines hidden (view full) ---

835 return (error);
836}
837
838static int
839recvit(td, s, mp, namelenp)
840 register struct thread *td;
841 int s;
842 register struct msghdr *mp;
845 caddr_t namelenp;
843 void *namelenp;
846{
847 struct uio auio;
848 register struct iovec *iov;
849 register int i;
850 int len, error;
851 struct mbuf *m, *control = 0;
852 caddr_t ctlbuf;
853 struct socket *so;

--- 19 unchanged lines hidden (view full) ---

873 fputsock(so);
874 return (EINVAL);
875 }
876 }
877#ifdef KTRACE
878 if (KTRPOINT(td, KTR_GENIO)) {
879 iovlen = auio.uio_iovcnt * sizeof (struct iovec);
880 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
844{
845 struct uio auio;
846 register struct iovec *iov;
847 register int i;
848 int len, error;
849 struct mbuf *m, *control = 0;
850 caddr_t ctlbuf;
851 struct socket *so;

--- 19 unchanged lines hidden (view full) ---

871 fputsock(so);
872 return (EINVAL);
873 }
874 }
875#ifdef KTRACE
876 if (KTRPOINT(td, KTR_GENIO)) {
877 iovlen = auio.uio_iovcnt * sizeof (struct iovec);
878 MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
881 bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
879 bcopy(auio.uio_iov, ktriov, iovlen);
882 ktruio = auio;
883 }
884#endif
885 len = auio.uio_resid;
886 error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
887 (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
888 &mp->msg_flags);
889 if (error) {

--- 24 unchanged lines hidden (view full) ---

914#endif
915 /* save sa_len before it is destroyed by MSG_COMPAT */
916 len = MIN(len, fromsa->sa_len);
917#ifdef COMPAT_OLDSOCK
918 if (mp->msg_flags & MSG_COMPAT)
919 ((struct osockaddr *)fromsa)->sa_family =
920 fromsa->sa_family;
921#endif
880 ktruio = auio;
881 }
882#endif
883 len = auio.uio_resid;
884 error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
885 (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
886 &mp->msg_flags);
887 if (error) {

--- 24 unchanged lines hidden (view full) ---

912#endif
913 /* save sa_len before it is destroyed by MSG_COMPAT */
914 len = MIN(len, fromsa->sa_len);
915#ifdef COMPAT_OLDSOCK
916 if (mp->msg_flags & MSG_COMPAT)
917 ((struct osockaddr *)fromsa)->sa_family =
918 fromsa->sa_family;
919#endif
922 error = copyout(fromsa,
923 (caddr_t)mp->msg_name, (unsigned)len);
920 error = copyout(fromsa, mp->msg_name, (unsigned)len);
924 if (error)
925 goto out;
926 }
927 mp->msg_namelen = len;
928 if (namelenp &&
921 if (error)
922 goto out;
923 }
924 mp->msg_namelen = len;
925 if (namelenp &&
929 (error = copyout((caddr_t)&len, namelenp, sizeof (int)))) {
926 (error = copyout(&len, namelenp, sizeof (int)))) {
930#ifdef COMPAT_OLDSOCK
931 if (mp->msg_flags & MSG_COMPAT)
932 error = 0; /* old recvfrom didn't check */
933 else
934#endif
935 goto out;
936 }
937 }

--- 16 unchanged lines hidden (view full) ---

954 }
955 control->m_len -= sizeof (struct cmsghdr);
956 control->m_data += sizeof (struct cmsghdr);
957 }
958#endif
959 len = mp->msg_controllen;
960 m = control;
961 mp->msg_controllen = 0;
927#ifdef COMPAT_OLDSOCK
928 if (mp->msg_flags & MSG_COMPAT)
929 error = 0; /* old recvfrom didn't check */
930 else
931#endif
932 goto out;
933 }
934 }

--- 16 unchanged lines hidden (view full) ---

951 }
952 control->m_len -= sizeof (struct cmsghdr);
953 control->m_data += sizeof (struct cmsghdr);
954 }
955#endif
956 len = mp->msg_controllen;
957 m = control;
958 mp->msg_controllen = 0;
962 ctlbuf = (caddr_t) mp->msg_control;
959 ctlbuf = mp->msg_control;
963
964 while (m && len > 0) {
965 unsigned int tocopy;
966
967 if (len >= m->m_len)
968 tocopy = m->m_len;
969 else {
970 mp->msg_flags |= MSG_CTRUNC;
971 tocopy = len;
972 }
973
960
961 while (m && len > 0) {
962 unsigned int tocopy;
963
964 if (len >= m->m_len)
965 tocopy = m->m_len;
966 else {
967 mp->msg_flags |= MSG_CTRUNC;
968 tocopy = len;
969 }
970
974 if ((error = copyout((caddr_t)mtod(m, caddr_t),
971 if ((error = copyout(mtod(m, caddr_t),
975 ctlbuf, tocopy)) != 0)
976 goto out;
977
978 ctlbuf += tocopy;
979 len -= tocopy;
980 m = m->m_next;
981 }
982 mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control;

--- 23 unchanged lines hidden (view full) ---

1006 } */ *uap;
1007{
1008 struct msghdr msg;
1009 struct iovec aiov;
1010 int error;
1011
1012 mtx_lock(&Giant);
1013 if (uap->fromlenaddr) {
972 ctlbuf, tocopy)) != 0)
973 goto out;
974
975 ctlbuf += tocopy;
976 len -= tocopy;
977 m = m->m_next;
978 }
979 mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control;

--- 23 unchanged lines hidden (view full) ---

1003 } */ *uap;
1004{
1005 struct msghdr msg;
1006 struct iovec aiov;
1007 int error;
1008
1009 mtx_lock(&Giant);
1010 if (uap->fromlenaddr) {
1014 error = copyin((caddr_t)uap->fromlenaddr,
1015 (caddr_t)&msg.msg_namelen, sizeof (msg.msg_namelen));
1011 error = copyin(uap->fromlenaddr,
1012 &msg.msg_namelen, sizeof (msg.msg_namelen));
1016 if (error)
1017 goto done2;
1018 } else {
1019 msg.msg_namelen = 0;
1020 }
1021 msg.msg_name = uap->from;
1022 msg.msg_iov = &aiov;
1023 msg.msg_iovlen = 1;

--- 572 unchanged lines hidden (view full) ---

1596}
1597
1598#define dtosf(x) (&sf_bufs[((uintptr_t)(x) - (uintptr_t)sf_base) >> PAGE_SHIFT])
1599
1600/*
1601 * Detatch mapped page and release resources back to the system.
1602 */
1603void
1013 if (error)
1014 goto done2;
1015 } else {
1016 msg.msg_namelen = 0;
1017 }
1018 msg.msg_name = uap->from;
1019 msg.msg_iov = &aiov;
1020 msg.msg_iovlen = 1;

--- 572 unchanged lines hidden (view full) ---

1593}
1594
1595#define dtosf(x) (&sf_bufs[((uintptr_t)(x) - (uintptr_t)sf_base) >> PAGE_SHIFT])
1596
1597/*
1598 * Detatch mapped page and release resources back to the system.
1599 */
1600void
1604sf_buf_free(caddr_t addr, void *args)
1601sf_buf_free(void *addr, void *args)
1605{
1606 struct sf_buf *sf;
1607 struct vm_page *m;
1608
1609 GIANT_REQUIRED;
1610
1611 sf = dtosf(addr);
1612 pmap_qremove((vm_offset_t)addr, 1);

--- 340 unchanged lines hidden ---
1602{
1603 struct sf_buf *sf;
1604 struct vm_page *m;
1605
1606 GIANT_REQUIRED;
1607
1608 sf = dtosf(addr);
1609 pmap_qremove((vm_offset_t)addr, 1);

--- 340 unchanged lines hidden ---