summaryrefslogtreecommitdiff
path: root/src/irmd
Commit message (Collapse)AuthorAgeFilesLines
* irmd: Fix memleak on cancelDimitri Staessens2024-02-261-5/+12
| | | | | | | | | | | If the mainloop is cancelled during a write, the response buffer leaks. The IRMd now warns about failed writes only when the error is not EPIPE, as EPIPE is expected to happen with timed out requests. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix flow deallocation timeoutDimitri Staessens2024-02-261-5/+6
| | | | | | | | The timeout was set to a value calculated as abstime for a cond_wait instead of a timeout, causing flows to linger in the IPCP. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Always use reg_destroy_procDimitri Staessens2024-02-236-125/+94
| | | | | | | | | | | Destroying a process will now always be done with reg_destroy_proc, regardless of whether it was an IPCP or spawned. This makes it easier to keep the registry consistent and avoid races. Also improves some logs and updates some default settings. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix race between alloc timeout and respondDimitri Staessens2024-02-231-2/+6
| | | | | | | | | If a flow allocation times out just before the response, there is a short window where the response will still find the flow, but in DEALLOCATED state. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Revise app flow allocationDimitri Staessens2024-02-235-91/+82
| | | | | | | | | | | | | This revises the application flow allocator to use the flow_info struct/message between the components. Revises the messaging to move the use protocol buffers to its own source (serdes-irm). Adds a timeout to the IRMd flow allocator to make sure flow allocations don't hang forever (this was previously taken care of by the sanitize thread). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix free of uninitialized ptrDimitri Staessens2024-02-191-2/+3
| | | | | | | | | The reg_list_ipcps function left *ipcps uninitialized when there were no IPCPs in the system. This caused a free to SEGV in the IRMd when trying to allocate a flow. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Fix missing newlines at end of fileDimitri Staessens2024-02-199-9/+9
| | | | | | | Some files had a newline at the end, others didn't. Now they all do. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Revise IRMd internalsDimitri Staessens2024-02-1930-3051/+6604
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a full revision of the IRMd internal implementation. The registry is now a proper subcomponent managing its own internal lock (a single mutex). Some tests are added for the registry and its data structures. Some macros for tests are added in <ouroboros/test.h>. Flow allocation is now more symmetric between the client side (alloc) and server size (accept). Each will create a flow in pending state (ALLOC_PENDING/ACCEPT_PENDING) that is potentially fulfilled by an IPCP using respond_alloc and respond_accept primitives. Deallocation is split in flow_dealloc (application side) and ipcp_flow_dealloc (IPCP side) to get the flow in DEALLOC_PENDING and DEALLOCATED state. Cleanup of failed flow allocation is now properly handled instead of relying on the sanitizer thread. The new sanitizer only needs to monitor crashed processes. On shutdown, the IRMd will now detect hanging processes and SIGKILL them and clean up their fuse mountpoints if needed. A lot of other things have been cleaned up and shuffled around a bit. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* include: Use common definition between lib and IRMdDimitri Staessens2024-01-316-29/+17
| | | | | | | | Some definitions/enums were different between the library and IRMd (flow_state, ipcp_state). This moves them to common ground. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Don't release flow_id before destroying flowDimitri Staessens2024-01-132-4/+5
| | | | | | | | | | When flow_alloc failed, it was releasing the flow_id, but the flow was needs to be cleaned up by the sanitizer. Bug introduced by ongoing refactor of the flow allocator, which - when done - will properly clean up the flow after a failure and not depend on the sanitizer. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Error when config not foundThijs Paelman2024-01-132-3/+4
| | | | | | | | | | | | | Error instead of warn when the --config param is set, but the file is not found. This prevents the IRMd from being in a 'half state', where it is started, but the expected config is not applied. One simply has to remove the --config option OR supply a correct filepath. Also fix compile option for the help message. Signed-off-by: Thijs Paelman <thijs@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix parsing empty argument in configfileThijs Paelman2024-01-131-1/+1
| | | | | | | | | | | | | | Previously, args=[""] would crash the IRMd when it tried to auto-instantiate the program. Now, specifying an empty string as argument to a program WILL automatically start that program if there is an incoming flow, but without any arguments, as intended. Remark: The semantics might be a bit less clear than e.g. args=["--listen"], but they are a natural extension. Signed-off-by: Thijs Paelman <thijs@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update licenses to 2024Dimitri Staessens2024-01-1319-19/+19
| | | | | | | Slow but steady. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix parsing multiple args in configfileThijs Paelman2023-12-311-9/+11
| | | | | | | | | | | | | | | | | New method retains the original string in parsing the args string into an argv dynamic array. Previous method (`strtok`) didn't work, because it is a destructive function, changing the supplied string. We however needed to apply it twice to the same string. It is still done twice in a loop, to make sure argc is exact. Other methods, like counting the amount of spaces to determine argc, would be incorrect for his particular way of tokenizing if arguments are separated by e.g. two spaces. Also fixes a wrong pointer dereference, which did go unnoticed before due to the previous error. Signed-off-by: Thijs Paelman <thijs@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix passing symmetric key on allocationDimitri Staessens2023-12-311-4/+8
| | | | | | | | | The check if the flow requires a key in irmd flow_alloc was missing when setting the pointers for the piggyback data, so non-encrypted flow allocations failed on irm_msg__pack(). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Move public key handling from app to IRMdDimitri Staessens2023-12-171-48/+171
| | | | | | | | | | | | | | | The application was generating its public keypair for its ECDHE key exchange. This is now done by the IRMd, which will check the requested qosspec and then apply what is needed. The flow_alloc and flow_accept calls will just return the symmetric key to the application. This makes it easier when we add configurations with given public key pairs and other encryption algorithms, which can then all be configured globally in the IRMd instead of having all the options replicated and implemented in each and every application. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Don't log an error when server quitsDimitri Staessens2023-11-301-2/+7
| | | | | | | | | | The revision of the IRMd caused it to log an error when an application terminates and closes the unix socket (EPIPE) or the IRMd shutds down (EIRMD). These are expected and correct behaviour. Replaced the error logs with debug logs. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* include: Store IPCP name and type in info structDimitri Staessens2023-11-297-73/+89
| | | | | | | | The information for an IPCP is now stored in an ipcp_info struct, containing name and type. The IRM public API is not changed. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* include: Rename layer.layer_name to layer.nameDimitri Staessens2023-11-293-8/+8
| | | | | | | | The layer_info had a member layer_name which is a bit redundant. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Rename ipcp_info to ipcp_list_infoDimitri Staessens2023-11-291-4/+4
| | | | | | | | | The ipcp_info struct / message contains information only used for listing IPCPs, and I will reuse the ipcp_info name for general IPCP information common to all IPCPs such as name and type. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix parsing names without args in configfile0.20.2Dimitri Staessens2023-11-201-0/+5
| | | | | | | | Config files that had service names without the args option specified would cause the IRMd to segfault. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix use of uninitialized valueDimitri Staessens2023-11-081-1/+1
| | | | | | | | The value for 'ret' was not initialized when comparing to -ETIMEDOUT in reg_name_leave_state(). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Don't load config file without --config setDimitri Staessens2023-10-251-1/+1
| | | | | | | | | | The irmd was automatically loading the default configfile (usually /etc/ouroboros/irmd.conf) if present. Now the --config parameter has to be set for the irmd to load a config. The service is adapted to have the --config command line parameter set at install. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Wrap pthread_cond_timedwait for NULL abstimeDimitri Staessens2023-10-254-26/+11
| | | | | | | | | We often have the pattern where we NULL-check abstime for pthread_cond_timedwait to call pthread_cond_wait if it is. Added a __timedwait function to wrap this. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Remove separate rwlock for flowsDimitri Staessens2023-10-251-62/+36
| | | | | | | | | | Modifications for flows were made under a different rwlock (flows_lock) than the rwlock used for names, etc (reg_lock). This has little value and unnecessarily complicates things. This removes the flows_lock and uses the reg_lock for all registry objects. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Simplify mainloopDimitri Staessens2023-10-251-212/+213
| | | | | | | | This moves the command parsing function out of the mainloop implementation to make it a bit less unwieldy. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Print ascii Ouroboros logo at startupDimitri Staessens2023-09-202-1/+34
| | | | | | | | | | | | | | | | | | The IRMd will now print a stylized logo at startup: ▄▄█████▄▄▄ ▄█▀▀ ▀▀███▄ █ ██ ▄▄▄ ▄███▄ ▄ ▄ ▄ ▄▄ ▄▄ █ ▄▄ ▄▄ ▄ ▄▄ ▄▄ ▄▄ ██ █ █ █████ █ █ █▀ ▀ █ █ █▀ █ █ █ █▀ ▀ █ █ ▀▄ ▀ ██ ▀▄▄▄▀ ▀█▀ █ █ █ █ █ █▄ █ █ █ █ █ █ ▄ ▀▄ █▄ █ ▀▀▀ ▀ ▀ ▀▀ ▀ ▀▀ ▀▀ ▀ ▀▀ ▀▀ ▀█▄▄▄▄▄▄▄▄▀ ▀▀▀▀▀▀ All credits to Zen for providing the ASCII art! Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* include: Revise printing hashesDimitri Staessens2023-08-231-9/+9
| | | | | | | | | | | The code was a bit convoluted to print hashes as hex strings. Renamed to HASH_FMT32 and HASH_VAL32 to make clear we are printing the first 32 bits only, and added options to print 64 up to 512 bits as well. This doesn't depend on endianness anymore. Adds a small test for the hash (printing) functions. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix exit status when failing on configfileDimitri Staessens2023-08-231-2/+5
| | | | | | | | If there was an error reading the configuration file, the IRMd would shutdown, but still return EXIT_SUCCESS instead of EXIT_FAILURE. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Check lockfile first on initDimitri Staessens2023-08-231-27/+41
| | | | | | | | The IRMd will now check the lockfile before initializing any other internals. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Simplify ipcp and name listingDimitri Staessens2023-08-041-41/+69
| | | | | | | | These functions were too complex. This splits off the creation of the info messages for each ipcp/name. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Use CMAKE_INSTALL_SBINDIR to spawn IPCPsDimitri Staessens2023-04-032-10/+10
| | | | | | | | The "/sbin/" was hard-coded, which will fail if the installation SBIN directory is configured to something else. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Move registry objects to their own sourcesDimitri Staessens2023-03-2120-1762/+1822
| | | | | | | | | | | | | | Rename internal data structures so it's clear that they are the IRMd representation of these objects for management purposes. Split functionality for these objects off and and move them to their own source files. Rename internal functions of the IRMd to reflect this, with some small refactoring. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Use buffer_t for piggybacked dataDimitri Staessens2023-03-185-157/+134
| | | | | | | | | | Instead of passing a const void * and len, it now passes buffer_t to operations that send piggybacked data (flow_req_arr and flow_reply) and a buffer_t * for operations that send and receive piggybacked data (flow_alloc and flow_accept). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Use deadline instead of timeout in mainloopDimitri Staessens2023-03-183-33/+25
| | | | | | | | Reduces the places where we need to do this conversion for pthread_cond_timedwait. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Remove unused function reg_entry_wait_stateDimitri Staessens2023-03-182-43/+0
| | | | | Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Split flow_alloc from flow_joinDimitri Staessens2023-03-181-25/+104
| | | | | | | | Better to keep these separate during IRMd revision. Moves the qosspec default out of the protobuf message parsing. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Fix TOML library variableDimitri Staessens2023-03-081-5/+6
| | | | | | | | LIBTOML_LIBRARIES should be explicitly set to "" if the TOML C99 library is not present. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Add configuration file supportDimitri Staessens2023-03-0810-70/+1081
| | | | | | | | | | | | | | | | | | | | | This adds initial support for configuration files using the C99 TOML parser (to be installed separately from https://github.com/cktan/tomlc99). The default location for the IRMd configuration file is /etc/ouroboros/irmd.conf. This is configurable at build time. An example file will be installed in the configuration directory with the name irmd.conf.example. Config file support can be disabled using the DISABLE_CONFIGFILE build option. There were some refactors and changes to the configuration messages and protobuf files. This works towards consolidation of protobuf C as an option for more generic handling of serialization/deserialization of various messages. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix cleanup of failed flowsDimitri Staessens2023-03-083-3/+7
| | | | | | | | If a flow allocation failed, the flow was left in a pending state instead of a failed state, which caused the irmd to hang on exit. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update copyright to 2023Dimitri Staessens2023-02-1314-14/+14
| | | | | | | 2022 was a rather slow year... Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Refactor main functionDimitri Staessens2022-07-131-162/+192
| | | | | | | | This splits the main function into init/start/sigwait/stop/fini to make it easier to read, similar to the IPCPs. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update copyright to 2022Dimitri Staessens2022-04-0314-14/+14
| | | | | | | Growing pains. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix buffer allocation when retransmitting0.19.0Dimitri Staessens2022-03-111-0/+3
| | | | | | | | | | | | | | | The timerwheel was retransmitting packets and the error check for negative values of the rbuff allocation was instead checking for non-zero values, causing a buffer allocation to succeed but the program to continue down the unhappy path leaving that packet stuck in the buffer unattended. Also fixes wrongly scheduled retransmissions that cause packet storms. FRCP is much more stable now. Still needs some work for high bandwidth-delay products (fast-retransmit). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* ipcpd: Fix memcpy with NULL in piggyback APIDimitri Staessens2022-03-081-3/+5
| | | | | | | | If there is no piggyback data, memcpy was passed a NULL pointer in memcpy(buf, NULL, 0) calls, which is undefined behaviour. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* ipdpd: Pass MPL to application at flow_allocationDimitri Staessens2022-03-083-4/+22
| | | | | | | | | | | | The maximum packet lifetime (MPL) is a property of the flow that needs to be passed to the reliable transmission protocol (FRCP) for its correct operation. Previously, the value of MPL was set fixed as one of the (fixed) Delta-t parameters. This patch makes the MPL a property of the layer, and it can now be set per layer-type at build time. This is a step towards a proper MPL estimator in the flow allocator. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Flag all flows down as the IRMd exitsDimitri Staessens2022-03-031-1/+2
| | | | | | | | | | | | | | On exit of the IRMd all flows will now be flagged as down, so external applications will not hang anymore. Note: reads keep work from flows that are down until there are no more remaining packets in the buffer, but no more packets can be written. When the RIB is used, the external application may exit a bit later than the IRMd, so I added a brief sleep before the IRMd tries to remove the fuse main directory. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd, ipcp: Remove socket option in acceptloopDimitri Staessens2022-03-031-8/+2
| | | | | | | | | | | | | We cancel the thread, so the SO_RCVTIMEO is not needed anymore (it dated from when we checked the state every so often. The address sanitizer is complaining about the the cleanup handlers in the acceptloops after the thread gets cancelled in the read(). I've tried to resolve it, but no avail. Pretty convinced it's a false-positive, so ASan will ignore these functions for now. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Make flow liveness timeout configurableDimitri Staessens2022-03-031-1/+1
| | | | | | | | | The qosspec_t now has a timeout value that sets the timeout value of the flow. Flows with a peer that has timed out will now return -EFLOWPEER on flow_read() or flow_write(). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix memory leak of ret_msgDimitri Staessens2022-03-032-2/+2
| | | | | | | | The ret_msg variable can leak in the main loop of the irmd in this failure path. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>