Home | History | Annotate | Download | only in libsockin
History log of /src/sys/rump/net/lib/libsockin/sockin.c
RevisionDateAuthorComments
 1.67  03-Sep-2022  thorpej Garbage-collect everything related to struct domain::dom_ifqueues
(except dom_ifqueues itself, until the next kernel version bump).
It's no longer used now that nothing uses the legacy netisr mechanism.
 1.66  26-Jun-2018  msaitoh Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.65  21-Sep-2017  ozaki-r branches: 1.65.2;
Invalidate rtcache based on a global generation counter

The change introduces a global generation counter that is incremented when any
routes have been added or deleted. When a rtcache caches a rtentry into itself,
it also stores a snapshot of the generation counter. If the snapshot equals to
the global counter, the cache is still valid, otherwise invalidated.

One drawback of the change is that all rtcaches of all protocol families are
invalidated when any routes of any protocol families are added or deleted.
If that matters, we should have separate generation counters based on
protocol families.

This change removes LIST_ENTRY from struct route, which fixes a part of
PR kern/52515.
 1.64  15-Nov-2016  ozaki-r branches: 1.64.8;
Fix build of usr.sbin/puffs/rump_nfs

XXX a better fix should be to separate nfs codes and let rump_nfs link only
XXX one that doesn't depend on rt_delete_matched_entries (and rtrequest).
 1.63  26-Jan-2016  pooka branches: 1.63.2;
Put the kernelside rump kernel headers into <rump-sys> instead of
sprinkling them around the faction directories. Avoids having
to add a CPPFLAGS (or several) to pretty much every component
Makefile.

Leave compat headers around in the old locations.

The commit changes some autogenerated files, but I'll fix the
generators shortly and regen.
 1.62  02-May-2015  rtr 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}
 1.61  26-Apr-2015  rtr remove pr_generic from struct pr_usrreqs and all implementations of
pr_generic in protocols.

bump to 7.99.13

approved by rmind@
 1.60  24-Apr-2015  rtr make accept, getsockname and getpeername syscalls use sockaddr_big and modify
pr_{accept,sockname,peername} nam parameter type from mbuf * to sockaddr *.

* retained use of mbuftypes[MT_SONAME] for now.
* bump to netbsd version 7.99.12 for parameter type change.

patch posted to tech-net@ 2015/04/19
 1.59  03-Apr-2015  rtr * 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@
 1.58  09-Aug-2014  rtr branches: 1.58.4;
split PRU_CONNECT2 & PRU_PURGEIF function out of pr_generic() usrreq
switches and put into separate functions

- always KASSERT(solocked(so)) even if not implemented
(for PRU_CONNECT2 only)

- replace calls to pr_generic() with req = PRU_CONNECT2 with calls to
pr_connect2()

- replace calls to pr_generic() with req = PRU_PURGEIF with calls to
pr_purgeif()

put common code from unp_connect2() (used by unp_connect() into
unp_connect1() and call out to it when needed

patch only briefly reviewed by rmind@
 1.57  08-Aug-2014  rtr split PRU_RCVD function out of pr_generic() usrreq switches and put into
separate functions

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_RCVD with calls to
pr_rcvd()
 1.56  05-Aug-2014  rtr split PRU_SEND function out of pr_generic() usrreq switches and put into
separate functions

xxx_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *, struct lwp *)

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_SEND with calls to
pr_send()

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_send() PRUs

- l2cap_send() -> l2cap_send_pcb()
- sco_send() -> sco_send_pcb()
- rfcomm_send() -> rfcomm_send_pcb()

patch reviewed by rmind
 1.55  05-Aug-2014  rtr revert the removal of struct lwp * parameter from bind, listen and connect
user requests.

this should resolve the issue relating to nfs client hangs presented
recently by wiz on current-users@
 1.54  31-Jul-2014  rtr split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions

xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)

- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively

rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().

- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()

patch reviewed by rmind
 1.53  30-Jul-2014  rtr split PRU_CONNECT function out of pr_generic() usrreq switches and put
into seaparate functions

xxx_listen(struct socket *, struct mbuf *)

- always KASSERT(solocked(so)) and KASSERT(nam != NULL)
- replace calls to pr_generic() with req = PRU_CONNECT with
pr_connect()
- rename existin {l2cap,sco,rfcomm}_connect() to
{l2cap,sco,rfcomm}_connect_pcb() respectively to permit
naming consistency with other protocols functions.
- drop struct lwp * parameter from unp_connect() and at_pcbconnect()
and use curlwp instead where appropriate.

