Skip to content

Conversation

@t3hk0d3
Copy link

@t3hk0d3 t3hk0d3 commented Jan 19, 2026

This PR adds option to override interface used for backbone network.

Currently it always uses primary interface, and that's really inconvenient with multi-VLAN setup.

For example i prefer to have my IoT devices to be isolated in a separate network with strict firewall policies enforced on router.

Summary by CodeRabbit

  • New Features
    • Added a configurable backbone network interface option with automatic multi-stage fallback (configured → supervisor primary → first available system interface).
  • Documentation
    • Added a translation entry describing the new backbone interface setting and behavior.
  • Bug Fixes / Reliability
    • Improved logging and error handling during interface resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Adds an optional backbone_interface configuration field, updates runtime resolution to prefer that value with supervisor and system fallbacks for selecting the interface, and adds a corresponding translation entry.

Changes

Cohort / File(s) Summary
Configuration Schema
openthread_border_router/config.yaml
Added optional backbone_interface: str? to the public configuration schema.
Runtime Logic / Init Script
openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run
Implemented multi-stage interface resolution: use config backbone_interface; if empty, query supervisor for primary interface; if supervisor unavailable or empty, choose first enabled interface from ip -br link show up; exit with error if none found. Added logging for chosen fallbacks.
Translations
openthread_border_router/translations/en.yaml
Added configuration.backbone_interface entry with name and multi-line description explaining the interface setting and fallback behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Agent as otbr-agent
    participant Config as Configuration
    participant Supervisor as Supervisor API
    participant System as System

    Agent->>Config: Read backbone_interface
    alt configured
        Config-->>Agent: Return configured interface
        Agent->>Agent: Use configured interface
    else not configured
        Agent->>Supervisor: Query primary interface
        alt supervisor responds
            Supervisor-->>Agent: Return primary interface
            Agent->>Agent: Log and use primary interface
        else supervisor unavailable
            Agent->>System: Run `ip -br link show up`
            alt enabled interfaces found
                System-->>Agent: Return first enabled interface
                Agent->>Agent: Log and use fallback interface
            else none found
                Agent->>Agent: Exit with error
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature being added: the ability to configure which network interface is used for the backbone, matching the core objective of making the backbone interface configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run`:
- Around line 81-88: The fallback selection for backbone_if in the run script
incorrectly assumes loopback is always first (it uses awk 'NR==2'); update the
block that sets backbone_if to pick the first non-loopback interface instead
(e.g. pipe ip -br link show up through a filter to exclude "lo" and take the
first match) so backbone_if="$(ip -br link show up | awk '$1 != "lo" {print $1;
exit}')" (or equivalent grep -v/awk combo); change the code that assigns
backbone_if and keep the existing error and log handling (references:
backbone_if variable and the fallback block in the run script).

In `@openthread_border_router/translations/en.yaml`:
- Around line 13-17: The description for backbone_interface is awkwardly
phrased; update the sentence "If not specified it would fallback to the primary
interface." to present tense with a comma and correct spacing: change it to "If
not specified, it falls back to the primary interface." Ensure the
backbone_interface.description entry is edited accordingly (use "falls back" as
two words and insert the comma after "specified").
🧹 Nitpick comments (1)
openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run (1)

26-79: Verify optional backbone_interface handling when unset.
If bashio::config returns null for missing keys, Line 26 sets backbone_if to null, so Line 76 won’t trigger fallback and otbr-agent will be passed an invalid interface. Guard with bashio::config.has_value and quote the -z check.

🛠️ Suggested update
-backbone_if=$(bashio::config 'backbone_interface')
+backbone_if=""
+if bashio::config.has_value 'backbone_interface'; then
+    backbone_if="$(bashio::config 'backbone_interface')"
+fi
@@
-if [ -z ${backbone_if} ]; then
+if [ -z "${backbone_if}" ]; then

@t3hk0d3 t3hk0d3 force-pushed the otbr_backbone_if_config branch from 3e11dea to bbc924a Compare January 19, 2026 12:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run`:
- Around line 76-79: Quote the variable test and only log the "using primary
interface" message when the supervisor API actually returned a value: change the
conditional to test [ -z "${backbone_if}" ] and call bashio::api.supervisor to
populate backbone_if before emitting a warning; if backbone_if is non-empty log
the existing warning via bashio::log.warning referencing the resolved
backbone_if, otherwise log a different error/warning that the supervisor
returned no interface. Ensure references to backbone_if, bashio::api.supervisor
and bashio::log.warning are updated accordingly.

@t3hk0d3 t3hk0d3 force-pushed the otbr_backbone_if_config branch from bbc924a to 6672f62 Compare January 19, 2026 12:45
@GollyJer
Copy link

would love to have this ability.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Jan 30, 2026

@agners Do you think a more sophisticated fallback for default network interface would be necessary? Previously it was just hardcoded "eth0" (that no longer in use with modern systemd/Linux kernels).

Current behaviour is to pick first interface if primary interface is not available from Supervisor API.
Maybe more correct behaviour would to give an fatal error instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants