Skip to content

Commit

Permalink
Get failed neighbors from kernel instead of db
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
  • Loading branch information
theasianpianist committed Aug 4, 2022
1 parent 54d6051 commit 899b165
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions files/scripts/arp_update
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@ while /bin/true; do
eval `eval $ip6cmd`
done

DBNEIGH=$(sonic-db-cli APPL_DB keys NEIGH_TABLE*)
# on dual ToR devices, try to resolve failed neighbor entries since
# these entries will have tunnel routes installed, preventing normal
# neighbor resolution
KERNEL_NEIGHBORS=$(ip -4 neigh show | grep Vlan | cut -d ' ' -f 1,3,6 --output-delimiter=','; \
ip -6 neigh show | grep -v fe80 | grep Vlan | cut -d ' ' -f 1,3,5 --output-delimiter=',')
TUNNEL_ENTRY=$(sonic-db-cli CONFIG_DB keys "TUNNEL|*")
if [[ ! -z $TUNNEL_ENTRY ]]; then
for neigh in $DBNEIGH; do
MAC=$(sonic-db-cli APPL_DB hgetall $neigh | cut -d '{' -f 2 | cut -d ',' -f 1 | cut -d ' ' -f 2 | cut -d "'" -f 2)
if [[ $MAC == "00:00:00:00:00:00" ]]; then
intf="$( cut -d ':' -f 2 <<< "$neigh" )"
ip="$( cut -d ':' -f 3- <<< "$neigh" )"
for neigh in $KERNEL_NEIGHBORS; do
STATE=$(cut -d ',' -f 3 <<< $neigh)
if [[ $STATE == "FAILED" ]] || [[ $STATE == "INCOMPLETE" ]]; then
intf=$(cut -d ',' -f 2 <<< $neigh)
ip=$(cut -d ',' -f 1 <<< $neigh)
pingcmd="timeout 0.2 ping -I $intf -n -q -i 0 -c 1 -W 1 $ip >/dev/null"
eval $pingcmd
logger "arp_update: resolving failed neighbor entry, pinging ${ip} on ${intf}"
Expand Down

0 comments on commit 899b165

Please sign in to comment.