Commit Graph

23 Commits

Author SHA1 Message Date
Christian Prochaska
5adb6f0c5f socket_fs: show ioctl FIONREAD error message only once
Fixes #2969
2018-09-13 15:21:10 +02:00
Emery Hemingway
d9a4773194 LwIP VFS plugin
This patch reintroduces the LwIP stack to libc as a VFS plugin
implementing the socket_fs interface. Rather than use LwIP's socket
emulation layer this plugin interfaces directly to LwIP raw API and is
single threaded.

The internal TCP parameters of the stack are untuned.

Fix #2050
Fix #2335
2018-08-02 14:36:48 +02:00
1097a5c7c2 Libc: ignore address argument to TCP sendto
Generic code that operates over both UDP and TCP sockets might use
'sendto', but in the case of TCP the destination address ought to be
safely discarded. This seems to be the case for certain DNS software
that operates over both UDP and TCP.

Fix #2807
2018-05-30 13:36:13 +02:00
96579a72e0 Libc: gracefully handle invalid socketaddr arguments
Ref #2682
2018-05-03 15:31:58 +02:00
401ba6e7fd Manage socket_fs socket lifetime via handles
Socket_fs sockets are now created each time a 'new_socket' control file
is opened, not each time a 'new_socket' file is read. When a handle on a
'new_socket' file is closed the socket and its socket files are
destroyed. The accept control file on a listening socket reads "1" or
reads nothing to indicate a client connection is queued. Client sockets
are accepted by opening an 'accept_socket' file in the listen socket
directory. This file behaves like the aforementioned 'new_socket' file.

Ref #2707
2018-05-03 15:31:57 +02:00
Christian Helmuth
adc3aa452a libc: close all handles of a socket before release
This prevents diagnostic messages like

  Error: partial write detected 0 vs 31

for writes into already released socket directories due to a still-open
handle to the socket data file.
2018-02-28 11:05:05 +01:00
Christian Helmuth
064e738d53 libc: reduce noise on setsockopt/getsockopt 2018-02-28 11:05:04 +01:00
Emery Hemingway
88757a674a libc: sync socket control files to check for write errors
Ref #2335
2018-02-28 11:04:58 +01:00
Christian Helmuth
2b649cb633 libc: handle socket_fs special cases
- catch inaccessible file on bind()
- support UDP ENETDOWN and TCP EAGAIN on sendto()
2017-11-30 11:23:17 +01:00
Emery Hemingway
8207fb8d98 libc: sync bind sock control file before continuing with listen
Fix #2512
2017-10-05 17:39:54 +02:00
Christian Helmuth
c223f74ce5 libc: support getsockopt(SO_TYPE) 2017-06-19 12:35:57 +02:00
Josef Söntgen
b361de8379 libc: return true on writefd checks in select on sockets
Instead of files we have to check this condition on sockets but
technically our sockets are regular files as well...
2017-05-31 13:16:15 +02:00
Josef Söntgen
dbec8d7710 libc: pretend to support SO_ERROR
There are programs, e.g. curl, that check if a connection was
established successfully by looking at SO_ERROR. Pretend that
the getsockopt() call was executed to keep them happy. If they
try to use a broken connection, the other socket functions will
bail.
2017-05-31 13:16:15 +02:00
Christian Helmuth
9802ae83e0 libc: rework socket fs for O_NONBLOCK 2017-05-31 13:15:58 +02:00
Emery Hemingway
50ee91e738 libc: poll listening sockets during select
Open the accept file at the listen call and poll for read henceforce.

Fix #2319
2017-03-24 16:19:55 +01:00
Emery Hemingway
7ef8c81607 libc: socket fcntl flags inheritence
Set O_NONBLOCK on sockets from the fcntl syscall and propagate this flag
to socket_fs control files and sockets returned from accept.

Fix #2318
2017-03-24 16:19:55 +01:00
Norman Feske
29b8d609c9 Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
Josef Söntgen
b2dd0ab436 libc: remove global env from socket_fs_plugin
Issue #2280.
2017-02-28 12:59:27 +01:00
Martin Stein
d61cb2714c libc/socket_fs: unlink during close
If 'close' does not call 'unlink' like 'shutdown', the Lxip_socket_dir
never gets destroyed and thus the socket server leaks resources like
RAM and ports.

Ref #2285
2017-02-28 12:59:25 +01:00
Martin Stein
43fcdc43e6 libc/socket_fs: warn on unexpected arg in shutdown
Our 'shutdown' implementation handles only the case that 'how' is 'RDWR'.
Thus, print an error and continue if a user calls it with another value.

Fixes #2285
2017-02-28 12:59:24 +01:00
Alexander Boettcher
1a6963813c libc: avoid race using Libc::suspend with pthreads
TOCTTOU bug, in our case time of check to time of sleep bug
2017-02-28 12:59:24 +01:00
Martin Stein
222a789fef LibC socket FS: Fix leak of remote and local files 2017-02-28 12:59:19 +01:00
Christian Helmuth
fdad5116dd libc: support for socket file system
The socket file system can be configured in the "socket" attribute of
the libc config node like follows.

  <vfs> <dir name="socket"> <fs/> </dir> </vfs>
  <libc ... socket="/socket"/>

This configures the socket file system libc backend to access files in
"/socket" for socket operations.
2017-02-28 12:59:16 +01:00