dtn7 / dtn7-rs

Rust implementation of a DTN based on RFC 9171
Other
81 stars 20 forks source link

Sporadic panic on startup: InvalidUrlFormat in nodeid #51

Closed felix-walter closed 11 months ago

felix-walter commented 11 months ago

Hi! We just stumbled over an issue with starting DTN7 while building an interoperability test against µD3TN: Starting DTN7 randomly fails [1,2] with:

thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/dtn7-0.19.0/src/dtnconfig.rs:88:49:
called `Result::unwrap()` on an `Err` value: InvalidUrlFormat
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We are starting dtnd via: dtnd --nodeid "node1" --routing "epidemic" --cla "mtcp" --endpoint "incoming" --config "/DTN7/config/example_config.toml" with the config file /DTN7/config/example_config.toml being:

[statics]
peers = ["mtcp://127.0.0.1:4224/bundlesink"]

We tried to track down the issue and are suspecting the following:

  1. main calls DtnConfig::from
  2. as the config file does not contain a node ID (it will be replaced only later by main using the commandline argument), from sets nodeid to the result of rnd_node_name()
  3. the result can be any combination of alphanumeric characters, including strings starting with a number
  4. is_valid_node_name returns false if the first character is a number because chars.next().unwrap().is_alphabetic() is false
  5. the else branch is triggered and nodeid.try_into().unwrap() fails as documented above

[1] Successful job: https://gitlab.com/d3tn/ud3tn/-/jobs/5586386733 [2] Failed job: https://gitlab.com/d3tn/ud3tn/-/jobs/5585311869

gh0st42 commented 11 months ago

Thanks for finding this issue and the detailed error report! The issue should be fixed in the most recent commit (https://github.com/dtn7/dtn7-rs/commit/f6b0e9152b88d041dc1b84c379fe26b9ffc59ef4)

If the issue persists please reopen the ticket.

I'm also very interested in the results of your interop tests :)

felix-walter commented 11 months ago

Thank you for the quick fix!

Regarding the interop tests, all in all, it works very well - we can exchange BPv7 bundles via MTCP, independently of whether we create the bundles in DTN7 or uD3TN.