Skip to content

Commit 1a0ce98

Browse files
authored
Update arp_update to refresh neighbor entries from APP_DB (#4125)
1 parent 031e69d commit 1a0ce98

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

files/scripts/arp_update

+21
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,26 @@ while /bin/true; do
4646
ip6cmd="ip -6 neigh show | grep -v fe80 | grep $vlan | cut -d ' ' -f 1,3 | $ndisc6cmd"
4747
eval `eval $ip6cmd`
4848
done
49+
50+
# refresh neighbor entries from APP_DB in case of mismatch with kernel
51+
DBNEIGH=$(sonic-db-cli APPL_DB keys NEIGH_TABLE*)
52+
KERNEIGH4=$(ip -4 neigh show | grep Vlan | cut -d ' ' -f 1,3 --output-delimiter=',')
53+
KERNEIGH6=$(ip -6 neigh show | grep -v fe80 | grep Vlan | cut -d ' ' -f 1,3 --output-delimiter=',')
54+
for neigh in $DBNEIGH; do
55+
intf="$( cut -d ':' -f 2 <<< "$neigh" )"
56+
ip="$( cut -d ':' -f 3- <<< "$neigh" )"
57+
if [[ $intf == *"Vlan"* ]]; then
58+
if [[ $ip == *"."* ]] && [[ ! $KERNEIGH4 =~ "${ip},${intf}" ]]; then
59+
pingcmd="timeout 0.2 ping -I $intf -n -q -i 0 -c 1 -W 1 $ip >/dev/null"
60+
eval $pingcmd
61+
logger "arp_update: mismatch arp entry, pinging ${ip} on ${intf}"
62+
elif [[ $ip == *":"* ]] && [[ ! $KERNEIGH6 =~ "${ip},${intf}" ]]; then
63+
ping6cmd="timeout 0.2 ping6 -I $intf -n -q -i 0 -c 1 -W 1 $ip >/dev/null"
64+
eval $ping6cmd
65+
logger "arp_update: mismatch v6 nbr entry, pinging ${ip} on ${intf}"
66+
fi
67+
fi
68+
done
69+
4970
sleep 300
5071
done

0 commit comments

Comments
 (0)