state: add ability to sync a state to if_collection cache

This commit is contained in:
Ariadne Conill 2020-07-24 04:48:50 -06:00
parent a3c138b9b2
commit e0a7444640
3 changed files with 25 additions and 2 deletions

View file

@ -114,3 +114,19 @@ lif_state_lookup(struct lif_dict *state, struct lif_dict *if_collection, const c
return if_entry->data;
}
bool
lif_state_sync(struct lif_dict *state, struct lif_dict *if_collection)
{
struct lif_node *iter;
LIF_DICT_FOREACH(iter, state)
{
struct lif_dict_entry *entry = iter->data;
struct lif_interface *iface = lif_interface_collection_find(if_collection, entry->key);
iface->is_up = true;
}
return true;
}

View file

@ -26,5 +26,6 @@ extern void lif_state_delete(struct lif_dict *state, const char *ifname);
extern void lif_state_write(const struct lif_dict *state, FILE *f);
extern bool lif_state_write_path(const struct lif_dict *state, const char *path);
extern struct lif_interface *lif_state_lookup(struct lif_dict *state, struct lif_dict *if_collection, const char *ifname);
extern bool lif_state_sync(struct lif_dict *state, struct lif_dict *if_collection);
#endif