From 950775f6fa3d569a9d7cd05e33538d35e895d688 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sun, 15 May 2022 18:09:30 +0200 Subject: Route destination field merged with nexthop attribute; splitting flowspec validation result out. As there is either a nexthop or another destination specification (or othing in case of ROAs and Flowspec), it may be merged together. This code is somehow quirky and should be replaced in future by better implementation of nexthop. Also flowspec validation result has its own attribute now as it doesn't have anything to do with route nexthop. --- proto/babel/babel.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'proto/babel/babel.c') diff --git a/proto/babel/babel.c b/proto/babel/babel.c index 9a43f484..b90dcd3f 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -677,10 +677,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) } }; - rta a0 = { - .dest = RTD_UNICAST, - .eattrs = &eattrs.l, - }; + rta a0 = { .eattrs = &eattrs.l, }; rta *a = rta_lookup(&a0); rte *rte = rte_get_temp(a, p->p.main_source); @@ -691,12 +688,11 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) else if (e->valid && (e->router_id != p->router_id)) { /* Unreachable */ - rta a0 = { - .dest = RTD_UNREACHABLE, - }; + rta a0 = {}; ea_set_attr_u32(&a0.eattrs, &ea_gen_preference, 0, 1); ea_set_attr_u32(&a0.eattrs, &ea_gen_source, 0, RTS_BABEL); + ea_set_dest(&a0.eattrs, 0, RTD_UNREACHABLE); rta *a = rta_lookup(&a0); rte *rte = rte_get_temp(a, p->p.main_source); @@ -2263,9 +2259,13 @@ babel_kick_timer(struct babel_proto *p) static int babel_preexport(struct proto *P, struct rte *new) { - struct rta *a = new->attrs; + if (new->src->proto != P) + return 0; + /* Reject our own unreachable routes */ - if ((a->dest == RTD_UNREACHABLE) && (new->src->proto == P)) + eattr *ea = ea_find(new->attrs->eattrs, &ea_gen_nexthop); + struct nexthop_adata *nhad = (void *) ea->u.ptr; + if (!NEXTHOP_IS_REACHABLE(nhad)) return -1; return 0; -- cgit v1.2.3