ifupdown: skip interface config/deconfig based on refcounts
This commit is contained in:
parent
8de83fdd9a
commit
efe9b60e37
1 changed files with 28 additions and 0 deletions
|
@ -93,6 +93,26 @@ acquire_state_lock(const char *state_path, const char *lifname)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
skip_interface(struct lif_interface *iface, const char *ifname)
|
||||||
|
{
|
||||||
|
if (up && iface->refcount > 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: skipping %s (already configured), use --force to force configuration\n",
|
||||||
|
argv0, ifname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!up && iface->refcount == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: skipping %s (already deconfigured), use --force to force deconfiguration\n",
|
||||||
|
argv0, ifname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname)
|
change_interface(struct lif_interface *iface, struct lif_dict *collection, struct lif_dict *state, const char *ifname)
|
||||||
{
|
{
|
||||||
|
@ -104,6 +124,14 @@ change_interface(struct lif_interface *iface, struct lif_dict *collection, struc
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skip_interface(iface, ifname))
|
||||||
|
{
|
||||||
|
if (lockfd != -1)
|
||||||
|
close(lockfd);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (exec_opts.verbose)
|
if (exec_opts.verbose)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: changing state of interface %s to '%s'\n",
|
fprintf(stderr, "%s: changing state of interface %s to '%s'\n",
|
||||||
|
|
Loading…
Reference in a new issue