summaryrefslogtreecommitdiff
path: root/proto/ospf
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-03-14 17:22:22 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-03-14 17:31:40 +0100
commit875cc073b067f295cccc668008e10218f8e98dd3 (patch)
tree28f65beeab81c8b422dd9d7c18a4f4f331adeb31 /proto/ospf
parent9aa77fccebc4d84b5e1496884cd124d09893041b (diff)
Nest: Update handling of temporary attributes
The temporary atttributes are no longer removed by ea_do_prune(), but they are undefined by store_tmp_attrs() protocol hooks. This fixes several bugs where temporary attributes were removed when they should not or not removed when they should be. The flag EAF_TEMP is no longer needed and was removed. Update all protocol make_tmp_attrs() / store_tmp_attrs() hooks to use helper functions and to handle unset attributes properly. Also fix some related bugs like improper handling of empty eattr list.
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/ospf.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index def73cb6..f3eabb47 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -106,8 +106,8 @@
#include "ospf.h"
static int ospf_preexport(struct proto *P, rte **new, struct linpool *pool);
-static struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
-static void ospf_store_tmp_attrs(struct rte *rt);
+static void ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
+static void ospf_store_tmp_attrs(struct rte *rt, struct linpool *pool);
static void ospf_reload_routes(struct channel *C);
static int ospf_rte_better(struct rte *new, struct rte *old);
static int ospf_rte_same(struct rte *new, struct rte *old);
@@ -438,26 +438,20 @@ ospf_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED)
return 0;
}
-static struct ea_list *
+static void
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
{
- struct ea_list *e = lp_alloc(pool, sizeof(struct ea_list) + 4 * sizeof(eattr));
-
- e->next = NULL;
- e->flags = EALF_SORTED;
- e->count = 0;
-
- rte_make_tmp_attr(rt, e, EA_OSPF_METRIC1, EAF_TYPE_INT, rt->u.ospf.metric1);
- rte_make_tmp_attr(rt, e, EA_OSPF_METRIC2, EAF_TYPE_INT, rt->u.ospf.metric2);
- rte_make_tmp_attr(rt, e, EA_OSPF_TAG, EAF_TYPE_INT, rt->u.ospf.tag);
- rte_make_tmp_attr(rt, e, EA_OSPF_ROUTER_ID, EAF_TYPE_ROUTER_ID, rt->u.ospf.router_id);
-
- return e;
+ rte_init_tmp_attrs(rt, pool, 4);
+ rte_make_tmp_attr(rt, EA_OSPF_METRIC1, EAF_TYPE_INT, rt->u.ospf.metric1);
+ rte_make_tmp_attr(rt, EA_OSPF_METRIC2, EAF_TYPE_INT, rt->u.ospf.metric2);
+ rte_make_tmp_attr(rt, EA_OSPF_TAG, EAF_TYPE_INT, rt->u.ospf.tag);
+ rte_make_tmp_attr(rt, EA_OSPF_ROUTER_ID, EAF_TYPE_ROUTER_ID, rt->u.ospf.router_id);
}
static void
-ospf_store_tmp_attrs(struct rte *rt)
+ospf_store_tmp_attrs(struct rte *rt, struct linpool *pool)
{
+ rte_init_tmp_attrs(rt, pool, 4);
rt->u.ospf.metric1 = rte_store_tmp_attr(rt, EA_OSPF_METRIC1);
rt->u.ospf.metric2 = rte_store_tmp_attr(rt, EA_OSPF_METRIC2);
rt->u.ospf.tag = rte_store_tmp_attr(rt, EA_OSPF_TAG);