Update arp_update to refresh neighbor entries from APP_DB (#4102)

* Update arp_update to refresh neighbor entries from APP_DB
This commit is contained in:
Prince Sunny 2020-02-05 15:42:15 -08:00 committed by GitHub
parent fe44b7ae4f
commit c53f09684a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,5 +46,26 @@ while /bin/true; do
ip6cmd="ip -6 neigh show | grep -v fe80 | grep $vlan | cut -d ' ' -f 1,3 | $ndisc6cmd"
eval `eval $ip6cmd`
done
# refresh neighbor entries from APP_DB in case of mismatch with kernel
DBNEIGH=$(redis-cli -n 0 --scan --pattern NEIGH_TABLE*)
KERNEIGH4=$(ip -4 neigh show | grep Vlan | cut -d ' ' -f 1,3 --output-delimiter=',')
KERNEIGH6=$(ip -6 neigh show | grep -v fe80 | grep Vlan | cut -d ' ' -f 1,3 --output-delimiter=',')
for neigh in $DBNEIGH; do
intf="$( cut -d ':' -f 2 <<< "$neigh" )"
ip="$( cut -d ':' -f 3- <<< "$neigh" )"
if [[ $intf == *"Vlan"* ]]; then
if [[ $ip == *"."* ]] && [[ ! $KERNEIGH4 =~ "${ip},${intf}" ]]; then
pingcmd="ping -I $intf -n -q -i 0 -c 1 -W 0 $ip >/dev/null"
eval $pingcmd
logger "arp_update: mismatch arp entry, pinging ${ip} on ${intf}"
elif [[ $ip == *":"* ]] && [[ ! $KERNEIGH6 =~ "${ip},${intf}" ]]; then
ping6cmd="ping6 -I $intf -n -q -i 0 -c 1 -W 0 $ip >/dev/null"
eval $ping6cmd
logger "arp_update: mismatch v6 nbr entry, pinging ${ip} on ${intf}"
fi
fi
done
sleep 300
done