Update subnet-down

This commit is contained in:
Manevolent 2023-04-13 00:38:40 -06:00 committed by GitHub
parent 7f20f60f00
commit c5b253f7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,12 +3,13 @@ echo "[ROUTE] down: $SUBNET weight $WEIGHT via $NODE ($REMOTEADDRESS:$REMOTEPORT
nonMACChars=`echo $SUBNET | tr -d "[:digit:]" | tr -d [:ABCDEFabcdef]`
date=`date -u`
arpEntries=`arp -an`
mkdir -p /tmp/tinc/peer/$NODE/mac/ /tmp/tinc/peer/$NODE/ip/
if [ -z "$nonMACChars" ]; then
# This subnet is a MAC
rm -f /tmp/tinc/$NODE_mac_$SUBNET
rm -f /tmp/tinc/peer/$NODE/mac/$SUBNET
if echo $arpEntries | grep -q -E "at $SUBNET "; then
echo ""
echo $arpEntries | grep -E "at 0?*$SUBNET0?* " | sed -r 's/^.+\((.+)\).+$/\1/g' | xargs -n1 echo "[ARP] Removing from table: "
echo $arpEntries | grep -E "at 0?*$SUBNET0?* " | sed -r 's/^.+\((.+)\).+$/\1/g' | xargs -n1 arp -d
fi
@ -16,7 +17,8 @@ else
# This subnet is an IP address
if echo "$SUBNET" | grep -q -E ".+/32$"; then
address=`echo "$SUBNET" | cut -d '/' -f 1`
rm -f /tmp/tinc/$NODE_ip_$address
rm -f /tmp/tinc/peer/$NODE/ip/$address
if echo $arpEntries | grep -q "\($address\)"; then
echo "[ARP] Removing from table: $addresss"
arp -d $address