simplify loopback
This commit is contained in:
parent
9e4e17707f
commit
cae16c5758
4 changed files with 2 additions and 16 deletions
|
@ -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) */
|
/* pass requires as compatibility env vars to appropriate executors (bridge, bond) */
|
||||||
if (!strcmp(executor, "dhcp"))
|
if (!strcmp(executor, "dhcp"))
|
||||||
cur_iface->is_dhcp = true;
|
cur_iface->is_dhcp = true;
|
||||||
else if (!strcmp(executor, "loopback"))
|
|
||||||
cur_iface->is_loopback = true;
|
|
||||||
else if (!strcmp(executor, "bridge"))
|
else if (!strcmp(executor, "bridge"))
|
||||||
cur_iface->is_bridge = true;
|
cur_iface->is_bridge = true;
|
||||||
else if (!strcmp(executor, "bond"))
|
else if (!strcmp(executor, "bond"))
|
||||||
|
|
|
@ -141,10 +141,8 @@ lif_interface_collection_init(struct lif_dict *collection)
|
||||||
|
|
||||||
/* always enable loopback interface as part of a collection */
|
/* always enable loopback interface as part of a collection */
|
||||||
if_lo = lif_interface_collection_find(collection, "lo");
|
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_dict_add(&if_lo->vars, "use", strdup("loopback"));
|
||||||
|
|
||||||
lif_interface_address_add(if_lo, "127.0.0.1/8");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -48,7 +48,6 @@ struct lif_interface {
|
||||||
char *ifname;
|
char *ifname;
|
||||||
|
|
||||||
bool is_dhcp;
|
bool is_dhcp;
|
||||||
bool is_loopback;
|
|
||||||
bool is_auto;
|
bool is_auto;
|
||||||
bool is_bridge;
|
bool is_bridge;
|
||||||
bool is_bond;
|
bool is_bond;
|
||||||
|
|
|
@ -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))
|
if (!lif_execute_fmt(opts, NULL, "/sbin/ip link set up dev %s", lifname))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (iface->is_loopback)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
LIF_DICT_FOREACH(iter, &iface->vars)
|
LIF_DICT_FOREACH(iter, &iface->vars)
|
||||||
{
|
{
|
||||||
struct lif_dict_entry *entry = iter->data;
|
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;
|
struct lif_node *iter;
|
||||||
|
|
||||||
if (iface->is_loopback)
|
|
||||||
goto skip_addresses;
|
|
||||||
|
|
||||||
LIF_DICT_FOREACH(iter, &iface->vars)
|
LIF_DICT_FOREACH(iter, &iface->vars)
|
||||||
{
|
{
|
||||||
struct lif_dict_entry *entry = iter->data;
|
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))
|
if (!lif_execute_fmt(opts, NULL, "/sbin/ip link set down dev %s", lifname))
|
||||||
return false;
|
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);
|
lif_environment_push(&envp, "PHASE", phase);
|
||||||
|
|
||||||
/* try to provide $METHOD for ifupdown1 scripts if we can */
|
/* try to provide $METHOD for ifupdown1 scripts if we can */
|
||||||
if (iface->is_loopback)
|
if (iface->is_dhcp)
|
||||||
lif_environment_push(&envp, "METHOD", "loopback");
|
|
||||||
else if (iface->is_dhcp)
|
|
||||||
lif_environment_push(&envp, "METHOD", "dhcp");
|
lif_environment_push(&envp, "METHOD", "dhcp");
|
||||||
|
|
||||||
/* same for $MODE */
|
/* same for $MODE */
|
||||||
|
|
Loading…
Reference in a new issue