From de207a59505643392e5dcf890e9a448a380cb7e4 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Wed, 14 Oct 2020 01:47:49 +0200 Subject: [PATCH] lifecyle: Use lif_address_format_cidr() for IF_ADDRESSES Previously IF_ADDRESSES would not contain a prefix length if the address entry in the configuration did not was in CIDR format but had a netmask set seperately. This commit fixes that behaviour and computes a CIDR netmask if necessary. Signed-off-by: Maximilian Wilhelm --- libifupdown/lifecycle.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libifupdown/lifecycle.c b/libifupdown/lifecycle.c index 4e59526..c12bb38 100644 --- a/libifupdown/lifecycle.c +++ b/libifupdown/lifecycle.c @@ -174,14 +174,13 @@ build_environment(char **envp[], const struct lif_execute_opts *opts, const stru LIF_DICT_FOREACH(iter, &iface->vars) { - const struct lif_dict_entry *entry = iter->data; + struct lif_dict_entry *entry = iter->data; if (!strcmp(entry->key, "address")) { - struct lif_address *addr = entry->data; char addrbuf[4096]; - if (!lif_address_unparse(addr, addrbuf, sizeof addrbuf, true)) + if (!lif_address_format_cidr(iface, entry, addrbuf, sizeof(addrbuf))) continue; /* Append address to buffer */