RDKEMW-21714: Network connection recovery script should handle IPv4-only/IPv6-only networks - #580
Merged
Merged
Conversation
…led. 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.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the RDK network connection recovery script to make packet-loss based recovery decisions correctly on IPv4-only, IPv6-only, and dual-stack networks, while reducing log duplication and improving observability of network state transitions.
Changes:
- Adds per-stack (IPv4/IPv6) gateway presence + packet loss tracking and updates recovery logic to avoid tearing down L2 when any routed stack is healthy.
- Adds a
log()helper and uses it for consistent timestamped logging; adds state-change logging via a persisted/tmp/.ncr_laststate. - Adjusts gateway pinging to bind to the default-route interface and emits 100% gateway-loss telemetry every run (independent of the gateway logging interval).
Comments suppressed due to low confidence (1)
lib/rdk/networkConnectionRecovery.sh:243
- IPv6 default-route parsing has the same fixed-field assumption (
$3/$5) as IPv4. If theip -6 routeoutput format differs or lacksvia,gwIpcan become a non-address token and the ping will never produce a parseable packet-loss value. Parsevia/devexplicitly and avoid callingping6 -Iwith an empty interface.
gwIp=$(/sbin/ip -6 route | awk '/default/ { print $3 }' | head -n1 | awk '{print $1;}')
gwIp_interface=$(/sbin/ip -6 route | awk '/default/ { print $5 }' | head -n1 | awk '{print $1;}')
pingCmd="ping6 -I $gwIp_interface"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
237
to
+239
| gwIp=$(/sbin/ip -4 route | awk '/default/ { print $3 }' | head -n1 | awk '{print $1;}') | ||
| pingCmd="ping" | ||
| gwIp_interface=$(/sbin/ip -4 route | awk '/default/ { print $5 }' | head -n1 | awk '{print $1;}') | ||
| pingCmd="ping -I $gwIp_interface" |
nhanasi
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reason for change: fix network connection recovery script
Test Procedure: See ticket
Priority: P1
Risk: Medium