summaryrefslogtreecommitdiffstats
path: root/src/server/net.c
Commit message (Collapse)AuthorAgeFilesLines
* [KERNEL] Removes duplicate word 'of' in license headersManuel Bentele2021-04-161-1/+1
|
* [BUILD] rewrite CMake build system to track changes of source filesManuel Bentele2020-10-161-8/+8
| | | | | | | | | | This change restructures the source code directories, separates shared form non-shared application code and adds CMake dependencies. These dependencies allow the tracking of changes and trigger a rebuild of those build targets where changed files are involved. WARNING: Note that the support of the DNBD3_SERVER_AFL build option is not supported yet. Thus, the option should be never turned on.
* [SERVER] Add FUSE modeSimon Rettberg2020-07-281-10/+31
| | | | | Still needs some cleanup and optimizations, variable naming sucks, comments, etc.
* [SERVER] Remember atime in .meta fileSimon Rettberg2020-03-201-0/+2
|
* [SERVER] Rewrite uplink queue handlingSimon Rettberg2020-03-131-33/+11Star
| | | | | | - Now uses linked lists instead of huge array - Does prefetch data on client requests - Can have multiple replication requests in-flight
* [SERVER] Fix: Image would be assumed complete if no uplink existsSimon Rettberg2020-03-061-1/+1
| | | | Severe data corruption on client. Nice.
* [SERVER] Likewise, get rid of same loops in client handlerSimon Rettberg2020-03-041-35/+23Star
|
* [SERVER] Optimize client handler for CMD_GET_BLOCKSimon Rettberg2020-03-031-25/+43
| | | | | | | | Move CMD_GET_BLOCK out of switch block and mark as likely. Don't acquire and release cache map for every single request, but keep reference around and only release when a message other than CMD_GET_BLOCK arrives. On idle links, this should happen through CMD_KEEPALIVE every now and then.
* [SERVER] Also add a flag for uplink queue overloadSimon Rettberg2020-03-031-7/+3Star
|
* [SERVER] Remove "working" flag, introduce fine-grained flagsSimon Rettberg2020-03-031-6/+11
| | | | | | | | Tracking the "working" state of images using one boolean is insufficient regarding the different ways in which providing an image can fail. Introduce separate flags for different conditions, like "file not readable", "file not writable", "no uplink server available", "file content has changed".
* [SERVER] Support limiting alt-servers to specific namespaceSimon Rettberg2019-09-041-1/+1
| | | | | | Not really namespace but simple string matching for the image path. Path is matched from start with no support for glob or regex, so usually you want to have a trailing '/' to limit to certain directories.
* [SERVER] Tear down whole uplink on idle timeoutSimon Rettberg2019-08-291-8/+5Star
| | | | | | Keeping the uplink thread around forever even though we disconnected from the upstream server seems wasteful. Get rid of this and rear down the uplink entirely.
* [SERVER] Use weakref for cache mapsSimon Rettberg2019-08-291-43/+38Star
| | | | | | Gets rid of a bunch of locking, especially the hot path in net.c where clients are requesting data. Many clients unsing the same incomplete image previously created a bottleneck here.
* [SERVER] Make signal handling more POSIXSimon Rettberg2019-08-281-5/+6
| | | | | | | | | | | | | | | According to POSIX, a signal sent to a PID can be delivered to an arbitrary thread of that process that hasn't the signal blocked. This seens to never happen on Linux, but would mess things up since the code expected the main signal handler to only be executed by the main thread. This should now be fixed by examining the destination PID of the signal as well as the ID of the thread currently running the signal handler. If we notice the signal wasn't sent by our own PID and the handler is not currently run by the main thread, we re-send the signal to the main thread. Otherwise, if the signal was sent by our own PID but the handler is not run in the main thread, do nothing. This way we can use pthread_kill() to wake up threads that might be stuck in a blocking syscall when it's time to shut down.
* [SERVER] Use reference counting for uplinkSimon Rettberg2019-08-271-15/+33
| | | | First step towards less locking for proxy mode
* [SERVER] Get rid of alt-servers thread, per-uplink rtt historySimon Rettberg2019-08-221-4/+12
| | | | | | | | | | Alt-Server checks are now run using the threadpool, so we don't need a queue and dedicated thread anymore. The rtt history is now kept per uplink, so many uplinks won't overwhelm the history, making its time window very short. Also the fail counter is now split up; a global one for when the server actually isn't reachable, a local (per-uplink) one for when the server is reachable but doesn't serve the requested image.
* [SERVER] Put request handle into CMD_ERROR replySimon Rettberg2019-08-221-1/+1
|
* [SERVER] net.c: Minor reorderingSimon Rettberg2019-08-181-8/+9
|
* [SERVER] Better lock debugging: Always check lock orderSimon Rettberg2019-08-071-3/+3
| | | | | | Lock order is predefined in locks.h. Immediately bail out if a lock with lower priority is obtained while the same thread already holds one with higher priority.
* [SERVER] Use more _AtomicSimon Rettberg2019-08-071-2/+1Star
|
* [SERVER] Fix race condition and invalid lock orderSimon Rettberg2019-08-071-4/+7
|
* [SERVER] Turn all spinlocks into mutexesSimon Rettberg2019-07-261-55/+55
| | | | | | | | Just assume sane platforms offer smart mutexes that have a fast-path with spinlocks internally for locks that have little to no congestion. In all other cases, mutexes should perform better anyways.
* [SERVER] Cosmetic changes (loglvl, comment)Simon Rettberg2019-02-041-2/+2
|
* [SERVER] Don't keep an uplink connection established foreverSimon Rettberg2019-01-311-5/+13
| | | | | | In case we don't use background replication a connection to an uplink server can potentially stay around forever. This in turn would prevent the uplink server from freeing the image as it appears to be in use.
* [SERVER] Only set BGR flag in handshake for BGR_FULLSimon Rettberg2018-11-161-1/+1
| | | | | | | _backgroundReplication was still treated as a boolean flag, so a server with BGR_NONE would reject a server with BGR_HASHBLOCK. While this still forces the BGR_NONE proxy to replicate more than it normally would, it seems reasonable to allow this.
* [SERVER] rpc: Distinguish between client and server (proxy) connectionsSimon Rettberg2018-08-141-5/+14
|
* [SERVER] Use atomic var for (total)bytesSent countersSimon Rettberg2018-08-081-74/+47Star
| | | | | | Gets rid of the lastBytesSent field as well as the stats lock per client. Cleaned and split up the messy net_clientsToJson function while at it.
* [SERVER] Reduce debug spamSimon Rettberg2018-07-091-2/+1Star
|
* [SERVER] Refactor uplink/cache handling, improve crc checkingSimon Rettberg2018-07-041-2/+4
| | | | | | | | | | | | | The cacheFd is now moved to the uplink data structure and will only be handled by the uplink thread. The integrity checker now supports checking all blocks of an image. This will be triggered automatically whenever a check for a single block failed. Also, if a crc check on startup fails, the image won't be discarded anymore, but rather a full check will be initiated. Furthermore, when calling image_updateCacheMap() on an image that was previously complete, the cache map will now be re-initialized, and a new uplink connection created.
* [SERVER] Fix int overflows on 32bit builds in CRC generationSimon Rettberg2018-03-161-1/+1
|
* [SERVER] Make TSAN happySimon Rettberg2017-12-191-1/+3
|
* [SERVER] Add multiple config options for limiting stuffSimon Rettberg2017-11-081-1/+1
| | | | | maxClients, maxImages, maxPayload, maxReplicationSize Refs #3231
* [SERVER] altservers: Tweak, cleanup, refactor, renameSimon Rettberg2017-11-081-1/+1
|
* [SERVER] Support finer control over replication when a proxy connects to a proxySimon Rettberg2017-11-021-2/+22
| | | | | | | Introduce new flag in "select image" message to tell the uplink server whether we have background replication enabled or not. Also reject a connecting proxy if the connecting proxy uses BGR but we don't, as this would basically force the image to be replicated locally too.
* [SERVER] Since fuse client assumed no backwards compat before v3, lie to clientsSimon Rettberg2017-11-011-1/+1
| | | | | | If client reports protocol version < 3 on connect, just pretend we're at the same version. This sucks but we can't update servers before clients otherwise. :(
* [*] Mark logadd() as printf-style function, fix errors that it revealedSimon Rettberg2017-10-311-3/+4
| | | | ...there were quite a few format string errors as it turns out :/
* [SERVER] net.c: Refactoring and renamingSimon Rettberg2017-10-311-58/+33Star
| | | | | | Less copy & paste for sendfile alternatives, changed naming of old dnbd3_* functions moved over from server.c a while ago.
* [SERVER] Add AFL supportSimon Rettberg2017-10-301-1/+36
| | | | | | | | | | | AFL is an instrumenting fuzzer. It expects to pass input to the program to be tested via command line (file name) or via stdin. This adds support for reading messages that normally would arrive via network directly from stdin. In this mode, the server is pretty useless otherwise. http://lcamtuf.coredump.cx/afl/
* [SERVER] net: Simplify check for HTTPSimon Rettberg2017-10-261-10/+11
| | | | | Pretty loose guesswork, but preventing the false positives would not lead to any meaningful result anyways, so why bother.
* [SERVER] Improve handling of byte stats countersSimon Rettberg2017-10-251-12/+12
| | | | Less writes to variables, more up-to-date values for uplinks.
* [SERVER] Fix types or add explicit casts everywhere we might have type ↵Simon Rettberg2017-10-241-28/+29
| | | | conversion problems
* [SERVER] Mute signedness warning on 32bitSimon Rettberg2017-10-201-2/+2
|
* [SERVER] Use monotonic clock for measuring timeSimon Rettberg2017-10-191-2/+3
| | | | | Introduces new shared source unit timing.[ch] Closes #3214
* [*] Support hop-counting in request header, protocol version 3Simon Rettberg2017-10-171-12/+13
| | | | | | | | | | | | | | We steal 8 bits from the request offset to count hops when requests get relayed by proxies. This still leaves plenty of bits for the offset (56 bits, supporting images of up to 72 petabytes). This is used to detect proxy cycles. The algorithm is not perfect but should prevent endless relays of the same request. This is backwards compatible to old clients and servers, as the server only ever sets the hopcount in relayed requests if the upstream server is using protocol version 3 or newer, and clients are automatically upwards compatible as there is practically no image larger than 74PB, so the newly introduced hop count field is always 0 even in requests from old clients.
* [SERVER] Fix invalid pointer derefSimon Rettberg2017-10-061-1/+1
|
* [SERVER] Return client count when requesting stats but not client listSimon Rettberg2017-10-061-1/+7
|
* [SERVER] How about updating atime on connect?Simon Rettberg2017-10-041-0/+3
|
* [SERVER] Implement HTTP RPC that supports different queries and ACLSimon Rettberg2017-10-011-6/+14
| | | | | | | | | - ACL is defined in new file rpc.acl - Queries are still WIP, for now something like /query?q=stats&q=images /query?q=clients works, although the parsing is still ugly - Also supports HTTP keep-alive
* [SERVER] Refactor: Move client list to net.* and isolateSimon Rettberg2017-09-071-60/+256
|
* [SERVER] Split server-only defs from config.h to serverconfig.hSimon Rettberg2017-08-261-1/+1
|