7070 Commits

Author SHA1 Message Date
David van Moolenbroek
903ca1e525 Import NetBSD ping6(8)
Change-Id: Ife49f5fac0e50852c74a0f85b6129c204d172c68
2017-03-09 23:40:15 +00:00
David van Moolenbroek
04e82b7dc9 Import NetBSD arp(8)
Behaviorally this port should already be largely on par with the
NetBSD 8 version, in that it sets the RTF_LLDATA flag on routing
socket requests to indicate that they target link-local data.

Many parts of the arp(8) functionality are currently not yet supported
by the operating system, largely due to lwIP not exposing appropriate
means of implementing them.

Change-Id: Icfac054b4deddda03eee4acf0e261aa48cd031ba
2017-03-09 23:40:14 +00:00
David van Moolenbroek
66dfcc8533 Import NetBSD netstat(1)
The port forces the use of sysctl(7), as obtaining information through
KVM is not and will never be viable.  The sysctl mode of netstat(1) is
currently somewhat limited and buggy, though.  We fix a few minimal
issues, but more improvements will have to come from NetBSD reimports.

Some of netstat(1)'s views are currently not supported by the
operating system.  Later improvements on this point will not require
changes to the imported code, though.

Change-Id: If74a6811f0fc81bd1ecc31010a28379b14b2a0eb
2017-03-09 23:40:14 +00:00
David van Moolenbroek
483e595557 Import NetBSD route(8)
Change-Id: I724a2a56157ea72afdd3f6a82239687894c8e3e8
2017-03-09 23:40:13 +00:00
David van Moolenbroek
90b801219a Import NetBSD ifconfig(8)
Not all of its functionality is actually implemented in the operating
system.  In addition, a few modules (agr, vlan) have been disabled
because we have not imported the necessary headers yet.

Change-Id: I4c9271065d640bd9112b4bd27e2652e1d51b18b4
2017-03-09 23:40:12 +00:00
David van Moolenbroek
f1fab66e7d Import NetBSD libwrap
Change-Id: Ib8b979fb9a96c2048b8ea93038944c743048bff4
2017-03-09 23:40:12 +00:00
David van Moolenbroek
c2a43b2200 Import NetBSD nsswitch.conf(5)
Change-Id: I0464b474d50b39cd6259c492e1fae6fecfd9d984
2017-03-09 23:40:11 +00:00
David van Moolenbroek
9b6c0eaf74 Import NetBSD hosts(5)
Change-Id: I0924dcc7d4eb9151b77305f370360722d4a7533a
2017-03-09 23:40:11 +00:00
David van Moolenbroek
5588c638c0 libutil: drop some MINIX-specific changes
Change-Id: I8deeac84deb4a986b62caabe96c8f7c722d97921
2017-03-09 23:40:10 +00:00
David van Moolenbroek
722c5aa73f Enable IPv6 support
Change-Id: I3f68c38ca5efbecd04941064542ed24004db1429
2017-03-09 23:40:09 +00:00
David van Moolenbroek
08cbf5a04d Enable a few more NetBSD functions
Change-Id: Ia8463adfb12b465bd43a62aee9f14b21eaa13b19
2017-03-09 23:40:09 +00:00
David van Moolenbroek
e6dabba58b PTY: add minimal support for TIOCPKT
With TIOCPKT enabled, each piece of output is preceded by a zero byte
on the PTY master.  In addition, a non-zero byte is a flags field
that conveys information about changes on the pseudoterminal.  This
patch implements the former, but not the latter.  That is enough to
get telnetd(8) going, however.  TIOCPKT support may be extended later.

