Commit graph

466 commits

Author SHA1 Message Date
Felix Walter
69ea89474d BP: Do not drop all nodes in FIB if no concrete CLA address is present
Sometimes we use CLA addresses such as "smtcp:" or "tcpclv3:", without
an actual next-hop address on the CL. In this case, we do not drop all
FIB entries referencing the "generic" CLA link if a FIB request for
deleting an entry is received.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:18 +02:00
Felix Walter
78bef1a089 Refactor FIB: Separate node entry from CLA link
The FIB fulfils two purposes: 1) map node IDs to next-hop CLA addresses
and 2) store the current status of a link associated with a given CLA
address.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-23 11:59:02 +02:00
Felix Walter
00e4602dbd aap2, agent_manager: Do not warn on double de-registration
If an agent finds out it has a broken connection (the client
disconnected) on a liveliness check (e.g., if another client wants to
register the same agent ID), the agent manager will de-register it, as
it needs to register the new agent immediately and there is a race
condition otherwise. In this case, a warning was shown that should
however only be a debug information.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-09 15:01:46 +02:00
Felix Walter
6775fd8782 aap1: Set admin. config flag on all bundles if no BDM secret set
This makes aap-config / aap_config.py (AAPv1) work again in the default
configuration (debug build, default BDM, no secret set). This way,
pre-existing documentation (YouTube videos, ...) stays usable.

The security properties will not be impacted by this change as AAPv2
clients will be able to do administrative actions anyways if no secret
is set.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-09 15:01:46 +02:00
Felix Walter
a34a785d39 aap2: Properly differentiate connection closure from Protobuf error
This adds a check for detecting EOF and differentiate such an "error"
from actual Protobuf decoding errors so people do not get confusing
log messages.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-08-09 15:01:46 +02:00
Felix Walter
b01d74bb21
Merge branch 'fix/docs'
See !182
2024-07-15 23:01:49 +02:00
Felix Walter
a83098f9fe CLA: Disallow CLA addresses without colon
Allowing both "cla:" and "cla" may lead to issues for single-connection
CLAs (those that do not use CLA-specific addresses): the FIB may contain
entries for both and only one may be marked as "up" if both forms are
used interchangeably.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
281b3ec248 config_parser: Remove unused parser stage
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
ccbeac91f3 Unify and document compile-time options of compat. router
This prefixes all compile-time options of the compat. router with
`ROUTER_` and adds them to config.mk.example so they can be easily
discovered and adapted.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
87be9749af Re-integrate v0.13.0 routing code as "integrated default BDM"
This makes µD3TN behave the same as v0.13.0 when executed without an
additional commandline argument. A new commandline argument `-d` /
`--external-dispatch` is added, which enables the use of external BDMs.
The default forwarding implementation is now again provided using the
v0.13 code, extracted from e1621765a4 and
adapted to the new agent-based forwarding implementation.

Central changes to the old code include:

- A new "Routing Agent" that handles incoming configuration commands,
  FIB updates, and BDM dispatch requests.
- The use of the BDM authorization flag to authorize contact
  configuration commands.
- The Contact Manager now only triggers the creation and removal of
  links / FIB entries; bundle dispatch is triggered through the FIB and
  BDM callback functions of the Routing Agent.
- The fragmentation logic is adapted to store the original bundle along
  with an offset and length value, instead of pre-creating and storing
  the fragments.
- The bundle re-scheduling logic integrated into the Routing Agent is
  simplified and does not support changing the fragmentation parameters.
  A new function is added to the Router that searches for a new route
  for such fragments that were already scheduled at some point,
  considering them as un-fragmentable bundle with overridden fragment
  offset and length.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
