Skip to content

RDKBACCL-1905: Align bridge-mode handlers for bridged wan interface a…#484

Open
manigandanj wants to merge 2 commits into
rdkcentral:developfrom
manigandanj:RDKBACCL-1905_wan_bridge_linking
Open

RDKBACCL-1905: Align bridge-mode handlers for bridged wan interface a…#484
manigandanj wants to merge 2 commits into
rdkcentral:developfrom
manigandanj:RDKBACCL-1905_wan_bridge_linking

Conversation

@manigandanj

@manigandanj manigandanj commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

…pproach

Reason for change: Linking both WAN and LAN bridges
Test procedure: Checked bridgemode functionality and SSH to erouter0 IP
Risks: Low
Priority: P0

Copilot AI review requested due to automatic review settings June 26, 2026 16:21

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

Aligns bridge-mode behavior when the configured WAN “physical” interface is itself a Linux bridge, by linking the WAN bridge and brlan0 rather than attempting to add one bridge directly into the other.

Changes:

  • Detects when wan_physical_ifname is a bridge and creates a veth pair to connect the WAN bridge to brlan0.
  • Deletes the veth link on bridge-mode teardown when the WAN interface is a bridge.

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

Comment thread meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh
Comment thread meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh
@manigandanj
manigandanj marked this pull request as draft June 26, 2026 16:35
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch 2 times, most recently from 772f6a6 to bd30ad1 Compare June 29, 2026 13:13
@manigandanj
manigandanj requested a review from Copilot June 29, 2026 13:34

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

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

Comment on lines +574 to +583
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link add wanbr-link type veth peer name lanbr-link
brctl addif $wan_if wanbr-link
brctl addif brlan0 lanbr-link
ip link set up dev wanbr-link
ip link set up dev lanbr-link
else
echo "brctl addif brlan0 $wan_if"
brctl addif brlan0 "$wan_if"
fi
Comment on lines +636 to 643
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link del wanbr-link
brctl delif brlan0 l$cmdiag_if
return
fi

echo "brctl delif brlan0 l$cmdiag_if $wan_if"
brctl delif brlan0 l$cmdiag_if "$wan_if"
@manigandanj
manigandanj marked this pull request as ready for review June 29, 2026 15:05

@muffin-top muffin-top left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me. Component owner to approve.

@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from bd30ad1 to 09f10e4 Compare July 6, 2026 12:34
Copilot AI review requested due to automatic review settings July 6, 2026 13:26
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from 09f10e4 to 3490810 Compare July 6, 2026 13:26

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment on lines +55 to +68
determine_wan_ifname()
{
#Currently BPI has 2 Interfaces
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ]; then
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
return
fi
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
#Legacy approach to determine wan interface name
#wan_if=`sysevent get current_wan_ifname`
}
Comment on lines +586 to +595
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link add wanbr-link type veth peer name lanbr-link
brctl addif $wan_if wanbr-link
brctl addif brlan0 lanbr-link
ip link set up dev wanbr-link
ip link set up dev lanbr-link
else
echo "brctl addif brlan0 $wan_if"
brctl addif brlan0 "$wan_if"
fi
Comment on lines +647 to +651
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link del wanbr-link
brctl delif brlan0 l$cmdiag_if
return
fi
Comment on lines +53 to +55
#Setting erouter0 as default wan_if
wan_if="erouter0"
determine_wan_ifname()
Copilot AI review requested due to automatic review settings July 9, 2026 13:27
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from 3490810 to 15bd6ad Compare July 9, 2026 13:27

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

retry=`expr $retry + 1`
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
interface2_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ] || [ "$interface2_status" == "Active" ]; then
done
#Currently BPI has 2 Interfaces
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ]; then
Comment on lines +75 to +76
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
Comment on lines +597 to +603
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link add wanbr-link type veth peer name lanbr-link
brctl addif $wan_if wanbr-link
brctl addif brlan0 lanbr-link
ip link set up dev wanbr-link
ip link set up dev lanbr-link
else
Comment on lines +658 to +662
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link del wanbr-link
brctl delif brlan0 l$cmdiag_if
return
fi
INSTANCE=`sysevent get primary_lan_l2net`
LAN_NETMASK=`syscfg get lan_netmask`

determine_wan_ifname
Copilot AI review requested due to automatic review settings July 9, 2026 14:01
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from 15bd6ad to c2faa74 Compare July 9, 2026 14:01

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

