Merge pull request #122 from ifupdown-ng/feature/configure-auto-executor-selection

Feature/configure auto executor selection
This commit is contained in:
Ariadne Conill 2020-11-04 21:53:42 -07:00 committed by GitHub
commit d250ab213c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 8 deletions

View file

@ -17,6 +17,13 @@ allow_addon_scripts = 1
# templates. Valid values are 0 and 1, the default is 1.
allow_any_iface_as_template = 1
# auto_executor_selection:
# Automatically determine which executors are needed to bring up an
# interface. An admin may choose to disable this setting and explicitly
# define which executors to use with `use` statements.
# Valid values are 0 and 1, the default is 1.
auto_executor_selection = 1
# compat_create_interfaces:
# Denotes where or not to create interfaces when compat_* settings are
# active and it would be necessary to create an interface to be fully

View file

@ -60,6 +60,12 @@ Currently the following settings are supported in
in order to require inheritance from specified templates.
Valid values are `0` and `1`, the default is `1`.
* `auto_executor_selection`: Automatically select executors based
on the presence of their config options. An admin may choose to
disable this setting in order to require explicitly enabling
executors through `use` statements. Valid values are `0` and `1`,
the default is `1`.
* `compat_create_interfaces`:
Denotes where or not to create interfaces when compat\_* settings are
active and it would be necessary to create an interface to be fully

View file

@ -17,6 +17,12 @@ configuration options.
performance improvements in setups where only ifupdown-ng executors
are used. Valid values are _0_ and _1_, the default is _1_.
*auto_executor_selection* _bool_
Automatically determine which executors to use. At present, this
is done by inserting `use` statements for the namespace a config
option has. The namespace is separated from the config option with
a dash (`-`). Valid values are _0_ and _1_, the default is _1_.
*use_hostname_for_dhcp* _bool_
Automatically learn the hostname property, used for DHCP
configuration by querying the system hostname using uname(2).

View file

@ -108,9 +108,9 @@ the system will only respond to certain keywords by default:
configuration data from _object_. Normally _object_
must be a *template*.
*use* _option_
Designates that an option should be used. See _OPTIONS_
section for more information on options.
*use* _executor_
Designates that an executor should be used. See _EXECUTORS_
section for more information on executors.
*pre-down* _command_
Runs _command_ before taking the interface down.
@ -133,11 +133,11 @@ the system will only respond to certain keywords by default:
Additional packages such as *bonding*, *bridge*, *tunnel*, *vrf* and
*vxlan* add additional keywords to this vocabulary.
# OPTIONS
# EXECUTORS
The *use* keyword designates that an _option_ should be used.
The *use* keyword designates that an _executor_ should be used.
This system is extendable by additional packages, but the
most common options are:
most common executors are:
*batman*
The interface is a B.A.T.M.A.N. adv. mesh interface.
@ -181,8 +181,12 @@ most common options are:
*wireguard*
The interface is a Wireguard VPN tunnel endpoint.
Check *interfaces-<option>(5)* for further informaton about a given
option and available configuration parameters.
Check *interfaces-<executor>(5)* for further informaton about a given
executor and available configuration parameters.
If the _auto\_executor\_selection_ ifupdown-ng.conf option is enabled,
*use* statements will automatically be added for executors when their
configuration statements are present in the interfaces file.
# EXAMPLES

View file

@ -21,6 +21,7 @@
struct lif_config_file lif_config = {
.allow_addon_scripts = true,
.allow_any_iface_as_template = true,
.auto_executor_selection = true,
.compat_create_interfaces = true,
.compat_ifupdown2_bridge_ports_inherit_vlans = true,
.implicit_template_conversion = true,
@ -49,6 +50,7 @@ set_bool_value(const char *key, const char *value, void *opaque)
static struct lif_config_handler handlers[] = {
{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts},
{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template},
{"auto_executor_selection", set_bool_value, &lif_config.auto_executor_selection},
{"compat_create_interfaces", set_bool_value, &lif_config.compat_create_interfaces},
{"compat_ifupdown2_bridge_ports_inherit_vlans", set_bool_value, &lif_config.compat_ifupdown2_bridge_ports_inherit_vlans},
{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion},

View file

@ -21,6 +21,7 @@
struct lif_config_file {
bool allow_addon_scripts;
bool allow_any_iface_as_template;
bool auto_executor_selection;
bool compat_create_interfaces;
bool compat_ifupdown2_bridge_ports_inherit_vlans;
bool implicit_template_conversion;

View file

@ -216,6 +216,9 @@ handle_generic(struct lif_interface_file_parse_state *state, char *token, char *
lif_dict_add(&state->cur_iface->vars, token, strdup(bufp));
if (!lif_config.auto_executor_selection)
return true;
/* Check if token looks like <word1>-<word*> and assume <word1> is an addon */
char *word_end = strchr(token, '-');
if (word_end != NULL)