interface: make interface-to-template conversion a config option (defaulting to enabled)
This commit is contained in:
parent
243a9b92ce
commit
60d0ed34b8
4 changed files with 13 additions and 2 deletions
8
dist/ifupdown-ng.conf.example
vendored
8
dist/ifupdown-ng.conf.example
vendored
|
@ -15,3 +15,11 @@ allow_addon_scripts = 1
|
||||||
# to disable this setting in order to require inheritance from specified
|
# to disable this setting in order to require inheritance from specified
|
||||||
# templates.
|
# templates.
|
||||||
allow_any_iface_as_template = 1
|
allow_any_iface_as_template = 1
|
||||||
|
|
||||||
|
# implicit_template_conversion:
|
||||||
|
# In some legacy configs, a template may be declared as an iface, and
|
||||||
|
# ifupdown-ng automatically converts those declarations to a proper
|
||||||
|
# template. If this setting is disabled, inheritance will continue to
|
||||||
|
# work against non-template interfaces without converting them to a
|
||||||
|
# template.
|
||||||
|
implicit_template_conversion = 1
|
||||||
|
|
|
@ -45,6 +45,7 @@ set_bool_value(const char *key, const char *value, void *opaque)
|
||||||
static struct lif_config_handler handlers[] = {
|
static struct lif_config_handler handlers[] = {
|
||||||
{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts},
|
{"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},
|
{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template},
|
||||||
|
{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion},
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
struct lif_config_file {
|
struct lif_config_file {
|
||||||
bool allow_addon_scripts;
|
bool allow_addon_scripts;
|
||||||
bool allow_any_iface_as_template;
|
bool allow_any_iface_as_template;
|
||||||
|
bool implicit_template_conversion;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct lif_config_file lif_config;
|
extern struct lif_config_file lif_config;
|
||||||
|
|
|
@ -243,8 +243,9 @@ lif_interface_collection_inherit(struct lif_interface *interface, struct lif_dic
|
||||||
if (!lif_config.allow_any_iface_as_template && !parent->is_template)
|
if (!lif_config.allow_any_iface_as_template && !parent->is_template)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* explicitly convert any interface we are inheriting from into a template */
|
/* maybe convert any interface we are inheriting from into a template */
|
||||||
parent->is_template = true;
|
if (lif_config.implicit_template_conversion)
|
||||||
|
parent->is_template = true;
|
||||||
|
|
||||||
lif_dict_add(&interface->vars, "inherit", strdup(ifname));
|
lif_dict_add(&interface->vars, "inherit", strdup(ifname));
|
||||||
interface->is_bond = parent->is_bond;
|
interface->is_bond = parent->is_bond;
|
||||||
|
|
Loading…
Reference in a new issue