simplify executor use statements
This commit is contained in:
parent
9caffc01c2
commit
d463d455da
3 changed files with 20 additions and 16 deletions
|
|
@ -63,10 +63,7 @@ lif_interface_init(struct lif_interface *interface, const char *ifname)
|
|||
|
||||
interface->ifname = strdup(ifname);
|
||||
|
||||
if (strchr(ifname, '.') == NULL)
|
||||
lif_dict_add(&interface->vars, "use", strdup("link"));
|
||||
else
|
||||
lif_dict_add(&interface->vars, "use", strdup("vlan"));
|
||||
lif_interface_use_executor(interface, strchr(ifname, '.') == NULL ? "link" : "vlan");
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -80,11 +77,8 @@ lif_interface_address_add(struct lif_interface *interface, const char *address)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!interface->is_static)
|
||||
{
|
||||
lif_dict_add(&interface->vars, "use", strdup("static"));
|
||||
interface->is_static = true;
|
||||
}
|
||||
lif_interface_use_executor(interface, "static");
|
||||
interface->is_static = true;
|
||||
|
||||
lif_dict_add(&interface->vars, "address", addr);
|
||||
|
||||
|
|
@ -137,6 +131,15 @@ lif_interface_fini(struct lif_interface *interface)
|
|||
free(interface->ifname);
|
||||
}
|
||||
|
||||
void
|
||||
lif_interface_use_executor(struct lif_interface *interface, const char *executor)
|
||||
{
|
||||
char *exec_addon = strdup(executor);
|
||||
|
||||
if (lif_dict_add_once(&interface->vars, "use", exec_addon, (lif_dict_cmp_t) strcmp) == NULL)
|
||||
free(exec_addon);
|
||||
}
|
||||
|
||||
void
|
||||
lif_interface_collection_init(struct lif_dict *collection)
|
||||
{
|
||||
|
|
@ -147,7 +150,7 @@ lif_interface_collection_init(struct lif_dict *collection)
|
|||
/* always enable loopback interface as part of a collection */
|
||||
if_lo = lif_interface_collection_find(collection, "lo");
|
||||
if_lo->is_auto = true;
|
||||
lif_dict_add(&if_lo->vars, "use", strdup("loopback"));
|
||||
lif_interface_use_executor(if_lo, "loopback");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue