openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
3.94k stars 3.46k forks source link

frr: Service frr restart stop all deamons and service frr reload didn't stop #23005

Open astrcomp opened 8 months ago

astrcomp commented 8 months ago

Maintainer: @lucize Environment: OpenWRT 23.05.0 x86-64 generic ran inside QEMU in GNS3, FRRouting 9.0.0

Description

  1. In code frr service restart, all daemons stoped, becouse variable $daemons is always empty, variable is defined below. in_list $i $daemons || daemon_stop $i https://github.com/openwrt/packages/blob/master/net/frr/files/frr
  2. In code frr service reload, restart only watchfrr, if enable daemons in /etc/frr/daemons watchfrr run this deamons, if disabled daemons in /etc/frr/daemons didn't stop daemons. Fix (just add code from restart to reload, for stop diabled daemons):

    reload() {
    RELOAD_SCRIPT="/usr/sbin/frr-reload"
    if [ ! -x "$RELOAD_SCRIPT" ]; then
        log_failure_msg "The frr-pythontools package is required for reload functionality."
        exit 1
    fi
    
    # restart watchfrr to pick up added daemons.
    # NB: This will NOT cause the other daemons to be restarted.
    daemon_list daemons
    all_daemon_list all_daemons
    watchfrr_pid=`pidof watchfrr`
    for i in `tr '\0' '\n' < /proc/$watchfrr_pid/cmdline | sed -n '1!G;h;$p'`; do
    in_list $i $all_daemons || break
    in_list $i $daemons || daemon_stop $i
    done
    watchfrr_options="$watchfrr_options $daemons"
    daemon_stop watchfrr && \
        daemon_start watchfrr
    
    NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}"
    [ ! -r $NEW_CONFIG_FILE ] && log_failure_msg "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1
    "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE"
    exit $?
    }

    Sorry if I'm wrong, main problem I don't know how stop daemons without stoped all daemons

feckert commented 8 months ago

I have already encountered the same problem. I'm not quite sure how the whole thing is handled here. I find it really confusing too how all these daemons are started, stopped and used. I think they really need to do a refactoring here. And use procd.? Unfortunately, I don't know how the whole thing is connected and which daemons are based on each others. We first need to shed some light on this.