Change-Id: I6ef9cc8cf1b4406147b088400fc8499684b62a30
2017-03-09 23:40:08 +00:00
David van Moolenbroek
d7c7182ad4 Retire MINIX rlogin(1)
Change-Id: Ib85e74e5333e8fffa05631dbc760284761bf3ecb
2017-03-09 23:40:08 +00:00
David van Moolenbroek
47ebcd22bd Retire MINIX rget(1), rput(1)
Change-Id: I70e3ec9281275730c589fb7683801dc1ca584cab
2017-03-09 23:40:07 +00:00
David van Moolenbroek
a9ef5b90e6 Retire MINIX in.telnetd(8)
Change-Id: Ib54998e7a81f924d19b8013ef567703996d24a03
2017-03-09 23:40:06 +00:00
David van Moolenbroek
4d04ccc15b Retire MINIX telnet(1)
..which, for some strange reason, was installed as "ttn".

Change-Id: I5ad2f969ad7978a27fb7345f8434470ca427d429
2017-03-09 23:40:06 +00:00
David van Moolenbroek
34a8cf369f Retire MINIX rarpd(8)
Change-Id: I2d7b7edbb8fa6000ba368d156cf947e7691cf454
2017-03-09 23:40:05 +00:00
David van Moolenbroek
9cf227216d Retire MINIX irdpd(8)
Change-Id: Id11c6db9db5da18346d993cb9c3faa4313ed3ed4
2017-03-09 23:40:04 +00:00
David van Moolenbroek
f130137a5e Retire MINIX arp(8)
Change-Id: I8351fbb99d73811282e46dae7fae1b6abb130bf2
2017-03-09 23:40:04 +00:00
David van Moolenbroek
b8046fb69b Retire MINIX tcpd(8)
Change-Id: If419d441c5df0b9f2e29db1ef0d904d102739f9b
2017-03-09 23:40:03 +00:00
David van Moolenbroek
fd8826c892 Retire MINIX host(1)
Change-Id: I19d2e866d6d397d3bff9ba698cb8ec26267ee82c
2017-03-09 23:40:03 +00:00
David van Moolenbroek
9490732a59 Retire MINIX dhcpd(8)
Change-Id: I4b8c738b6176ce390a7a7817b0dcaf9caffe636c
2017-03-09 23:40:02 +00:00
David van Moolenbroek
035c234ade Retire MINIX hostaddr(1)
Change-Id: I30c7b5fe4c96ea040c3eea46f1dc4d9bd135745d
2017-03-09 23:40:01 +00:00
David van Moolenbroek
407c396431 Retire MINIX nonamed(8)
Also retire support for the MINIX versions of /etc/hosts and
/etc/resolv.conf.  These files will be brought back with NetBSD
imports, although like NetBSD, MINIX 3 will be using external
resolvers directly from then on.  Since resolv.conf is hand-created
rather than installed, we do not mark it as obsolete.

Change-Id: Ie6154d5a4d8d977c19b9754bf920ae868680e9d1
2017-03-09 23:40:01 +00:00
David van Moolenbroek
50c98e1f41 Retire MINIX pr_routes(8)
Change-Id: Ic7494d097f9d19185b7173edb7590044baee5abc
2017-03-09 23:40:00 +00:00
David van Moolenbroek
73ee574be3 Retire MINIX add_route(8)
Change-Id: I900a3c6ac8e8fac15f5f84960bb89f92aeb90863
2017-03-09 23:40:00 +00:00
David van Moolenbroek
96339c07fd Retire MINIX ifconfig(8)
Change-Id: I26f3ceff01bbd31e4c009752c7454a58e8a72abf
2017-03-09 23:39:59 +00:00
David van Moolenbroek
c5da0dffe2 Retire inet: the previous MINIX TCP/IP service
This commit (temporarily) leaves MINIX 3 without a TCP/IP service.

Thanks go out to Philip Homburg for providing this TCP/IP stack in the
first place.  It has served MINIX well for a long time.

Change-Id: I0e3eb6fe64204081e4e3c2b9d6e6bd642f121973
2017-03-09 23:39:58 +00:00
David van Moolenbroek
3ea34559da Retire lwip: the previous lwIP-based TCP/IP service
Change-Id: Id9bbf96344a6e9d796f6773547588a981e70bf0f
2017-03-09 23:39:58 +00:00
David van Moolenbroek
49bf8d5c6a Retire MINIX tcpstat(1), udpstat(1)
This needs to be done before retiring inet itself, since these
utilities include headers from inet directly.

