change lif_interface.is_up to lif_interface.refcount

This commit is contained in:
Ariadne Conill 2020-09-08 14:41:25 -06:00
parent 30fa4c4a2e
commit 3b10494b40
4 changed files with 7 additions and 7 deletions

View file

@ -63,7 +63,7 @@ print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, st
if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname)) if (!lif_lifecycle_query_dependents(&exec_opts, iface, iface->ifname))
return; return;
if (iface->is_up) if (iface->refcount > 0)
return; return;
if (parent != NULL) if (parent != NULL)
@ -87,7 +87,7 @@ print_interface_dot(struct lif_dict *collection, struct lif_interface *iface, st
struct lif_interface *child_if = lif_interface_collection_find(collection, tokenp); struct lif_interface *child_if = lif_interface_collection_find(collection, tokenp);
print_interface_dot(collection, child_if, iface); print_interface_dot(collection, child_if, iface);
child_if->is_up = true; child_if->refcount++;
} }
} }

View file

@ -53,7 +53,7 @@ struct lif_interface {
struct lif_dict vars; struct lif_dict vars;
bool is_up; size_t refcount; /* >= 0 if up, else 0 */
}; };
#define LIF_INTERFACE_COLLECTION_FOREACH(iter, collection) \ #define LIF_INTERFACE_COLLECTION_FOREACH(iter, collection) \

View file

@ -279,7 +279,7 @@ handle_dependents(const struct lif_execute_opts *opts, struct lif_interface *par
struct lif_interface *iface = lif_interface_collection_find(collection, tokenp); struct lif_interface *iface = lif_interface_collection_find(collection, tokenp);
/* already up or down, skip */ /* already up or down, skip */
if (up == iface->is_up) if (up && iface->refcount > 0)
{ {
if (opts->verbose) if (opts->verbose)
fprintf(stderr, "ifupdown: skipping dependent interface %s (of %s)\n", fprintf(stderr, "ifupdown: skipping dependent interface %s (of %s)\n",
@ -328,7 +328,7 @@ lif_lifecycle_run(const struct lif_execute_opts *opts, struct lif_interface *ifa
lif_state_upsert(state, lifname, iface); lif_state_upsert(state, lifname, iface);
iface->is_up = true; iface->refcount++;
} }
else else
{ {
@ -347,7 +347,7 @@ lif_lifecycle_run(const struct lif_execute_opts *opts, struct lif_interface *ifa
lif_state_delete(state, lifname); lif_state_delete(state, lifname);
iface->is_up = false; iface->refcount--;
} }
return true; return true;

View file

@ -126,7 +126,7 @@ lif_state_sync(struct lif_dict *state, struct lif_dict *if_collection)
struct lif_dict_entry *entry = iter->data; struct lif_dict_entry *entry = iter->data;
struct lif_interface *iface = lif_interface_collection_find(if_collection, entry->key); struct lif_interface *iface = lif_interface_collection_find(if_collection, entry->key);
iface->is_up = true; iface->refcount++;
} }
return true; return true;