patch reviewed by rmind
 1.52  28-Jul-2014  rtr add missing KASSERT()s at the top of sockin_usrreq(), req shall not be
either of these operations.

> KASSERT(req != PRU_BIND);
> KASSERT(req != PRU_LISTEN);
 1.51  24-Jul-2014  rtr split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreq
switches and put into separate functions
xxx_bind(struct socket *, struct mbuf *)
xxx_listen(struct socket *)

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_BIND with call to
pr_bind()

- replace calls to pr_generic() with req = PRU_LISTEN with call to
pr_listen()

- drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and
unp_bind() and always use curlwp.

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_{bind,listen}() PRUs

- l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb()
- sco_{bind,listen}() -> sco_{bind,listen}_pcb()
- rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb()

patch reviewed by rmind

welcome to netbsd 6.99.48
 1.50  23-Jul-2014  rtr split PRU_SENDOOB and PRU_RCVOOB function out of pr_generic() usrreq
switches and put into separate functions
xxx_sendoob(struct socket *, struct mbuf *, struct mbuf *)
xxx_recvoob(struct socket *, struct mbuf *, int)

- always KASSERT(solocked(so)) even if request is not implemented

- replace calls to pr_generic() with req = PRU_{SEND,RCV}OOB with
calls to pr_{send,recv}oob() respectively.

there is still some tweaking of m_freem(m) and m_freem(control) to come
for consistency. not performed with this commit for clarity.

reviewed by rmind
 1.49  09-Jul-2014  rtr fix name clash i introduced when adding sockin_accept() pru by renaming
the rump sockin_accept(struct socket *) to sockin_waccept(struct socket *)

not a very creative name the 'w' indicates worker and was chosen to
prefix the word accept to make it not pattern match with _accept. if
someone prefers a different name then please feel free to change it.
 1.48  09-Jul-2014  rtr * split PRU_ACCEPT function out of pr_generic() usrreq switches and put
into a separate function xxx_accept(struct socket *, struct mbuf *)

note: future cleanup will take place to remove struct mbuf parameter
type and replace it with a more appropriate type.

patch reviewed by rmind
 1.47  09-Jul-2014  rtr * 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
 1.46  07-Jul-2014  rtr * sprinkle KASSERT(solocked(so)); in all pr_stat() functions.
* fix remaining inconsistent struct socket parameter names.
 1.45  07-Jul-2014  rtr backout change that made pr_stat return EOPNOTSUPP for protocols that
were not filling in struct stat.

decision made after further discussion with rmind and investigation of
how other operating systems behave. soo_stat() is doing just enough to
be able to call what gets returned valid and thus justifys a return of
success.

additional review will be done to determine of the pr_stat functions
that were already returning EOPNOTSUPP can be considered successful with
what soo_stat() is doing.
 1.44  07-Jul-2014  rtr * have pr_stat return EOPNOTSUPP consistently for all protocols that do
not fill in struct stat instead of returning success.

