@@ -14,36 +14,25 @@ while /bin/true; do
14
14
ARP_UPDATE_VARS=$( sonic-cfggen -d -t ${ARP_UPDATE_VARS_FILE} )
15
15
SWITCH_TYPE=$( echo $ARP_UPDATE_VARS | jq -r ' .switch_type' )
16
16
if [[ " $SWITCH_TYPE " == " chassis-packet" ]]; then
17
- # Get array of Nexthops and ifnames. Nexthops and ifnames are mapped one to one
18
- STATIC_ROUTE_NEXTHOPS=($( echo $ARP_UPDATE_VARS | jq -r ' .static_route_nexthops' ) )
19
- STATIC_ROUTE_IFNAMES=($( echo $ARP_UPDATE_VARS | jq -r ' .static_route_ifnames' ) )
17
+ STATIC_ROUTE_NEXTHOPS=$( echo $ARP_UPDATE_VARS | jq -r ' .static_route_nexthops' )
20
18
# on supervisor/rp exit the script gracefully
21
- if [[ -z " $STATIC_ROUTE_NEXTHOPS " ]] || [[ -z " $STATIC_ROUTE_IFNAMES " ]] ; then
19
+ if [[ -z " $STATIC_ROUTE_NEXTHOPS " ]]; then
22
20
logger " arp_update: exiting as no static route in packet based chassis"
23
21
exit 0
24
22
fi
25
- for i in ${! STATIC_ROUTE_NEXTHOPS[@]} ; do
26
- nexthop=" ${STATIC_ROUTE_NEXTHOPS[i]} "
23
+ for nexthop in $STATIC_ROUTE_NEXTHOPS ; do
27
24
if [[ $nexthop == * " ." * ]]; then
28
25
neigh_state=( $( ip -4 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
29
26
ping_prefix=ping
30
27
elif [[ $nexthop == * " :" * ]] ; then
31
28
neigh_state=( $( ip -6 neigh show | grep -w $nexthop | tr -s ' ' | cut -d ' ' -f 3,4) )
32
29
ping_prefix=ping6
33
30
fi
34
- if [[ -z " ${neigh_state} " ]] || [[ " ${neigh_state[1]} " == " INCOMPLETE" ]] || [[ " ${neigh_state[1]} " == " FAILED" ]]; then
35
- interface=" ${STATIC_ROUTE_IFNAMES[i]} "
36
- if [[ -z " $interface " ]]; then
37
- # should never be here, handling just in case
38
- logger " ERR: arp_update: missing interface entry for static route $nexthop "
39
- interface=${neigh_state[0]}
40
- fi
41
- intf_up=$( ip link show $interface | grep " state UP" )
42
- if [[ -n " $intf_up " ]]; then
43
- pingcmd=" timeout 0.2 $ping_prefix -I ${interface} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null"
44
- eval $pingcmd
45
- logger " arp_update: static route nexthop not resolved, pinging $nexthop on ${neigh_state[0]} "
46
- fi
31
+
32
+ if [[ " ${neigh_state[1]} " == " INCOMPLETE" ]] || [[ " ${neigh_state[1]} " == " FAILED" ]]; then
33
+ pingcmd=" timeout 0.2 $ping_prefix -I ${neigh_state[0]} -n -q -i 0 -c 1 -W 1 $nexthop >/dev/null"
34
+ eval $pingcmd
35
+ logger " arp_update: sttaic route nexthop not resolved, pinging $nexthop on ${neigh_state[0]} "
47
36
fi
48
37
done
49
38
0 commit comments