From 987e6399de79fd6e7f7dcfb91e294afba4945c87 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 26 Jul 2020 02:32:00 -0600 Subject: [PATCH] libifupdown: interface: add support for automatic "use static" insertion --- libifupdown/interface-file.c | 2 ++ libifupdown/interface.c | 7 +++++++ libifupdown/interface.h | 1 + 3 files changed, 10 insertions(+) diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index d7c2835..a1e93a2 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -115,6 +115,8 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename) cur_iface->is_bridge = true; else if (!strcmp(executor, "bond")) cur_iface->is_bond = true; + else if (!strcmp(executor, "static")) + cur_iface->is_static = true; lif_dict_add(&cur_iface->vars, token, strdup(executor)); } diff --git a/libifupdown/interface.c b/libifupdown/interface.c index 7d59813..7ffa767 100644 --- a/libifupdown/interface.c +++ b/libifupdown/interface.c @@ -75,7 +75,14 @@ lif_interface_address_add(struct lif_interface *interface, const char *address) return false; } + if (!interface->is_static) + { + lif_dict_add(&interface->vars, "use", strdup("static")); + interface->is_static = true; + } + lif_dict_add(&interface->vars, "address", addr); + return true; } diff --git a/libifupdown/interface.h b/libifupdown/interface.h index ae7abfe..6e52308 100644 --- a/libifupdown/interface.h +++ b/libifupdown/interface.h @@ -52,6 +52,7 @@ struct lif_interface { bool is_auto; bool is_bridge; bool is_bond; + bool is_static; struct lif_dict vars;