Merge pull request #38 from ifupdown-ng/bugfix/vlan-complex
vlan and assorted fixes
This commit is contained in:
commit
3997b6a952
8 changed files with 86 additions and 28 deletions
|
|
@ -35,6 +35,9 @@ struct lif_dict_entry {
|
|||
#define LIF_DICT_FOREACH_SAFE(iter, iter_next, dict) \
|
||||
LIF_LIST_FOREACH_SAFE((iter), (iter_next), (dict)->list.head)
|
||||
|
||||
#define LIF_DICT_FOREACH_REVERSE(iter, dict) \
|
||||
LIF_LIST_FOREACH_REVERSE((iter), (dict)->list.tail)
|
||||
|
||||
typedef int (*lif_dict_cmp_t)(const void *, const void *);
|
||||
|
||||
extern void lif_dict_init(struct lif_dict *dict);
|
||||
|
|
|
|||
|
|
@ -43,21 +43,33 @@ handle_commands_for_phase(const struct lif_execute_opts *opts, char *const envp[
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
handle_single_executor_for_phase(const struct lif_dict_entry *entry, const struct lif_execute_opts *opts, char *const envp[])
|
||||
{
|
||||
if (strcmp(entry->key, "use"))
|
||||
return true;
|
||||
|
||||
const char *cmd = entry->data;
|
||||
if (!lif_maybe_run_executor(opts, envp, cmd))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
handle_executors_for_phase(const struct lif_execute_opts *opts, char *const envp[], struct lif_interface *iface)
|
||||
handle_executors_for_phase(const struct lif_execute_opts *opts, char *const envp[], struct lif_interface *iface, bool up)
|
||||
{
|
||||
struct lif_node *iter;
|
||||
|
||||
LIF_DICT_FOREACH(iter, &iface->vars)
|
||||
if (up)
|
||||
{
|
||||
struct lif_dict_entry *entry = iter->data;
|
||||
|
||||
if (strcmp(entry->key, "use"))
|
||||
continue;
|
||||
|
||||
const char *cmd = entry->data;
|
||||
if (!lif_maybe_run_executor(opts, envp, cmd))
|
||||
return false;
|
||||
LIF_DICT_FOREACH(iter, &iface->vars)
|
||||
handle_single_executor_for_phase(iter->data, opts, envp);
|
||||
}
|
||||
else
|
||||
{
|
||||
LIF_DICT_FOREACH_REVERSE(iter, &iface->vars)
|
||||
handle_single_executor_for_phase(iter->data, opts, envp);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -219,7 +231,7 @@ lif_lifecycle_run_phase(const struct lif_execute_opts *opts, struct lif_interfac
|
|||
|
||||
build_environment(&envp, opts, iface, lifname, phase, up ? "start" : "stop");
|
||||
|
||||
if (!handle_executors_for_phase(opts, envp, iface))
|
||||
if (!handle_executors_for_phase(opts, envp, iface, up))
|
||||
goto handle_error;
|
||||
|
||||
if (!handle_commands_for_phase(opts, envp, iface, phase))
|
||||
|
|
@ -255,7 +267,11 @@ handle_dependents(const struct lif_execute_opts *opts, struct lif_interface *par
|
|||
|
||||
/* already up or down, skip */
|
||||
if (up == iface->is_up)
|
||||
{
|
||||
fprintf(stderr, "ifupdown: skipping dependent interface %s (of %s)\n",
|
||||
iface->ifname, parent->ifname);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opts->verbose)
|
||||
fprintf(stderr, "ifupdown: changing state of dependent interface %s (of %s) to %s\n",
|
||||
|
|
|
|||
|
|
@ -42,4 +42,7 @@ extern void lif_node_delete(struct lif_node *node, struct lif_list *list);
|
|||
#define LIF_LIST_FOREACH_SAFE(iter, iter_next, head) \
|
||||
for ((iter) = (head), (iter_next) = (iter)->next; (iter) != NULL; (iter) = (iter_next), (iter_next) = (iter) != NULL ? (iter)->next : NULL)
|
||||
|
||||
#define LIF_LIST_FOREACH_REVERSE(iter, tail) \
|
||||
for ((iter) = (tail); (iter) != NULL; (iter) = (iter)->prev)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue