Skip to content

[fix] Change openwrt list_identifiers to not merge vlan interfaces - #413

Closed
pascal260303 wants to merge 2 commits into
openwisp:masterfrom
pascal260303:master
Closed

pascal260303 wants to merge 2 commits into
openwisp:masterfrom
pascal260303:master

Conversation

@pascal260303

Copy link
Copy Markdown

Checklist

Reference to Existing Issue

Closes #412 .

Description of Changes

Change the order and content of list_identifiers to prevent merging of different vlan interfaces which share the same trunk port, therefore the same name.

Added a test which merges two templates with 8021q interface definitions using the Openwrt backend which previously resulted in only one interface staying but now both stay.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 04b631c5-821b-472e-8379-216c95ab72da

📥 Commits

Reviewing files that changed from the base of the PR and between caf6a74 and 51522f0.

📒 Files selected for processing (1)
  • tests/openwrt/test_backend.py

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Python==3.12
  • GitHub Check: Python==3.13
  • GitHub Check: Python==3.10
  • GitHub Check: Python==3.11
🧰 Additional context used
📓 Path-based instructions (2)
Ensure tests cover relevant success, error, boundary, and unusual input scenarios.

⚙️ CodeRabbit configuration file

Files:

  • tests/openwrt/test_backend.py
Flag potential security vulnerabilities Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries Flag unused or redundant code Flag outdated or incorrect comments/docstrings Ensure new code handles err...

⚙️ CodeRabbit configuration file

Files:

  • tests/openwrt/test_backend.py
🔇 Additional comments (1)
tests/openwrt/test_backend.py (1)

271-311: LGTM!


📝 Walkthrough

Walkthrough

The OpenWrt backend now matches list entries using config_value, id, network, and name, in that order. This keeps VLAN interfaces with the same physical interface name separate when their network values differ. The documentation describes the matching order. A regression test verifies that both VLAN templates remain distinct and retain template order.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required [fix] prefix and clearly describes the OpenWrt identifier change that prevents VLAN interface merging.
Description check ✅ Passed The description includes the checklist, issue reference, change summary, and test details. It omits a screenshot, but no relevant screenshot is required for this change.
Linked Issues check ✅ Passed The change satisfies #412. OpenWrt.list_identifiers now checks network before the shared trunk name, so VLAN interfaces with the same trunk name and different networks remain separate during tem…
Out of Scope Changes check ✅ Passed The changes remain within #412. The identifier update implements the VLAN merge fix. The test covers the reported regression. The documentation explains the matching behavior. No unrelated functional …
Ui Changes, Regression Test, Docs ✅ Passed The PR does not change an end-user-facing UI. The authoritative diff contains only OpenWrt backend code, a regression test, and documentation, so screenshots or recordings are not required. The new `t…

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

@pascal260303 pascal260303 changed the title Fix openwrt list_identifiers to not merge vlan interfaces [fix] Change openwrt list_identifiers to not merge vlan interfaces Sep 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pre-merge checks failed. Please resolve the failing checks before merging.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 99.152%. remained the same — pascal260303:master into openwisp:master

parser = OpenWrtParser
renderer = OpenWrtRenderer
list_identifiers = ["name", "config_value", "id"]
list_identifiers = ["config_value", "id", "network", "name"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a delicate part of the code, changing this can easily have negative consequences on many OpenWISP deployments: after this patch, users could see their configurations change, because a different element may match (see my next comment for a more detailed explanation).

The identifiers for VLAN interfaces seem to be a special case, therefore I think we need to be able to pass different list identifiers for these special cases, I prepared a patch based on this concept, see #414.
Please try it when you can.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh you're right.
I will try it tomorrow

parser = OpenWrtParser
renderer = OpenWrtRenderer
list_identifiers = ["name", "config_value", "id"]
list_identifiers = ["config_value", "id", "network", "name"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This valid VLAN configuration still fails:

template1 = {
    "interfaces": [
        {"type": "8021q", "name": "eth0", "vid": 10}
    ]
}

template2 = {
    "interfaces": [
        {"type": "8021q", "name": "eth0", "vid": 20}
    ]
}

The code checks config_value, id, network, then name.

Neither VLAN has config_value, id, or network, so both use:

"name": "eth0"

They are merged, and VLAN 10 is lost.

It also introduces this unrelated regression:

template = {
    "interfaces": [
        {"type": "ethernet", "name": "eth0", "network": "lan", "mtu": 1500}
    ]
}

config = {
    "interfaces": [
        {"type": "ethernet", "name": "eth0", "network": "wan", "autostart": True}
    ]
}

Previously these merged by name, allowing the device configuration to override its logical network. This change treats lan and wan as separate identities and produces two interfaces for eth0.

@pascal260303

Copy link
Copy Markdown
Author

I tested #414 and it works and is obviously a better solution than what i did here.
So I'm closing this PR

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.

[bug] merge_list call drops vlan interfaces

3 participants