libifupdown: interface: add support for automatic "use static" insertion

This commit is contained in:
Ariadne Conill 2020-07-26 02:32:00 -06:00
parent 052156ac09
commit 987e6399de
3 changed files with 10 additions and 0 deletions

View file

@ -115,6 +115,8 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename)
cur_iface->is_bridge = true; cur_iface->is_bridge = true;
else if (!strcmp(executor, "bond")) else if (!strcmp(executor, "bond"))
cur_iface->is_bond = true; cur_iface->is_bond = true;
else if (!strcmp(executor, "static"))
cur_iface->is_static = true;
lif_dict_add(&cur_iface->vars, token, strdup(executor)); lif_dict_add(&cur_iface->vars, token, strdup(executor));
} }

View file

@ -75,7 +75,14 @@ lif_interface_address_add(struct lif_interface *interface, const char *address)
return false; return false;
} }
if (!interface->is_static)
{
lif_dict_add(&interface->vars, "use", strdup("static"));
interface->is_static = true;
}
lif_dict_add(&interface->vars, "address", addr); lif_dict_add(&interface->vars, "address", addr);
return true; return true;
} }

View file

@ -52,6 +52,7 @@ struct lif_interface {
bool is_auto; bool is_auto;
bool is_bridge; bool is_bridge;
bool is_bond; bool is_bond;
bool is_static;
struct lif_dict vars; struct lif_dict vars;