summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorrtr <rtr@NetBSD.org>2015-04-03 20:01:07 +0000
committerrtr <rtr@NetBSD.org>2015-04-03 20:01:07 +0000
commit0da58ac00a9b5753aba6c2f4714b9d499759d1f2 (patch)
treef85b2abd805d39ad26a562d1836377ec5f5a012d /sys
parent96d58810e5e839733058d3448402f7aac437b4ea (diff)
* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr * instead of mbuf * * introduce sockaddr_big struct for storage of addr data passed via sys_bind; sockaddr_big is of sufficient size and alignment to accommodate all addr data sizes received. * modify sys_bind to allocate sockaddr_big instead of using an mbuf. * bump kernel version to 7.99.9 for change to pr_bind() parameter type. Patch posted to tech-net@ http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html The choice to use a new structure sockaddr_big has been retained since changing sockaddr_storage size would lead to unnecessary ABI change. The use of the new structure does not preclude future work that increases the size of sockaddr_storage and at that time sockaddr_big may be trivially replaced. Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/common/linux_socket.c83
-rw-r--r--sys/compat/svr4/svr4_stream.c24
-rw-r--r--sys/kern/uipc_socket.c6
-rw-r--r--sys/kern/uipc_syscalls.c54
-rw-r--r--sys/kern/uipc_usrreq.c24
-rw-r--r--sys/net/if_gre.c6
-rw-r--r--sys/net/link_proto.c8
-rw-r--r--sys/net/rtsock.c6
-rw-r--r--sys/netatalk/ddp_usrreq.c19
-rw-r--r--sys/netbt/hci_socket.c9
-rw-r--r--sys/netbt/l2cap_socket.c9
-rw-r--r--sys/netbt/rfcomm_socket.c9
-rw-r--r--sys/netbt/sco_socket.c9
-rw-r--r--sys/netinet/in_pcb.c12
-rw-r--r--sys/netinet/in_pcb.h4
-rw-r--r--sys/netinet/raw_ip.c16
-rw-r--r--sys/netinet/tcp_usrreq.c14
-rw-r--r--sys/netinet/udp_usrreq.c9
-rw-r--r--sys/netinet6/in6_pcb.c12
-rw-r--r--sys/netinet6/in6_pcb.h4
-rw-r--r--sys/netinet6/raw_ip6.c11
-rw-r--r--sys/netinet6/udp6_usrreq.c9
-rw-r--r--sys/netipsec/keysock.c6
-rw-r--r--sys/netmpls/mpls_proto.c6
-rw-r--r--sys/netnatm/natm.c6
-rw-r--r--sys/nfs/nfs_boot.c20
-rw-r--r--sys/nfs/nfs_socket.c35
-rw-r--r--sys/rump/net/lib/libsockin/sockin.c12
-rw-r--r--sys/sys/param.h4
-rw-r--r--sys/sys/protosw.h8
-rw-r--r--sys/sys/socket.h20
-rw-r--r--sys/sys/socketvar.h6
32 files changed, 293 insertions, 187 deletions
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c
index dbad73174b6..442c5d1923c 100644
--- a/sys/compat/linux/common/linux_socket.c
+++ b/sys/compat/linux/common/linux_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $ */
+/* $NetBSD: linux_socket.c,v 1.123 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.122 2014/11/26 09:53:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.123 2015/04/03 20:01:07 rtr Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -121,6 +121,8 @@ int linux_getifconf(struct lwp *, register_t *, void *);
int linux_getifhwaddr(struct lwp *, register_t *, u_int, void *);
static int linux_get_sa(struct lwp *, int, struct mbuf **,
const struct osockaddr *, unsigned int);
+static int linux_get_sa_sb(struct lwp *, int, struct sockaddr_big *,
+ const struct osockaddr *, socklen_t);
static int linux_sa_put(struct osockaddr *osa);
static int linux_to_bsd_msg_flags(int);
static int bsd_to_linux_msg_flags(int);
@@ -1445,14 +1447,14 @@ linux_sys_bind(struct lwp *l, const struct linux_sys_bind_args *uap, register_t
syscallarg(int) namelen;
} */
int error;
- struct mbuf *nam;
+ struct sockaddr_big sb;
- error = linux_get_sa(l, SCARG(uap, s), &nam, SCARG(uap, name),
+ error = linux_get_sa_sb(l, SCARG(uap, s), &sb, SCARG(uap, name),
SCARG(uap, namelen));
if (error)
return (error);
- return do_sys_bind(l, SCARG(uap, s), nam);
+ return do_sys_bind(l, SCARG(uap, s), (struct sockaddr *)&sb);
}
int
@@ -1493,6 +1495,77 @@ linux_sys_getpeername(struct lwp *l, const struct linux_sys_getpeername_args *ua
return (0);
}
+static int
+linux_get_sa_sb(struct lwp *l, int s, struct sockaddr_big *sb,
+ const struct osockaddr *name, socklen_t namelen)
+{
+ int error, bdom;
+
+ if (namelen > UCHAR_MAX ||
+ namelen <= offsetof(struct sockaddr_big, sb_data))
+ return EINVAL;
+
+ error = copyin(name, sb, namelen);
+ if (error)
+ return error;
+
+ bdom = linux_to_bsd_domain(sb->sb_family);
+ if (bdom == -1)
+ return EINVAL;
+
+ /*
+ * If the family is unspecified, use address family of the socket.
+ * This avoid triggering strict family checks in netinet/in_pcb.c et.al.
+ */
+ if (bdom == AF_UNSPEC) {
+ struct socket *so;
+
+ /* fd_getsock() will use the descriptor for us */
+ if ((error = fd_getsock(s, &so)) != 0)
+ return error;
+
+ bdom = so->so_proto->pr_domain->dom_family;
+ fd_putfile(s);
+ }
+
+ /*
+ * Older Linux IPv6 code uses obsolete RFC2133 struct sockaddr_in6,
+ * which lacks the scope id compared with RFC2553 one. If we detect
+ * the situation, reject the address and write a message to system log.
+ *
+ * Still accept addresses for which the scope id is not used.
+ */
+ if (bdom == AF_INET6 &&
+ namelen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sb;
+ if (!IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) &&
+ (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_V4COMPAT(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))) {
+ struct proc *p = l->l_proc;
+ int uid = l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1;
+
+ log(LOG_DEBUG,
+ "pid %d (%s), uid %d: obsolete pre-RFC2553 "
+ "sockaddr_in6 rejected",
+ p->p_pid, p->p_comm, uid);
+ return EINVAL;
+ }
+ namelen = sizeof(struct sockaddr_in6);
+ sin6->sin6_scope_id = 0;
+ }
+
+ if (bdom == AF_INET)
+ namelen = sizeof(struct sockaddr_in);
+
+ sb->sb_family = bdom;
+ sb->sb_len = namelen;
+ ktrkuser("mbsoname", sb, namelen);
+ return 0;
+}
+
/*
* Copy the osockaddr structure pointed to by osa to mbuf, adjust
* family and convert to sockaddr.
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
index 4d263cfbbac..df09dd000d1 100644
--- a/sys/compat/svr4/svr4_stream.c
+++ b/sys/compat/svr4/svr4_stream.c
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_stream.c,v 1.81 2014/09/05 09:21:55 matt Exp $ */
+/* $NetBSD: svr4_stream.c,v 1.82 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.81 2014/09/05 09:21:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.82 2015/04/03 20:01:07 rtr Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -752,10 +752,10 @@ ti_bind(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
struct svr4_strm *st = svr4_stream_get(fp);
struct sockaddr_in sain;
struct sockaddr_un saun;
- void *skp, *sup = NULL;
+ struct sockaddr_big *sbig;
+ void *sup = NULL;
int sasize;
struct svr4_strmcmd bnd;
- struct mbuf *name;
if (st == NULL) {
DPRINTF(("ti_bind: bad file descriptor\n"));
@@ -775,8 +775,8 @@ ti_bind(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
switch (st->s_family) {
case AF_INET:
- skp = &sain;
- sasize = sizeof(sain);
+ sbig = (struct sockaddr_big *)&sain;
+ sbig->sb_len = sasize = sizeof(sain);
if (bnd.offs == 0)
goto reply;
@@ -789,8 +789,8 @@ ti_bind(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
break;
case AF_LOCAL:
- skp = &saun;
- sasize = sizeof(saun);
+ sbig = (struct sockaddr_big *)&saun;
+ sbig->sb_len = sasize = sizeof(saun);
if (bnd.offs == 0)
goto reply;
@@ -814,15 +814,9 @@ ti_bind(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
return ENOSYS;
}
- name = m_get(M_WAIT, MT_SONAME);
- if (sasize > MLEN)
- MEXTMALLOC(name, sasize, M_WAITOK);
-
- memcpy(mtod(name, void *), skp, sasize);
-
DPRINTF(("TI_BIND: fileno %d\n", fd));
- error = do_sys_bind(l, fd, name);
+ error = do_sys_bind(l, fd, (struct sockaddr *)sbig);
if (error != 0) {
DPRINTF(("TI_BIND: bind failed %d\n", error));
return error;
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 43f83f38db4..3003e3ace12 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.235 2014/09/05 09:20:59 matt Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.235 2014/09/05 09:20:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $");
#include "opt_compat_netbsd.h"
#include "opt_sock_counters.h"
@@ -624,7 +624,7 @@ sofamily(const struct socket *so)
}
int
-sobind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sobind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
int error;
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index a6b2a03520f..03ba27556fb 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.174 2015/03/06 03:35:00 rtr Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.175 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.174 2015/03/06 03:35:00 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.175 2015/04/03 20:01:07 rtr Exp $");
#include "opt_pipe.h"
@@ -91,6 +91,8 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.174 2015/03/06 03:35:00 rtr Exp
*/
extern const struct fileops socketops;
+static int sockargs_sb(struct sockaddr_big *, const void *, socklen_t);
+
int
sys___socket30(struct lwp *l, const struct sys___socket30_args *uap,
register_t *retval)
@@ -118,30 +120,25 @@ sys_bind(struct lwp *l, const struct sys_bind_args *uap, register_t *retval)
syscallarg(const struct sockaddr *) name;
syscallarg(unsigned int) namelen;
} */
- struct mbuf *nam;
int error;
+ struct sockaddr_big sb;
- error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
- MT_SONAME);
+ error = sockargs_sb(&sb, SCARG(uap, name), SCARG(uap, namelen));
if (error)
return error;
- return do_sys_bind(l, SCARG(uap, s), nam);
+ return do_sys_bind(l, SCARG(uap, s), (struct sockaddr *)&sb);
}
int
-do_sys_bind(struct lwp *l, int fd, struct mbuf *nam)
+do_sys_bind(struct lwp *l, int fd, struct sockaddr *nam)
{
struct socket *so;
int error;
- if ((error = fd_getsock(fd, &so)) != 0) {
- m_freem(nam);
- return (error);
- }
- MCLAIM(nam, so->so_mowner);
+ if ((error = fd_getsock(fd, &so)) != 0)
+ return error;
error = sobind(so, nam, l);
- m_freem(nam);
fd_putfile(fd);
return error;
}
@@ -1444,6 +1441,37 @@ sys_getpeername(struct lwp *l, const struct sys_getpeername_args *uap,
return error;
}
+static int
+sockargs_sb(struct sockaddr_big *sb, const void *name, socklen_t buflen)
+{
+ int error;
+
+ /*
+ * We can't allow socket names > UCHAR_MAX in length, since that
+ * will overflow sb_len. Further no reasonable buflen is <=
+ * offsetof(sockaddr_big, sb_data) since it shall be at least
+ * the size of the preamble sb_len and sb_family members.
+ */
+ if (buflen > UCHAR_MAX ||
+ buflen <= offsetof(struct sockaddr_big, sb_data))
+ return EINVAL;
+
+ error = copyin(name, (void *)sb, buflen);
+ if (error)
+ return error;
+
+#if BYTE_ORDER != BIG_ENDIAN
+ /*
+ * 4.3BSD compat thing - need to stay, since bind(2),
+ * connect(2), sendto(2) were not versioned for COMPAT_43.
+ */
+ if (sb->sb_family == 0 && sb->sb_len < AF_MAX)
+ sb->sb_family = sb->sb_len;
+#endif
+ sb->sb_len = buflen;
+ return 0;
+}
+
/*
* XXX In a perfect world, we wouldn't pass around socket control
* XXX arguments in mbufs, and this could go away.
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 2a2fa22ac1a..5d6b974d293 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.175 2015/03/01 01:14:41 christos Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.176 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.175 2015/03/01 01:14:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.176 2015/04/03 20:01:07 rtr Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -931,8 +931,24 @@ makeun(struct mbuf *nam, size_t *addrlen)
return sun;
}
+/*
+ * we only need to perform this allocation until syscalls other than
+ * bind are adjusted to use sockaddr_big.
+ */
+static struct sockaddr_un *
+makeun_sb(struct sockaddr *nam, size_t *addrlen)
+{
+ struct sockaddr_un *sun;
+
+ *addrlen = nam->sa_len + 1;
+ sun = malloc(*addrlen, M_SONAME, M_WAITOK);
+ memcpy(sun, nam, nam->sa_len);
+ *(((char *)sun) + nam->sa_len) = '\0';
+ return sun;
+}
+
static int
-unp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+unp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct sockaddr_un *sun;
struct unpcb *unp;
@@ -963,7 +979,7 @@ unp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
sounlock(so);
p = l->l_proc;
- sun = makeun(nam, &addrlen);
+ sun = makeun_sb(nam, &addrlen);
pb = pathbuf_create(sun->sun_path);
if (pb == NULL) {
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index f6f767675a4..2b123a6baaa 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $ */
+/* $NetBSD: if_gre.c,v 1.162 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.161 2014/09/05 09:22:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.162 2015/04/03 20:01:07 rtr Exp $");
#include "opt_atalk.h"
#include "opt_gre.h"
@@ -444,7 +444,7 @@ gre_socreate(struct gre_softc *sc, const struct gre_soparm *sp, int *fdout)
sockaddr_copy(sa, MIN(MLEN, sizeof(sp->sp_src)), sstocsa(&sp->sp_src));
m->m_len = sp->sp_src.ss_len;
- if ((rc = sobind(so, m, curlwp)) != 0) {
+ if ((rc = sobind(so, sa, curlwp)) != 0) {
GRE_DPRINTF(sc, "sobind failed\n");
goto out;
}
diff --git a/sys/net/link_proto.c b/sys/net/link_proto.c
index b3054e66583..04830a8211f 100644
--- a/sys/net/link_proto.c
+++ b/sys/net/link_proto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: link_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: link_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -51,7 +51,7 @@ static int sockaddr_dl_cmp(const struct sockaddr *, const struct sockaddr *);
static int link_attach(struct socket *, int);
static void link_detach(struct socket *);
static int link_accept(struct socket *, struct mbuf *);
-static int link_bind(struct socket *, struct mbuf *, struct lwp *);
+static int link_bind(struct socket *, struct sockaddr *, struct lwp *);
static int link_listen(struct socket *, struct lwp *);
static int link_connect(struct socket *, struct mbuf *, struct lwp *);
static int link_connect2(struct socket *, struct socket *);
@@ -274,7 +274,7 @@ link_accept(struct socket *so, struct mbuf *nam)
}
static int
-link_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+link_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index c6c53563bad..d9eb515d287 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.166 2014/12/02 21:28:31 christos Exp $ */
+/* $NetBSD: rtsock.c,v 1.167 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.166 2014/12/02 21:28:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.167 2015/04/03 20:01:07 rtr Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -239,7 +239,7 @@ COMPATNAME(route_accept)(struct socket *so, struct mbuf *nam)
}
static int
-COMPATNAME(route_bind)(struct socket *so, struct mbuf *nam, struct lwp *l)
+COMPATNAME(route_bind)(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c
index 810e68f7a45..4937d215ac7 100644
--- a/sys/netatalk/ddp_usrreq.c
+++ b/sys/netatalk/ddp_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ddp_usrreq.c,v 1.63 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: ddp_usrreq.c,v 1.64 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.63 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.64 2015/04/03 20:01:07 rtr Exp $");
#include "opt_mbuftrace.h"
@@ -58,7 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.63 2014/08/09 05:33:01 rtr Exp $");
static void at_pcbdisconnect(struct ddpcb *);
static void at_sockaddr(struct ddpcb *, struct mbuf *);
-static int at_pcbsetaddr(struct ddpcb *, struct mbuf *);
+static int at_pcbsetaddr(struct ddpcb *, struct sockaddr_at *);
static int at_pcbconnect(struct ddpcb *, struct mbuf *);
static void ddp_detach(struct socket *);
@@ -142,19 +142,16 @@ at_sockaddr(struct ddpcb *ddp, struct mbuf *addr)
}
static int
-at_pcbsetaddr(struct ddpcb *ddp, struct mbuf *addr)
+at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr_at *sat)
{
- struct sockaddr_at lsat, *sat;
+ struct sockaddr_at lsat;
struct at_ifaddr *aa;
struct ddpcb *ddpp;
if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT) { /* shouldn't be bound */
return (EINVAL);
}
- if (addr != 0) { /* validate passed address */
- sat = mtod(addr, struct sockaddr_at *);
- if (addr->m_len != sizeof(*sat))
- return (EINVAL);
+ if (NULL != sat) { /* validate passed address */
if (sat->sat_family != AF_APPLETALK)
return (EAFNOSUPPORT);
@@ -413,12 +410,12 @@ ddp_accept(struct socket *so, struct mbuf *nam)
}
static int
-ddp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+ddp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
KASSERT(sotoddpcb(so) != NULL);
- return at_pcbsetaddr(sotoddpcb(so), nam);
+ return at_pcbsetaddr(sotoddpcb(so), (struct sockaddr_at *)nam);
}
static int
diff --git a/sys/netbt/hci_socket.c b/sys/netbt/hci_socket.c
index 36185167dbc..e071751f6d9 100644
--- a/sys/netbt/hci_socket.c
+++ b/sys/netbt/hci_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hci_socket.c,v 1.40 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: hci_socket.c,v 1.41 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.40 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.41 2015/04/03 20:01:07 rtr Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@@ -492,16 +492,15 @@ hci_accept(struct socket *so, struct mbuf *nam)
}
static int
-hci_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+hci_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct hci_pcb *pcb = so->so_pcb;
- struct sockaddr_bt *sa;
+ struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
KASSERT(solocked(so));
KASSERT(pcb != NULL);
KASSERT(nam != NULL);
- sa = mtod(nam, struct sockaddr_bt *);
if (sa->bt_len != sizeof(struct sockaddr_bt))
return EINVAL;
diff --git a/sys/netbt/l2cap_socket.c b/sys/netbt/l2cap_socket.c
index 6f03db08167..7cfb3eb03de 100644
--- a/sys/netbt/l2cap_socket.c
+++ b/sys/netbt/l2cap_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: l2cap_socket.c,v 1.31 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: l2cap_socket.c,v 1.32 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.31 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.32 2015/04/03 20:01:07 rtr Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@@ -134,10 +134,10 @@ l2cap_accept(struct socket *so, struct mbuf *nam)
}
static int
-l2cap_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+l2cap_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct l2cap_channel *pcb = so->so_pcb;
- struct sockaddr_bt *sa;
+ struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
KASSERT(solocked(so));
KASSERT(nam != NULL);
@@ -145,7 +145,6 @@ l2cap_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
if (pcb == NULL)
return EINVAL;
- sa = mtod(nam, struct sockaddr_bt *);
if (sa->bt_len != sizeof(struct sockaddr_bt))
return EINVAL;
diff --git a/sys/netbt/rfcomm_socket.c b/sys/netbt/rfcomm_socket.c
index 435a0b69833..aa8d5292940 100644
--- a/sys/netbt/rfcomm_socket.c
+++ b/sys/netbt/rfcomm_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rfcomm_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: rfcomm_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@@ -142,10 +142,10 @@ rfcomm_accept(struct socket *so, struct mbuf *nam)
}
static int
-rfcomm_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rfcomm_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct rfcomm_dlc *pcb = so->so_pcb;
- struct sockaddr_bt *sa;
+ struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
KASSERT(solocked(so));
KASSERT(nam != NULL);
@@ -153,7 +153,6 @@ rfcomm_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
if (pcb == NULL)
return EINVAL;
- sa = mtod(nam, struct sockaddr_bt *);
if (sa->bt_len != sizeof(struct sockaddr_bt))
return EINVAL;
diff --git a/sys/netbt/sco_socket.c b/sys/netbt/sco_socket.c
index f2a9d828546..5cd7acd4332 100644
--- a/sys/netbt/sco_socket.c
+++ b/sys/netbt/sco_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sco_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: sco_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.33 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.34 2015/04/03 20:01:07 rtr Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@@ -125,10 +125,10 @@ sco_accept(struct socket *so, struct mbuf *nam)
}
static int
-sco_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sco_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct sco_pcb *pcb = so->so_pcb;
- struct sockaddr_bt *sa;
+ struct sockaddr_bt *sa = (struct sockaddr_bt *)nam;
KASSERT(solocked(so));
KASSERT(nam != NULL);
@@ -136,7 +136,6 @@ sco_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
if (pcb == NULL)
return EINVAL;
- sa = mtod(nam, struct sockaddr_bt *);
if (sa->bt_len != sizeof(struct sockaddr_bt))
return EINVAL;
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 8f68ca05698..ba2bc311c56 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.155 2014/11/25 19:09:13 seanb Exp $ */
+/* $NetBSD: in_pcb.c,v 1.156 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.155 2014/11/25 19:09:13 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.156 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -401,10 +401,9 @@ in_pcbbind_port(struct inpcb *inp, struct sockaddr_in *sin, kauth_cred_t cred)
}
int
-in_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
+in_pcbbind(void *v, struct sockaddr_in *sin, struct lwp *l)
{
struct inpcb *inp = v;
- struct sockaddr_in *sin = NULL; /* XXXGCC */
struct sockaddr_in lsin;
int error;
@@ -416,9 +415,8 @@ in_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
if (inp->inp_lport || !in_nullhost(inp->inp_laddr))
return (EINVAL);
- if (nam != NULL) {
- sin = mtod(nam, struct sockaddr_in *);
- if (nam->m_len != sizeof (*sin))
+ if (NULL != sin) {
+ if (sin->sin_len != sizeof(*sin))
return (EINVAL);
} else {
lsin = *((const struct sockaddr_in *)
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 2e824d0da43..a02a5e026cc 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.h,v 1.55 2014/11/25 15:04:37 seanb Exp $ */
+/* $NetBSD: in_pcb.h,v 1.56 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -131,7 +131,7 @@ struct inpcb {
#ifdef _KERNEL
void in_losing(struct inpcb *);
int in_pcballoc(struct socket *, void *);
-int in_pcbbind(void *, struct mbuf *, struct lwp *);
+int in_pcbbind(void *, struct sockaddr_in *, struct lwp *);
int in_pcbconnect(void *, struct mbuf *, struct lwp *);
void in_pcbdetach(void *);
void in_pcbdisconnect(void *);
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 8049dca8c46..b93e151a6ee 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip.c,v 1.146 2014/11/10 18:52:51 maxv Exp $ */
+/* $NetBSD: raw_ip.c,v 1.147 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.146 2014/11/10 18:52:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.147 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_compat_netbsd.h"
@@ -557,10 +557,10 @@ rip_accept(struct socket *so, struct mbuf *nam)
}
static int
-rip_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct inpcb *inp = sotoinpcb(so);
- struct sockaddr_in *addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *)nam;
int error = 0;
int s;
@@ -568,12 +568,10 @@ rip_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
KASSERT(inp != NULL);
KASSERT(nam != NULL);
+ if (addr->sin_len != sizeof(*addr))
+ return EINVAL;
+
s = splsoftnet();
- addr = mtod(nam, struct sockaddr_in *);
- if (nam->m_len != sizeof(*addr)) {
- error = EINVAL;
- goto release;
- }
if (IFNET_EMPTY()) {
error = EADDRNOTAVAIL;
goto release;
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 13f703684d5..31464c4f066 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_usrreq.c,v 1.204 2015/03/31 08:47:01 ozaki-r Exp $ */
+/* $NetBSD: tcp_usrreq.c,v 1.205 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.204 2015/03/31 08:47:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.205 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_tcp_debug.h"
@@ -711,10 +711,14 @@ tcp_accept(struct socket *so, struct mbuf *nam)
}
static int
-tcp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+tcp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct inpcb *inp = NULL;
struct in6pcb *in6p = NULL;
+ struct sockaddr_in *sin = (struct sockaddr_in *)nam;
+#ifdef INET6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
+#endif /* INET6 */
struct tcpcb *tp = NULL;
int s;
int error = 0;
@@ -732,12 +736,12 @@ tcp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
switch (so->so_proto->pr_domain->dom_family) {
#ifdef INET
case PF_INET:
- error = in_pcbbind(inp, nam, l);
+ error = in_pcbbind(inp, sin, l);
break;
#endif
#ifdef INET6
case PF_INET6:
- error = in6_pcbbind(in6p, nam, l);
+ error = in6_pcbbind(in6p, sin6, l);
if (!error) {
/* mapped addr case */
if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_laddr))
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 4c184ba1843..9da95c0f1ad 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udp_usrreq.c,v 1.217 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.218 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.217 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.218 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_compat_netbsd.h"
@@ -905,9 +905,10 @@ udp_accept(struct socket *so, struct mbuf *nam)
}
static int
-udp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct inpcb *inp = sotoinpcb(so);
+ struct sockaddr_in *sin = (struct sockaddr_in *)nam;
int error = 0;
int s;
@@ -916,7 +917,7 @@ udp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
KASSERT(nam != NULL);
s = splsoftnet();
- error = in_pcbbind(inp, nam, l);
+ error = in_pcbbind(inp, sin, l);
splx(s);
return error;
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 5936d0eb70c..649b5d08daa 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.c,v 1.134 2014/11/25 19:09:13 seanb Exp $ */
+/* $NetBSD: in6_pcb.c,v 1.135 2015/04/03 20:01:07 rtr Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.134 2014/11/25 19:09:13 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.135 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -364,11 +364,10 @@ in6_pcbbind_port(struct in6pcb *in6p, struct sockaddr_in6 *sin6, struct lwp *l)
}
int
-in6_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
+in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
{
struct in6pcb *in6p = v;
struct sockaddr_in6 lsin6;
- struct sockaddr_in6 *sin6 = NULL;
int error;
if (in6p->in6p_af != AF_INET6)
@@ -383,10 +382,9 @@ in6_pcbbind(void *v, struct mbuf *nam, struct lwp *l)
in6p->in6p_laddr.s6_addr32[3] == 0)))
return (EINVAL);
- if (nam != NULL) {
+ if (NULL != sin6) {
/* We were provided a sockaddr_in6 to use. */
- sin6 = mtod(nam, struct sockaddr_in6 *);
- if (nam->m_len != sizeof(*sin6))
+ if (sin6->sin6_len != sizeof(*sin6))
return (EINVAL);
} else {
/* We always bind to *something*, even if it's "anything". */
diff --git a/sys/netinet6/in6_pcb.h b/sys/netinet6/in6_pcb.h
index eae14dd757e..799b08a15f3 100644
--- a/sys/netinet6/in6_pcb.h
+++ b/sys/netinet6/in6_pcb.h
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.h,v 1.41 2015/03/30 02:23:21 ozaki-r Exp $ */
+/* $NetBSD: in6_pcb.h,v 1.42 2015/04/03 20:01:07 rtr Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@@ -156,7 +156,7 @@ struct in6pcb {
void in6_losing(struct in6pcb *);
void in6_pcbinit(struct inpcbtable *, int, int);
int in6_pcballoc(struct socket *, void *);
-int in6_pcbbind(void *, struct mbuf *, struct lwp *);
+int in6_pcbbind(void *, struct sockaddr_in6 *, struct lwp *);
int in6_pcbconnect(void *, struct mbuf *, struct lwp *);
void in6_pcbdetach(struct in6pcb *);
void in6_pcbdisconnect(struct in6pcb *);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index cd4da4c65c2..fadc1160968 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip6.c,v 1.136 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: raw_ip6.c,v 1.137 2015/04/03 20:01:07 rtr Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.137 2015/04/03 20:01:07 rtr Exp $");
#include "opt_ipsec.h"
@@ -653,10 +653,10 @@ rip6_accept(struct socket *so, struct mbuf *nam)
}
static int
-rip6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct in6pcb *in6p = sotoin6pcb(so);
- struct sockaddr_in6 *addr;
+ struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam;
struct ifaddr *ia = NULL;
int error = 0;
@@ -664,8 +664,7 @@ rip6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
KASSERT(in6p != NULL);
KASSERT(nam != NULL);
- addr = mtod(nam, struct sockaddr_in6 *);
- if (nam->m_len != sizeof(*addr))
+ if (addr->sin6_len != sizeof(*addr))
return EINVAL;
if (IFNET_EMPTY() || addr->sin6_family != AF_INET6)
return EADDRNOTAVAIL;
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index d27096397a0..b579fdc461e 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udp6_usrreq.c,v 1.116 2015/03/30 04:25:26 ozaki-r Exp $ */
+/* $NetBSD: udp6_usrreq.c,v 1.117 2015/04/03 20:01:07 rtr Exp $ */
/* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.116 2015/03/30 04:25:26 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.117 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_inet_csum.h"
@@ -696,9 +696,10 @@ udp6_accept(struct socket *so, struct mbuf *nam)
}
static int
-udp6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp6_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
struct in6pcb *in6p = sotoin6pcb(so);
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam;
int error = 0;
int s;
@@ -706,7 +707,7 @@ udp6_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
KASSERT(in6p != NULL);
s = splsoftnet();
- error = in6_pcbbind(in6p, nam, l);
+ error = in6_pcbbind(in6p, sin6, l);
splx(s);
return error;
}
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index 1c91d230ac6..4ff6673babd 100644
--- a/sys/netipsec/keysock.c
+++ b/sys/netipsec/keysock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keysock.c,v 1.44 2015/03/30 03:51:50 ozaki-r Exp $ */
+/* $NetBSD: keysock.c,v 1.45 2015/04/03 20:01:07 rtr Exp $ */
/* $FreeBSD: src/sys/netipsec/keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.44 2015/03/30 03:51:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.45 2015/04/03 20:01:07 rtr Exp $");
/* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
@@ -493,7 +493,7 @@ key_accept(struct socket *so, struct mbuf *nam)
}
static int
-key_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+key_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c
index c90d2b8351b..2a15330ae0e 100644
--- a/sys/netmpls/mpls_proto.c
+++ b/sys/netmpls/mpls_proto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: mpls_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.24 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.25 2015/04/03 20:01:07 rtr Exp $");
#include "opt_inet.h"
#include "opt_mbuftrace.h"
@@ -103,7 +103,7 @@ mpls_accept(struct socket *so, struct mbuf *nam)
}
static int
-mpls_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+mpls_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
diff --git a/sys/netnatm/natm.c b/sys/netnatm/natm.c
index 99445e7f62d..a6621184a66 100644
--- a/sys/netnatm/natm.c
+++ b/sys/netnatm/natm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: natm.c,v 1.45 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: natm.c,v 1.46 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (c) 1996 Charles D. Cranor and Washington University.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.45 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.46 2015/04/03 20:01:07 rtr Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -106,7 +106,7 @@ natm_accept(struct socket *so, struct mbuf *nam)
}
static int
-natm_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+natm_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c
index d831886ff15..250878be2e4 100644
--- a/sys/nfs/nfs_boot.c
+++ b/sys/nfs/nfs_boot.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $ */
+/* $NetBSD: nfs_boot.c,v 1.83 2015/04/03 20:01:07 rtr Exp $ */
/*-
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.83 2015/04/03 20:01:07 rtr Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@@ -404,18 +404,14 @@ nfs_boot_enbroadcast(struct socket *so)
int
nfs_boot_sobind_ipport(struct socket *so, uint16_t port, struct lwp *l)
{
- struct mbuf *m;
- struct sockaddr_in *sin;
+ struct sockaddr_in sin;
int error;
- m = m_getclr(M_WAIT, MT_SONAME);
- sin = mtod(m, struct sockaddr_in *);
- sin->sin_len = m->m_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- sin->sin_port = htons(port);
- error = sobind(so, m, l);
- m_freem(m);
+ sin.sin_len = sizeof(sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_port = htons(port);
+ error = sobind(so, (struct sockaddr *)&sin, l);
return (error);
}
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 90370810e37..d1632c798c1 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $ */
+/* $NetBSD: nfs_socket.c,v 1.194 2015/04/03 20:01:07 rtr Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.194 2015/04/03 20:01:07 rtr Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@@ -182,9 +182,8 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep, struct lwp *l)
struct socket *so;
int error, rcvreserve, sndreserve;
struct sockaddr *saddr;
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct mbuf *m;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
int val;
nmp->nm_so = NULL;
@@ -210,15 +209,11 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep, struct lwp *l)
if ((error = so_setsockopt(NULL, so, IPPROTO_IP, IP_PORTRANGE,
&val, sizeof(val))))
goto bad;
- m = m_get(M_WAIT, MT_SONAME);
- MCLAIM(m, so->so_mowner);
- sin = mtod(m, struct sockaddr_in *);
- sin->sin_len = m->m_len = sizeof (struct sockaddr_in);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- sin->sin_port = 0;
- error = sobind(so, m, &lwp0);
- m_freem(m);
+ sin.sin_len = sizeof(struct sockaddr_in);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_port = 0;
+ error = sobind(so, (struct sockaddr *)&sin, &lwp0);
if (error)
goto bad;
}
@@ -228,14 +223,10 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep, struct lwp *l)
if ((error = so_setsockopt(NULL, so, IPPROTO_IPV6,
IPV6_PORTRANGE, &val, sizeof(val))))
goto bad;
- m = m_get(M_WAIT, MT_SONAME);
- MCLAIM(m, so->so_mowner);
- sin6 = mtod(m, struct sockaddr_in6 *);
- memset(sin6, 0, sizeof(*sin6));
- sin6->sin6_len = m->m_len = sizeof (struct sockaddr_in6);
- sin6->sin6_family = AF_INET6;
- error = sobind(so, m, &lwp0);
- m_freem(m);
+ memset(&sin6, 0, sizeof(sin6));
+ sin6.sin6_len = sizeof(struct sockaddr_in6);
+ sin6.sin6_family = AF_INET6;
+ error = sobind(so, (struct sockaddr *)&sin6, &lwp0);
if (error)
goto bad;
}
diff --git a/sys/rump/net/lib/libsockin/sockin.c b/sys/rump/net/lib/libsockin/sockin.c
index 01261a69510..19985a2c28f 100644
--- a/sys/rump/net/lib/libsockin/sockin.c
+++ b/sys/rump/net/lib/libsockin/sockin.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sockin.c,v 1.58 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: sockin.c,v 1.59 2015/04/03 20:01:08 rtr Exp $ */
/*
* Copyright (c) 2008, 2009 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.58 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.59 2015/04/03 20:01:08 rtr Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -70,7 +70,7 @@ static int sockin_attach(struct socket *, int);
static void sockin_detach(struct socket *);
static int sockin_accept(struct socket *, struct mbuf *);
static int sockin_connect2(struct socket *, struct socket *);
-static int sockin_bind(struct socket *, struct mbuf *, struct lwp *);
+static int sockin_bind(struct socket *, struct sockaddr *, struct lwp *);
static int sockin_listen(struct socket *, struct lwp *);
static int sockin_connect(struct socket *, struct mbuf *, struct lwp *);
static int sockin_disconnect(struct socket *);
@@ -494,14 +494,12 @@ sockin_accept(struct socket *so, struct mbuf *nam)
}
static int
-sockin_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+sockin_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
{
KASSERT(solocked(so));
KASSERT(nam != NULL);
- return rumpcomp_sockin_bind(SO2S(so),
- mtod(nam, const struct sockaddr *),
- nam->m_len);
+ return rumpcomp_sockin_bind(SO2S(so), nam, nam->sa_len);
}
static int
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 72a09cfefa8..7d23df3dfdf 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.468 2015/03/28 19:29:16 maxv Exp $ */
+/* $NetBSD: param.h,v 1.469 2015/04/03 20:01:08 rtr Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -63,7 +63,7 @@
* 2.99.9 (299000900)
*/
-#define __NetBSD_Version__ 799000800 /* NetBSD 7.99.8 */
+#define __NetBSD_Version__ 799000900 /* NetBSD 7.99.9 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h
index 548292aef93..db7c070048d 100644
--- a/sys/sys/protosw.h
+++ b/sys/sys/protosw.h
@@ -1,4 +1,4 @@
-/* $NetBSD: protosw.h,v 1.60 2014/08/09 05:33:01 rtr Exp $ */
+/* $NetBSD: protosw.h,v 1.61 2015/04/03 20:01:08 rtr Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -241,7 +241,7 @@ struct pr_usrreqs {
int (*pr_accept)(struct socket *, struct mbuf *);
int (*pr_connect)(struct socket *, struct mbuf *, struct lwp *);
int (*pr_connect2)(struct socket *, struct socket *);
- int (*pr_bind)(struct socket *, struct mbuf *, struct lwp *);
+ int (*pr_bind)(struct socket *, struct sockaddr *, struct lwp *);
int (*pr_listen)(struct socket *, struct lwp *);
int (*pr_disconnect)(struct socket *);
int (*pr_shutdown)(struct socket *);
@@ -317,8 +317,8 @@ name##_accept_wrapper(struct socket *a, struct mbuf *b) \
return rv; \
} \
static int \
-name##_bind_wrapper(struct socket *a, struct mbuf *b, \
- struct lwp *c) \
+name##_bind_wrapper(struct socket *a, \
+ struct sockaddr *b, struct lwp *c) \
{ \
int rv; \
KERNEL_LOCK(1, NULL); \
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index 930043074d8..4b68f0e22c5 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.h,v 1.116 2015/02/10 19:11:52 rjs Exp $ */
+/* $NetBSD: socket.h,v 1.117 2015/04/03 20:01:08 rtr Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -242,6 +242,24 @@ struct sockproto {
u_short sp_family; /* address family */
u_short sp_protocol; /* protocol */
};
+
+/*
+ * we make the entire struct at least UCHAR_MAX + 1 in size since existing
+ * use of sockaddr_un permits a path up to 253 bytes + '\0'.
+ * sizeof(sb_len) + sizeof(sb_family) + 253 + '\0'
+ */
+#define _SB_DATASIZE 254
+struct sockaddr_big {
+ union {
+ struct {
+ __uint8_t sb_len;
+ sa_family_t sb_family;
+ char sb_data[_SB_DATASIZE];
+ };
+ uint64_t dummy; /* solicit natural alignment */
+ };
+};
+
#endif /* _KERNEL */
#if 1
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index e4a1157aaec..f7312325ff5 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: socketvar.h,v 1.135 2014/09/05 05:37:37 matt Exp $ */
+/* $NetBSD: socketvar.h,v 1.136 2015/04/03 20:01:08 rtr Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -289,7 +289,7 @@ void soinit2(void);
int soabort(struct socket *);
int soaccept(struct socket *, struct mbuf *);
int sofamily(const struct socket *);
-int sobind(struct socket *, struct mbuf *, struct lwp *);
+int sobind(struct socket *, struct sockaddr *, struct lwp *);
void socantrcvmore(struct socket *);
void socantsendmore(struct socket *);
int soclose(struct socket *);
@@ -354,7 +354,7 @@ int do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *);
int do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
struct mbuf **, register_t *);
-int do_sys_bind(struct lwp *, int, struct mbuf *);
+int do_sys_bind(struct lwp *, int, struct sockaddr *);
int do_sys_connect(struct lwp *, int, struct mbuf *);
int do_sys_accept(struct lwp *, int, struct mbuf **, register_t *,
const sigset_t *, int, int);