ad4f56b62d Re-import v0.13.0 router code
This adds the code from e1621765a4 back
into the tree unchanged, but moved into two new directories, in
preparation of the following commit, which adds a routing agent on this
basis, to make it possible to review the diff properly.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
379ad048e8 bundle_processor: Allow for directly calling FIB and dispatch functions
In agents performing such functions we do not need to add elements to
the queue if we can directly call the corresponding BP function.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
4021d07c27 agent_manager: Remove flexible array member from dispatch_result
It prevents us from declaring the array in a function body without
malloc() and also has a possible risk out-of-bounds accesses when not
used carefully.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
53c1df9252 Harmonize log levels in BP and AM
Everything related to single bundle transmissions only triggers DEBUG log
messages. Non-critical errors trigger warnings. State changes that
potentially affect many transmissions but are part of normal operation
trigger info messages.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:14 +02:00
Felix Walter
c2fef74ea9 bundle: Allow 64-bit bundle payload lengths
The bundle block length, fragment offset, and total ADU length fields
were using 32-bit uint types, effectively reducing the maximum bundle
payload size to 4 GiB. This changes the field types to 64-bit uint, so
we can support larger bundles.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-15 00:46:10 +02:00
Maximilian Nitsch
7e9b9b6dee cmdline: Reorder help text CLI arguments
Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-07-12 10:33:24 +02:00
Felix Walter
1a9e714993 bundle_processor: Enforce fragmentation to max. bundle size
If either the CLA to be used reports a maximum bundle size larger than
the anticipated serialized size of the bundle or a smaller global
maximum bundle size has been set on the command line, the bundle to be
sent must be fragmented before sending it to the next hop.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Felix Walter
c7d9d9c0f9 bundle_processor: Do not increment refcount for unsent fragments
Seems this was just an oversight in the implementation.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Felix Walter
bd9b92b823 bundle_processor: Enforce a maximum number of fragments
This ensures that internal counters do not overflow and we can prevent
DoS by BDM responses containing lots of next hops (e.g. in case of BDM
bugs) to some extent.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:03:31 +02:00
Felix Walter
9837055b5c init: Print max. bundle size limit to the console if set
Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:01:42 +02:00
Felix Walter
aa2ac9c024 cmdline: Allow 0 as valid value for MBS
We were previously reporting it as an error, although we now use it as
default value.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:01:03 +02:00
Felix Walter
6838078139 cla: Report 0 if the max. bundle size is unlimited
We now treat this value specifically and it is easier to handle in AAPv2
as Protobuf will not transmit fields that have been assigned their
default value (0 in this case).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:00:30 +02:00
Felix Walter
ee59a74443 aap2, cla, cmdline: Pass maximum bundle size to BDM
We should be able to honor the fragmentation threshold again. This
passes the maximum bundle size variable to the AAPv2 agent. The value is
determined as the minimum of all maximum bundle sizes reported by the
CLAs and the one specified on the command line, with the special case
of the value 0, which means a maximum bundle size of 2^64 ("unlimited").

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:00:30 +02:00
Felix Walter
b0f2f79e3c Revert "cmdline: Remove max-bundle-size argument"
This reverts commit 8249d0f6ff.

We will use this feature through a new field provided by AAP 2.0.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-07-04 16:00:26 +02:00
Felix Walter
13dc229c18
Merge branch 'hotfix/agent-null-registration-allows-all'
See !166
2024-06-26 13:33:55 +02:00
Felix Walter
5779598f32 CLA: RX: Drop EID spoofing detection
It is not necessary anymore to secure our configuration. Loops in DTNs
should be allowed and only be controlled through the bundle lifetime.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 13:32:28 +02:00
Felix Walter
7e810fa4c4 AAPv1: Set the BDM auth. flag if remote config is allowed
This keeps AAPv1 compatible for configuring our BDMs if we set the
additional flag.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 13:32:23 +02:00
Felix Walter
6df1fa7ae3 agent_manager: Allow more than one RPC BDM agent
For example, we want to allow aap2_config.py and a BDM to run
concurrently.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:31:41 +02:00
Felix Walter
2dcf3b35d9 aap2: Secure the control of the storage and BDMs through AAP 2.0
With the addition of the storage agent and the compat. BDM we have the
issue that two new agents accept configuration through bundles, which
cannot check that those bundles come from trustworthy sources. In the
past we restricted contact configuration messages to local clients and
performed an "EID spoofing detection" so that we could check the source
EID - if it is the same as the local node ID, we allowed the
configuration bundle to be processed. With AAPv2 and potentially more
security-relevant components (such as BDMs) appearing in the future, we
need a new mechanism.

The idea behind the implemented mechanism is to reuse the existing AAP
2.0 shared-secret authentication that is applied for BDMs themselves
also for sending configuration messages: We add the possibility to
register an AAP 2.0 RPC agent (one that sends commands *toward* uD3TN)
with the "dispatch" authorization flag. This client can then request a
special flag to be added when sending bundles. The new flag is only
added internally by uD3TN to its in-memory data structure and is
delivered to all internal agents as well as AAP 2.0 clients receiving
the marked bundles. Those agents and clients (such as the sqlite/storage
agent) can then easily check for the flag to be present and thus
determine whether the bundle comes from an authenticated and authorized
source.

Note: The `adu_flags` field for the BundleADU AAP 2.0 message is now a
`repeated` field to represent the option of multiple flags being present
(Protobuf does not support bit fields for this purpose).

