From cae16c5758586e4fe9a643b8335ea96bd16ff8a7 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 26 Jul 2020 02:59:15 -0600 Subject: [PATCH] simplify loopback --- libifupdown/interface-file.c | 2 -- libifupdown/interface.c | 4 +--- libifupdown/interface.h | 1 - libifupdown/lifecycle.c | 11 +---------- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index a1e93a2..5b28227 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -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")) diff --git a/libifupdown/interface.c b/libifupdown/interface.c index 7ffa767..fa149ed 100644 --- a/libifupdown/interface.c +++ b/libifupdown/interface.c @@ -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 diff --git a/libifupdown/interface.h b/libifupdown/interface.h index 6e52308..9ef9387 100644 --- a/libifupdown/interface.h +++ b/libifupdown/interface.h @@ -48,7 +48,6 @@ struct lif_interface { char *ifname; bool is_dhcp; - bool is_loopback; bool is_auto; bool is_bridge; bool is_bond; diff --git a/libifupdown/lifecycle.c b/libifupdown/lifecycle.c index c47f50c..c361df2 100644 --- a/libifupdown/lifecycle.c +++ b/libifupdown/lifecycle.c @@ -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 */