* in pr_stat remove all checks for non-NULL so->so_pcb except where the
pcb is actually used (i.e. cases where we don't return EOPNOTSUPP).

proposed on tech-net@
 1.43  06-Jul-2014  rtr * split PRU_SENSE functionality out of sockin_usrreq() and place into
separate sockin_stat(struct socket *, struct stat *) function.
* change behavior of function to just return success (like pretty much
every other implementation) instead of panic()ing due to lack of
implementation.
 1.42  01-Jul-2014  rtr fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
 1.41  22-Jun-2014  rtr * split PRU_CONTROL functionality out of xxx_userreq() switches and place
into separate xxx_ioctl() functions.
* place KASSERT(req != PRU_CONTROL) inside xxx_userreq() as it is now
inappropriate for req = PRU_CONTROL in xxx_userreq().
* replace calls to pr_generic() with req = PRU_CONTROL with pr_ioctl().
* remove & fixup references to PRU_CONTROL xxx_userreq() function comments.
* fix various comments references for xxx_userreq() that mentioned
PRU_CONTROL as xxx_userreq() no longer handles the request.

a further change will follow to fix parameter and naming inconsistencies
retained from original code.

Reviewed by rmind@
 1.40  19-May-2014  rmind - Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.
 1.39  18-May-2014  rmind Fix RUMP build.
 1.38  09-May-2014  pooka comment meets reality
 1.37  26-Apr-2014  pooka Move a few stubs to where they really belong; allows us to create
them as strong instead of weak symbols.
 1.36  13-Mar-2014  pooka branches: 1.36.2;
rename rumpcomp_user.* -> sockin_user.*
 1.35  29-Aug-2013  rmind Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.
 1.34  23-Jun-2013  stacktic branches: 1.34.2;
Make sure sockin module is initialized only once
 1.33  01-Jun-2013  pooka check for EOF from backing sucket
 1.32  01-Jun-2013  pooka Assert that we get PRU_ATTACH requests only for the families we
have registered.
 1.31  01-Jun-2013  stacktic Add IPv6 support
 1.30  30-Apr-2013  pooka few more conversions
 1.29  30-Apr-2013  pooka Make hypercall calling conventions consistent: iff a hypercall can fail,
it returns an int containing the error value.
 1.28  27-Apr-2013  pooka rumpuser_poll() is used only by sockin, so make the hypercall
private to that component.
 1.27  18-Mar-2013  pooka Move the rumpuser_net set of hypercalls to be a private to the sockin
component. This cleans up the generic hypercall interfaces from ones
specific to only one component. They should always have been private,
but the infrastructure to "make it so" didn't exist earlier.

no functional change
 1.26  31-Mar-2011  dyoung branches: 1.26.4; 1.26.14;
Hide the radix-trie implementation of the forwarding table so that we
will have an easier time replacing it with something different, even if
it is a second radix-trie implementation.

sys/net/route.c and sys/net/rtsock.c no longer operate directly on
radix_nodes or radix_node_heads.

Hopefully this will reduce the temptation to implement multipath or
source-based routing using grotty hacks to the grotty old radix-trie
code, too. :-)
 1.25  05-Dec-2010  pooka branches: 1.25.2;
claim ENOTTY for PRU_CONTROL for now
 1.24  05-Dec-2010  pooka Revert previous: it introduces a dependency between sockin and the
netinet rump components and will have to be done another way.
 1.23  05-Dec-2010  pooka use in_control() for PRU_CONTROL
 1.22  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.21  26-Jan-2010  pooka branches: 1.21.2; 1.21.4;
support bpf
 1.20  20-Oct-2009  tron Only allocate a "struct iovec" array from the healp if a reasonably sized
stack array isn't large enough.
 1.19  18-Oct-2009  tron Avoid panic if a file system tries to write a chain of more than 32 mbuf-s
to a socket. This happens e.g. when copying large files to SMBFS.

Code reviewed by Antti Kantee.
 1.18  17-Oct-2009  pooka fix off-by-one in sanity check and bump lazy bum magic value
 1.17  16-Oct-2009  pooka for udp sockets crank snd/rcvbufsize to 64k
 1.16  02-Sep-2009  pooka * implement pr_ctloutput
* check for errno before more costly checks
 1.15  18-Mar-2009  cegger branches: 1.15.2;
Ansify function definitions w/o arguments. Generated with sed.
 1.14  30-Jan-2009  pooka branches: 1.14.2;
.. but we still need to check if nam is passed to PRU_SEND for
non-connected sockets.
 1.13  30-Jan-2009  pooka Call soisconnected() in PRU_CONNECT for udp sockets too.
 1.12  27-Jan-2009  pooka * read TCP sockets in cluster-sized chunks instead of IP_MAXPACKET.
(it might be a better to chain a few clusters into the iov
instead of just one since we are making the syscall anyway)
* don't overwrite the useful error value
 1.11  27-Jan-2009  pooka Hold softnet_lock only when we need it.
 1.10  26-Jan-2009  pooka * support PRU_SOCK/PEERADDR
* soisdisconnected() TCP sockets if read returns a non-transient error or 0
 1.9  26-Jan-2009  pooka Convert compile-time SOCKIN_NOTHREADS into runtime rump_threads check.
 1.8  18-Dec-2008  pooka __KERNEL_RCSID
 1.7  26-Nov-2008  pooka Add dummy pr_ctloutput. I'm sure I had one at some point, since
it's required for rump_nfs to work, but I guess I lost it somewhere.
(yes, it should actually be implemented also)
 1.6  25-Nov-2008  pooka Make sockin radix-capable.
 1.5  25-Nov-2008  pooka Support PRU_BIND / PRU_LISTEN / PRU_ACCEPT in sockin.
 1.4  26-Oct-2008  minskim branches: 1.4.2;
Remove trailing whitespace.
 1.3  16-Oct-2008  pooka branches: 1.3.2;
appease 64bit gcc
 1.2  15-Oct-2008  pooka Mostly support TCP, mostly meaning "client-side TCP", since listen,