Also retire the now-obsolete paramvalue(3).

Change-Id: I9b27771190a6a32ee533b0c0d9d37f61a16ee36c
2017-03-09 23:39:57 +00:00
David van Moolenbroek
baa5830f28 tests: add advanced UDS tests (test90)
Change-Id: Ib4b81d441368fd9b7e7c7b9cab802bb01fa04065
2017-03-09 23:39:56 +00:00
David van Moolenbroek
27852ebe53 UDS: full rewrite
This new implementation of the UDS service is built on top of the
libsockevent library.  It thereby inherits all the advantages that
libsockevent brings.  However, the fundamental restructuring
required for that change also paved the way for resolution of a
number of other important open issues with the old UDS code.  Most
importantly, the rewrite brings the behavior of the service much
closer to POSIX compliance and NetBSD compatibility.  These are the
most important changes:

- due to the use of libsockevent, UDS now supports multiple suspending
  calls per socket and a large number of standard socket flags and
  options;
- socket address matching is now based on <device,inode> lookups
  instead of canonized path names, and socket addresses are no longer
  altered either due to canonization or at connect time;
- the socket state machine is now well defined, most importantly
  resolving the erroneous reset-on-EOF semantics of the old UDS, but
  also allowing socket reuse;
- sockets are now connected before being accepted instead of being
  held in connecting state, unless the LOCAL_CONNWAIT option is set
  on either the connecting or the listening socket;
- connect(2) on datagram sockets is now supported (needed by syslog),
  and proper datagram socket disconnect notification is provided;
- the receive queue now supports segmentation, associating ancillary
  data (in-flight file descriptors and credentials) with each segment
  instead of being kept fully separately; this is a POSIX requirement
  (and needed by tmux);
- as part of the segmentation support, the receive queue can now hold
  as many packets as can fit, instead of one;
- in addition to the flags supported by libsockevent, the MSG_PEEK,
  MSG_WAITALL, MSG_CMSG_CLOEXEC, MSG_TRUNC, and MSG_CTRUNC send and
  receive flags are now supported;
- the SO_PASSCRED and SO_PEERCRED socket options are replaced by
  LOCAL_CREDS and LOCAL_PEEREID respectively, now following NetBSD
  semantics and allowing use of NetBSD libc's getpeereid(3);
- memory usage is reduced by about 250 KB due to centralized in-flight
  file descriptor tracking, with a limit of OPEN_MAX total rather than
  of OPEN_MAX per socket;
- memory usage is reduced by another ~50 KB due to removal of state
  redundancy, despite the fact that socket path names may now be up to
  253 bytes rather than the previous 104 bytes;
- compared to the old UDS, there is now very little direct indexing on
  the static array of sockets, thus allowing dynamic allocation of
  sockets more easily in the future;
- the UDS service now has RMIB support for the net.local sysctl tree,
  implementing preliminary support for NetBSD netstat(1).

Change-Id: I4a9b6fe4aaeef0edf2547eee894e6c14403fcb32
2017-03-09 23:39:56 +00:00
David van Moolenbroek
241ebcae9b RMIB: expose full node path; improve restartability
A single function may be used to handle the implementation of more
than one node.  In some cases, the behavior of that function may
depend on the path name used to reach the node.  Therefore, provide
the full path name as part of the call information.

As a result, RMIB has to save the paths for each of its remote MIB
mount points.  That in turn also allows it to autonomously remount its
mount points after a MIB service restart, thus bringing us a step
closer to proper recovery after a MIB crash without requiring the
service using RMIB to perform explicit steps.  As before, the missing
ingredient is actual notification of MIB service restarts, and proper
support for *that* will likely require changes to the DS service.

