Source-Changes-HG archive

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

[src/trunk]: src/sys make connect syscall use sockaddr_big and modify pr_{sen...



details:   https://anonhg.NetBSD.org/src/rev/d84e3047e0f9
branches:  trunk
changeset: 808033:d84e3047e0f9
user:      rtr <rtr%NetBSD.org@localhost>
date:      Sat May 02 17:18:03 2015 +0000

description:
make connect syscall use sockaddr_big and modify pr_{send,connect}
nam parameter type from buf * to sockaddr *.

final commit for parameter type changes to protocol user requests

* bump kernel version to 7.99.15 for parameter type changes to pr_{send,connect}

diffstat:

 sys/compat/linux/common/linux_socket.c |  10 +++++-----
 sys/compat/svr4/svr4_stream.c          |   7 ++++---
 sys/kern/uipc_socket.c                 |  17 +++++++++++------
 sys/kern/uipc_syscalls.c               |  16 ++++++----------
 sys/kern/uipc_usrreq.c                 |  32 +++++---------------------------
 sys/net/if_gre.c                       |  28 +++++++---------------------
 sys/net/link_proto.c                   |  12 ++++++------
 sys/net/raw_cb.h                       |   4 ++--
 sys/net/raw_usrreq.c                   |   6 +++---
 sys/net/rtsock.c                       |   8 ++++----
 sys/netatalk/ddp_usrreq.c              |  16 ++++++----------
 sys/netbt/hci_socket.c                 |  15 ++++++---------
 sys/netbt/l2cap_socket.c               |  11 +++++------
 sys/netbt/rfcomm_socket.c              |  11 +++++------
 sys/netbt/sco_socket.c                 |  11 +++++------
 sys/netinet/dccp_usrreq.c              |  27 ++++++++++-----------------
 sys/netinet/dccp_var.h                 |   6 +++---
 sys/netinet/in_pcb.c                   |  24 ++++++++++++++++++------
 sys/netinet/in_pcb.h                   |   5 +++--
 sys/netinet/raw_ip.c                   |  16 ++++++----------
 sys/netinet/tcp_input.c                |   8 ++++----
 sys/netinet/tcp_usrreq.c               |  12 ++++++------
 sys/netinet/udp_usrreq.c               |  12 ++++++------
 sys/netinet6/dccp6_usrreq.c            |  12 +++++-------
 sys/netinet6/dccp6_var.h               |   4 ++--
 sys/netinet6/in6_pcb.c                 |  24 ++++++++++++++++++------
 sys/netinet6/in6_pcb.h                 |   5 +++--
 sys/netinet6/raw_ip6.c                 |  21 ++++++---------------
 sys/netinet6/udp6_output.c             |  12 ++++--------
 sys/netinet6/udp6_usrreq.c             |  12 ++++++------
 sys/netinet6/udp6_var.h                |   4 ++--
 sys/netipsec/keysock.c                 |   8 ++++----
 sys/netmpls/mpls_proto.c               |   8 ++++----
 sys/netnatm/natm.c                     |  13 +++++--------
 sys/netsmb/smb_trantcp.c               |   6 +++---
 sys/nfs/nfs_socket.c                   |   9 +++++----
 sys/rump/net/lib/libsockin/sockin.c    |  19 ++++++++-----------
 sys/sys/param.h                        |   4 ++--
 sys/sys/protosw.h                      |  10 +++++-----
 sys/sys/socketvar.h                    |   6 +++---
 sys/sys/un.h                           |   5 +++--
 41 files changed, 224 insertions(+), 272 deletions(-)

diffs (truncated from 1849 to 300 lines):

diff -r e1361f4c9224 -r d84e3047e0f9 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Sat May 02 17:15:20 2015 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.123 2015/04/03 20:01:07 rtr Exp $   */
+/*     $NetBSD: linux_socket.c,v 1.124 2015/05/02 17:18:03 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.123 2015/04/03 20:01:07 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.124 2015/05/02 17:18:03 rtr Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1402,14 +1402,14 @@
                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;
diff -r e1361f4c9224 -r d84e3047e0f9 sys/compat/svr4/svr4_stream.c
--- a/sys/compat/svr4/svr4_stream.c     Sat May 02 17:15:20 2015 +0000
+++ b/sys/compat/svr4/svr4_stream.c     Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_stream.c,v 1.84 2015/04/24 22:32:37 rtr Exp $      */
+/*     $NetBSD: svr4_stream.c,v 1.85 2015/05/02 17:18:03 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.84 2015/04/24 22:32:37 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.85 2015/05/02 17:18:03 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1495,7 +1495,8 @@
        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);
diff -r e1361f4c9224 -r d84e3047e0f9 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Sat May 02 17:15:20 2015 +0000
+++ b/sys/kern/uipc_socket.c    Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.239 2015/04/24 22:32:37 rtr Exp $    */
+/*     $NetBSD: uipc_socket.c,v 1.240 2015/05/02 17:18:03 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.239 2015/04/24 22:32:37 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.240 2015/05/02 17:18:03 rtr Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -811,7 +811,7 @@
 }
 
 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 @@
                                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)
diff -r e1361f4c9224 -r d84e3047e0f9 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c  Sat May 02 17:15:20 2015 +0000
+++ b/sys/kern/uipc_syscalls.c  Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_syscalls.c,v 1.176 2015/04/24 22:32:37 rtr Exp $  */
+/*     $NetBSD: uipc_syscalls.c,v 1.177 2015/05/02 17:18:03 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.176 2015/04/24 22:32:37 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.177 2015/05/02 17:18:03 rtr Exp $");
 
 #include "opt_pipe.h"
 
@@ -336,28 +336,25 @@
                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 @@
  out:
        sounlock(so);
        fd_putfile(fd);
-       m_freem(nam);
        return error;
 }
 
diff -r e1361f4c9224 -r d84e3047e0f9 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c    Sat May 02 17:15:20 2015 +0000
+++ b/sys/kern/uipc_usrreq.c    Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_usrreq.c,v 1.178 2015/04/26 21:40:48 rtr Exp $    */
+/*     $NetBSD: uipc_usrreq.c,v 1.179 2015/05/02 17:18:03 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.178 2015/04/26 21:40:48 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.179 2015/05/02 17:18:03 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -409,7 +409,7 @@
 }
 
 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);
@@ -861,28 +861,6 @@
 }
 
 /*
- * 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.
  */
@@ -1105,7 +1083,7 @@
 }
 
 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;
@@ -1127,7 +1105,7 @@
        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;
diff -r e1361f4c9224 -r d84e3047e0f9 sys/net/if_gre.c
--- a/sys/net/if_gre.c  Sat May 02 17:15:20 2015 +0000
+++ b/sys/net/if_gre.c  Sat May 02 17:18:03 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gre.c,v 1.164 2015/04/24 22:32:37 rtr Exp $ */
+/*     $NetBSD: if_gre.c,v 1.165 2015/05/02 17:18:03 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.164 2015/04/24 22:32:37 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.165 2015/05/02 17:18:03 rtr Exp $");
 
 #include "opt_atalk.h"
 #include "opt_gre.h"
@@ -418,9 +418,8 @@
 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 @@
        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) {



Home | Main Index | Thread Index | Old Index