summaryrefslogtreecommitdiff
path: root/proto/ospf/ospf.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-05-24 14:51:05 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-05-24 14:51:05 +0200
commitfeae132e0f9bdc62d2b90bf676d12241af8e794c (patch)
tree2767cf9b23d85fdd7f029e27afe855f758430a60 /proto/ospf/ospf.c
parentb24b781117179f301116837f0a39468343e4805b (diff)
Do not initialize route metrics in import_control hook
During route export, the receiving protocol often initialized route metrics to default value in its import_control hook before export filter was executed. This is inconsistent with the expectation that an export filter would process the same route as one in the routing table and it breaks setting these metrics before (e.g. for static routes directly in static protocol). The patch removes the initialization of route metrics in import_control hook, the default values are already handled in rt_notify hook called after export filters. The patch also changed the behavior of OSPF to keep metrics when a route is reannounced between OSPF instances (to be consistent with other protocols) and the behavior when both ospf_metric1 and ospf_metric2 are specified (to have more expected behavior).
Diffstat (limited to 'proto/ospf/ospf.c')
-rw-r--r--proto/ospf/ospf.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index df6c452e..0a9efd19 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -446,34 +446,21 @@ ospf_disp(timer * timer)
* import to the filters.
*/
static int
-ospf_import_control(struct proto *P, rte **new, ea_list **attrs, struct linpool *pool)
+ospf_import_control(struct proto *P, rte **new, ea_list **attrs UNUSED, struct linpool *pool UNUSED)
{
struct ospf_proto *p = (struct ospf_proto *) P;
struct ospf_area *oa = ospf_main_area(p);
rte *e = *new;
+ /* Reject our own routes */
if (e->attrs->src->proto == P)
- return -1; /* Reject our own routes */
+ return -1;
+ /* Do not export routes to stub areas */
if (oa_is_stub(oa))
- return -1; /* Do not export routes to stub areas */
-
- ea_list *ea = e->attrs->eattrs;
- u32 m0 = ea_get_int(ea, EA_GEN_IGP_METRIC, LSINFINITY);
- u32 m1 = MIN(m0, LSINFINITY);
- u32 m2 = 10000;
- u32 tag = 0;
-
- /* Hack for setting attributes directly in static protocol */
- if (e->attrs->source == RTS_STATIC)
- {
- m1 = ea_get_int(ea, EA_OSPF_METRIC1, m1);
- m2 = ea_get_int(ea, EA_OSPF_METRIC2, 10000);
- tag = ea_get_int(ea, EA_OSPF_TAG, 0);
- }
+ return -1;
- *attrs = ospf_build_attrs(*attrs, pool, m1, m2, tag, 0);
- return 0; /* Leave decision to the filters */
+ return 0;
}
static struct ea_list *