Change-Id: Ic0c79931d6f3a76c2c998047f8b47350fd0fa5b0
2017-03-09 23:39:55 +00:00
David van Moolenbroek
bfa518c7ec PM/libsys: extend getepinfo, add getsockcred(3)
The service-only getepinfo(2) PM call returns information about a
given endpoint.  This patch extends that call so that it returns
enough information to allow correctly filling a sockcred structure.
A new getsockcred(3) function is added to libsys to fill an actual
sockcred structure with the obtained information.  However, for the
caller's convenience, the groups list is kept separate.

Change-Id: I9f1a6d1a221c77eabaa3498ff4ec9a5fb922e4fd
2017-03-09 23:39:55 +00:00
David van Moolenbroek
462713495a libsys: retire getnucred in favor of getepinfo
The getnucred() function was used by UDS to obtain credentials of user
processes in a form used in the UDS API, namely the ucred structure.
Since the NetBSD merge, this structure has changed drastically (aside
from being renamed to "uucred"), and it is no longer in UDS's best
interest to use this structure internally.  Therefore, getnucred() is
no longer a useful API either, and instead we directly use the
previously private getepinfo() function to obtain credentials.

Change-Id: I80bc809de716ec0a9b7497cb109d2f2708a629d5
2017-03-09 23:39:54 +00:00
David van Moolenbroek
dd96967135 UDS: prepare for socket file creation in bind(2)
This patch prepares for moving of the creation of socket files on the
file system from the libc bind(2) stub into the UDS service.  This
change is necessary for the socket type agnostic libc implementation.
The change is not yet activated - the code that is not yet used is
enclosed in "#if NOT_YET" blocks.  The activation needs to be atomic
with UDS's switch to libsockdriver; otherwise, user applications may
break.

As part of the change, various UDS bind(2) semantics are changed to
match the POSIX standard and other operating systems.  In
implementation terms, the service-only VFS API checkperms(2) is
renamed to socketpath(2), and extended with a new subcall which
creates a new socket file.  An extension to test56 checks the new
bind(2) semantics of UDS, although most new tests are still disabled
until activation as well.

Finally, as further preparation for a more structural redesign of the
UDS service, also return the <device,inode> number pair for the
created or checked file name, and make returning the canonized path
name optional.

Change-Id: I892d04b3301d4b911bdc571632ddde65fb747a8a
2017-03-09 23:39:53 +00:00
David van Moolenbroek
4c27a83389 Add libsockevent: a socket event dispatching library
This library provides an event-based abstraction model and dispatching
facility for socket drivers.  Its main goal is to eliminate any and
all need for socket drivers to keep track of pending socket calls.
Additionally, this library takes over responsibility of a number of
other tasks that would otherwise be duplicated between socket drivers,
but in such a way that individual socket drivers retain a large degree
of freedom in terms of API behavior.  The library's main features are:

- suspension, resumption, and cancellation of socket calls;
- an abstraction layer for select(2);
- state tracking of shutdown(2);
- pending (asynchronous) errors and the SO_ERROR socket option;
- listening-socket tracking and the SO_ACCEPTCONN socket option;
- generation of SIGPIPE signals; SO_NOSIGPIPE, MSG_NOSIGNAL;
- send and receive low-watermark tracking, SO_SNDLOWAT, SO_RCVLOWAT;
- send and receive timeout support and SO_SNDTIMEO, SO_RCVTIMEO;
- an abstraction layer for the SO_LINGER socket option;
- tracking of various on/off socket options as well as SO_TYPE;
- a range of pre-checks on socket calls that are required POSIX.

In order to track per-socket state, the library manages an opaque
"sock" object for each socket.  The allocation of such objects is left
entirely to the socket driver.  Each sock object has an associated
callback table for calls from libsockevent to the socket driver.  The
socket driver can raise events on the sock object in order to flag
that any previously suspended operations of a particular type should
be resumed.  The library may defer processing such raised events if
immediate processing could interfere with internal consistency.

