simplify loopback

This commit is contained in:
Ariadne Conill 2020-07-26 02:59:15 -06:00
parent 9e4e17707f
commit cae16c5758
4 changed files with 2 additions and 16 deletions

View file

@ -109,8 +109,6 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename)
/* pass requires as compatibility env vars to appropriate executors (bridge, bond) */
if (!strcmp(executor, "dhcp"))
cur_iface->is_dhcp = true;
else if (!strcmp(executor, "loopback"))
cur_iface->is_loopback = true;
else if (!strcmp(executor, "bridge"))
cur_iface->is_bridge = true;
else if (!strcmp(executor, "bond"))

View file

@ -141,10 +141,8 @@ 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 = if_lo->is_loopback = true;
if_lo->is_auto = true;
lif_dict_add(&if_lo->vars, "use", strdup("loopback"));
lif_interface_address_add(if_lo, "127.0.0.1/8");
}
void

View file

@ -48,7 +48,6 @@ struct lif_interface {
char *ifname;
bool is_dhcp;
bool is_loopback;
bool is_auto;
bool is_bridge;
bool is_bond;

View file

@ -143,9 +143,6 @@ handle_up(const struct lif_execute_opts *opts, struct lif_interface *iface, cons
if (!lif_execute_fmt(opts, NULL, "/sbin/ip link set up dev %s", lifname))
return false;
if (iface->is_loopback)
return true;
LIF_DICT_FOREACH(iter, &iface->vars)
{
struct lif_dict_entry *entry = iter->data;
@ -172,9 +169,6 @@ handle_down(const struct lif_execute_opts *opts, struct lif_interface *iface, co
{
struct lif_node *iter;
if (iface->is_loopback)
goto skip_addresses;
LIF_DICT_FOREACH(iter, &iface->vars)
{
struct lif_dict_entry *entry = iter->data;
@ -193,7 +187,6 @@ handle_down(const struct lif_execute_opts *opts, struct lif_interface *iface, co
}
}
skip_addresses:
if (!lif_execute_fmt(opts, NULL, "/sbin/ip link set down dev %s", lifname))
return false;
@ -219,9 +212,7 @@ lif_lifecycle_run_phase(const struct lif_execute_opts *opts, struct lif_interfac
lif_environment_push(&envp, "PHASE", phase);
/* try to provide $METHOD for ifupdown1 scripts if we can */
if (iface->is_loopback)
lif_environment_push(&envp, "METHOD", "loopback");
else if (iface->is_dhcp)
if (iface->is_dhcp)
lif_environment_push(&envp, "METHOD", "dhcp");
/* same for $MODE */