RDKBACCL-1905: Align bridge-mode handlers for bridged wan interface a…#484
RDKBACCL-1905: Align bridge-mode handlers for bridged wan interface a…#484manigandanj wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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_ifnameis a bridge and creates a veth pair to connect the WAN bridge tobrlan0. - 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.
772f6a6 to
bd30ad1
Compare
| 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 |
| 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" |
muffin-top
left a comment
There was a problem hiding this comment.
Looks good to me. Component owner to approve.
bd30ad1 to
09f10e4
Compare
09f10e4 to
3490810
Compare
| 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` | ||
| } |
| 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 |
| if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then | ||
| ip link del wanbr-link | ||
| brctl delif brlan0 l$cmdiag_if | ||
| return | ||
| fi |
| #Setting erouter0 as default wan_if | ||
| wan_if="erouter0" | ||
| determine_wan_ifname() |
3490810 to
15bd6ad
Compare
| 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 |
| interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs` | ||
| wan_if=$interface_name |
| 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 |
| 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 |
15bd6ad to
c2faa74
Compare
| 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 |
| interface_name=`dmcli eRT getv Device.X_RDK_WanManager.Interface.2.VirtualInterface.1.Name | grep value | cut -d':' -f3 | xargs` | ||
| wan_if=$interface_name |
| if [ ! -f /tmp/wan_ip_assigned_to_erouter ]; then | ||
| while [ "30" -ge "$retry" ] |
| 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 |
| if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then | ||
| ip link del wanbr-link | ||
| brctl delif brlan0 l$cmdiag_if | ||
| return | ||
| fi |
c2faa74 to
d279111
Compare
…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>
d279111 to
e6f7298
Compare
| 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` | ||
| } |
| 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 |
| if [ -f /sys/class/net/$wan_if/bridge/bridge_id ]; then | ||
| ip link del wanbr-link | ||
| brctl delif brlan0 l$cmdiag_if | ||
| return | ||
| fi |
There was a problem hiding this comment.
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_ifnameuses==in[tests.==is not POSIX and can fail under some/bin/shimplementations; 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_ifnameoverwrites the defaultwan_ifwith 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 likeip 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_waitnow 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_ifis a bridge,add_to_groupcreates a fixed veth pair (wanbr-link/lanbr-link) unconditionally. If bridge mode toggles oradd_to_groupis re-run,ip link addwill fail and leave the system in a partially configured state; make creation idempotent and quote variables in sysfs/brctloperations.
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 deletingwanbr-link, which skips the subsequent logic that restores the LAN IP to$bridge_namewhen 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
…pproach
Reason for change: Linking both WAN and LAN bridges
Test procedure: Checked bridgemode functionality and SSH to erouter0 IP
Risks: Low
Priority: P0