ifupdown: Don't configure errornous interfaces.

Do not configure interfaces which have a configuration know to be broken.
  Currently this only happens when using "inherit" to an non-existing iface
  or to an iface and not a template, and having allow_any_iface_as_template
  set to 0.

  In those cases broken ifaces will not be configured unless ifup/ifdown is
  invoked with --force.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
Maximilian Wilhelm 2020-09-25 02:15:16 +02:00
parent fafce2f262
commit 8dc2295006
5 changed files with 76 additions and 24 deletions

View file

@ -3,6 +3,7 @@
* Purpose: management of interface lifecycle (bring up, takedown, reload)
*
* Copyright (c) 2020 Ariadne Conill <ariadne@dereferenced.org>
* Copyright (c) 2020 Maximilian Wilhelm <max@sdn.clinic>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -313,6 +314,19 @@ handle_dependents(const struct lif_execute_opts *opts, struct lif_interface *par
{
struct lif_interface *iface = lif_interface_collection_find(collection, tokenp);
if (iface->has_config_error)
{
if (opts->force)
fprintf (stderr, "ifupdown: (de)configuring dependent interface %s (of %s) despite config errors\n",
iface->ifname, parent->ifname);
else
{
fprintf (stderr, "ifupdown: skipping dependent interface %s (of %s) as it has config errors\n",
iface->ifname, parent->ifname);
continue;
}
}
/* if handle_refcounting returns true, it means we've already
* configured the interface, or it is too soon to deconfigure
* the interface.