summaryrefslogtreecommitdiff
path: root/src/lib
Commit message (Collapse)AuthorAgeFilesLines
* irmd: Always use reg_destroy_procDimitri Staessens2024-02-231-1/+1
| | | | | | | | | | | 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>
* lib: Revise app flow allocationDimitri Staessens2024-02-2313-445/+917
| | | | | | | | | | | | | 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>
* lib: Fix CRC32 hashing0.21.1Dimitri Staessens2024-02-192-14/+36
| | | | | | | | | I assumed that all hashes were stored in Big Endian, but apparently the CRC32 was still in machine endianness when calculated by the rhash implementation. Fixed and updated hash tests a bit. 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-194-4/+4
| | | | | | | 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-1917-125/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-311-15/+9
| | | | | | | | 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>
* lib: Make list empty on deleteDimitri Staessens2024-01-311-1/+1
| | | | | | | | The list_del operation now lets nxt and prv point to the element itself, so that list_is_empty(e) is true after list_del(e). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update licenses to 2024Dimitri Staessens2024-01-1344-45/+45
| | | | | | | Slow but steady. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Fix passing symmetric key on allocationDimitri Staessens2023-12-311-1/+1
| | | | | | | | | 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: Fix wrong fccntl return for FLOWGRCVTIMEOThijs Paelman2023-12-171-1/+1
| | | | | | | The send timeout was returned instead of the receive timeout. Signed-off-by: Thijs Paelman <thijs@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Move public key handling from app to IRMdDimitri Staessens2023-12-173-77/+17
| | | | | | | | | | | | | | | 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>
* lib: Fix memleak when creating IPCPDimitri Staessens2023-12-171-0/+4
| | | | | | | The irm_create_ipcp leaked the ipcp_info protobuf message. 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-293-30/+76
| | | | | | | | 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-292-6/+6
| | | | | | | | 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-292-3/+3
| | | | | | | | | 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>
* lib: Fix reading FUSE output on RaspbianDimitri Staessens2023-11-261-6/+11
| | | | | | | | | | | | | | | | | The previous patch only fixed listing the contents on the fuse filesystem. Apparently files with st_blocks = 0 as seen as empty on Raspbian, and the FUSE read() function isn't invoked for such files. Setting st_blocks to 1 fixes that, but st_blksize is ignored for fuse. So, on raspbian the filesize is now a huge number, but at least reading the fuse filesystem works. Corrected the filesystem attributes for the IPCP output for systems that don't rely on st_blocks to assess filesize. Also set the file mode to 0644 as these are not executables. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Add newlines to stderr output at initDimitri Staessens2023-11-261-16/+16
| | | | | | | The stderr lines had no newline. Fixed. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix FUSE output on RaspbianDimitri Staessens2023-11-201-0/+4
| | | | | | | | | | | | For some reason, 'ls' on raspbian invoked the fuse readdir() in a loop where the first call had fuse_file_info * info set to NULL and subsequent calls had info->nonseekable set to 1. Since we don't check the value the info struct, this caused an infinite loop when trying to list the contents of the fuse filesystem subdirectories of /tmp/ouroboros/. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix timeout overflow on 32-bit systems0.20.1Dimitri Staessens2023-11-081-2/+2
| | | | | | | | | | The timeout comparison for keepalives could overflow on 32-bit systems, as times were converted to nanoseconds and be limited to a bit over 4 seconds. This caused flow reads to fail miserably with EFLOWPEER errors when keepalives were set higher on these systems. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Remove pid from flow structDimitri Staessens2023-10-251-4/+0
| | | | | | | | | The pid of the N-1 IPCP process was needlessly stored in the flow struct. We only need it to open the right shared memory maps, which is done when the flow is created. 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-255-47/+9
| | | | | | | | | 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>
* lib: Make crypt.c independent source fileDimitri Staessens2023-10-254-54/+68
| | | | | | | | | | | The cryptography functions were in a C source that was directly imported into dev.c, enabling ECDHE+AES256 symmetric key encryption on flows. Now crypt.c is an independent source file with associated crypt.h header, to prepare for security management and configuration in the IRMd. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Revise port construct in applicationDimitri Staessens2023-09-201-84/+91
| | | | | | | | | | | | | | | | | | The application had a port construct, which is a leftover from the early days implementing RINA specs, which had a "port_id" to access flows. O7s doesn't really have a "port" concept, only flows. The port_wait_assign function was used in the IPCP to wait for the IRMd to assign the flow_id and return so the flow object could be created. This renames things a bit, and also simplifies the locking to us a single lock/condvar for managing flows. This should be further improved to move the flow state into the flow object, maintain a double mapping of to flow objects (id_to_flow and fd_to_flow) and malloc flow objects at flow allocation, instead of keeping the full table in memory at init to further reduce memory footprint. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Revise application init and finiDimitri Staessens2023-09-201-50/+72
| | | | | | | | The init will now print more useful errors if a process fails to initialize. Also rearranged these procedures a little bit. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Rename portevent to floweventDimitri Staessens2023-09-202-10/+9
| | | | | | | Doesn't make any sense to call it a port event... Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Move protobuf definitions to pb/ directoryDimitri Staessens2023-08-307-8/+8
| | | | | | | | | | This moves the protobuf definition in the library to a pb/ directory. Also renames the protobuf files and does a quick review of the #define guards in the include library to specify _LIB_ for internal/non-public library headers. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* ipcpd: Add IDs to enrollmentDimitri Staessens2023-08-233-38/+94
| | | | | | | | The enrollment messages now have a 64-bit ID to easier track enrollments in the logs in larger scale tests. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* include: Revise printing hashesDimitri Staessens2023-08-233-0/+185
| | | | | | | | | | | 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>
* lib: Fix lengths of shared memory objectsDimitri Staessens2023-08-233-23/+18
| | | | | | | | Seems like all shared memory objects were truncated to a size that came up a byte short. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix lockfile lengthDimitri Staessens2023-08-231-55/+39
| | | | | | | | Off-by-one error in lockfile file length. Refactor to reduce code duplication. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix signed/unsigned mismatches on raspbianDimitri Staessens2023-08-232-3/+3
| | | | | | | | Compilation on raspberry pi revealed some previously undetected signed/unsigned comparisons in the library. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Link libcrypt and fix cmake compatibilityDimitri Staessens2023-08-231-3/+4
| | | | | | | | | | | | | | | Compatibility with versions of CMake older than 3.5 is deprecated from CMake 3.27 onwards, and will be removed from a future version. Calls to cmake_minimum_required() or cmake_policy() that set the policy version to an older value now issue a deprecation diagnostic. Fixed by indicating a max tested value for cmake_minimum_required(). Changed linking with OpenSSL to link with libcrypto only, we don't require libssl. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix memleak in bitmap testDimitri Staessens2023-05-121-12/+13
| | | | | | | There was a missing bmp_destroy, refactored exiting after a failure. 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-211-3/+3
| | | | | | | | | | | | | | 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>
* lib: Remove while loop around frcti_window_waitDimitri Staessens2023-03-181-4/+3
| | | | | | | That while loop is not needed anymore. 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-182-32/+79
| | | | | | | | 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>
* lib: Remove semicolon after protobuf messagesDimitri Staessens2023-03-183-7/+7
| | | | | | | | Doesn't seem to be needed, this makes it uniform in all protobuf files. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* irmd: Add configuration file supportDimitri Staessens2023-03-0810-126/+673
| | | | | | | | | | | | | | | | | | | | | 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>
* lib: Refactor hash internalsDimitri Staessens2023-02-232-24/+33
| | | | | | | | The internal hash enum now matches the public one w.r.t. directory hash policies. This removes some unnecessary conversion. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* ipcpd: refactor IPCP configurationDimitri Staessens2023-02-132-52/+60
| | | | | | | | | | The ipcp configuration struct now has internal structures for the different IPCPs and for IPCP components of the unicast IPCP. Split the very long IPCP main loop into individual handler functions. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update copyright to 2023Dimitri Staessens2023-02-1340-40/+40
| | | | | | | 2022 was a rather slow year... Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix prototypes missing 'void'Dimitri Staessens2023-02-133-7/+9
| | | | | | | Found by Clang version 15. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Add version and symlinks to shared objects0.19.3Marco Casaroli2022-08-061-0/+10
| | | | | | Building with Yocto was giving some package QA warnings. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
* lib: Fix dealloc with unread keepalivesDimitri Staessens2022-05-251-12/+20
| | | | | | | | | The dealloc call will now always do a non-blocking read before attempting to destroy the rbuff, ensuring all keepalives are processed. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Rename timerwheel_ack timerwheel_delayed_ack0.19.2Dimitri Staessens2022-04-132-7/+5
| | | | | | | | | This makes it clear that we are scheduling a potential delayed acknowledgment instead of acknowledging a packet scheduled for retransmission. Also some small cosmetic fixes. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix RTO update on timeoutDimitri Staessens2022-04-033-12/+9
| | | | | | | | | | | | | This fixes the RTO doubling on timeout according to Karn/Partridge. Exponentially increasing RTO when it times out (e.g. doubling) fixes the problem that a sudden increase in real RTT starves the sRTT updates by never getting out of backoff as retransmitted packets can't update RTT. Added an parameter to make it less aggressive, default is doubling. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Remove timerwheel from instanceDimitri Staessens2022-04-031-2/+0
| | | | | | | | There was an unused struct timerwheel * lingering in the application instance. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* build: Update copyright to 2022Dimitri Staessens2022-04-0340-40/+40
| | | | | | | Growing pains. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Fix delayed ACK under high loadDimitri Staessens2022-04-031-3/+9
| | | | | | | | | | The delayed ACK was wrongly measuring the delay against the receiver activity instead of the sender activity. Also fixed receiver activity not being updated for non-data packets (and duplicates and other dropped traffic). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
* lib: Add support for Linux RTT estimatorDimitri Staessens2022-04-033-2/+13
| | | | | | | | | | | | | This adds the option to use the Round-Trip-Time (RTT) estimation algorithm as it is implemented in the TCP implementation in Linux. It looks like it outperforms the TCP default algorithm, so I enabled this one by default. Also adds the option to change the RTO timeout calculation to include more (or less) than 4 times the mdev (specified as a power of 2. Left the default value to 2 (so, 4 mdevs), but 3 (8 mdevs) gives better results in my tests. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>