Skip to content

Commit 3a29249

Browse files
committed
[Multi-asic] Fixed Default Route to be BGP (#5548)
Learned and not docker default route for multi-asic platforms. Signed-off-by: Abhishek Dosi <[email protected]>
1 parent de30451 commit 3a29249

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dockers/docker-fpm-frr/start.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@ mkdir -p /etc/frr
44

55
CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`
66

7-
if [[ ! -z "$NAMESPACE_ID" ]]; then
7+
update_default_gw()
8+
{
9+
IP_VER=${1}
810
# FRR is not running in host namespace so we need to delete
911
# default gw kernel route added by docker network via eth0 and add it back
1012
# with higher administrative distance so that default route learnt
1113
# by FRR becomes best route if/when available
12-
GATEWAY_IP=$(ip route show 0.0.0.0/0 dev eth0 | awk '{print $3}')
14+
GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
1315
#Check if docker default route is there
1416
if [[ ! -z "$GATEWAY_IP" ]]; then
15-
ip route del 0.0.0.0/0 dev eth0
17+
ip -${IP_VER} route del default dev eth0
1618
#Make sure route is deleted
17-
CHECK_GATEWAY_IP=$(ip route show 0.0.0.0/0 dev eth0 | awk '{print $3}')
19+
CHECK_GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
1820
if [[ -z "$CHECK_GATEWAY_IP" ]]; then
1921
# Ref: http://docs.frrouting.org/en/latest/zebra.html#zebra-vrf
2022
# Zebra does treat Kernel routes as special case for the purposes of Admin Distance. \
2123
# Upon learning about a route that is not originated by FRR we read the metric value as a uint32_t.
2224
# The top byte of the value is interpreted as the Administrative Distance and
2325
# the low three bytes are read in as the metric.
2426
# so here we are programming administrative distance of 210 (210 << 24) > 200 (for routes learnt via IBGP)
25-
ip route add 0.0.0.0/0 via $GATEWAY_IP dev eth0 metric 3523215360
27+
ip -${IP_VER} route add default via $GATEWAY_IP dev eth0 metric 3523215360
2628
fi
2729
fi
30+
}
31+
32+
if [[ ! -z "$NAMESPACE_ID" ]]; then
33+
update_default_gw 4
34+
update_default_gw 6
2835
fi
2936

3037
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then

0 commit comments

Comments
 (0)