Skip to content

Conversation

@bpunnuru
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings December 19, 2025 19:27
@bpunnuru bpunnuru requested a review from a team as a code owner December 19, 2025 19:27
Copy link

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 refactors network script functionality by inlining code from updateGlobalIPInfo.sh directly into the dispatcher scripts, eliminating external script invocations and improving script organization.

Key Changes

  • Refactored updateGlobalIPInfo.sh functionality into inline functions within NM_preDown.sh and NM_Dispatcher.sh
  • Replaced external script calls with direct function invocations for better performance
  • Added helper functions refresh_devicedetails(), check_valid_IPaddress(), and update_global_ip_info_{add,delete}() to both scripts

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.

File Description
lib/rdk/NM_preDown.sh Added three helper functions and replaced external updateGlobalIPInfo.sh calls with inline update_global_ip_info_delete() function for handling IP address deletion
lib/rdk/NM_Dispatcher.sh Added three helper functions and replaced external updateGlobalIPInfo.sh calls with inline update_global_ip_info_add() function for handling IP address addition

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


NMdispatcherLog "update_global_ip_info: cmd:$cmd, mode:$mode, ifc:$ifc, addr:$addr, flags:$flags"

if [ "x$cmd" == "xadd" ] && [ "x$flags" == "xglobal" ]; then
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Use single brackets '[' with '=' instead of double brackets '[[' with '==' for POSIX compliance in shell scripts. The current syntax is bash-specific, but the shebang indicates a generic sh interpreter.

Copilot uses AI. Check for mistakes.
return 1
fi
elif [ "x$mode" == "xipv4" ]; then
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The variable 'autoIPTrunc' is not declared as local, which could lead to variable leakage in the shell environment. Declare it with 'local' to keep it scoped to this function.

Suggested change
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
local autoIPTrunc=$(echo $addr | cut -d "." -f1-2)

Copilot uses AI. Check for mistakes.
return 1
fi
elif [ "x$mode" == "xipv4" ]; then
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The variable 'autoIPTrunc' is not declared as local, which could lead to variable leakage in the shell environment. Declare it with 'local' to keep it scoped to this function.

Suggested change
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
local autoIPTrunc=$(echo $addr | cut -d "." -f1-2)

Copilot uses AI. Check for mistakes.

NMdispatcherLog "update_global_ip_info: cmd:$cmd, mode:$mode, ifc:$ifc, addr:$addr, flags:$flags"

if [ "x$cmd" == "xdelete" ] && [ "x$flags" == "xglobal" ]; then
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Use single brackets '[' with '=' instead of double brackets '[[' with '==' for POSIX compliance in shell scripts. The current syntax is bash-specific, but the shebang indicates a generic sh interpreter.

Copilot uses AI. Check for mistakes.
if [[ $addr == fc* || $addr == fd* ]]; then
return 1
fi
elif [ "x$mode" == "xipv4" ]; then
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Use single brackets '[' with '=' instead of double brackets '[[' with '==' for POSIX compliance in shell scripts. The current syntax is bash-specific, but the shebang indicates a generic sh interpreter.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +100
if [[ "$ifc" == "$ESTB_INTERFACE" || "$ifc" == "$DEFAULT_ESTB_INTERFACE" || "$ifc" == "$ESTB_INTERFACE:0" ]]; then
NMdispatcherLog "Updating Box/ESTB IP"
echo "$addr" > /tmp/.$mode$ESTB_INTERFACE
refresh_devicedetails "estb_ip"
elif [[ "$ifc" == "$MOCA_INTERFACE" || "$ifc" == "$MOCA_INTERFACE:0" ]]; then
NMdispatcherLog "Updating MoCA IP"
echo "$addr" > /tmp/.$mode$MOCA_INTERFACE
refresh_devicedetails "moca_ip"
elif [[ "$ifc" == "$WIFI_INTERFACE" || "$ifc" == "$WIFI_INTERFACE:0" ]]; then
NMdispatcherLog "Updating Wi-Fi IP"
echo "$addr" > /tmp/.$mode$WIFI_INTERFACE
refresh_devicedetails "boxIP"
fi
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Use single brackets '[' with '=' instead of double brackets '[[' with '==' for POSIX compliance in shell scripts. The pattern matching in these conditions should use 'case' statements or be refactored to use single brackets with proper quoting.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 68
refresh_devicedetails()
{
#Refresh device cache info
if [ -f /lib/rdk/getDeviceDetails.sh ]; then
sh /lib/rdk/getDeviceDetails.sh refresh $1
else
NMdispatcherLog "DeviceDetails file not present"
fi
}

check_valid_IPaddress()
{
local mode=$1
local addr=$2
# Neglect IPV6 ULA address and autoconfigured IPV4 address
if [ "x$mode" == "xipv6" ]; then
if [[ $addr == fc* || $addr == fd* ]]; then
return 1
fi
elif [ "x$mode" == "xipv4" ]; then
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
if [ "$autoIPTrunc" == "169.254" ]; then
return 1
fi
fi
return 0
}
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The code is duplicated between NM_preDown.sh and NM_Dispatcher.sh. Consider creating a shared library file that both scripts can source to avoid code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +71
refresh_devicedetails()
{
#Refresh device cache info
if [ -f /lib/rdk/getDeviceDetails.sh ]; then
sh /lib/rdk/getDeviceDetails.sh refresh $1
else
NMdispatcherLog "DeviceDetails file not present"
fi
}

check_valid_IPaddress()
{
local mode=$1
local addr=$2
# Neglect IPV6 ULA address and autoconfigured IPV4 address
if [ "x$mode" == "xipv6" ]; then
if [[ $addr == fc* || $addr == fd* ]]; then
return 1
fi
elif [ "x$mode" == "xipv4" ]; then
autoIPTrunc=$(echo $addr | cut -d "." -f1-2)
if [ "$autoIPTrunc" == "169.254" ]; then
return 1
fi
fi
return 0
}
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The code is duplicated between NM_preDown.sh and NM_Dispatcher.sh. Consider creating a shared library file that both scripts can source to avoid code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
local mode=$1
local addr=$2
# Neglect IPV6 ULA address and autoconfigured IPV4 address
if [ "x$mode" == "xipv6" ]; then
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

Use single brackets '[' with '=' instead of double brackets '[[' with '==' for POSIX compliance in shell scripts. The current syntax is bash-specific, but the shebang indicates a generic sh interpreter.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 19, 2025 21:16
Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants