interface: add lif_interface_finalize() which rewrites addresses as CIDR when an interface stanza ends

This commit is contained in:
Ariadne Conill 2020-12-02 11:38:39 -07:00
parent 0dd7756df2
commit c4d9d6fd06
3 changed files with 56 additions and 8 deletions

View file

@ -263,6 +263,12 @@ handle_iface(struct lif_interface_file_parse_state *state, char *token, char *bu
return true;
}
/* if we have a current interface, call lif_interface_finalize to finalize any
* address properties by converting them to CIDR and flushing the netmask property.
*/
if (state->cur_iface != NULL)
lif_interface_finalize(state->cur_iface);
state->cur_iface = lif_interface_collection_find(state->collection, ifname);
if (state->cur_iface == NULL)
{
@ -501,6 +507,11 @@ lif_interface_file_parse(struct lif_interface_file_parse_state *state, const cha
}
fclose(f);
/* finalize any open interface */
if (state->cur_iface != NULL)
lif_interface_finalize(state->cur_iface);
state->cur_filename = old_filename;
state->cur_lineno = old_lineno;
return true;