Fixes: #187

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-26 10:23:17 +02:00
Felix Walter
2f17075ff3
Merge branch 'feature/sqlite-in-memory-db'
See !174
2024-06-26 10:04:30 +02:00
Maximilian Nitsch
ed6bdcbf96 SQLiteCLA: Support volatile in-memory database
Adds support for a volatile in-memory database by enabling support for
URI-based database file names. Since the in-memory DB can only be
accessed within the process, the integration tests are changed so that
external SQL queries are only performed when a persistent DB file is
used.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2024-06-26 09:28:45 +02:00
Felix Walter
3ae2f06c3a bundle_processor: Work with the original bundle on TX events
We do not want to deal with the complexity of recursive fragmentation
when potentially re-dispatching fragments. Additionally, we need to be
able to properly report forwarding success or failure as per BP. This is
achieved by tracking everything based on the original bundle and
associating created fragments with it.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:25:14 +02:00
Felix Walter
3fc93b6507 aap2: Pass the next-hop node ID and CLA address to the BDM
When transmission had been attempted and generated a "TX
success/failure" result, the BDM will need the information which
transmission is affected by the generated dispatch. Additionally, the
term "DispatchRequest" is imprecise, as uD3TN does not require the BDM
to dispatch the bundle in any case (it can do so, but especially after
TX success/failure, oftentimes, it is intended to just proceed with
normal bundle processing).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:25:12 +02:00
Felix Walter
512c8b9e19 bundle_processor: Log when re-dispatching a locally-fragmented bundle
This adds a flag to the bundle data structure indicating whether the
bundle is a fragment created in the current process. Based on that, a
log message is issued when re-dispatching such a bundle, as this may
be a BDM bug. We should evaluate whether or not to forbid this
altogether in the future.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:23:46 +02:00
Felix Walter
67715310c6 bundle: Remove unused field
This was never used in the new version of AAP 2.0 - we will decide
whether or not to dispatch externally based on a flag in the FIB in the
future.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-25 10:23:46 +02:00
Felix Walter
d238804c6a
Merge branch 'hotfix/bundle-serializer-result'
See !167
2024-06-25 10:20:59 +02:00
Felix Walter
79f7f5f5dc bundle_processor: Use HAS_FLAG macro for checking flag
This makes the code more readable. See !165.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-24 14:34:30 +02:00
Felix Walter
7b686802b9 cla: TX: Remove FIXME comment
We now take the result into account.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-24 14:31:54 +02:00
Felix Walter
2dcc1387eb bundle6/serializer: Replace flow control in macro with condition var
The previous version may lead to hard-to-spot issues later on.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-24 14:30:26 +02:00
Felix Walter
7b959e4cb8 aap2, FIB: Implement direct dispatch
This adds a "flags" field to the FIB link, allowing for configuring a
link for "direct dispatch", i.e., to make it usable without first
contacting a BDM. It is important to make this optional as otherwise
contact-based routing and QoS could not be implemented properly via a
BDM.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:39:59 +02:00
Felix Walter
1c383a1abb aap2: Remove LINK_STATUS_DETECTED
This value makes no sense as it does not represent a valid state of the
Link. A discovered Link is only added to the FIB in case it is really
active. We may make this an additional flag in the future but, for now,
it is not used and can be safely removed.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:39:59 +02:00
Felix Walter
ff2012ab68 agent_manager: Disallow concurrent reg. with empty secret
If an existing agent has set an empty secret, we now disallow the
registration of another agent under the same sink to make secure
operation the default.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:39:22 +02:00
Felix Walter
e8a319a277 TX: Allow the bundle serializers to indicate failure if CLA fails
If the write method of the CLA fails, the serailizers will now return
early and this failure is handled properly by the TX task.

In the case of the BPv6 serializer, we add the necessary flow control to
the `write_bytes` macro, to prevent needing a conditional for every
write* or serialize* statement.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 12:38:15 +02:00
Felix Walter
b04ecb36c9 hal_task: Only catch SIGINT in release builds
This otherwise prevents efficient debugging with GDB as GDB does not get
the signal anymore.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=9425

Closes: #197

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 11:16:07 +02:00
Felix Walter
4d98cd9265 init: Only terminate tasks if they were sarted beforehand
In the unit test runner we do not start the uD3TN tasks, but tried to
terminate them cleanly if we send a signal to the application.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 11:16:07 +02:00
Felix Walter
b07407112a sqlite: Remove destination EID from compund bundle ID
It is not part of the unique bundle identifier as per RFC 9171.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
8249d0f6ff cmdline: Remove max-bundle-size argument
We are not using it anymore. As the BDM decides on anything related to
fragmentation, the parameter perspectively needs to be passed there,
either directly or through the mechanism we use for the minimum bundle
size (the `BundleDispatchInfo` message as part of the `DispatchRequest`
message).

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
2ef7e9f398 bundle_processor: Properly handle already-fragmented bundles in dispatch
If we receive a dispatch result for an already-fragmented bundle that is
to be fragmented further, we need to calculate the offset inside the
bundle as it is expected by the bundle fragmenter in this way.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
4c5a8ec47b BP: Do not treat empty dispatch result after TX success event as failure
On TX success, we issue a dispatch request, which typically receives an
empty result (-> ok; bundle can be dropped). This was treated as a
transmission failure, which it clearly is not.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00
Felix Walter
4db66daccc Static analysis: Fix reported false-positive memory leak
cpppcheck as well as clang-analyzer report a memory leak as they cannot
infer that the pointers are pushed through the queue to a consumer
free()ing them.

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
2024-06-21 10:36:30 +02:00