diff options
author | Maria Matejka <mq@ucw.cz> | 2022-05-05 18:08:37 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-05-26 12:34:26 +0200 |
commit | f15f2fcee7eeb5a100bd204a0e67018e25953420 (patch) | |
tree | 12a99cfb8b6ee5aba555af282b356fb712457b18 /proto/babel/babel.c | |
parent | f2e725a76882ba6b75c3ce4fb3c760bd83462410 (diff) |
Moved nexthop from struct rta to extended attribute.
This doesn't do anything more than to put the whole structure inside
adata. The overall performance is certainly going downhill; we'll
optimize this later.
Anyway, this is one of the latest items inside rta and in several
commits we may drop rta completely and move to eattrs-only routes.
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r-- | proto/babel/babel.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c index a7dcee09..9a43f484 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -643,15 +643,34 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) if (r) { + struct nexthop_adata nhad = { + .nh = { + .gw = r->next_hop, + .iface = r->neigh->ifa->iface, + }, + .ad = { + .length = sizeof nhad - sizeof nhad.ad, + }, + }; + + /* + * If we cannot find a reachable neighbour, set the entry to be onlink. This + * makes it possible to, e.g., assign /32 addresses on a mesh interface and + * have routing work. + */ + if (!neigh_find(&p->p, r->next_hop, r->neigh->ifa->iface, 0)) + nhad.nh.flags = RNF_ONLINK; + struct { ea_list l; - eattr a[6]; + eattr a[7]; } eattrs = { .l.count = ARRAY_SIZE(eattrs.a), .a = { EA_LITERAL_EMBEDDED(&ea_gen_preference, 0, c->preference), EA_LITERAL_STORE_ADATA(&ea_gen_from, 0, &r->neigh->addr, sizeof(r->neigh->addr)), EA_LITERAL_EMBEDDED(&ea_gen_source, 0, RTS_BABEL), + EA_LITERAL_STORE_ADATA(&ea_gen_nexthop, 0, nhad.ad.data, nhad.ad.length), EA_LITERAL_EMBEDDED(&ea_babel_metric, 0, r->metric), EA_LITERAL_STORE_ADATA(&ea_babel_router_id, 0, &r->router_id, sizeof(r->router_id)), EA_LITERAL_EMBEDDED(&ea_babel_seqno, 0, r->seqno), @@ -660,19 +679,9 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) rta a0 = { .dest = RTD_UNICAST, - .nh.gw = r->next_hop, - .nh.iface = r->neigh->ifa->iface, .eattrs = &eattrs.l, }; - /* - * If we cannot find a reachable neighbour, set the entry to be onlink. This - * makes it possible to, e.g., assign /32 addresses on a mesh interface and - * have routing work. - */ - if (!neigh_find(&p->p, r->next_hop, r->neigh->ifa->iface, 0)) - a0.nh.flags = RNF_ONLINK; - rta *a = rta_lookup(&a0); rte *rte = rte_get_temp(a, p->p.main_source); |