accept etc. is not supported yet. Disconnect is not really supported
either, but doesn't matter in most cases.
 1.1  02-Oct-2008  pooka branches: 1.1.2; 1.1.4;
Add a very simplistic PF_INET/SOCK_DGRAM domain/proto implementation,
which delegates the work to host kernel sockets. This does not
run the entire kernel TCP/IP stack in userspace and therefore does
not require the ability to send or receive raw packets. This
implies that root priviledges are not required. As already said
above, only supports UDPv4 for now. Extending should be easy.
 1.1.4.2  10-Oct-2008  skrll Sync with HEAD.
 1.1.4.1  02-Oct-2008  skrll file sockin.c was added on branch wrstuden-revivesa on 2008-10-10 22:37:09 +0000
 1.1.2.3  17-Jan-2009  mjf Sync with HEAD.
 1.1.2.2  05-Oct-2008  mjf Sync with HEAD.
 1.1.2.1  02-Oct-2008  mjf file sockin.c was added on branch mjf-devfs2 on 2008-10-05 20:11:34 +0000
 1.3.2.3  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.2.2  19-Oct-2008  haad Sync with HEAD.
 1.3.2.1  16-Oct-2008  haad file sockin.c was added on branch haad-dm on 2008-10-19 22:18:08 +0000
 1.4.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.4.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.4.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.14.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.2.5  11-Aug-2010  yamt sync with head.
 1.15.2.4  11-Mar-2010  yamt sync with head
 1.15.2.3  16-Sep-2009  yamt sync with head
 1.15.2.2  04-May-2009  yamt sync with head.
 1.15.2.1  18-Mar-2009  yamt file sockin.c was added on branch yamt-nfs-mp on 2009-05-04 08:14:33 +0000
 1.21.4.3  21-Apr-2011  rmind sync with head
 1.21.4.2  05-Mar-2011  rmind sync with head
 1.21.4.1  30-May-2010  rmind sync with head
 1.21.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.25.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.26.14.3  03-Dec-2017  jdolecek update from HEAD
 1.26.14.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.14.1  23-Jun-2013  tls resync from head
 1.26.4.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.34.2.1  18-May-2014  rmind sync with head
 1.36.2.1  10-Aug-2014  tls Rebase.
 1.58.4.4  05-Dec-2016  skrll Sync with HEAD
 1.58.4.3  19-Mar-2016  skrll Sync with HEAD
 1.58.4.2  06-Jun-2015  skrll Sync with HEAD
 1.58.4.1  06-Apr-2015  skrll Sync with HEAD
 1.63.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.64.8.1  24-Oct-2017  snj Pull up following revision(s) (requested by ozaki-r in ticket #305):
distrib/sets/lists/tests/mi: revision 1.762
sys/net/route.c: revision 1.198-1.201
sys/net/route.h: revision 1.114
sys/netatalk/at_proto.c: revision 1.22
sys/netinet/in_proto.c: revision 1.124
sys/netinet6/in6_proto.c: revision 1.118
sys/netmpls/mpls_proto.c: revision 1.31
sys/netnatm/natm_proto.c: revision 1.18
sys/rump/net/lib/libsockin/sockin.c: revision 1.65
sys/sys/domain.h: revision 1.33
tests/net/route/Makefile: revision 1.6
tests/net/route/t_rtcache.sh: revision 1.1
Add tests of rtcache invalidation
Remove unnecessary NULL check of rt_ifp
It's always non-NULL.
Invalidate rtcache based on a global generation counter
The change introduces a global generation counter that is incremented when any
routes have been added or deleted. When a rtcache caches a rtentry into itself,
it also stores a snapshot of the generation counter. If the snapshot equals to
the global counter, the cache is still valid, otherwise invalidated.
One drawback of the change is that all rtcaches of all protocol families are
invalidated when any routes of any protocol families are added or deleted.
If that matters, we should have separate generation counters based on
protocol families.
This change removes LIST_ENTRY from struct route, which fixes a part of
PR kern/52515.
Remove the global lock for rtcache
Thanks to removal of LIST_ENTRY of struct route, rtcaches are accessed only by
their users. And in existing usages a rtcache is guranteed to be not accessed
simultaneously. So the rtcache framework doesn't need any exclusion controls
in itself.
Synchronize on rtcache_generation with rtlock
It's racy if NET_MPSAFE is enabled.
Pointed out by joerg@
 1.65.2.1  28-Jul-2018  pgoyette Sync with HEAD

RSS XML Feed