Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys * split PRU_PEERADDR and PRU_SOCKADDR function out of pr...
details: https://anonhg.NetBSD.org/src/rev/2743be4be234
branches: trunk
changeset: 330447:2743be4be234
user: rtr <rtr%NetBSD.org@localhost>
date: Wed Jul 09 04:54:03 2014 +0000
description:
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
diffstat:
sys/compat/svr4/svr4_stream.c | 21 ++--
sys/kern/uipc_syscalls.c | 45 +++++++--
sys/kern/uipc_usrreq.c | 38 +++++--
sys/net/if_gre.c | 27 ++---
sys/net/link_proto.c | 26 ++++-
sys/net/raw_usrreq.c | 22 +---
sys/net/rtsock.c | 40 +++++++-
sys/netatalk/ddp_usrreq.c | 33 +++++-
sys/netbt/hci_socket.c | 70 +++++++++----
sys/netbt/l2cap.h | 8 +-
sys/netbt/l2cap_socket.c | 54 +++++++---
sys/netbt/l2cap_upper.c | 12 +-
sys/netbt/rfcomm.h | 8 +-
sys/netbt/rfcomm_dlc.c | 10 +-
sys/netbt/rfcomm_session.c | 8 +-
sys/netbt/rfcomm_socket.c | 54 +++++++---
sys/netbt/rfcomm_upper.c | 16 +-
sys/netbt/sco.h | 6 +-
sys/netbt/sco_socket.c | 54 +++++++---
sys/netbt/sco_upper.c | 12 +-
sys/netinet/raw_ip.c | 40 ++++++--
sys/netinet/tcp_usrreq.c | 179 +++++++++++++++++++++++++++--------
sys/netinet/udp_usrreq.c | 40 ++++++--
sys/netinet6/raw_ip6.c | 40 ++++++--
sys/netinet6/udp6_usrreq.c | 40 ++++++--
sys/netipsec/keysock.c | 42 ++++++++-
sys/netmpls/mpls_proto.c | 24 ++++-
sys/netnatm/natm.c | 49 +++++++--
sys/rump/net/lib/libsockin/sockin.c | 57 +++++++---
sys/sys/param.h | 4 +-
sys/sys/protosw.h | 22 ++++-
sys/sys/socketvar.h | 5 +-
32 files changed, 798 insertions(+), 308 deletions(-)
diffs (truncated from 2384 to 300 lines):
diff -r 7fab60e11402 -r 2743be4be234 sys/compat/svr4/svr4_stream.c
--- a/sys/compat/svr4/svr4_stream.c Wed Jul 09 04:53:35 2014 +0000
+++ b/sys/compat/svr4/svr4_stream.c Wed Jul 09 04:54:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_stream.c,v 1.79 2011/06/26 16:42:41 christos Exp $ */
+/* $NetBSD: svr4_stream.c,v 1.80 2014/07/09 04:54: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.79 2011/06/26 16:42:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.80 2014/07/09 04:54:03 rtr Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -893,12 +893,16 @@
switch (cmd) {
case SVR4_TI_GETMYNAME:
DPRINTF(("TI_GETMYNAME\n"));
- cmd = PRU_SOCKADDR;
+ error = do_sys_getsockname(fd, &name);
+ if (error != 0)
+ return error;
break;
case SVR4_TI_GETPEERNAME:
DPRINTF(("TI_GETPEERNAME\n"));
- cmd = PRU_PEERADDR;
+ error = do_sys_getpeername(fd, &name);
+ if (error != 0)
+ return error;
break;
case SVR4_TI_SETMYNAME:
@@ -913,10 +917,6 @@
return ENOSYS;
}
- error = do_sys_getsockname(l, fd, cmd, &name);
- if (error != 0)
- return error;
-
switch (st->s_family) {
case AF_INET:
sockaddr_to_netaddr_in(&sc, mtod(name, void *));
@@ -1624,10 +1624,9 @@
* a connect verification.
*/
- error = do_sys_getsockname(l, SCARG(uap, fd), PRU_SOCKADDR,
- &name);
+ error = do_sys_getsockname(SCARG(uap, fd), &name);
if (error != 0) {
- DPRINTF(("getmsg: getpeername failed %d\n", error));
+ DPRINTF(("getmsg: getsockname failed %d\n", error));
goto out;
}
diff -r 7fab60e11402 -r 2743be4be234 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c Wed Jul 09 04:53:35 2014 +0000
+++ b/sys/kern/uipc_syscalls.c Wed Jul 09 04:54:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.170 2014/05/18 14:46:15 rmind Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.171 2014/07/09 04:54: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.170 2014/05/18 14:46:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.171 2014/07/09 04:54:03 rtr Exp $");
#include "opt_pipe.h"
@@ -1296,10 +1296,10 @@
#endif /* PIPE_SOCKETPAIR */
/*
- * Get socket name.
+ * Get peer socket name.
*/
int
-do_sys_getsockname(struct lwp *l, int fd, int which, struct mbuf **nam)
+do_sys_getpeername(int fd, struct mbuf **nam)
{
struct socket *so;
struct mbuf *m;
@@ -1312,12 +1312,11 @@
MCLAIM(m, so->so_mowner);
solock(so);
- if (which == PRU_PEERADDR && (so->so_state & SS_ISCONNECTED) == 0) {
+ if ((so->so_state & SS_ISCONNECTED) == 0)
error = ENOTCONN;
- } else {
+ else {
*nam = m;
- error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
- which, NULL, m, NULL, NULL);
+ error = (*so->so_proto->pr_usrreqs->pr_peeraddr)(so, m);
}
sounlock(so);
if (error != 0)
@@ -1326,6 +1325,32 @@
return error;
}
+/*
+ * Get local socket name.
+ */
+int
+do_sys_getsockname(int fd, struct mbuf **nam)
+{
+ struct socket *so;
+ struct mbuf *m;
+ int error;
+
+ if ((error = fd_getsock(fd, &so)) != 0)
+ return error;
+
+ m = m_getclr(M_WAIT, MT_SONAME);
+ MCLAIM(m, so->so_mowner);
+
+ *nam = m;
+ solock(so);
+ error = (*so->so_proto->pr_usrreqs->pr_sockaddr)(so, m);
+ sounlock(so);
+ if (error != 0)
+ m_free(m);
+ fd_putfile(fd);
+ return error;
+}
+
int
copyout_sockname(struct sockaddr *asa, unsigned int *alen, int flags,
struct mbuf *addr)
@@ -1382,7 +1407,7 @@
struct mbuf *m;
int error;
- error = do_sys_getsockname(l, SCARG(uap, fdes), PRU_SOCKADDR, &m);
+ error = do_sys_getsockname(SCARG(uap, fdes), &m);
if (error != 0)
return error;
@@ -1408,7 +1433,7 @@
struct mbuf *m;
int error;
- error = do_sys_getsockname(l, SCARG(uap, fdes), PRU_PEERADDR, &m);
+ error = do_sys_getpeername(SCARG(uap, fdes), &m);
if (error != 0)
return error;
diff -r 7fab60e11402 -r 2743be4be234 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Wed Jul 09 04:53:35 2014 +0000
+++ b/sys/kern/uipc_usrreq.c Wed Jul 09 04:54:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.157 2014/07/07 17:13:56 rtr Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.158 2014/07/09 04:54: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.157 2014/07/07 17:13:56 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.158 2014/07/09 04:54:03 rtr Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -378,6 +378,8 @@
KASSERT(req != PRU_DETACH);
KASSERT(req != PRU_CONTROL);
KASSERT(req != PRU_SENSE);
+ KASSERT(req != PRU_PEERADDR);
+ KASSERT(req != PRU_SOCKADDR);
KASSERT(solocked(so));
unp = sotounpcb(so);
@@ -638,14 +640,6 @@
error = EOPNOTSUPP;
break;
- case PRU_SOCKADDR:
- unp_setaddr(so, nam, false);
- break;
-
- case PRU_PEERADDR:
- unp_setaddr(so, nam, true);
- break;
-
default:
panic("piusrreq");
}
@@ -882,6 +876,28 @@
return (0);
}
+static int
+unp_peeraddr(struct socket *so, struct mbuf *nam)
+{
+ KASSERT(solocked(so));
+ KASSERT(sotounpcb(so) != NULL);
+ KASSERT(nam != NULL);
+
+ unp_setaddr(so, nam, true);
+ return 0;
+}
+
+static int
+unp_sockaddr(struct socket *so, struct mbuf *nam)
+{
+ KASSERT(solocked(so));
+ KASSERT(sotounpcb(so) != NULL);
+ KASSERT(nam != NULL);
+
+ unp_setaddr(so, nam, false);
+ return 0;
+}
+
/*
* Allocate the new sockaddr. We have to allocate one
* extra byte so that we can ensure that the pathname
@@ -1829,5 +1845,7 @@
.pr_detach = unp_detach,
.pr_ioctl = unp_ioctl,
.pr_stat = unp_stat,
+ .pr_peeraddr = unp_peeraddr,
+ .pr_sockaddr = unp_sockaddr,
.pr_generic = unp_usrreq,
};
diff -r 7fab60e11402 -r 2743be4be234 sys/net/if_gre.c
--- a/sys/net/if_gre.c Wed Jul 09 04:53:35 2014 +0000
+++ b/sys/net/if_gre.c Wed Jul 09 04:54:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gre.c,v 1.156 2014/06/05 23:48:16 rmind Exp $ */
+/* $NetBSD: if_gre.c,v 1.157 2014/07/09 04:54: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.156 2014/06/05 23:48:16 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.157 2014/07/09 04:54:03 rtr Exp $");
#include "opt_atalk.h"
#include "opt_gre.h"
@@ -149,8 +149,8 @@
static int gre_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct rtentry *);
static int gre_ioctl(struct ifnet *, u_long, void *);
-static int gre_getsockname(struct socket *, struct mbuf *, struct lwp *);
-static int gre_getpeername(struct socket *, struct mbuf *, struct lwp *);
+static int gre_getsockname(struct socket *, struct mbuf *);
+static int gre_getpeername(struct socket *, struct mbuf *);
static int gre_getnames(struct socket *, struct lwp *,
struct sockaddr_storage *, struct sockaddr_storage *);
static void gre_clearconf(struct gre_soparm *, bool);
@@ -969,22 +969,15 @@
}
static int
-gre_getname(struct socket *so, int req, struct mbuf *nam, struct lwp *l)
+gre_getsockname(struct socket *so, struct mbuf *nam)
{
- return (*so->so_proto->pr_usrreqs->pr_generic)(so,
- req, NULL, nam, NULL, l);
+ return (*so->so_proto->pr_usrreqs->pr_sockaddr)(so, nam);
}
static int
-gre_getsockname(struct socket *so, struct mbuf *nam, struct lwp *l)
+gre_getpeername(struct socket *so, struct mbuf *nam)
{
- return gre_getname(so, PRU_SOCKADDR, nam, l);
-}
-
-static int
-gre_getpeername(struct socket *so, struct mbuf *nam, struct lwp *l)
-{
- return gre_getname(so, PRU_PEERADDR, nam, l);
+ return (*so->so_proto->pr_usrreqs->pr_peeraddr)(so, nam);
}
static int
@@ -1001,11 +994,11 @@
ss = mtod(m, struct sockaddr_storage *);
solock(so);
- if ((rc = gre_getsockname(so, m, l)) != 0)
+ if ((rc = gre_getsockname(so, m)) != 0)
Home |
Main Index |
Thread Index |
Old Index