[FROG] nhrpd event manager
    Joe Maimon 
    jmaimon at jmaimon.com
       
    Sun Mar 15 21:11:01 EDT 2020
    
    
  
Fix is pretty straightforward.
--- a/nhrpd/nhrp_event.c
+++ b/nhrpd/nhrp_event.c
@@ -59,9 +59,9 @@
                 buf[len] = 0;
                 debugf(NHRP_DEBUG_EVENT, "evmgr: msg: %s", buf);
-               if (sscanf(buf, "eventid=%" SCNu32, &eventid) != 1)
+               if (sscanf(buf, "eventid=%" SCNu32, &eventid) == 1)
                         continue;
-               if (sscanf(buf, "result=%63s", result) != 1)
+               if (sscanf(buf, "result=%63s", result) == 1)
                         continue;
         }
         debugf(NHRP_DEBUG_EVENT, "evmgr: received: eventid=%d result=%s",
Fledgling script actually works now, forgive email formatting errors
---------cut here----
#!/bin/bash
PROGNAME=`basename $0`
VERSION="0.0.2"
usage()
{
         echo "Usage: $PROGNAME -s nhrp-sock [-i interface-name] [-u 
user] [-g group] "
         echo ""
         echo "-s nhrp-sock file"
         echo "-i interface-name to execute on, may be repeated multiple 
times"
         echo "-u user to own the sock"
         echo "-g group to own the sock"
         exit 1
}
SOCK="/var/run/frr/nhrp.sock"
USER="frr"
GROUP="frr"
j=0
while getopts s:i:u:g: opt; do
         case "$opt" in
                 s)
                         SOCK="$OPTARG"
                         ;;
                 i)
                         INTARR[((j++))]="$OPTARG"
                         ;;
                 u)
                         USER="$OPTARG"
                         ;;
                 g)
                         GROUP="$OPTARG"
                         ;;
         esac;
done
coproc socat - UNIX-LISTEN:$SOCK,unlink-early,setuid-early=$USER || exit 1
chown $USER:$GROUP $SOCK
OLDIFS="$IFS"
while read -r S; do
         if [[ "$S" == "" ]]; then
                 if [[ "$EVID" != "" ]]; then
                         echo -e "eventid=$EVID\nresult=accept\n";
                 fi
                 for((i=0;i<${#INTARR[@]};i++)); do
                         if [[ "$EVINT" == "" ]]; then break; fi
                         if [[ "${INTARR[$i]}" != "$EVINT" ]]; then 
continue; fi
                         if [[ "$EVREM" == "" ]]; then break; fi
                         if [[ "$EVNBMA" == "" ]]; then break; fi
                         if [[ "$EVTYPE" != "dynamic" ]]; then break; fi
                         ip neigh add $EVREM dev $EVINT lladdr $EVNBMA 
nud noarp
                         if [[ "$?" != "0" ]]; then
                                 ip neigh replace $EVREM dev $EVINT 
lladdr $EVNBMA nud noarp
                         fi
                         break
                 done
                 unset EVID
                 unset EVINT
                 unset EVREM
                 unset EVNBMA
                 unset EVTYPE
                 continue;
         fi
         IFS="${IFS}="
         SA=($S)
         IFS="$OLDIFS"
         case "${SA[0]}" in
                 eventid)
                         EVID="${SA[1]}"
                         ;;
                 interface)
                         EVINT="${SA[1]}"
                         ;;
                 type)
                         EVTYPE="${SA[1]}"
                         ;;
                 remote_addr)
                         EVREM="${SA[1]}"
                         ;;
                 remote_nbma)
                        EVNBMA="${SA[1]}"
                         ;;
         esac
done <&"${COPROC[0]}" >&"${COPROC[1]}"
kill "$COPROC_PID"
    
    
More information about the frog
mailing list