Skip to content

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

Open
wants to merge 1 commit into
base: current
Choose a base branch
from

Conversation

cblackburn-igl
Copy link

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

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:-

disconnect interface wwan0
connect interface wwan0

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:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • [N/A - No smoketests availible] I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • [N/A - No Change to user observed behaviour] My change requires a change to the documentation
  • [N/A] I have updated the documentation accordingly

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.
Copy link

👍
No issues in PR Title / Commit Title

Copy link

@Copilot Copilot AI left a 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 in apply.
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'])):
Copy link
Preview

Copilot AI May 27, 2025

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.

Suggested change
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.

@sever-sever sever-sever requested a review from Copilot May 27, 2025 19:53
Copy link

@Copilot Copilot AI left a 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'])):
Copy link
Preview

Copilot AI May 27, 2025

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.

Suggested change
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'])):
Copy link
Preview

Copilot AI May 27, 2025

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.

Suggested change
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.

Copy link

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) 👍 passed
  • CLI Smoketests (interfaces only) ❌ failed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

@c-po c-po self-requested a review May 29, 2025 12:36
@c-po c-po added the bp/circinus Create automatic backport for circinus label May 29, 2025
Copy link
Member

@c-po c-po left a 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.

@c-po c-po added the bp/sagitta Create automatic backport for sagitta LTS version label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bp/circinus Create automatic backport for circinus bp/sagitta Create automatic backport for sagitta LTS version current
Development

Successfully merging this pull request may close these issues.

2 participants