lifecycle: consider an interface eligible for takedown if it has only one dependent (itself)

This commit is contained in:
Ariadne Conill 2020-09-08 15:50:32 -06:00
parent ca07082ff4
commit f139bc2416

View file

@ -274,12 +274,17 @@ handle_refcounting(struct lif_dict *state, struct lif_interface *iface, bool up)
else else
lif_state_unref_if(state, iface->ifname, iface); lif_state_unref_if(state, iface->ifname, iface);
#ifdef DEBUG_REFCOUNTING
fprintf(stderr, "handle_refcounting(): orig_refcount=%zu, refcount=%zu, direction=%s\n",
orig_refcount, iface->refcount, up ? "UP" : "DOWN");
#endif
/* if going up and orig_refcount > 0 -- we're already configured. */ /* if going up and orig_refcount > 0 -- we're already configured. */
if (up && orig_refcount > 0) if (up && orig_refcount > 0)
return true; return true;
/* if going down and iface->refcount > 0 -- we still have other dependents. */ /* if going down and iface->refcount > 1 -- we still have other dependents. */
if (!up && iface->refcount > 0) if (!up && iface->refcount > 1)
return true; return true;
/* we can change this interface -- no blocking dependents. */ /* we can change this interface -- no blocking dependents. */