Skip to content

Conversation

@olerem
Copy link
Contributor

@olerem olerem commented Jan 13, 2026

Hi folks,

I recently had a relatively long vacation and felt inspired to work on some tests for can-utils.

The implementation isn't finished yet, but the tests are already usable. I'm not sure how long it will take until I'm fully "repowered" to finish the work, but a code review might give me the necessary push :)

Requirement: All tests need at least vcan0. This means they effectively test the kernel stack as a side effect.

Feel free to give it a try!

olerem added 5 commits January 2, 2026 15:55
Previously, the `canlogserver` could get stuck in infinite loops when
receiving a signal (e.g., SIGINT via Ctrl-C) in two scenarios:

1. Inside the `bind()` retry loop: If the port was busy (e.g., in
   TIME_WAIT), the loop retried indefinitely using `nanosleep` without
   checking the `running` flag set by the signal handler.

2. Inside the `accept()` loop: The loop was unconditional (`while(1)`).
   If `accept()` was interrupted by a signal, it returned with `EINTR`,
   but the loop immediately restarted, effectively ignoring the shutdown
   request.

This patch adds checks for the `running` flag in both loops to ensure
the server terminates correctly upon receiving a signal. It also ensures
the socket is closed properly and the correct exit code (128 + signal
number) is returned.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Stop using -EINTR for cmd_exit(). Introduce ISOBUSFS_CLI_RET_EXIT and
map it to exit code 0 in main(), keeping errno values for real errors.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
According to ISO 11783-13:2021 (sections C.3.4.2 and C.3.5.2), directory
operations differ significantly from standard file operations:
- The `Count` parameter in a "Read File" request represents the number of
  directory entries to read, not the number of bytes.
- The `Offset` parameter in a "Seek File" request represents the logical
  entry index, not a byte offset.

Previously, the implementation treated directories strictly as files,
using byte-based offsets and counts. This resulted in incorrect seeking
behavior and protocol violations when listing directories.

This patch aligns the implementation with the standard by:

1. Server side:
   - Introducing `isobusfs_srv_dir_entry_visible()` to consistently
     filter out invalid (unreadable, hidden, oversized) entries. This
     ensures that entry indices remain stable.
   - Implementing `isobusfs_srv_dir_skip_entries()` to advance the
     directory stream by logical visible entries rather than bytes.
   - Updating the "Read File" handler to interpret `count` as the
     maximum number of entries and return the number of entries read
     in the response header.
   - Updating the "Seek File" handler to seek by entry index.

2. Client side:
   - Calculating the request count based on the number of minimal-size
     entries that fit into the maximum data length.
   - Interpreting the response `count` as the number of entries received
     rather than the byte length of the payload.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant