summaryrefslogtreecommitdiffstats
path: root/src/kernel/net.c
Commit message (Collapse)AuthorAgeFilesLines
* [KERNEL] Rename logigng macros, change debug level of a few messagesSimon Rettberg2023-02-061-21/+25
|
* [KERNEL] Actually fix build on 6.0+Simon Rettberg2023-01-111-5/+5
|
* [KERNEL] Update for Linux 6.1Simon Rettberg2023-01-091-0/+5
|
* Fix linter issues to satisfy Linux kernel code styleManuel Bentele2022-10-051-6/+7
|
* [KERNEL] Fix copy&paste error (passing wrong sock)Simon Rettberg2022-02-231-2/+2
|
* [KERNEL] Refactor to use workqueues and blk-mq onlySimon Rettberg2022-02-181-738/+646Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using workqueues frees us from having to manage the lifecycle of three dedicated threads. Discovery (alt server checks) and sending keepalive packets is now done using work on the power efficient system queue. Sending and receiving happens via dedicated work queues with higher priority. blk-mq has also been around for quite a while in the kernel, so switching to it doesn't hurt backwards compatibility. As the code is now refactored to work more as blk-mq is designed, backwards compatibility even improved while at the same time freeing us from an arsenal of macros that were required to make the blk-mq port look and feel like the old implementation. For example, the code now compiles on CentOS 7 with kernel 3.10 without requiring special macros to detect the heavily modified RedHat kernel with all its backported features. A few other design limitations have been rectified along the way, e.g. switching to another server now doesn't internally disconnect from the current one first, which theoretically could lead to a non-working setup, if the new server isn't reachable and then - because of some transient network error - switching back also fails. As the discover-thread was torn down from the disconnect call, the connection would also not repair itself eventually. we now establish the new connection in parallel to the old one, and only if that succeeds do we replace the old one with it, similar to how the automatic alt-server switch already does it.
* [KERNEL] Add missing include to fix compile on 4.14.xSimon Rettberg2022-02-111-0/+1
|
* [KERNEL] Fix wurstfingered missing ;Simon Rettberg2021-11-081-1/+1
|
* [KERNEL] Explicitly pass proper addrlen on connect; improve debug logSimon Rettberg2021-11-081-3/+7
|
* [KERNEL] Don't log connect failures as errors for RTT checksSimon Rettberg2021-10-191-16/+24
| | | | | | | This spams scary red errors to dmesg when really an unreachable alt server isn't that much of a deal during normal operation. Change the log level to debug instead. Might even consider not printing anything at all.
* [KERNEL] Add support for Linux kernels without blk-mq (e.g. CentOS 7)Manuel Bentele2021-06-161-14/+19
|
* [KERNEL] Improve debug output in net.cSimon Rettberg2021-04-201-5/+10
|
* [KERNEL] Fix Linter errorsManuel Bentele2021-04-161-2/+3
|
* [KERNEL] Removes duplicate word 'of' in license headersManuel Bentele2021-04-161-1/+1
|
* [KERNEL] Deduplicate code, clean up, split into functionsSimon Rettberg2021-04-141-393/+339Star
|
* [KERNEL] Fix CMD name in debug messagesSimon Rettberg2021-04-141-3/+3
|
* [KERNEL] Improve socket connectSimon Rettberg2021-03-291-34/+59
| | | | | | | | - Remove the ugly timeout hack that apparently isn't required after all. - Set a few socket options that appear to make sense in out use case (no linger, only one SYN retry, NODELAY). - Adapt socket timeout in panic mode, in case we're on a very bad connection.
* [KERNEL] Implement best_count logic for load balancingSimon Rettberg2021-03-261-7/+28
| | | | | | | Similar logic already exists in the fuse client: Count how many times in a row a server was fastest when measuring RTTs, and lower the switching threshold more the higher the count gets.
* [KERNEL] Use sockaddr instead of dnbd3_host_t where possibleSimon Rettberg2021-03-241-110/+59Star
| | | | | | | | Convert dnbd3_host_t to struct sockaddr immediately when adding alt servers, so we don't have to convert it every time we establish a connection. Additionally we can now use %pISpc in printf-like functions instead of having if/else constructs whenever we want to print an address.
* [KERNEL] Synchronous add/remove of alt-servers via IOCTLSimon Rettberg2021-03-231-125/+82Star
|
* [KERNEL] Enable assertions if CONFIG_DEBUG_DRIVER is setManuel Bentele2021-03-161-0/+6
|
* [KERNEL] Refactor code to satisfy Linux kernel code styleManuel Bentele2021-03-121-356/+289Star
|
* [KERNEL] Fix race condition for request_queuereceive in receive threadSimon Rettberg2020-11-201-8/+7Star
| | | | | | | | | | Formerly, the request that was about to be received was looked up in the receive queue without removing it, then the request payload was received from the socket while the lock was not being held, and finally, the lock was required again and the request removed from the queue. This is dangrous as another thread can concurrently take the request from the queue while the receive thread reads the payload from the socket, leading to a double-free by calling blk_mq_end_request twice.
* [KERNEL] Cleanup thread cleanup, fix closing of device when busySimon Rettberg2020-11-201-49/+89
|
* [KERNEL] Fix several connect/disconnect race conditionsSimon Rettberg2020-11-191-174/+147Star
| | | | | | | | | | | | | | | | | | | Previously disconnect was protected against concurrent calls, but connect wasn't. It was easy to crash the kernel when calling connect and disconnect IOCTLs in a tight loop concurrently. A global lock was introduced to make sure only one caller can change the connection state at a time. dev->connection_lock needs to be aquired when calling dnbd3_net_connect or _disconnect. This atomic_t based locking mechanism should be turned into a mutex in a next step, relying on mutex_trylock for cases where we don't have the cmpxchg-schedule() loop. Along the way it was noticed that the send/receive timeouts don't apply to kernel_connect, which might have been the case in older 3.x kernel versions. A crude workaround using nonblocking connect has been introduced to emulate this, but a clean solution for this is welcomed. Also, devices are now properly closed on module unload.
* [KERNEL] add support for Linux kernel 4.19 on Ubuntu 18.04 (GCC 7.5)Manuel Bentele2020-11-161-8/+8
| | | | | | | This patch replaces the __VA_OPT__ varadic macro for the C preprocessor with a builtin GCC extension for optional varadic arguments. Based on this change, the dnbd3 Linux kernel module can be also built with GCC 7.5 on a fresh Ubuntu 18.04 with Linux kernel version 4.19.x.
* [KERNEL] add manual switching of dnbd3-server to specified serverManuel Bentele2020-11-101-55/+69
| | | | | | This patch adds the feature to manually switch the dnbd3-server to a specified server. The switching is implemented by the use of the ioctl call SWITCH.
* [KERNEL, CLIENT]: submit and probe multiple dnbd3-server with ioctl OPENManuel Bentele2020-11-061-76/+168
| | | | | | | | | | The ioctl OPEN call for DNBD3 devices exposed by the dnbd3 Linux kernel module, is extended with a fixed array of dnbd3 hosts. The fixed array allows the dnbd3-client to submit host information (IP address and port) of multiple dnbd3-servers. This information is used to probe all submitted dnbd3-servers and add them to the alternative dnbd3-server list. If at least one dnbd3-server is not reachable, the OPEN ioctl call will abort with an error code.
* [BUILD] rewrite CMake build system to track changes of source filesManuel Bentele2020-10-161-2/+2
| | | | | | | | | | 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.
* [KERNEL] ported socket time structures to support CentOS 8 kernel 4.18Manuel Bentele2020-10-131-1/+24
| | | | | | | | | This patch implements the old time structures to support Linux kernels prior to version 5.1.x. WARNING: This change to the deprecated time structures does not solve the Y2038 issue. Thus, the dnbd3 Linux kernel module can only run under Linux kernels prior to version 5.1.x until the end of year 2037.
* [KERNEL] set socket timeouts with new function and time structureManuel Bentele2020-08-311-8/+30
| | | | | | | | | | This patch replaces the deprecated kernel_setsockopt() function with the socket generic function sock_setsockopt() to set the send and receive timeout for all used sockets in the kernel module. The timeout data type is choosen according to the available kernel version, so that the dnbd3 kernel module supports the new y2038-problem-solving socket options. With both changes, the kernel module runs on Linux kernel 5.4 LTS and later (including Linux kernel 5.9).
* [KERNEL] make private network functions staticManuel Bentele2020-08-281-286/+286
|
* [KERNEL] convert debug messages and clean up codeManuel Bentele2020-08-281-150/+215
| | | | | | | | | | | | This change converts all debug messages to support the Linux kernel's dynamic debug feature. Debug messages can be enabled or disabled by the debug feature if the - kernel module is built in debug mode (EXTRA_CFLAGS=-g -DDEBUG) - Linux kernel supports dynamic debug (CONFIG_DYNAMIC_DEBUG is set) This patch removes outdated kernel compatibility macros (used for Linux kernels in version 4.x) and cleans up the kernel module's code.
* [KERNEL] convert to blk-mq and ktimeManuel Bentele2020-08-271-18/+18
| | | | | | | | | | | This converts the dnbd3 kernel module driver to use the blk-mq infrastructure, which allows the dnbd3 kernel module driver to be compatible with Linux kernels in version 5.x or later. The conversion of the implementation uses one hardware queue to preserve the existing send/receive and load-balancing logic, but can be scaled up in the future. In addition to that, time measurements in the implementation are converted to ktime based accessors to replace the use of deprecated time interfaces.
* [KERNEL] Fix keep alive timer on 4.15+Simon Rettberg2018-08-151-1/+1
|
* [KERNEL] Pre/post 4.11 handling of request opsJonathan Bauer2018-04-051-7/+10
|
* [KERNEL] #ifs and #defines for timer pre/post 4.15Simon Rettberg2018-04-051-13/+14
|
* [KERNEL] Macros for packing CMD_* into struct requestSimon Rettberg2018-03-271-4/+21
| | | | Version check for pre or post 4.11
* Follow https://lwn.net/Articles/735887/Rafael Gieschke2018-03-241-3/+15
|
* Include `linux/signal.h` for `siginitsetinv`, `sigmask`, `sigprocmask`Rafael Gieschke2018-03-241-0/+1
|
* Follow ↵Rafael Gieschke2018-03-231-7/+7
| | | | https://github.com/torvalds/linux/commit/aebf526b53aea164508730427597d45f3e06b376
* [*] Introduce constants for IPv4/6 in dnbd3_host_tSimon Rettberg2017-10-281-12/+12
| | | | | | | AF_INET luckily was "2" on all platforms checked, so no problems there with interoperation, but AF_INET6 is different between Linux, BSD, Windows and possibly others, so map back and forth between AF_INET/AF_INET6 and HOST_IP4/HOST_IP6 to fix this.
* [*] Continue splitting #defines to clientconfig.h etc.Simon Rettberg2017-09-021-0/+1
|
* [KERNEL/CLIENT] Several minor tweaks and changesSimon Rettberg2016-01-111-10/+9Star
| | | | | | | | | | - Disable panic timeout that reports errors to block layer by default - Get rid of "is_server" used by old proxy mode, introduce "honor_server_alts" that just controls whether we use alts provided by the server - Allow switching servers when we only have 3 RTT measurements - If using alts provided by server, don't ignore those that come from other servers than the initial one
* [KERNEL] Add support for kernel 4.2.xSimon Rettberg2015-10-131-2/+8
|
* [KERNEL] Support for kernel 3.14Simon Rettberg2014-07-041-1/+6
|
* [KERNEL] Improved read timeout handlingSimon Rettberg2013-12-201-4/+7
|
* [KERNEL] Don't pick a random block for RTT measurementSimon Rettberg2013-11-171-17/+3Star
| | | | It's a bad idea.
* tiny fixSimon Rettberg2013-11-111-1/+1
|
* [KERNEL] Fix possible deadlock on server switchSimon Rettberg2013-11-111-78/+73Star
| | | | | [KERNEL] Remove server mode support as it's not needed anymore [KERNEL] Some more sanity checks and debug messages