retry=`expr $retry + 1`
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
interface2_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ] || [ "$interface2_status" == "Active" ]; then
done
#Currently BPI has 2 Interfaces
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ]; then
Comment on lines +75 to +76
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
Comment on lines +552 to 553
if [ ! -f /tmp/wan_ip_assigned_to_erouter ]; then
while [ "30" -ge "$retry" ]
Comment on lines +596 to +601
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link add wanbr-link type veth peer name lanbr-link
brctl addif $wan_if wanbr-link
brctl addif brlan0 lanbr-link
ip link set up dev wanbr-link
ip link set up dev lanbr-link
Comment on lines +657 to +661
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link del wanbr-link
brctl delif brlan0 l$cmdiag_if
return
fi
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from c2faa74 to d279111 Compare July 17, 2026 09:09
…pproach

Reason for change: Linking both WAN and LAN bridges
Test procedure: Checked bridgemode functionality and SSH to erouter0 IP
Risks: Low
Priority: P0

Signed-off-by: Manigandan Gopalakrishnan <Manigandan_Gopalakrishnan@comcast.com>
Copilot AI review requested due to automatic review settings July 17, 2026 09:31
@manigandanj
manigandanj force-pushed the RDKBACCL-1905_wan_bridge_linking branch from d279111 to e6f7298 Compare July 17, 2026 09:31

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +55 to +79
determine_wan_ifname()
{
retry=0
while [ "30" -ge "$retry" ]
do
retry=`expr $retry + 1`
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
interface2_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ] || [ "$interface2_status" == "Active" ]; then
break
fi
sleep 1
done
#Currently BPI has 2 Interfaces
interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
if [ "$interface1_status" == "Active" ]; then
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
return
fi
interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
wan_if=$interface_name
#Legacy approach to determine wan interface name
#wan_if=`sysevent get current_wan_ifname`
}
Comment on lines +596 to +605
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link add wanbr-link type veth peer name lanbr-link
brctl addif $wan_if wanbr-link
brctl addif brlan0 lanbr-link
ip link set up dev wanbr-link
ip link set up dev lanbr-link
else
echo "brctl addif brlan0 $wan_if"
brctl addif brlan0 "$wan_if"
fi
Comment on lines +657 to +661
if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
ip link del wanbr-link
brctl delif brlan0 l$cmdiag_if
return
fi
Copilot AI review requested due to automatic review settings July 21, 2026 10:49

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (5)

meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh:71

  • This script is invoked with /bin/sh, but the new determine_wan_ifname uses == in [ tests. == is not POSIX and can fail under some /bin/sh implementations; use = for string comparison to avoid runtime errors during WAN selection.
      if [ "$interface1_status" == "Active" ] || [ "$interface2_status" == "Active" ]; then
          break
      fi
      sleep 1
   done
   #Currently BPI has 2 Interfaces
   interface1_status=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.Status | grep value | cut -d':' -f3 | xargs`
   if [ "$interface1_status" == "Active" ]; then
      interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.1.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`

meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh:76

  • determine_wan_ifname overwrites the default wan_if with whatever dmcli returns for Interface.2, even if the name is empty (e.g., dmcli not ready or Interface.2 inactive). That can later produce commands like ip link set "" down / brctl addif ... "".
   interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs`
   wan_if=$interface_name

meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh:560

  • wan_wait now keys its skip-file (/tmp/wan_ip_assigned_to_erouter) to a fixed name even though WAN interface selection is dynamic ($wan_if). If WAN changes between boots/mode switches, an existing file can incorrectly skip waiting for the new interface to receive an IP.
   retry=0
   if [ ! -f /tmp/wan_ip_assigned_to_erouter ]; then
   while [ "30" -ge "$retry" ]
   do
       sleep 1
       retry=`expr $retry + 1`
       #Make sure WAN interface has an IP address before mounting to brlan0
       WAN_IP=`ifconfig -a "$wan_if" | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1`
       if [ -n "$WAN_IP" ] ; then
          touch /tmp/wan_ip_assigned_to_erouter

meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh:600

  • When $wan_if is a bridge, add_to_group creates a fixed veth pair (wanbr-link/lanbr-link) unconditionally. If bridge mode toggles or add_to_group is re-run, ip link add will fail and leave the system in a partially configured state; make creation idempotent and quote variables in sysfs/brctl operations.
  if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
        ip link add wanbr-link type veth peer name lanbr-link
        brctl addif $wan_if wanbr-link
        brctl addif brlan0 lanbr-link
        ip link set up dev wanbr-link

meta-rdk-mtk-bpir4/recipes-ccsp/util/utopia/service_bridge_bpi.sh:661

  • In del_from_group, the new bridge-case path returns early after deleting wanbr-link, which skips the subsequent logic that restores the LAN IP to $bridge_name when needed. This can leave the LAN bridge without an IP after stopping bridge mode.
  if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then
        ip link del wanbr-link
        brctl delif brlan0 l$cmdiag_if
        return
  fi

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