@@ -4,27 +4,34 @@ mkdir -p /etc/frr
4
4
5
5
CONFIG_TYPE=` sonic-cfggen -d -v ' DEVICE_METADATA["localhost"]["docker_routing_config_mode"]' `
6
6
7
- if [[ ! -z " $NAMESPACE_ID " ]]; then
7
+ update_default_gw ()
8
+ {
9
+ IP_VER=${1}
8
10
# FRR is not running in host namespace so we need to delete
9
11
# default gw kernel route added by docker network via eth0 and add it back
10
12
# with higher administrative distance so that default route learnt
11
13
# 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}' )
13
15
# Check if docker default route is there
14
16
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
16
18
# 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}' )
18
20
if [[ -z " $CHECK_GATEWAY_IP " ]]; then
19
21
# Ref: http://docs.frrouting.org/en/latest/zebra.html#zebra-vrf
20
22
# Zebra does treat Kernel routes as special case for the purposes of Admin Distance. \
21
23
# Upon learning about a route that is not originated by FRR we read the metric value as a uint32_t.
22
24
# The top byte of the value is interpreted as the Administrative Distance and
23
25
# the low three bytes are read in as the metric.
24
26
# 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
26
28
fi
27
29
fi
30
+ }
31
+
32
+ if [[ ! -z " $NAMESPACE_ID " ]]; then
33
+ update_default_gw 4
34
+ update_default_gw 6
28
35
fi
29
36
30
37
if [ -z " $CONFIG_TYPE " ] || [ " $CONFIG_TYPE " == " separated" ]; then
0 commit comments