From: Baptiste Jonglez Date: Thu, 28 Aug 2014 11:30:08 +0000 (+0200) Subject: babeld: Handle ignore options X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=a4f5570e79665ce41558ddbd4175dfc84e198744;p=feed%2Frouting.git babeld: Handle ignore options --- diff --git a/babeld/files/babeld.init b/babeld/files/babeld.init index 65cd1ce..ea4b348 100755 --- a/babeld/files/babeld.init +++ b/babeld/files/babeld.init @@ -90,7 +90,7 @@ list_cb() { option_cb "$@" } -config_cb() { +babel_config_cb() { local type="$1" local section="$2" case "$type" in @@ -109,9 +109,19 @@ config_cb() { local value="$2" cfg_append "interface $interface ${option//_/-} $value" } - # Also include an empty "interface $interface" statement, so - # that babeld operates on this interface. - cfg_append "interface $interface" + # Handle ignore options. + local _ignored + # This works because we loaded the whole configuration + # beforehand (see config_load below). + config_get_bool _ignored "$section" 'ignore' 0 + if [ "$_ignored" -eq 1 ] + then + option_cb() { return; } + else + # Also include an empty "interface $interface" statement, + # so that babeld operates on this interface. + cfg_append "interface $interface" + fi ;; *) # Don't use reset_cb, this would also reset config_cb @@ -124,9 +134,13 @@ start() { mkdir -p /var/lib # Start by emptying the generated config file >"$CONFIGFILE" + # First load the whole config file, without callbacks, so that we are + # aware of all "ignore" options in the second pass. + config_load babeld # Parse general and interface sections thanks to the "config_cb()" # callback. This allows to loop over all options without having to # know their name in advance. + config_cb() { babel_config_cb "$@"; } config_load babeld # Parse filters separately, since we know which options we expect config_foreach babel_filter filter