Update subnet-down

This commit is contained in:
Manevolent 2023-04-13 00:35:05 -06:00 committed by GitHub
parent 672dc860a2
commit 9357eab491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,19 +2,23 @@
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`
if [ -z "$nonMACChars" ]; then
# This subnet is a MAC
rm -f /tmp/tinc_peer_mac_$NODE_$SUBNET
rm -f /tmp/tinc/$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
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_peer_mac_$NODE_$address
if arp -an | grep -q "\($address\)"; then
echo "[ARP] Unmapping $addresss from ARP table"
rm -f /tmp/tinc/$NODE_ip_$address
if echo $arpEntries | grep -q "\($address\)"; then
echo "[ARP] Removing from table: $addresss"
arp -d $address
fi
fi