Skip to content

CAN interface support#1858

Open
hundeboll wants to merge 6 commits into
labgrid-project:masterfrom
hundeboll:can-netns
Open

CAN interface support#1858
hundeboll wants to merge 6 commits into
labgrid-project:masterfrom
hundeboll:can-netns

Conversation

@hundeboll

@hundeboll hundeboll commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Description

Add a driver for CAN interfaces. Local CAN interfaces are "just" opened. Remote (exporter) interfaces are piped through SSH similar to the recently added raw network interface pipe support.

The driver has been tested both on a local CAN interface (with and without privileges), and on a remote/exported CAN interface.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • Add a section on how to use the feature to doc/usage.rst
  • Add a section on how to use the feature to doc/development.rst
  • PR has been tested
  • Man pages have been regenerated

Fixes #1289

Replaces #1719

Add a new "canpipe" verb to the ``labgrid-raw-interface`` helper script,
that configures a can interface according to its arguments, opens and
binds a raw can socket to the interface, and starts the
``labgrid-tap-fwd`` script to pipe frames between the interface and
stdin/stdout.

This allows a client to create a corresponding pipe on its own end to
pipe the frames to/from a local virtual can interface.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
To be able to pipe CAN frames to/from a remote agent, the network
namespace agent should support creating a virtual CAN interface. This
allows creating the pipe unprivileged, which is a prerequisite for
testing remote CAN interfaces with labgrid.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
@hundeboll hundeboll force-pushed the can-netns branch 2 times, most recently from 589a334 to 7a736c1 Compare April 29, 2026 13:56
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.04545% with 102 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.9%. Comparing base (c246fab) to head (06fe47b).
⚠️ Report is 30 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/caninterfacedriver.py 43.9% 93 Missing ⚠️
labgrid/util/agents/netns.py 0.0% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1858     +/-   ##
========================================
+ Coverage    45.8%   45.9%   +0.1%     
========================================
  Files         182     181      -1     
  Lines       14718   14639     -79     
========================================
- Hits         6743    6728     -15     
+ Misses       7975    7911     -64     
Flag Coverage Δ
3.10 45.9% <42.0%> (+0.1%) ⬆️
3.11 45.9% <42.0%> (+0.1%) ⬆️
3.12 45.9% <42.0%> (+0.1%) ⬆️
3.13 45.9% <42.0%> (+0.1%) ⬆️
3.14 45.9% <42.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@hundeboll hundeboll force-pushed the can-netns branch 6 times, most recently from 566427c to 5520c11 Compare May 4, 2026 07:27
@hundeboll

Copy link
Copy Markdown
Contributor Author

Let me know if there's anything I can do to get this moving.

@hundeboll

hundeboll commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@Emantor @jluebbe Can you share some thoughts on the timeline for this?

hundeboll added 4 commits June 7, 2026 12:41
Add a driver that utilizes the CAN pipe support added in the previous
commits.

The driver is primarily intended to used to send and receive frames
through its ``recv()`` and ``send()`` methods, but it also provides
CAN interface access to "external" programs using the
``namespace_prefix`` property.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
Since the unshare method doesn't create a mount namespace, the nsenter
method shouldn't try to enter a mount namespace.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Martin Hundebøll <martin@geanix.com>
The tests require the `vcan` kernel module to be available, and a
`vcan0` module must ve created manually before running the tests.

The `vcan` kernel module is not available in the Github Runner (azure)
images, but a request has been submitted to enable it in the Azure
kernel packages:
actions/runner-images#13991

Signed-off-by: Martin Hundebøll <martin@geanix.com>
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.

Add remote CAN resource

1 participant