Skip to content

Commit

Permalink
[Multi-asic] Fixed Default Route to be BGP (#5548)
Browse files Browse the repository at this point in the history
Learned and not docker default route for multi-asic platforms.

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi committed Oct 6, 2020
1 parent de30451 commit 3a29249
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dockers/docker-fpm-frr/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@ mkdir -p /etc/frr

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

if [[ ! -z "$NAMESPACE_ID" ]]; then
update_default_gw()
{
IP_VER=${1}
# FRR is not running in host namespace so we need to delete
# default gw kernel route added by docker network via eth0 and add it back
# with higher administrative distance so that default route learnt
# by FRR becomes best route if/when available
GATEWAY_IP=$(ip route show 0.0.0.0/0 dev eth0 | awk '{print $3}')
GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
#Check if docker default route is there
if [[ ! -z "$GATEWAY_IP" ]]; then
ip route del 0.0.0.0/0 dev eth0
ip -${IP_VER} route del default dev eth0
#Make sure route is deleted
CHECK_GATEWAY_IP=$(ip route show 0.0.0.0/0 dev eth0 | awk '{print $3}')
CHECK_GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
if [[ -z "$CHECK_GATEWAY_IP" ]]; then
# Ref: http://docs.frrouting.org/en/latest/zebra.html#zebra-vrf
# Zebra does treat Kernel routes as special case for the purposes of Admin Distance. \
# Upon learning about a route that is not originated by FRR we read the metric value as a uint32_t.
# The top byte of the value is interpreted as the Administrative Distance and
# the low three bytes are read in as the metric.
# so here we are programming administrative distance of 210 (210 << 24) > 200 (for routes learnt via IBGP)
ip route add 0.0.0.0/0 via $GATEWAY_IP dev eth0 metric 3523215360
ip -${IP_VER} route add default via $GATEWAY_IP dev eth0 metric 3523215360
fi
fi
}

if [[ ! -z "$NAMESPACE_ID" ]]; then
update_default_gw 4
update_default_gw 6
fi

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

0 comments on commit 3a29249

Please sign in to comment.