The sockevent library is layered on top of libsockdriver, and should
be used by all socket driver implementations if at all possible.

Change-Id: I3eb2c80602a63ef13035f646473360293607ab76
2017-03-09 23:39:53 +00:00
David van Moolenbroek
85723df033 Add libsockdriver: a library for socket drivers
This library provides abstractions for socket drivers, and should be
used as the basis for all socket driver implementations.  It provides
the following functionality:

  - a function call table abstraction, hiding the details of the
    socket driver protocol with simple parameters and presenting the
    socket driver with callback functions very similar to the BSD
    socket API calls made from userland;
  - abstracting data structures and helper functions for suspending
    and resuming blocking calls;
  - abstracting data structures and helper functions for copying data
    from and to the caller.

Overall, the library is similar to lib{block,char,fs,input,net}driver
in concept.  Some of the abstractions provided here should in fact be
applied to libchardriver as well.  As always, for the case that the
provided message loop is too restrictive, a set of more low-level
message processing functions is provided.

Change-Id: I79ec215f5e195c3b0197e223636f987d3755fb13
2017-03-09 23:39:52 +00:00
David van Moolenbroek
45443f35b5 VFS: support close-on-exec flag for copyfd(2)
The flag is supported only when copying out file descriptors (i.e.
COPYFD_TO).  It will be used by UDS to support MSG_CMSG_CLOEXEC.

Change-Id: I46bfd04b5f28e22ec48938e43e42f78d3931220d
2017-03-09 23:39:51 +00:00
David van Moolenbroek
c344203e48 VFS: deny copying sockets to owning socket driver
This patch stops a socket driver from using copyfd(2) to copy in a
file descriptor that is a reference to a socket owned by that socket
driver, returning EDEADLK instead.  In effect, this will stop deadlock
and resource exhaustion issues with UDS once it has been converted to
a socket driver.  See the comment in the patch for details.

Change-Id: I5728a405eabda207725618231a6ff7be2d517146
2017-03-09 23:39:51 +00:00
David van Moolenbroek
491d647a3b VFS: support for suspending close(2) for sockets
This change effectively adds the VFS side of support for the SO_LINGER
socket option, by allowing file descriptor close operations to be
suspended (and later resumed) by socket drivers.  Currently, support
is limited to the close(2) system call--in all other cases where file
descriptors are closed (dup2, close-on-exec, process exit..), the
close operation still completes instantly.  As a general policy, the
close(2) return value will always indicate that the file descriptor
has been closed: either 0, or -1 with errno set to EINPROGRESS.  The
latter error may be thrown only when a suspended close is interrupted
by a signal.

As necessary for UDS, this change also introduces a closenb(2) system
call extension, allowing the caller to bypass blocking SO_LINGER close
behavior.  This extension allows UDS to avoid blocking on closing the
last reference to an in-flight file descriptor, in an atomic fashion.
The extension is currently part of libsys, but there is no reason why
userland would not be allowed to make this call, so it is deliberately
not protected from use by userland.

Change-Id: Iec77d6665232110346180017fc1300b1614910b7
2017-03-09 23:39:50 +00:00
David van Moolenbroek
722cbc6186 VFS: change select(2) semantics for closed filps
If a select(2) call was issued on a file descriptor for which the file
pointer was closed due to invalidation (FILP_CLOSED), typically as the
result of a character/socket driver dying, the call would previously
return with an error: EINTR upon call entry or EIO on invalidation at
at a later time.  Especially the former could severely confuse
applications, which would assume the call was interrupted by a signal,
restart the select call and immediately get EINTR again, ad infinitum.

This patch changes the select(2) semantics such that for closed filps,
the file descriptor is returned as readable and/or writable (depending
on the requested operations), as such letting the entire select call
finish successfully.  Applications will then typically attempt to read
from and/or write to the file descriptor, resulting in an I/O error
that they should generally be better equipped to handle.

This patch also fixes a potential problem with returning early from a
select(2) call if a bad file descriptor is given: previously, in such
cases not all actions taken so far would be undone; now they are.

