-
Notifications
You must be signed in to change notification settings - Fork 375
T7492: Fix modem connection code #4527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
Conversation
Added another possible condition to the flow through the config apply function so that interfaces will reconnect as expected, even when there has been no significant change to the contig tags.
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures WWAN interfaces will reconnect via mmcli
even when no configuration tags have changed by adding a connectivity check to existing shutdown logic.
- Imported
is_wwan_connected
and extended both shutdown checks to trigger reconnect when the interface is currently disconnected. - No other functional changes besides updating the two
if
conditions inapply
.
Comments suppressed due to low confidence (1)
src/conf_mode/interfaces_wwan.py:141
- [nitpick] This new branch for disconnected interfaces should be covered by a unit or integration test to ensure future changes don’t break the reconnect flow when
is_wwan_connected
returns false.
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])):
@@ -137,7 +138,7 @@ def apply(wwan): | |||
break | |||
sleep(0.250) | |||
|
|||
if 'shutdown_required' in wwan: | |||
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The same compound condition is repeated later in the file (line 163). Consider extracting shutdown_required
or disconnected logic into a descriptive boolean variable (e.g. reconnect_required
) to reduce duplication and improve readability.
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): | |
reconnect_required = 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])) | |
if reconnect_required: |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures WWAN interfaces reconnect correctly by adding a check for actual modem connectivity in the apply flow.
- Imported
is_wwan_connected
and use it to trigger modem reconnect when the interface is down. - Expanded two
if 'shutdown_required'
conditions to also fire when the interface is not connected.
Comments suppressed due to low confidence (1)
src/conf_mode/interfaces_wwan.py:163
- This new branch that reconnects when the interface is not already connected isn't covered by existing tests. Add unit or integration tests to verify the
is_wwan_connected
fallback behavior.
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])):
@@ -137,7 +138,7 @@ def apply(wwan): | |||
break | |||
sleep(0.250) | |||
|
|||
if 'shutdown_required' in wwan: | |||
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The compound condition ('shutdown_required' in wwan or not is_wwan_connected(...))
is duplicated. Consider extracting it into a descriptive variable (e.g., needs_modem_connect
) to DRY up the code and improve readability.
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): | |
needs_modem_connect = 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])) | |
if needs_modem_connect: |
Copilot uses AI. Check for mistakes.
@@ -137,7 +138,7 @@ def apply(wwan): | |||
break | |||
sleep(0.250) | |||
|
|||
if 'shutdown_required' in wwan: | |||
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The call to is_wwan_connected
is made twice in this function. Consider calling it once, storing the result in a variable, and reusing it to avoid potential overhead or redundant checks.
if 'shutdown_required' in wwan or (not is_wwan_connected(wwan['ifname'])): | |
is_connected = is_wwan_connected(wwan['ifname']) | |
if 'shutdown_required' in wwan or (not is_connected): |
Copilot uses AI. Check for mistakes.
CI integration ❌ failed! Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extend logic to reconnect modem if required during config change if it "hung up" in the meantime.
Change summary
Added another possible condition to the flow through the config apply function so that interfaces will reconnect as expected, even when there has been no significant change to the contig tags.
Types of changes
Related Task(s)
https://vyos.dev/T7492
Related PR(s)
N/A
How to test / Smoketest result
This change was tested on out testbed in our lab. This system is virtualised with a Sierra Wireless EM7421 LTE Modem passed through to the guest. The system was spun up and confirmed working, then the connect and disconnect methods were used as below:-
Previous broken behaviour: command would silently fail and not connect modem
New correct behaviour: If disconnected, the script wil attempt to connect the modem using mmcli
Checklist: