Deleted Added
full compact
uipc_sockbuf.c (167715) uipc_sockbuf.c (167895)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 167715 2007-03-19 18:35:13Z andre $");
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 167895 2007-03-26 08:59:03Z rwatson $");
34
35#include "opt_param.h"
36
37#include <sys/param.h>
38#include <sys/aio.h> /* for aio_swake proto */
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/mbuf.h>

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

974sbdroprecord(struct sockbuf *sb)
975{
976
977 SOCKBUF_LOCK(sb);
978 sbdroprecord_locked(sb);
979 SOCKBUF_UNLOCK(sb);
980}
981
34
35#include "opt_param.h"
36
37#include <sys/param.h>
38#include <sys/aio.h> /* for aio_swake proto */
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/mbuf.h>

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

974sbdroprecord(struct sockbuf *sb)
975{
976
977 SOCKBUF_LOCK(sb);
978 sbdroprecord_locked(sb);
979 SOCKBUF_UNLOCK(sb);
980}
981
982/*
983 * Create a "control" mbuf containing the specified data
984 * with the specified type for presentation on a socket buffer.
985 */
986struct mbuf *
987sbcreatecontrol(p, size, type, level)
988 caddr_t p;
989 register int size;
990 int type, level;
991{
992 register struct cmsghdr *cp;
993 struct mbuf *m;
994
995 if (CMSG_SPACE((u_int)size) > MCLBYTES)
996 return ((struct mbuf *) NULL);
997 if (CMSG_SPACE((u_int)size) > MLEN)
998 m = m_getcl(M_DONTWAIT, MT_CONTROL, 0);
999 else
1000 m = m_get(M_DONTWAIT, MT_CONTROL);
1001 if (m == NULL)
1002 return ((struct mbuf *) NULL);
1003 cp = mtod(m, struct cmsghdr *);
1004 m->m_len = 0;
1005 KASSERT(CMSG_SPACE((u_int)size) <= M_TRAILINGSPACE(m),
1006 ("sbcreatecontrol: short mbuf"));
1007 if (p != NULL)
1008 (void)memcpy(CMSG_DATA(cp), p, size);
1009 m->m_len = CMSG_SPACE(size);
1010 cp->cmsg_len = CMSG_LEN(size);
1011 cp->cmsg_level = level;
1012 cp->cmsg_type = type;
1013 return (m);
1014}
1015
1016/*
1017 * This does the same for sockbufs. Note that the xsockbuf structure,
1018 * since it is always embedded in a socket, does not include a self
1019 * pointer nor a length. We make this entry point public in case
1020 * some other mechanism needs it.
1021 */
1022void
1023sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb)
1024{
1025 xsb->sb_cc = sb->sb_cc;
1026 xsb->sb_hiwat = sb->sb_hiwat;
1027 xsb->sb_mbcnt = sb->sb_mbcnt;
1028 xsb->sb_mbmax = sb->sb_mbmax;
1029 xsb->sb_lowat = sb->sb_lowat;
1030 xsb->sb_flags = sb->sb_flags;
1031 xsb->sb_timeo = sb->sb_timeo;
1032}
1033
982/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */
983static int dummy;
984SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, "");
985SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW,
986 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size");
987SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
988 &sb_efficiency, 0, "");
1034/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */
1035static int dummy;
1036SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, "");
1037SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW,
1038 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size");
1039SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
1040 &sb_efficiency, 0, "");