Change-Id: Ia6581f8789473a8a6c200852fccf552691a17025
2017-03-09 23:39:50 +00:00
David van Moolenbroek
e3b8d4bb58 VFS: add BSD socket API, socket driver support
This patch adds the implementation of the BSD socket system calls
which have been introduced in an earlier patch.  At the same time, it
adds support for communication with socket drivers, using a new
"socket device" (SDEV_) protocol.  These two parts, implemented in
socket.c and sdev.c respectively, form the upper and lower halves of
the new BSD socket support in VFS.  New mapping functionality for
socket domains and drivers is added as well, implemented in smap.c.

The rest of the changes mainly facilitate the separation of character
and socket driver calls, and do not make any fundamental alterations.
For example, while this patch changes VFS's select.c rather heavily,
the new select logic for socket drivers is the exact same as for
character drivers; the changes mainly separate the driver type
specific parts from the generic select logic further than before.

Change-Id: I2f13084dd3c8d3a68bfc69da0621120c8291f707
2017-03-09 23:39:49 +00:00
David van Moolenbroek
181fb1b2b5 RS: add infrastructure for mapping socket drivers
This patch introduces the first piece of support for the concept of
"socket drivers": services that implement one or more socket protocol
families.  The latter are also known as "domains", as per the first
parameter of the socket(2) API.  More specifically, this patch adds
the basic infrastructure for specifying that a particular service is
the socket driver for a set of domains.

Unlike major number mappings for block and character drivers, socket
domain mappings are static.  For that reason, they are specified in
system.conf files, using the "domain" keyword.  Such a keyword is to
be followed by one or more protocol families, without their "PF_"
prefix.  For example, a service with the line "domain INET INET6;"
will be mapped as the socket driver responsible for the AF_INET and
AF_INET6 protocol families.

This patch implements only the infrastructure for creating such
mappings; the actual mapping will be implemented in VFS in a later
patch.  The infrastructure is implemented in service(8), RS, and VFS.

For now there is a hardcoded limit of eight domains per socket driver.
This may sound like a lot, but the upcoming new LWIP service will
already use four of those.  Also, it is allowed for a service to be
both a block/character driver and a socket driver at the same time,
which is a requirement for the new LWIP service.

Change-Id: I93352d488fc6c481e7079248082895d388c39f2d
2017-03-09 23:39:49 +00:00
David van Moolenbroek
a1c660069f libc: switch to NetBSD getifaddrs(3)
Change-Id: I698f7cef84506ebd7beed6974a232eb75ab853c3
2017-03-09 23:39:48 +00:00
David van Moolenbroek
14d921278d Import NetBSD getent(1)
Disable RPC support for now.

Change-Id: I5ccb435220bf20cd9089cdd7aacb7d126f62f119
2017-03-09 20:04:33 +01:00
Jia-Ju Bai
0d23d856eb Fix two mistakes in IP1000 driver
Change-Id: Iafdfc7496c0ed45727f414c35350cf86b644413b
2017-03-09 14:36:42 +01:00
David van Moolenbroek
8d0759b089 isofs: fix reported st_blocks stat(2) field
The st_blocks field should count 512-byte units, not file system
block units.  The previous computation would cause utilities such
as du(1), when used on isofs, to be off by a factor four.

Change-Id: If47c234079d19bd5b41f35a97780667efd822509
2017-02-26 22:22:20 +00:00
David van Moolenbroek
1d9650c9c5 etc: replace one more "service" with minix-service
This omission would cause the test set to hang, at least, if the
old /bin/service was indeed deleted.

Change-Id: I9423ecc77a4bf778973de81a49300748ce8c3dfd
2017-02-26 00:03:38 +00:00
David van Moolenbroek
8898fa503b ramdisk: clean up CD boot output
In particular, remove a stray '1'.

Change-Id: If82689060a92a4af318b01325492627944fba07f
2017-02-24 18:19:43 +00:00