summaryrefslogtreecommitdiff
path: root/nest/rt-show.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-05 18:08:37 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-26 12:34:26 +0200
commitf15f2fcee7eeb5a100bd204a0e67018e25953420 (patch)
tree12a99cfb8b6ee5aba555af282b356fb712457b18 /nest/rt-show.c
parentf2e725a76882ba6b75c3ce4fb3c760bd83462410 (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 'nest/rt-show.c')
-rw-r--r--nest/rt-show.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/nest/rt-show.c b/nest/rt-show.c
index be4c0186..32f7aa2d 100644
--- a/nest/rt-show.c
+++ b/nest/rt-show.c
@@ -45,11 +45,12 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
rta *a = e->attrs;
int sync_error = d->kernel ? krt_get_sync_error(d->kernel, e) : 0;
void (*get_route_info)(struct rte *, byte *buf);
- struct nexthop *nh;
+ eattr *nhea = ea_find(a->eattrs, &ea_gen_nexthop);
+ struct nexthop_adata *nhad = nhea ? (struct nexthop_adata *) nhea->u.ptr : NULL;
tm_format_time(tm, &config->tf_route, e->lastmod);
ip_addr a_from = ea_get_ip(a->eattrs, &ea_gen_from, IPA_NONE);
- if (ipa_nonzero(a_from) && !ipa_equal(a_from, a->nh.gw))
+ if (ipa_nonzero(a_from) && (!nhad || !ipa_equal(a_from, nhad->nh.gw)))
bsprintf(from, " from %I", a_from);
else
from[0] = 0;
@@ -71,7 +72,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
e->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info);
if (a->dest == RTD_UNICAST)
- for (nh = &(a->nh); nh; nh = nh->next)
+ NEXTHOP_WALK(nh, nhad)
{
char mpls[MPLS_MAX_LABEL_STACK*12 + 5], *lsp = mpls;
char *onlink = (nh->flags & RNF_ONLINK) ? " onlink" : "";
@@ -85,7 +86,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary
}
*lsp = '\0';
- if (a->nh.next)
+ if (!NEXTHOP_ONE(nhad))
bsprintf(weight, " weight %d", nh->weight + 1);
if (ipa_nonzero(nh->gw))