ab05a2f58a
This PR is cherry-pick of master https://github.com/Azure/sonic-buildimage/pull/6920 Why I did it Add support for BGP Monitors on multi asic SONiC platforms. How I did it On multi ASIC SONiC platforms, BGP monitor session will be established from Backend ASIC. To achieve this following changes are done Add BGP monitor configuration on the backend ASIC. The BGP monitor configuration is present in the DPG of the device in minigraph.xml of multi-ASIC device, so this configuration will be added to the config_db of the host, when the minigraph is loaded. To add configuration for this in the Backend ASIC, a new class MultiAsicBgpMonCfg is added to the hostcfgd service to update the config_db of the backend ASIC when the BGP_MONITOR table of the host config_db is updated. This way incremental BGP_MONITOR configuration can also be handled. Changes to establish BGP session with bgp monitor. Add route in host main routing table to go to one of pre-define backend asic Add IP table rule on front asic to mark the BGP packets with destination as IPv4 Loopback. Add IP rule in front asic namespace to match mark BGP packet and lookup default table Program the default route in FrontEnd asic name space docker default table as part of start.sh of the BGP container. It need to be done as part of start.sh otherwise FRR default route will get over-written. How to verify it Signed-off-by: Abhishek Dosi <abdosi@microsoft.com> Co-authored-by: Arvind <arlakshm@microsoft.com>
95 lines
3.4 KiB
Bash
Executable File
95 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
mkdir -p /etc/frr
|
|
mkdir -p /etc/supervisor/conf.d
|
|
|
|
CFGGEN_PARAMS=" \
|
|
-d \
|
|
-y /etc/sonic/constants.yml \
|
|
-t /usr/share/sonic/templates/frr_vars.j2 \
|
|
-t /usr/share/sonic/templates/bgpd/bgpd.conf.j2,/etc/frr/bgpd.conf \
|
|
-t /usr/share/sonic/templates/zebra/zebra.conf.j2,/etc/frr/zebra.conf \
|
|
-t /usr/share/sonic/templates/staticd/staticd.conf.j2,/etc/frr/staticd.conf \
|
|
-t /usr/share/sonic/templates/frr.conf.j2,/etc/frr/frr.conf \
|
|
-t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \
|
|
-t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \
|
|
"
|
|
CONFIG_TYPE=$(sonic-cfggen $CFGGEN_PARAMS)
|
|
|
|
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 -${IP_VER} route show default dev eth0 | awk '{print $3}')
|
|
#Check if docker default route is there
|
|
if [[ ! -z "$GATEWAY_IP" ]]; then
|
|
ip -${IP_VER} route del default dev eth0
|
|
#Make sure route is deleted
|
|
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 -${IP_VER} route add default via $GATEWAY_IP dev eth0 metric 3523215360
|
|
fi
|
|
if [[ "$IP_VER" == "4" ]]; then
|
|
# Add route in default table. This is needed for BGPMON to route BGP Ipv4 loopback
|
|
# traffic from namespace to host
|
|
ip -${IP_VER} route add table default 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
|
|
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
|
|
rm -f /etc/frr/frr.conf
|
|
elif [ "$CONFIG_TYPE" == "unified" ]; then
|
|
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
|
|
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
|
|
fi
|
|
|
|
chown -R frr:frr /etc/frr/
|
|
|
|
chown root:root /usr/sbin/bgp-isolate
|
|
chmod 0755 /usr/sbin/bgp-isolate
|
|
|
|
chown root:root /usr/sbin/bgp-unisolate
|
|
chmod 0755 /usr/sbin/bgp-unisolate
|
|
|
|
mkdir -p /var/sonic
|
|
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
|
|
|
rm -f /var/run/rsyslogd.pid
|
|
|
|
supervisorctl start rsyslogd
|
|
|
|
# start eoiu pulling, only if configured so
|
|
if [[ $(sonic-cfggen -d -v 'WARM_RESTART.bgp.bgp_eoiu if WARM_RESTART and WARM_RESTART.bgp and WARM_RESTART.bgp.bgp_eoiu') == 'true' ]]; then
|
|
supervisorctl start bgp_eoiu_marker
|
|
fi
|
|
|
|
# Start Quagga processes
|
|
supervisorctl start zebra
|
|
supervisorctl start staticd
|
|
supervisorctl start bgpd
|
|
|
|
if [ "$CONFIG_TYPE" == "unified" ]; then
|
|
supervisorctl start vtysh_b
|
|
fi
|
|
|
|
supervisorctl start fpmsyncd
|
|
|
|
supervisorctl start bgpcfgd
|
|
supervisorctl start bgpmon
|