Skip to content

RDKEMW-21582: Network connection recovery script should handle IPv4-only/IPv6-only networks - #578

Closed
tukken-comcast wants to merge 7 commits into
support/4.2.1from
feature/xsb_wifidrops_8.4
Closed

RDKEMW-21582: Network connection recovery script should handle IPv4-only/IPv6-only networks#578
tukken-comcast wants to merge 7 commits into
support/4.2.1from
feature/xsb_wifidrops_8.4

Conversation

@tukken-comcast

Copy link
Copy Markdown
Contributor

Reason for change: fix network connection recovery script
Test Procedure: See ticket
Priority: P1
Risk: Medium

Balaji Punnuru and others added 7 commits June 28, 2026 23:45
…or ipv6.

Signed-off-by: Balaji Punnuru <Balaji_Punnuru@comcast.com>
Signed-off-by: Balaji Punnuru <Balaji_Punnuru@comcast.com>
…covery trigger

Recovery now fires only when no routed IP stack has acceptable
connectivity and at least one routed stack is at/above the reassociate
tolerance. This fixes the IPv4-only / IPv6-only case where a stack with
no default route left packetsLost at 0 and suppressed recovery.

Also folded in reliability/logging fixes:
- clear stale gwIp on the V6 test-hook path
- guard packet-loss comparisons against unparseable ping output
- emit SYST_WARN_GW100PERC_PACKETLOSS to the logs file on every run
- ping the IPv4 default-route interface explicitly (ping -I)
- log total ipv4/ipv6 packet loss when above threshold
- simplify the trigger to anyGood/anyBad classification
… packet-loss fix

- Introduce a log() helper that prepends the timestamp and appends to
  $logsFile, and convert the timestamped echo call sites to use it.
- Rename packetsLostipv4/packetsLostipv6 globals to
  ipv4PacketLoss/ipv6PacketLoss for clarity.
- Reset the per-call packetLoss to "" at the top of checkPacketLoss and
  guard the packet-loss telemetry block with [ -n "$packetLoss" ], so a
  routeless or unparseable ping no longer reuses the other family's value
  or triggers integer-comparison errors.
- Fix a "[" spacing bug in checkWifiDrvErrors.

Telemetry markers and t2CountNotify calls are unchanged.
…ate change

Emit a "network state changed" line with the per-stack route-present flags
and packet-loss values only when the snapshot differs from the previous run
(persisted in /tmp/.ncr_laststate), so field logs capture every transition
without printing on every run. Debugging aid for customer-site triage.
- Drop the temporary DEBUG_NCR field-debug logging; retain the
  "network state changed" transition log (now unprefixed).
- checkWifiDrvErrors(): $dir already holds the full debugfs path, so remove
  the duplicated /sys/kernel/debug/ieee80211/ prefix from the log messages,
  and capture the cat exit status so the failure log reports the real status
  instead of the enclosing test's result.
- Replace bashisms with POSIX/busybox-ash equivalents: source -> .,
  [[ =~ ]] -> case, [[ ]] -> [ ], and {1..9} -> explicit list (the brace
  form never expands under busybox ash, which had left the
  WIFIV_WARN_PL_20..90PERC packet-loss markers non-functional on target).
- Minor whitespace cleanup in checkDnsFile().
Reinstate the field-triage log marker for 100% packet loss that was lost
when checkPacketLoss() moved to a tolerance-based recovery decision. The
new log-only marker "100% Packet loss is observed on all routed IP stacks"
fires when every routed IP stack shows exactly 100% loss. It is independent
of WifiReassociateTolerance and does not alter the recovery/return path, so
recovery behaviour is unchanged. Unlike the legacy dual-stack
"...for both ipv4 and ipv6" print, it is also emitted correctly on
IPv4-only and IPv6-only networks. Triage associates the old and new strings
to the same 100%-packet-loss marker for trend continuity across images.

Also capitalise the "Packet loss more than 10% observed" marker (was
lowercase "packet loss ...") since triage marker matching is case-sensitive.
Copilot AI review requested due to automatic review settings July 24, 2026 12:32
@tukken-comcast
tukken-comcast requested a review from a team as a code owner July 24, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the RDK network connection recovery script to make packet-loss-based recovery decisions work correctly on IPv4-only, IPv6-only, and dual-stack networks, while reducing log duplication by centralizing timestamped logging.

Changes:

  • Adds a log() helper and refactors many log writes to use it consistently.
  • Reworks checkPacketLoss() to track IPv4/IPv6 route presence + packet loss separately and decide recovery based on routed stacks.
  • Adds state-change logging (via a persisted “last state” file) and adjusts gateway packet-loss telemetry behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +66 to +69
log()
{
echo "$(/bin/timestamp) $*" >> "$logsFile"
}
Comment on lines 229 to +233
if [ "$version" = "V4" ] ; then
gwIp=$(cat /tmp/checkpacketloss)
pingCmd="ping"
else
gwIp=""
Comment on lines 266 to +270
if [ "$(($GatewayLogTimeStamp+$GatewayLoggingInterval))" -le "$currentTime" ] ; then
echo "$(/bin/timestamp) $version gateway = $gwIp " >> "$logsFile"
if [ "$ret" = "100" ] ; then
echo "$(/bin/timestamp) TELEMETRY_GATEWAY_RESPONSE_TIME:NR,$gwIp" >> "$logsFile"
echo "$(/bin/timestamp) Current Packet loss is SYST_WARN_GW100PERC_PACKETLOSS"
t2CountNotify "SYST_WARN_GW100PERC_PACKETLOSS"
if [ "$packetLoss" = "100" ] ; then
log "TELEMETRY_GATEWAY_RESPONSE_TIME:NR,$gwIp"
else
echo "$(/bin/timestamp) TELEMETRY_GATEWAY_RESPONSE_TIME:$gwResponseTime,$gwIp" >> "$logsFile"
log "TELEMETRY_GATEWAY_RESPONSE_TIME:$gwResponseTime,$gwIp"
@tukken-comcast

Copy link
Copy Markdown
Contributor Author

Closing this PR because base branch needs to change to support/4.2.1_release. Opened #581 for that.

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants