0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Nest: Show mergable routes in 'show route' output

Routes mergable with the best route are marked by '+'.
This commit is contained in:
Ondrej Zajicek (work) 2019-08-03 00:16:49 +02:00
parent b08ca3d958
commit 3e389e6786
4 changed files with 9 additions and 4 deletions

View File

@ -533,6 +533,7 @@ r_args:
$$ = cfg_allocz(sizeof(struct rt_show_data)); $$ = cfg_allocz(sizeof(struct rt_show_data));
init_list(&($$->tables)); init_list(&($$->tables));
$$->filter = FILTER_ACCEPT; $$->filter = FILTER_ACCEPT;
$$->show_mergable = 1;
} }
| r_args net_any { | r_args net_any {
$$ = $1; $$ = $1;

View File

@ -320,6 +320,7 @@ void rte_free(rte *);
rte *rte_do_cow(rte *); rte *rte_do_cow(rte *);
static inline rte * rte_cow(rte *r) { return (r->flags & REF_COW) ? rte_do_cow(r) : r; } static inline rte * rte_cow(rte *r) { return (r->flags & REF_COW) ? rte_do_cow(r) : r; }
rte *rte_cow_rta(rte *r, linpool *lp); rte *rte_cow_rta(rte *r, linpool *lp);
int rte_mergable(rte *pri, rte *sec);
void rt_dump(rtable *); void rt_dump(rtable *);
void rt_dump_all(void); void rt_dump_all(void);
int rt_feed_channel(struct channel *c); int rt_feed_channel(struct channel *c);
@ -353,7 +354,7 @@ struct rt_show_data {
struct proto *export_protocol; struct proto *export_protocol;
struct channel *export_channel; struct channel *export_channel;
struct config *running_on_config; struct config *running_on_config;
int export_mode, primary_only, filtered, stats, show_for; int export_mode, primary_only, filtered, stats, show_for, show_mergable;
int table_open; /* Iteration (fit) is open */ int table_open; /* Iteration (fit) is open */
int net_counter, rt_counter, show_counter, table_counter; int net_counter, rt_counter, show_counter, table_counter;

View File

@ -35,6 +35,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
byte tm[TM_DATETIME_BUFFER_SIZE], info[256]; byte tm[TM_DATETIME_BUFFER_SIZE], info[256];
rta *a = e->attrs; rta *a = e->attrs;
int primary = (e->net->routes == e) && rte_is_valid(e); int primary = (e->net->routes == e) && rte_is_valid(e);
int mergable = d->show_mergable && !primary && rte_mergable(e->net->routes, e);
int sync_error = (e->net->n.flags & KRF_SYNC_ERROR); int sync_error = (e->net->n.flags & KRF_SYNC_ERROR);
void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs);
struct nexthop *nh; struct nexthop *nh;
@ -63,8 +64,10 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
if (d->last_table != d->tab) if (d->last_table != d->tab)
rt_show_table(c, d); rt_show_table(c, d);
cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s", ia, rta_dest_name(a->dest), cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s",
a->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info); ia, rta_dest_name(a->dest), a->src->proto->name, tm, from,
primary ? (sync_error ? " !" : " *") : (mergable ? " +" : ""),
info);
if (a->dest == RTD_UNICAST) if (a->dest == RTD_UNICAST)
for (nh = &(a->nh); nh; nh = nh->next) for (nh = &(a->nh); nh; nh = nh->next)

View File

@ -453,7 +453,7 @@ rte_better(rte *new, rte *old)
return 0; return 0;
} }
static int int
rte_mergable(rte *pri, rte *sec) rte_mergable(rte *pri, rte *sec)
{ {
int (*mergable)(rte *, rte *); int (*mergable)(rte *, rte *);