tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mbuf -> sockaddr patch for send and connect



hey,

here is the next patch in the series for review. as with the others
it converts the type of the sockaddr parameter from mbuf * to sockaddr *
for the user-requests send and connect.

comments welcome
Index: compat/linux/common/linux_socket.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_socket.c,v
retrieving revision 1.123
diff -p -u -r1.123 linux_socket.c
--- compat/linux/common/linux_socket.c	3 Apr 2015 20:01:07 -0000	1.123
+++ compat/linux/common/linux_socket.c	26 Apr 2015 17:31:58 -0000
@@ -1402,14 +1402,14 @@ linux_sys_connect(struct lwp *l, const s
 		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);
 
-	error = do_sys_connect(l, SCARG(uap, s), nam);
+	error = do_sys_connect(l, SCARG(uap, s), (struct sockaddr *)&sb);
 
 	if (error == EISCONN) {
 		struct socket *so;
Index: compat/svr4/svr4_stream.c
===================================================================
RCS file: /cvsroot/src/sys/compat/svr4/svr4_stream.c,v
retrieving revision 1.84
diff -p -u -r1.84 svr4_stream.c
--- compat/svr4/svr4_stream.c	24 Apr 2015 22:32:37 -0000	1.84
+++ compat/svr4/svr4_stream.c	26 Apr 2015 17:31:58 -0000
@@ -1495,7 +1495,8 @@ svr4_sys_putmsg(struct lwp *l, const str
  	switch (st->s_cmd = sc.cmd) {
 	case SVR4_TI_CONNECT_REQUEST:	/* connect 	*/
 	 	KERNEL_UNLOCK_ONE(NULL);
-		return do_sys_connect(l, SCARG(uap, fd), nam);
+		return do_sys_connect(l, SCARG(uap, fd),
+		    mtod(nam, struct sockaddr *));
 
 	case SVR4_TI_SENDTO_REQUEST:	/* sendto 	*/
 	 	KERNEL_UNLOCK_ONE(NULL);
Index: kern/uipc_socket.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_socket.c,v
retrieving revision 1.239
diff -p -u -r1.239 uipc_socket.c
--- kern/uipc_socket.c	24 Apr 2015 22:32:37 -0000	1.239
+++ kern/uipc_socket.c	26 Apr 2015 17:31:59 -0000
@@ -811,7 +811,7 @@ soaccept(struct socket *so, struct socka
 }
 
 int
-soconnect(struct socket *so, struct mbuf *nam, struct lwp *l)
+soconnect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	int error;
 
@@ -1051,12 +1051,17 @@ sosend(struct socket *so, struct mbuf *a
 				so->so_options |= SO_DONTROUTE;
 			if (resid > 0)
 				so->so_state |= SS_MORETOCOME;
-			if (flags & MSG_OOB)
+			if (flags & MSG_OOB) {
 				error = (*so->so_proto->pr_usrreqs->pr_sendoob)(so,
 				    top, control);
-			else
+			} else {
+				struct sockaddr *sin = NULL;
+				if (addr) {
+					sin = mtod(addr, struct sockaddr *);
+				}
 				error = (*so->so_proto->pr_usrreqs->pr_send)(so,
-				    top, addr, control, l);
+				    top, sin, control, l);
+			}
 			if (dontroute)
 				so->so_options &= ~SO_DONTROUTE;
 			if (resid > 0)
Index: kern/uipc_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.176
diff -p -u -r1.176 uipc_syscalls.c
--- kern/uipc_syscalls.c	24 Apr 2015 22:32:37 -0000	1.176
+++ kern/uipc_syscalls.c	26 Apr 2015 17:31:59 -0000
@@ -336,28 +336,25 @@ sys_connect(struct lwp *l, const struct 
 		syscallarg(unsigned int)		namelen;
 	} */
 	int		error;
-	struct mbuf	*nam;
+	struct sockaddr_big sbig;
 
-	error = sockargs(&nam, SCARG(uap, name), SCARG(uap, namelen),
-	    MT_SONAME);
+	error = sockargs_sb(&sbig, SCARG(uap, name), SCARG(uap, namelen));
 	if (error)
 		return error;
-	return do_sys_connect(l,  SCARG(uap, s), nam);
+	return do_sys_connect(l, SCARG(uap, s), (struct sockaddr *)&sbig);
 }
 
 int
-do_sys_connect(struct lwp *l, int fd, struct mbuf *nam)
+do_sys_connect(struct lwp *l, int fd, struct sockaddr *nam)
 {
 	struct socket	*so;
 	int		error;
 	int		interrupted = 0;
 
 	if ((error = fd_getsock(fd, &so)) != 0) {
-		m_freem(nam);
 		return (error);
 	}
 	solock(so);
-	MCLAIM(nam, so->so_mowner);
 	if ((so->so_state & SS_ISCONNECTING) != 0) {
 		error = EALREADY;
 		goto out;
@@ -396,7 +393,6 @@ do_sys_connect(struct lwp *l, int fd, st
  out:
 	sounlock(so);
 	fd_putfile(fd);
-	m_freem(nam);
 	return error;
 }
 
Index: kern/uipc_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.177
diff -p -u -r1.177 uipc_usrreq.c
--- kern/uipc_usrreq.c	24 Apr 2015 22:32:37 -0000	1.177
+++ kern/uipc_usrreq.c	26 Apr 2015 17:31:59 -0000
@@ -409,7 +409,7 @@ unp_recvoob(struct socket *so, struct mb
 }
 
 static int
-unp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+unp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct unpcb *unp = sotounpcb(so);
@@ -896,28 +896,6 @@ unp_sockaddr(struct socket *so, struct s
 }
 
 /*
- * Allocate the new sockaddr.  We have to allocate one
- * extra byte so that we can ensure that the pathname
- * is nul-terminated. Note that unlike linux, we don't
- * include in the address length the NUL in the path
- * component, because doing so, would exceed sizeof(sockaddr_un)
- * for fully occupied pathnames. Linux is also inconsistent,
- * because it does not include the NUL in the length of
- * what it calls "abstract" unix sockets.
- */
-static struct sockaddr_un *
-makeun(struct mbuf *nam, size_t *addrlen)
-{
-	struct sockaddr_un *sun;
-
-	*addrlen = nam->m_len + 1;
-	sun = malloc(*addrlen, M_SONAME, M_WAITOK);
-	m_copydata(nam, 0, nam->m_len, (void *)sun);
-	*(((char *)sun) + nam->m_len) = '\0';
-	return sun;
-}
-
-/*
  * we only need to perform this allocation until syscalls other than
  * bind are adjusted to use sockaddr_big.
  */
@@ -1140,7 +1118,7 @@ unp_connect1(struct socket *so, struct s
 }
 
 int
-unp_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+unp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct sockaddr_un *sun;
 	vnode_t *vp;
@@ -1162,7 +1140,7 @@ unp_connect(struct socket *so, struct mb
 	unp->unp_flags |= UNP_BUSY;
 	sounlock(so);
 
-	sun = makeun(nam, &addrlen);
+	sun = makeun_sb(nam, &addrlen);
 	pb = pathbuf_create(sun->sun_path);
 	if (pb == NULL) {
 		error = ENOMEM;
Index: net/if_gre.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_gre.c,v
retrieving revision 1.164
diff -p -u -r1.164 if_gre.c
--- net/if_gre.c	24 Apr 2015 22:32:37 -0000	1.164
+++ net/if_gre.c	26 Apr 2015 17:31:59 -0000
@@ -418,9 +418,8 @@ static int
 gre_socreate(struct gre_softc *sc, const struct gre_soparm *sp, int *fdout)
 {
 	int fd, rc;
-	struct mbuf *m;
-	struct sockaddr *sa;
 	struct socket *so;
+	struct sockaddr_big sbig;
 	sa_family_t af;
 	int val;
 
@@ -436,32 +435,21 @@ gre_socreate(struct gre_softc *sc, const
 	if ((rc = fd_getsock(fd, &so)) != 0)
 		return rc;
 
-	if ((m = getsombuf(so, MT_SONAME)) == NULL) {
-		rc = ENOBUFS;
-		goto out;
-	}
-	sa = mtod(m, struct sockaddr *);
-	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, sa, curlwp)) != 0) {
+	memcpy(&sbig, &sp->sp_src, sizeof(sp->sp_src));
+	if ((rc = sobind(so, (struct sockaddr *)&sbig, curlwp)) != 0) {
 		GRE_DPRINTF(sc, "sobind failed\n");
 		goto out;
 	}
 
-	sockaddr_copy(sa, MIN(MLEN, sizeof(sp->sp_dst)), sstocsa(&sp->sp_dst));
-	m->m_len = sp->sp_dst.ss_len;
-
+	memcpy(&sbig, &sp->sp_dst, sizeof(sp->sp_dst));
 	solock(so);
-	if ((rc = soconnect(so, m, curlwp)) != 0) {
+	if ((rc = soconnect(so, (struct sockaddr *)&sbig, curlwp)) != 0) {
 		GRE_DPRINTF(sc, "soconnect failed\n");
 		sounlock(so);
 		goto out;
 	}
 	sounlock(so);
 
-	m = NULL;
-
 	/* XXX convert to a (new) SOL_SOCKET call */
   	KASSERT(so->so_proto != NULL);
  	rc = so_setsockopt(curlwp, so, IPPROTO_IP, IP_TTL,
@@ -479,8 +467,6 @@ gre_socreate(struct gre_softc *sc, const
 		rc = 0;
 	}
 out:
-	m_freem(m);
-
 	if (rc != 0)
 		fd_close(fd);
 	else  {
Index: net/link_proto.c
===================================================================
RCS file: /cvsroot/src/sys/net/link_proto.c,v
retrieving revision 1.26
diff -p -u -r1.26 link_proto.c
--- net/link_proto.c	24 Apr 2015 22:32:37 -0000	1.26
+++ net/link_proto.c	26 Apr 2015 17:31:59 -0000
@@ -53,7 +53,7 @@ static void link_detach(struct socket *)
 static int link_accept(struct socket *, struct sockaddr *);
 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_connect(struct socket *, struct sockaddr *, struct lwp *);
 static int link_connect2(struct socket *, struct socket *);
 static int link_disconnect(struct socket *);
 static int link_shutdown(struct socket *);
@@ -64,7 +64,7 @@ static int link_peeraddr(struct socket *
 static int link_sockaddr(struct socket *, struct sockaddr *);
 static int link_rcvd(struct socket *, int, struct lwp *);
 static int link_recvoob(struct socket *, struct mbuf *, int);
-static int link_send(struct socket *, struct mbuf *, struct mbuf *,
+static int link_send(struct socket *, struct mbuf *, struct sockaddr *,
     struct mbuf *, struct lwp *);
 static int link_sendoob(struct socket *, struct mbuf *, struct mbuf *);
 static int link_purgeif(struct socket *, struct ifnet *);
@@ -290,7 +290,7 @@ link_listen(struct socket *so, struct lw
 }
 
 static int
-link_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+link_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
  	KASSERT(solocked(so));
 
@@ -376,7 +376,7 @@ link_recvoob(struct socket *so, struct m
 }
 
 static int
-link_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+link_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	KASSERT(solocked(so));
Index: net/raw_cb.h
===================================================================
RCS file: /cvsroot/src/sys/net/raw_cb.h,v
retrieving revision 1.24
diff -p -u -r1.24 raw_cb.h
--- net/raw_cb.h	24 Apr 2015 22:32:37 -0000	1.24
+++ net/raw_cb.h	26 Apr 2015 17:31:59 -0000
@@ -71,7 +71,7 @@ int	raw_usrreq(struct socket *,
 void	raw_setsockaddr(struct rawcb *, struct sockaddr *);
 void	raw_setpeeraddr(struct rawcb *, struct sockaddr *);
 int	raw_send(struct socket *,
-	    struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
+	    struct mbuf *, struct sockaddr *, struct mbuf *, struct lwp *);
 
 #endif /* _KERNEL */
 
Index: net/raw_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/net/raw_usrreq.c,v
retrieving revision 1.53
diff -p -u -r1.53 raw_usrreq.c
--- net/raw_usrreq.c	24 Apr 2015 22:32:37 -0000	1.53
+++ net/raw_usrreq.c	26 Apr 2015 17:31:59 -0000
@@ -152,7 +152,7 @@ raw_setpeeraddr(struct rawcb *rp, struct
 }
 
 int
-raw_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+raw_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct rawcb *rp = sotorawcb(so);
Index: net/rtsock.c
===================================================================
RCS file: /cvsroot/src/sys/net/rtsock.c,v
retrieving revision 1.169
diff -p -u -r1.169 rtsock.c
--- net/rtsock.c	24 Apr 2015 22:32:37 -0000	1.169
+++ net/rtsock.c	26 Apr 2015 17:31:59 -0000
@@ -255,7 +255,7 @@ COMPATNAME(route_listen)(struct socket *
 }
 
 static int
-COMPATNAME(route_connect)(struct socket *so, struct mbuf *nam, struct lwp *l)
+COMPATNAME(route_connect)(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
@@ -378,7 +378,7 @@ COMPATNAME(route_recvoob)(struct socket 
 
 static int
 COMPATNAME(route_send)(struct socket *so, struct mbuf *m,
-    struct mbuf *nam, struct mbuf *control, struct lwp *l)
+    struct sockaddr *nam, struct mbuf *control, struct lwp *l)
 {
 	int error = 0;
 	int s;
Index: netatalk/ddp_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netatalk/ddp_usrreq.c,v
retrieving revision 1.66
diff -p -u -r1.66 ddp_usrreq.c
--- netatalk/ddp_usrreq.c	24 Apr 2015 23:36:48 -0000	1.66
+++ netatalk/ddp_usrreq.c	26 Apr 2015 17:31:59 -0000
@@ -421,7 +421,7 @@ ddp_listen(struct socket *so, struct lwp
 }
 
 static int
-ddp_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+ddp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct ddpcb *ddp = sotoddpcb(so);
 	int error = 0;
@@ -432,9 +432,7 @@ ddp_connect(struct socket *so, struct mb
 
 	if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT)
 		return EISCONN;
-	if (nam->m_len != sizeof(struct sockaddr_at))
-		return EINVAL;
-	error = at_pcbconnect(ddp, mtod(nam, struct sockaddr_at *));
+	error = at_pcbconnect(ddp, (struct sockaddr_at *)nam);
 	if (error == 0)
 		soisconnected(so);
 
@@ -535,7 +533,7 @@ ddp_recvoob(struct socket *so, struct mb
 }
 
 static int
-ddp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+ddp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct ddpcb *ddp = sotoddpcb(so);
@@ -549,9 +547,7 @@ ddp_send(struct socket *so, struct mbuf 
 		if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT)
 			return EISCONN;
 		s = splnet();
-		if (nam->m_len != sizeof(struct sockaddr_at))
-			return EINVAL;
-		error = at_pcbconnect(ddp, mtod(nam, struct sockaddr_at *));
+		error = at_pcbconnect(ddp, (struct sockaddr_at *)nam);
 		if (error) {
 			splx(s);
 			return error;
Index: netbt/hci_socket.c
===================================================================
RCS file: /cvsroot/src/sys/netbt/hci_socket.c,v
retrieving revision 1.42
diff -p -u -r1.42 hci_socket.c
--- netbt/hci_socket.c	24 Apr 2015 22:32:37 -0000	1.42
+++ netbt/hci_socket.c	26 Apr 2015 17:31:59 -0000
@@ -526,16 +526,15 @@ hci_listen(struct socket *so, struct lwp
 }
 
 static int
-hci_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+hci_connect(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;
 
@@ -666,11 +665,11 @@ hci_recvoob(struct socket *so, struct mb
 }
 
 static int
-hci_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+hci_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct hci_pcb *pcb = so->so_pcb;
-	struct sockaddr_bt * sa = NULL;
+	struct sockaddr_bt * sa = (struct sockaddr_bt *)nam;
 	int err = 0;
 
 	KASSERT(solocked(so));
@@ -680,8 +679,6 @@ hci_send(struct socket *so, struct mbuf 
 		m_freem(control);
 
 	if (nam) {
-		sa = mtod(nam, struct sockaddr_bt *);
-
 		if (sa->bt_len != sizeof(struct sockaddr_bt)) {
 			err = EINVAL;
 			goto release;
Index: netbt/l2cap_socket.c
===================================================================
RCS file: /cvsroot/src/sys/netbt/l2cap_socket.c,v
retrieving revision 1.33
diff -p -u -r1.33 l2cap_socket.c
--- netbt/l2cap_socket.c	24 Apr 2015 22:32:37 -0000	1.33
+++ netbt/l2cap_socket.c	26 Apr 2015 17:31:59 -0000
@@ -165,10 +165,10 @@ l2cap_listen(struct socket *so, struct l
 }
 
 static int
-l2cap_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+l2cap_connect(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);
@@ -176,7 +176,6 @@ l2cap_connect(struct socket *so, struct 
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
@@ -292,7 +291,7 @@ l2cap_recvoob(struct socket *so, struct 
 }
 
 static int
-l2cap_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+l2cap_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct l2cap_channel *pcb = so->so_pcb;
Index: netbt/rfcomm_socket.c
===================================================================
RCS file: /cvsroot/src/sys/netbt/rfcomm_socket.c,v
retrieving revision 1.35
diff -p -u -r1.35 rfcomm_socket.c
--- netbt/rfcomm_socket.c	24 Apr 2015 22:32:37 -0000	1.35
+++ netbt/rfcomm_socket.c	26 Apr 2015 17:31:59 -0000
@@ -173,10 +173,10 @@ rfcomm_listen(struct socket *so, struct 
 }
 
 static int
-rfcomm_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+rfcomm_connect(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);
@@ -184,7 +184,6 @@ rfcomm_connect(struct socket *so, struct
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
@@ -307,7 +306,7 @@ rfcomm_recvoob(struct socket *so, struct
 }
 
 static int
-rfcomm_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+rfcomm_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct rfcomm_dlc *pcb = so->so_pcb;
Index: netbt/sco_socket.c
===================================================================
RCS file: /cvsroot/src/sys/netbt/sco_socket.c,v
retrieving revision 1.35
diff -p -u -r1.35 sco_socket.c
--- netbt/sco_socket.c	24 Apr 2015 22:32:37 -0000	1.35
+++ netbt/sco_socket.c	26 Apr 2015 17:31:59 -0000
@@ -156,10 +156,10 @@ sco_listen(struct socket *so, struct lwp
 }
 
 static int
-sco_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+sco_connect(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);
@@ -167,7 +167,6 @@ sco_connect(struct socket *so, struct mb
 	if (pcb == NULL)
 		return EINVAL;
 
-	sa = mtod(nam, struct sockaddr_bt *);
 	if (sa->bt_len != sizeof(struct sockaddr_bt))
 		return EINVAL;
 
@@ -285,7 +284,7 @@ sco_recvoob(struct socket *so, struct mb
 }
 
 static int
-sco_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+sco_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct sco_pcb *pcb = so->so_pcb;
Index: netinet/dccp_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/dccp_usrreq.c,v
retrieving revision 1.3
diff -p -u -r1.3 dccp_usrreq.c
--- netinet/dccp_usrreq.c	24 Apr 2015 22:32:37 -0000	1.3
+++ netinet/dccp_usrreq.c	26 Apr 2015 17:31:59 -0000
@@ -1852,11 +1852,10 @@ dccp_bind(struct socket *so, struct sock
  * Called by the connect system call.
  */
 static int
-dccp_connect(struct socket *so, struct mbuf *m, struct lwp *l)
+dccp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp;
 	struct dccpcb *dp;
-	struct sockaddr *nam;
 	int error;
 	struct sockaddr_in *sin;
 	char test[2];
@@ -1890,7 +1889,6 @@ dccp_connect(struct socket *so, struct m
 
 	dccpstat.dccps_connattempt++;
 
-	nam = mtod(m, struct sockaddr *);
 	sin = (struct sockaddr_in *)nam;
 	if (sin->sin_family == AF_INET
 	    && IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
@@ -1898,7 +1896,7 @@ dccp_connect(struct socket *so, struct m
 		goto bad;
 	}
 
-	error = dccp_doconnect(so, m, l, 0);
+	error = dccp_doconnect(so, nam, l, 0);
 
 	if (error != 0)
 		goto bad;
@@ -1932,7 +1930,8 @@ dccp_connect2(struct socket *so, struct 
  *
  */
 int
-dccp_doconnect(struct socket *so, struct mbuf *m, struct lwp *l, int isipv6)
+dccp_doconnect(struct socket *so, struct sockaddr *nam,
+    struct lwp *l, int isipv6)
 { 
 	struct inpcb *inp;
 #ifdef INET6
@@ -1975,11 +1974,11 @@ dccp_doconnect(struct socket *so, struct
 
 #ifdef INET6
 	if (isipv6) {
-		error = in6_pcbconnect(in6p, m, l);
+		error = in6_pcbconnect(in6p, (struct sockaddr_in6 *)nam, l);
 		DCCP_DEBUG((LOG_INFO, "in6_pcbconnect=%d\n",error));
 	} else
 #endif
-		error = in_pcbconnect(inp, m, l);
+		error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l);
 	if (error) {
 		DCCP_DEBUG((LOG_INFO, "in_pcbconnect=%d\n",error));
 		return error;
@@ -2113,12 +2112,11 @@ dccp_disconnect2(struct dccpcb *dp)
 }
 
 int
-dccp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+dccp_send(struct socket *so, struct mbuf *m, struct sockaddr *addr,
     struct mbuf *control, struct lwp *l)
 {
 	struct inpcb	*inp;
 	struct dccpcb	*dp;
-	struct sockaddr *addr;
 	int		error = 0;
 	int		isipv6 = 0;
 
@@ -2132,11 +2130,6 @@ dccp_send(struct socket *so, struct mbuf
 		return EINVAL;
 	}
 
-	if (nam == 0)
-		addr = NULL;
-	else
-		addr = mtod(nam, struct sockaddr *);
-
 #ifdef INET6
 	isipv6 = addr && addr->sa_family == AF_INET6;
 #endif
@@ -2198,7 +2191,7 @@ dccp_send(struct socket *so, struct mbuf
 	dp->pktcnt ++;
 
 	if (addr && dp->state == DCCPS_CLOSED) {
-		error = dccp_doconnect(so, nam, l, isipv6);
+		error = dccp_doconnect(so, addr, l, isipv6);
 		if (error)
 			goto out;
 	}
Index: netinet/dccp_var.h
===================================================================
RCS file: /cvsroot/src/sys/netinet/dccp_var.h,v
retrieving revision 1.1
diff -p -u -r1.1 dccp_var.h
--- netinet/dccp_var.h	10 Feb 2015 19:11:52 -0000	1.1
+++ netinet/dccp_var.h	26 Apr 2015 17:31:59 -0000
@@ -306,14 +306,14 @@ struct dccpcb *
 	dccp_newdccpcb(int, void *);
 int	dccp_shutdown(struct socket *);
 int	dccp_output(struct dccpcb *, u_int8_t);
-int	dccp_doconnect(struct socket *, struct mbuf *, struct lwp *, int);
+int	dccp_doconnect(struct socket *, struct sockaddr *, struct lwp *, int);
 int	dccp_add_option(struct dccpcb *, u_int8_t, char *, u_int8_t);
 int	dccp_add_feature(struct dccpcb *, u_int8_t, u_int8_t,  char *, u_int8_t);
 int	dccp_detach(struct socket *);
 int	dccp_attach(struct socket *, int);
 int	dccp_abort(struct socket *);
 int	dccp_disconnect(struct socket *);
-int	dccp_send(struct socket *, struct mbuf *, struct mbuf *,
+int	dccp_send(struct socket *, struct mbuf *, struct sockaddr *,
 		  struct mbuf *, struct lwp *);
 void	dccp_retrans_t(void *);
 void	dccp_connect_t(void *);
Index: netinet/in_pcb.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/in_pcb.c,v
retrieving revision 1.158
diff -p -u -r1.158 in_pcb.c
--- netinet/in_pcb.c	26 Apr 2015 16:45:51 -0000	1.158
+++ netinet/in_pcb.c	26 Apr 2015 17:31:59 -0000
@@ -441,26 +441,40 @@ in_pcbbind(void *v, struct sockaddr_in *
 }
 
 /*
+ * adapter function that accepts nam as mbuf while transitioning
+ * pr_usrreqs parameters from type mbuf to type sockaddr.  this
+ * function will disappear when transition is complete.
+ */
+int
+in_pcbconnect_m(void *v, struct mbuf *nam, struct lwp *l)
+{
+	struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
+
+	if (sizeof (*sin) != nam->m_len) {
+		return EINVAL;
+	}
+
+	return in_pcbconnect(v, sin, l);
+}
+
+/*
  * Connect from a socket to a specified address.
  * Both address and port must be specified in argument sin.
  * If don't have a local address for this socket yet,
  * then pick one.
  */
 int
-in_pcbconnect(void *v, struct mbuf *nam, struct lwp *l)
+in_pcbconnect(void *v, struct sockaddr_in *sin, struct lwp *l)
 {
 	struct inpcb *inp = v;
 	struct in_ifaddr *ia = NULL;
 	struct sockaddr_in *ifaddr = NULL;
-	struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
 	vestigial_inpcb_t vestige;
 	int error;
 
 	if (inp->inp_af != AF_INET)
 		return (EINVAL);
 
-	if (nam->m_len != sizeof (*sin))
-		return (EINVAL);
 	if (sin->sin_len != sizeof (*sin))
 		return (EINVAL);
 	if (sin->sin_family != AF_INET)
Index: netinet/in_pcb.h
===================================================================
RCS file: /cvsroot/src/sys/netinet/in_pcb.h,v
retrieving revision 1.57
diff -p -u -r1.57 in_pcb.h
--- netinet/in_pcb.h	24 Apr 2015 22:32:37 -0000	1.57
+++ netinet/in_pcb.h	26 Apr 2015 17:31:59 -0000
@@ -132,7 +132,8 @@ struct inpcb {
 void	in_losing(struct inpcb *);
 int	in_pcballoc(struct socket *, void *);
 int	in_pcbbind(void *, struct sockaddr_in *, struct lwp *);
-int	in_pcbconnect(void *, struct mbuf *, struct lwp *);
+int	in_pcbconnect(void *, struct sockaddr_in *, struct lwp *);
+int	in_pcbconnect_m(void *, struct mbuf *, struct lwp *);
 void	in_pcbdetach(void *);
 void	in_pcbdisconnect(void *);
 void	in_pcbinit(struct inpcbtable *, int, int);
Index: netinet/raw_ip.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/raw_ip.c,v
retrieving revision 1.149
diff -p -u -r1.149 raw_ip.c
--- netinet/raw_ip.c	25 Apr 2015 15:19:54 -0000	1.149
+++ netinet/raw_ip.c	26 Apr 2015 17:31:59 -0000
@@ -598,7 +598,7 @@ rip_listen(struct socket *so, struct lwp
 }
 
 static int
-rip_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
 	int error = 0;
@@ -609,9 +609,7 @@ rip_connect(struct socket *so, struct mb
 	KASSERT(nam != NULL);
 
 	s = splsoftnet();
-	if (nam->m_len != sizeof(struct sockaddr_in))
-		return EINVAL;
-	error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *));
+	error = rip_connect_pcb(inp, (struct sockaddr_in *)nam);
 	if (! error)
 		soisconnected(so);
 	splx(s);
@@ -735,7 +733,7 @@ rip_recvoob(struct socket *so, struct mb
 }
 
 static int
-rip_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+rip_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
@@ -762,9 +760,7 @@ rip_send(struct socket *so, struct mbuf 
 			error = EISCONN;
 			goto die;
 		}
-		if (nam->m_len != sizeof(struct sockaddr_in))
-			return EINVAL;
-		error = rip_connect_pcb(inp, mtod(nam, struct sockaddr_in *));
+		error = rip_connect_pcb(inp, (struct sockaddr_in *)nam);
 		if (error) {
 		die:
 			m_freem(m);
Index: netinet/tcp_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_input.c,v
retrieving revision 1.337
diff -p -u -r1.337 tcp_input.c
--- netinet/tcp_input.c	14 Mar 2015 02:08:16 -0000	1.337
+++ netinet/tcp_input.c	26 Apr 2015 17:32:00 -0000
@@ -4077,7 +4077,7 @@ syn_cache_get(struct sockaddr *src, stru
 	am->m_len = src->sa_len;
 	bcopy(src, mtod(am, void *), src->sa_len);
 	if (inp) {
-		if (in_pcbconnect(inp, am, &lwp0)) {
+		if (in_pcbconnect_m(inp, am, &lwp0)) {
 			(void) m_free(am);
 			goto resetandabort;
 		}
@@ -4098,7 +4098,7 @@ syn_cache_get(struct sockaddr *src, stru
 				&sin6->sin6_addr.s6_addr32[3],
 				sizeof(sin6->sin6_addr.s6_addr32[3]));
 		}
-		if (in6_pcbconnect(in6p, am, NULL)) {
+		if (in6_pcbconnect_m(in6p, am, NULL)) {
 			(void) m_free(am);
 			goto resetandabort;
 		}
Index: netinet/tcp_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_usrreq.c,v
retrieving revision 1.206
diff -p -u -r1.206 tcp_usrreq.c
--- netinet/tcp_usrreq.c	24 Apr 2015 22:32:37 -0000	1.206
+++ netinet/tcp_usrreq.c	26 Apr 2015 17:32:00 -0000
@@ -801,7 +801,7 @@ release:
 }
 
 static int
-tcp_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+tcp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = NULL;
 	struct in6pcb *in6p = NULL;
@@ -830,7 +830,7 @@ tcp_connect(struct socket *so, struct mb
 			if (error)
 				goto release;
 		}
-		error = in_pcbconnect(inp, nam, l);
+		error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l);
 	}
 #endif
 #ifdef INET6
@@ -840,7 +840,7 @@ tcp_connect(struct socket *so, struct mb
 			if (error)
 				goto release;
 		}
-		error = in6_pcbconnect(in6p, nam, l);
+		error = in6_pcbconnect(in6p, (struct sockaddr_in6 *)nam, l);
 		if (!error) {
 			/* mapped addr case */
 			if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr))
@@ -1161,7 +1161,7 @@ tcp_recvoob(struct socket *so, struct mb
 }
 
 static int
-tcp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+tcp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct inpcb *inp = NULL;
Index: netinet/udp_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.219
diff -p -u -r1.219 udp_usrreq.c
--- netinet/udp_usrreq.c	24 Apr 2015 22:32:37 -0000	1.219
+++ netinet/udp_usrreq.c	26 Apr 2015 17:32:00 -0000
@@ -932,7 +932,7 @@ udp_listen(struct socket *so, struct lwp
 }
 
 static int
-udp_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
 	int error = 0;
@@ -943,7 +943,7 @@ udp_connect(struct socket *so, struct mb
 	KASSERT(nam != NULL);
 
 	s = splsoftnet();
-	error = in_pcbconnect(inp, nam, l);
+	error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l);
 	if (! error)
 		soisconnected(so);
 	splx(s);
@@ -1066,7 +1066,7 @@ udp_recvoob(struct socket *so, struct mb
 }
 
 static int
-udp_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+udp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct inpcb *inp = sotoinpcb(so);
@@ -1093,7 +1093,7 @@ udp_send(struct socket *so, struct mbuf 
 			error = EISCONN;
 			goto die;
 		}
-		error = in_pcbconnect(inp, nam, l);
+		error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l);
 		if (error)
 			goto die;
 	} else {
Index: netinet6/dccp6_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/dccp6_usrreq.c,v
retrieving revision 1.4
diff -p -u -r1.4 dccp6_usrreq.c
--- netinet6/dccp6_usrreq.c	25 Apr 2015 14:56:05 -0000	1.4
+++ netinet6/dccp6_usrreq.c	26 Apr 2015 17:32:00 -0000
@@ -143,13 +143,12 @@ dccp6_bind(struct socket *so, struct soc
 }
 
 int
-dccp6_connect(struct socket *so, struct mbuf *m, struct lwp *l)
+dccp6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct in6pcb *in6p;
 	struct dccpcb *dp;
 	int error;
 	struct sockaddr_in6 *sin6;
-	struct sockaddr *nam;
 	char test[2];
 
 	DCCP_DEBUG((LOG_INFO, "Entering dccp6_connect!\n"));
@@ -187,7 +186,6 @@ dccp6_connect(struct socket *so, struct 
 	dp->who = DCCP_CLIENT;
 	dp->seq_snd = (((u_int64_t)random() << 32) | random()) % 281474976710656LL;
 
-	nam = mtod(m, struct sockaddr *);
 	sin6 = (struct sockaddr_in6 *)nam;
 	if (sin6->sin6_family == AF_INET6
 	    && IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
@@ -198,7 +196,7 @@ dccp6_connect(struct socket *so, struct 
 	dp->inp_vflag &= ~INP_IPV4;
 	dp->inp_vflag |= INP_IPV6;
 
-	error = dccp_doconnect(so, m, l, 1);
+	error = dccp_doconnect(so, nam, l, 1);
 
 	if (error != 0)
 		goto bad;
@@ -458,7 +456,7 @@ dccp6_rcvd(struct socket *so, int flags,
 }
 
 static int
-dccp6_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+dccp6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	return dccp_send(so, m, nam, control, l);
Index: netinet6/dccp6_var.h
===================================================================
RCS file: /cvsroot/src/sys/netinet6/dccp6_var.h,v
retrieving revision 1.3
diff -p -u -r1.3 dccp6_var.h
--- netinet6/dccp6_var.h	25 Apr 2015 14:56:05 -0000	1.3
+++ netinet6/dccp6_var.h	26 Apr 2015 17:32:00 -0000
@@ -45,7 +45,7 @@ int	dccp6_usrreq(struct socket *, int, s
 		     struct mbuf *, struct lwp *);
 int	dccp6_bind(struct socket *, struct sockaddr *, struct lwp *);
 int	dccp6_listen(struct socket *, struct lwp *);
-int	dccp6_connect(struct socket *, struct mbuf *, struct lwp *);
+int	dccp6_connect(struct socket *, struct sockaddr *, struct lwp *);
 int	dccp6_accept(struct socket *, struct sockaddr *);
 
 #endif
Index: netinet6/in6_pcb.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.137
diff -p -u -r1.137 in6_pcb.c
--- netinet6/in6_pcb.c	26 Apr 2015 16:45:50 -0000	1.137
+++ netinet6/in6_pcb.c	26 Apr 2015 17:32:00 -0000
@@ -418,18 +418,34 @@ in6_pcbbind(void *v, struct sockaddr_in6
 }
 
 /*
+ * adapter function that accepts nam as mbuf while transitioning
+ * pr_usrreqs parameters from type mbuf to type sockaddr.  this
+ * function will disappear when transition is complete.
+ */
+int
+in6_pcbconnect_m(void *v, struct mbuf *nam, struct lwp *l)
+{
+	struct sockaddr_in6 *sin6 = mtod(nam, struct sockaddr_in6 *);
+
+	if (sizeof (*sin6) != nam->m_len) {
+		return EINVAL;
+	}
+
+	return in6_pcbconnect(v, sin6, l);
+}
+
+/*
  * Connect from a socket to a specified address.
  * Both address and port must be specified in argument sin6.
  * If don't have a local address for this socket yet,
  * then pick one.
  */
 int
-in6_pcbconnect(void *v, struct mbuf *nam, struct lwp *l)
+in6_pcbconnect(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
 {
 	struct rtentry *rt;
 	struct in6pcb *in6p = v;
 	struct in6_addr *in6a = NULL;
-	struct sockaddr_in6 *sin6 = mtod(nam, struct sockaddr_in6 *);
 	struct ifnet *ifp = NULL;	/* outgoing interface */
 	int error = 0;
 	int scope_ambiguous = 0;
@@ -444,8 +460,6 @@ in6_pcbconnect(void *v, struct mbuf *nam
 	if (in6p->in6p_af != AF_INET6)
 		return (EINVAL);
 
-	if (nam->m_len != sizeof(*sin6))
-		return (EINVAL);
 	if (sin6->sin6_len != sizeof(*sin6))
 		return (EINVAL);
 	if (sin6->sin6_family != AF_INET6)
Index: netinet6/in6_pcb.h
===================================================================
RCS file: /cvsroot/src/sys/netinet6/in6_pcb.h,v
retrieving revision 1.43
diff -p -u -r1.43 in6_pcb.h
--- netinet6/in6_pcb.h	24 Apr 2015 22:32:37 -0000	1.43
+++ netinet6/in6_pcb.h	26 Apr 2015 17:32:00 -0000
@@ -157,7 +157,8 @@ void	in6_losing(struct in6pcb *);
 void	in6_pcbinit(struct inpcbtable *, int, int);
 int	in6_pcballoc(struct socket *, void *);
 int	in6_pcbbind(void *, struct sockaddr_in6 *, struct lwp *);
-int	in6_pcbconnect(void *, struct mbuf *, struct lwp *);
+int	in6_pcbconnect(void *, struct sockaddr_in6 *, struct lwp *);
+int	in6_pcbconnect_m(void *, struct mbuf *, struct lwp *);
 void	in6_pcbdetach(struct in6pcb *);
 void	in6_pcbdisconnect(struct in6pcb *);
 struct	in6pcb *in6_pcblookup_port(struct inpcbtable *, struct in6_addr *,
Index: netinet6/raw_ip6.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/raw_ip6.c,v
retrieving revision 1.138
diff -p -u -r1.138 raw_ip6.c
--- netinet6/raw_ip6.c	24 Apr 2015 22:32:37 -0000	1.138
+++ netinet6/raw_ip6.c	26 Apr 2015 17:32:00 -0000
@@ -698,10 +698,10 @@ rip6_listen(struct socket *so, struct lw
 }
 
 static int
-rip6_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+rip6_connect(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 in6_addr *in6a = NULL;
 	struct ifnet *ifp = NULL;
 	int scope_ambiguous = 0;
@@ -711,10 +711,6 @@ rip6_connect(struct socket *so, struct m
 	KASSERT(in6p != NULL);
 	KASSERT(nam != NULL);
 
-	addr = mtod(nam, struct sockaddr_in6 *);
-
-	if (nam->m_len != sizeof(*addr))
-		return EINVAL;
 	if (IFNET_EMPTY())
 		return EADDRNOTAVAIL;
 	if (addr->sin6_family != AF_INET6)
@@ -853,7 +849,7 @@ rip6_recvoob(struct socket *so, struct m
 }
 
 static int
-rip6_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+rip6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct in6pcb *in6p = sotoin6pcb(so);
@@ -884,12 +880,7 @@ rip6_send(struct socket *so, struct mbuf
 			error = ENOTCONN;
 			goto release;
 		}
-		if (nam->m_len != sizeof(tmp)) {
-			error = EINVAL;
-			goto release;
-		}
-
-		tmp = *mtod(nam, struct sockaddr_in6 *);
+		tmp = *(struct sockaddr_in6 *)nam;
 		dst = &tmp;
 
 		if (dst->sin6_family != AF_INET6) {
Index: netinet6/udp6_output.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/udp6_output.c,v
retrieving revision 1.47
diff -p -u -r1.47 udp6_output.c
--- netinet6/udp6_output.c	5 Dec 2014 18:45:37 -0000	1.47
+++ netinet6/udp6_output.c	26 Apr 2015 17:32:00 -0000
@@ -112,7 +112,7 @@ __KERNEL_RCSID(0, "$NetBSD: udp6_output.
 
 int
 udp6_output(struct in6pcb * const in6p, struct mbuf *m,
-    struct mbuf * const addr6, struct mbuf * const control,
+    struct sockaddr_in6 * const addr6, struct mbuf * const control,
     struct lwp * const l)
 {
 	struct rtentry *rt;
@@ -138,11 +138,7 @@ udp6_output(struct in6pcb * const in6p, 
 	struct sockaddr_in6 tmp;
 
 	if (addr6) {
-		if (addr6->m_len != sizeof(*sin6)) {
-			error = EINVAL;
-			goto release;
-		}
-		sin6 = mtod(addr6, struct sockaddr_in6 *);
+		sin6 = addr6;
 		if (sin6->sin6_family != AF_INET6) {
 			error = EAFNOSUPPORT;
 			goto release;
Index: netinet6/udp6_usrreq.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/udp6_usrreq.c,v
retrieving revision 1.118
diff -p -u -r1.118 udp6_usrreq.c
--- netinet6/udp6_usrreq.c	24 Apr 2015 22:32:37 -0000	1.118
+++ netinet6/udp6_usrreq.c	26 Apr 2015 17:32:00 -0000
@@ -721,7 +721,7 @@ udp6_listen(struct socket *so, struct lw
 }
 
 static int
-udp6_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+udp6_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	struct in6pcb *in6p = sotoin6pcb(so);
 	int error = 0;
@@ -733,7 +733,7 @@ udp6_connect(struct socket *so, struct m
 	if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr))
 		return EISCONN;
 	s = splsoftnet();
-	error = in6_pcbconnect(in6p, nam, l);
+	error = in6_pcbconnect(in6p, (struct sockaddr_in6 *)nam, l);
 	splx(s);
 	if (error == 0)
 		soisconnected(so);
@@ -863,7 +863,7 @@ udp6_recvoob(struct socket *so, struct m
 }
 
 static int
-udp6_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+udp6_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	struct in6pcb *in6p = sotoin6pcb(so);
@@ -875,7 +875,7 @@ udp6_send(struct socket *so, struct mbuf
 	KASSERT(m != NULL);
 
 	s = splsoftnet();
-	error = udp6_output(in6p, m, nam, control, l);
+	error = udp6_output(in6p, m, (struct sockaddr_in6 *)nam, control, l);
 	splx(s);
 
 	return error;
Index: netinet6/udp6_var.h
===================================================================
RCS file: /cvsroot/src/sys/netinet6/udp6_var.h,v
retrieving revision 1.27
diff -p -u -r1.27 udp6_var.h
--- netinet6/udp6_var.h	22 May 2014 22:56:53 -0000	1.27
+++ netinet6/udp6_var.h	26 Apr 2015 17:32:00 -0000
@@ -106,7 +106,7 @@ void	*udp6_ctlinput(int, const struct so
 int	udp6_ctloutput(int, struct socket *, struct sockopt *);
 void	udp6_init(void);
 int	udp6_input(struct mbuf **, int *, int);
-int	udp6_output(struct in6pcb *, struct mbuf *, struct mbuf *,
+int	udp6_output(struct in6pcb *, struct mbuf *, struct sockaddr_in6 *,
     struct mbuf *, struct lwp *);
 int	udp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 int	udp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
Index: netipsec/keysock.c
===================================================================
RCS file: /cvsroot/src/sys/netipsec/keysock.c,v
retrieving revision 1.46
diff -p -u -r1.46 keysock.c
--- netipsec/keysock.c	24 Apr 2015 22:32:38 -0000	1.46
+++ netipsec/keysock.c	26 Apr 2015 17:32:00 -0000
@@ -509,7 +509,7 @@ key_listen(struct socket *so, struct lwp
 }
 
 static int
-key_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+key_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
@@ -631,7 +631,7 @@ key_recvoob(struct socket *so, struct mb
 }
 
 static int
-key_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+key_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	int error = 0;
Index: netmpls/mpls_proto.c
===================================================================
RCS file: /cvsroot/src/sys/netmpls/mpls_proto.c,v
retrieving revision 1.26
diff -p -u -r1.26 mpls_proto.c
--- netmpls/mpls_proto.c	24 Apr 2015 22:32:38 -0000	1.26
+++ netmpls/mpls_proto.c	26 Apr 2015 17:32:00 -0000
@@ -119,7 +119,7 @@ mpls_listen(struct socket *so, struct lw
 }
 
 static int
-mpls_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+mpls_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	KASSERT(solocked(so));
 
@@ -205,7 +205,7 @@ mpls_recvoob(struct socket *so, struct m
 }
 
 static int
-mpls_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+mpls_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control, struct lwp *l)
 {
 	KASSERT(solocked(so));
Index: netnatm/natm.c
===================================================================
RCS file: /cvsroot/src/sys/netnatm/natm.c,v
retrieving revision 1.47
diff -p -u -r1.47 natm.c
--- netnatm/natm.c	24 Apr 2015 22:32:38 -0000	1.47
+++ netnatm/natm.c	26 Apr 2015 17:32:00 -0000
@@ -122,11 +122,11 @@ natm_listen(struct socket *so, struct lw
 }
 
 static int
-natm_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+natm_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	int error = 0, s2;
 	struct natmpcb *npcb;
-	struct sockaddr_natm *snatm;
+	struct sockaddr_natm *snatm = (struct sockaddr_natm *)nam;
 	struct atm_pseudoioctl api;
 	struct atm_pseudohdr *aph;
 	struct ifnet *ifp;
@@ -138,9 +138,6 @@ natm_connect(struct socket *so, struct m
 	 * validate nam and npcb
 	 */
 
-	if (nam->m_len != sizeof(*snatm))
-		return EINVAL;
-	snatm = mtod(nam, struct sockaddr_natm *);
 	if (snatm->snatm_len != sizeof(*snatm) ||
 	    (npcb->npcb_flags & NPCB_FREE) == 0)
 		return EINVAL;
@@ -342,7 +339,7 @@ natm_recvoob(struct socket *so, struct m
 }
 
 static int
-natm_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+natm_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
     struct mbuf *control)
 {
 	struct natmpcb *npcb = (struct natmpcb *) so->so_pcb;
Index: netsmb/smb_trantcp.c
===================================================================
RCS file: /cvsroot/src/sys/netsmb/smb_trantcp.c,v
retrieving revision 1.47
diff -p -u -r1.47 smb_trantcp.c
--- netsmb/smb_trantcp.c	19 May 2014 02:51:25 -0000	1.47
+++ netsmb/smb_trantcp.c	26 Apr 2015 17:32:00 -0000
@@ -185,7 +185,7 @@ nb_connect_in(struct nbpcb *nbp, struct 
 	*mtod(m, struct sockaddr *) = *(struct sockaddr *)to;
 	m->m_len = sizeof(struct sockaddr);
 	solock(so);
-	error = soconnect(so, m, l);
+	error = soconnect(so, mtod(m, struct sockaddr*), l);
 	m_free(m);
 	if (error) {
 		sounlock(so);
Index: nfs/nfs_socket.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_socket.c,v
retrieving revision 1.194
diff -p -u -r1.194 nfs_socket.c
--- nfs/nfs_socket.c	3 Apr 2015 20:01:07 -0000	1.194
+++ nfs/nfs_socket.c	26 Apr 2015 17:32:00 -0000
@@ -243,7 +243,7 @@ nfs_connect(struct nfsmount *nmp, struct
 			goto bad;
 		}
 	} else {
-		error = soconnect(so, nmp->nm_nam, l);
+		error = soconnect(so, mtod(nmp->nm_nam, struct sockaddr *), l);
 		if (error) {
 			sounlock(so);
 			goto bad;
@@ -800,7 +800,8 @@ nfs_timer(void *arg)
 			    m, NULL, NULL, NULL);
 			else
 			    error = (*so->so_proto->pr_usrreqs->pr_send)(so,
-			    m, nmp->nm_nam, NULL, NULL);
+				m, mtod(nmp->nm_nam, struct sockaddr *),
+				NULL, NULL);
 			if (error) {
 				if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) {
 #ifdef DEBUG
Index: rump/net/lib/libsockin/sockin.c
===================================================================
RCS file: /cvsroot/src/sys/rump/net/lib/libsockin/sockin.c,v
retrieving revision 1.60
diff -p -u -r1.60 sockin.c
--- rump/net/lib/libsockin/sockin.c	24 Apr 2015 22:32:38 -0000	1.60
+++ rump/net/lib/libsockin/sockin.c	26 Apr 2015 17:32:00 -0000
@@ -72,7 +72,7 @@ static int	sockin_accept(struct socket *
 static int	sockin_connect2(struct socket *, struct socket *);
 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_connect(struct socket *, struct sockaddr *, struct lwp *);
 static int	sockin_disconnect(struct socket *);
 static int	sockin_shutdown(struct socket *);
 static int	sockin_abort(struct socket *);
@@ -82,7 +82,7 @@ static int	sockin_peeraddr(struct socket
 static int	sockin_sockaddr(struct socket *, struct sockaddr *);
 static int	sockin_rcvd(struct socket *, int, struct lwp *);
 static int	sockin_recvoob(struct socket *, struct mbuf *, int);
-static int	sockin_send(struct socket *, struct mbuf *, struct mbuf *,
+static int	sockin_send(struct socket *, struct mbuf *, struct sockaddr *,
 			    struct mbuf *, struct lwp *);
 static int	sockin_sendoob(struct socket *, struct mbuf *, struct mbuf *);
 static int	sockin_purgeif(struct socket *, struct ifnet *);
@@ -511,15 +511,14 @@ sockin_listen(struct socket *so, struct 
 }
 
 static int
-sockin_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
+sockin_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
 {
 	int error = 0;
 
 	KASSERT(solocked(so));
 	KASSERT(nam != NULL);
 
-	error = rumpcomp_sockin_connect(SO2S(so),
-	    mtod(nam, struct sockaddr *), nam->m_len);
+	error = rumpcomp_sockin_connect(SO2S(so), nam, nam->sa_len);
 	if (error == 0)
 		soisconnected(so);
 
@@ -620,10 +619,9 @@ sockin_recvoob(struct socket *so, struct
 }
 
 static int
-sockin_send(struct socket *so, struct mbuf *m, struct mbuf *nam,
+sockin_send(struct socket *so, struct mbuf *m, struct sockaddr *saddr,
     struct mbuf *control, struct lwp *l)
 {
-	struct sockaddr *saddr;
 	struct msghdr mhdr;
 	size_t iov_max, i;
 	struct iovec iov_buf[32], *iov;
@@ -658,8 +656,7 @@ sockin_send(struct socket *so, struct mb
 	mhdr.msg_iovlen = i;
 	s = SO2S(so);
 
-	if (nam != NULL) {
-		saddr = mtod(nam, struct sockaddr *);
+	if (saddr != NULL) {
 		mhdr.msg_name = saddr;
 		mhdr.msg_namelen = saddr->sa_len;
 	}
Index: sys/param.h
===================================================================
RCS file: /cvsroot/src/sys/sys/param.h,v
retrieving revision 1.474
diff -p -u -r1.474 param.h
--- sys/param.h	24 Apr 2015 22:32:38 -0000	1.474
+++ sys/param.h	26 Apr 2015 17:32:00 -0000
@@ -63,7 +63,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799001200	/* NetBSD 7.99.12 */
+#define	__NetBSD_Version__	799001300	/* NetBSD 7.99.13 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
Index: sys/protosw.h
===================================================================
RCS file: /cvsroot/src/sys/sys/protosw.h,v
retrieving revision 1.62
diff -p -u -r1.62 protosw.h
--- sys/protosw.h	24 Apr 2015 22:32:38 -0000	1.62
+++ sys/protosw.h	26 Apr 2015 17:32:00 -0000
@@ -239,7 +239,7 @@ struct pr_usrreqs {
 	int	(*pr_attach)(struct socket *, int);
 	void	(*pr_detach)(struct socket *);
 	int	(*pr_accept)(struct socket *, struct sockaddr *);
-	int	(*pr_connect)(struct socket *, struct mbuf *, struct lwp *);
+	int	(*pr_connect)(struct socket *, struct sockaddr *, struct lwp *);
 	int	(*pr_connect2)(struct socket *, struct socket *);
 	int	(*pr_bind)(struct socket *, struct sockaddr *, struct lwp *);
 	int	(*pr_listen)(struct socket *, struct lwp *);
@@ -252,7 +252,7 @@ struct pr_usrreqs {
 	int	(*pr_sockaddr)(struct socket *, struct sockaddr *);
 	int	(*pr_rcvd)(struct socket *, int, struct lwp *);
 	int	(*pr_recvoob)(struct socket *, struct mbuf *, int);
-	int	(*pr_send)(struct socket *, struct mbuf *, struct mbuf *,
+	int	(*pr_send)(struct socket *, struct mbuf *, struct sockaddr *,
 	    struct mbuf *, struct lwp *);
 	int	(*pr_sendoob)(struct socket *, struct mbuf *, struct mbuf *);
 	int	(*pr_purgeif)(struct socket *, struct ifnet *);
@@ -329,7 +329,7 @@ name##_bind_wrapper(struct socket *a,			
 }							\
 static int						\
 name##_connect_wrapper(struct socket *a,		\
-    struct mbuf *b, struct lwp *c)			\
+    struct sockaddr *b, struct lwp *c)			\
 {							\
 	int rv;						\
 	KERNEL_LOCK(1, NULL);				\
@@ -444,7 +444,7 @@ name##_recvoob_wrapper(struct socket *a,
 }							\
 static int						\
 name##_send_wrapper(struct socket *a, struct mbuf *b,	\
-    struct mbuf *c, struct mbuf *d, struct lwp *e)	\
+    struct sockaddr *c, struct mbuf *d, struct lwp *e)	\
 {							\
 	int rv;						\
 	KERNEL_LOCK(1, NULL);				\
Index: sys/socketvar.h
===================================================================
RCS file: /cvsroot/src/sys/sys/socketvar.h,v
retrieving revision 1.137
diff -p -u -r1.137 socketvar.h
--- sys/socketvar.h	24 Apr 2015 22:32:38 -0000	1.137
+++ sys/socketvar.h	26 Apr 2015 17:32:00 -0000
@@ -293,7 +293,7 @@ int	sobind(struct socket *, struct socka
 void	socantrcvmore(struct socket *);
 void	socantsendmore(struct socket *);
 int	soclose(struct socket *);
-int	soconnect(struct socket *, struct mbuf *, struct lwp *);
+int	soconnect(struct socket *, struct sockaddr *, struct lwp *);
 int	soconnect2(struct socket *, struct socket *);
 int	socreate(int, struct socket **, int, int, struct lwp *,
 		 struct socket *);
@@ -355,7 +355,7 @@ int	do_sys_recvmsg(struct lwp *, int, st
 	    struct mbuf **, register_t *);
 
 int	do_sys_bind(struct lwp *, int, struct sockaddr *);
-int	do_sys_connect(struct lwp *, int, struct mbuf *);
+int	do_sys_connect(struct lwp *, int, struct sockaddr *);
 int	do_sys_accept(struct lwp *, int, struct sockaddr *, register_t *,
 	    const sigset_t *, int, int);
 
Index: sys/un.h
===================================================================
RCS file: /cvsroot/src/sys/sys/un.h,v
retrieving revision 1.55
diff -p -u -r1.55 un.h
--- sys/un.h	9 Aug 2014 05:33:01 -0000	1.55
+++ sys/un.h	26 Apr 2015 17:32:00 -0000
@@ -75,6 +75,7 @@ struct unpcbid {
 struct unpcb;
 struct socket;
 struct sockopt;
+struct sockaddr;
 
 extern const struct pr_usrreqs unp_usrreqs;
 
@@ -84,7 +85,7 @@ kmutex_t *uipc_dgramlock(void);
 kmutex_t *uipc_streamlock(void);
 kmutex_t *uipc_rawlock(void);
 
-int	unp_connect(struct socket *, struct mbuf *, struct lwp *);
+int	unp_connect(struct socket *, struct sockaddr *, struct lwp *);
 int	unp_connect2(struct socket *, struct socket *);
 void 	unp_dispose(struct mbuf *);
 int 	unp_externalize(struct mbuf *, struct lwp *, int);


Home | Main Index | Thread Index | Old Index