0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Merge branch 'mq-aggregator-for-v3' into thread-next

This commit is contained in:
Maria Matejka 2023-11-09 15:50:13 +01:00
commit c7cc1ccd2e
6 changed files with 118 additions and 4 deletions

View File

@ -90,6 +90,7 @@ CF_DECLS
struct sym_show_data *sd;
struct lsadb_show_data *ld;
struct mrt_dump_data *md;
struct mpls_show_ranges_cmd *msrc;
struct iface *iface;
void *g;
btime time;

View File

@ -61,7 +61,8 @@ Reply codes of BIRD command-line interface
1023 Show Babel interfaces
1024 Show Babel neighbors
1025 Show Babel entries
1026 Show threads
1026 Show MPLS ranges
1027 Show threads
8000 Reply too long
8001 Route not found

View File

@ -24,6 +24,7 @@ CF_KEYWORDS(MPLS, DOMAIN, LABEL, RANGE, STATIC, DYNAMIC, START, LENGTH, POLICY,
%type <i> mpls_label_policy
%type <cc> mpls_channel_start mpls_channel
%type <msrc> show_mpls_ranges_args
CF_GRAMMAR
@ -137,6 +138,59 @@ mpls_channel_opt_list:
mpls_channel_end: { mpls_channel_postconfig(this_channel); } channel_end;
show_mpls_ranges_args:
/* empty */
{
if (EMPTY_LIST(config->mpls_domains))
cf_error("No MPLS domain defined");
$$ = cfg_allocz(sizeof(struct mpls_show_ranges_cmd));
}
| show_mpls_ranges_args CF_SYM_KNOWN
{
if ($2->class == SYM_MPLS_DOMAIN)
{
if ($$->domain)
cf_error("Only one MPLS domain expected");
$$->domain = $2->mpls_domain;
}
else if ($2->class == SYM_MPLS_RANGE)
{
if ($$->range)
cf_error("Only one MPLS label range expected");
if ($$->domain != $2->mpls_range->domain)
cf_error("MPLS label range from different MPLS domain");
$$->domain = $2->mpls_range->domain;
$$->range = $2->mpls_range;
}
else
cf_error("MPLS domain or label range expected");
}
| show_mpls_ranges_args STATIC
{
if ($$->range)
cf_error("Only one MPLS label range expected");
$$->domain = $$->domain ?: cf_default_mpls_domain(config);
$$->range = $$->domain->static_range;
}
| show_mpls_ranges_args DYNAMIC
{
if ($$->range)
cf_error("Only one MPLS label range expected");
$$->domain = $$->domain ?: cf_default_mpls_domain(config);
$$->range = $$->domain->dynamic_range;
}
;
CF_CLI(SHOW MPLS RANGES, show_mpls_ranges_args, [<MPLS domain> | <MPLS range>], [[Show MPLS ranges]])
{ mpls_show_ranges($4); } ;
CF_CODE
CF_END

View File

@ -76,7 +76,6 @@
* and withdrawal of MPLS routes.
*
* TODO:
* - show mpls labels CLI command
* - label range non-intersection check
* - better range reconfigurations (allow reduce ranges over unused labels)
* - protocols should do route refresh instead of resetart when reconfiguration
@ -89,6 +88,7 @@
#include "nest/bird.h"
#include "nest/route.h"
#include "nest/mpls.h"
#include "nest/cli.h"
static struct mpls_range *mpls_new_range(struct mpls_domain *m, struct mpls_range_config *cf);
static struct mpls_range *mpls_find_range_(list *l, const char *name);
@ -1026,6 +1026,53 @@ mpls_rte_preimport(rte *new, const rte *old)
mpls_unlock_fec(old_mt.m, old_mt.fec);
}
static void
mpls_show_ranges_rng(struct mpls_show_ranges_cmd *cmd, struct mpls_range *r)
{
uint last = lmap_last_one_in_range(&cmd->dom->labels, r->lo, r->hi);
if (last == r->hi) last = 0;
cli_msg(-1026, "%-11s %7u %7u %7u %7u %7u",
r->name, r->lo, r->hi - r->lo, r->hi, r->label_count, last);
}
void
mpls_show_ranges_dom(struct mpls_show_ranges_cmd *cmd, struct mpls_domain *m)
{
if (cmd->dom)
cli_msg(-1026, "");
cmd->dom = m;
cli_msg(-1026, "MPLS domain %s:", m->name);
cli_msg(-1026, "%-11s %7s %7s %7s %7s %7s",
"Range", "Start", "Length", "End", "Labels", "Last");
if (cmd->range)
mpls_show_ranges_rng(cmd, cmd->range->range);
else
{
struct mpls_range *r;
WALK_LIST(r, m->ranges)
if (!r->removed)
mpls_show_ranges_rng(cmd, r);
}
}
void
mpls_show_ranges(struct mpls_show_ranges_cmd *cmd)
{
if (cmd->domain)
mpls_show_ranges_dom(cmd, cmd->domain->domain);
else
{
struct mpls_domain *m;
WALK_LIST(m, mpls_domains)
mpls_show_ranges_dom(cmd, m);
}
cli_msg(0, "");
}
struct ea_class ea_gen_mpls_policy = {
.name = "mpls_policy",
.type = T_ENUM_MPLS_POLICY,

View File

@ -167,4 +167,15 @@ void mpls_free_fec(struct mpls_fec_map *x, struct mpls_fec *fec);
void mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r);
void mpls_rte_preimport(rte *new, const rte *old);
struct mpls_show_ranges_cmd {
struct mpls_domain_config *domain;
struct mpls_range_config *range;
/* Runtime */
struct mpls_domain *dom;
};
void mpls_show_ranges(struct mpls_show_ranges_cmd *cmd);
#endif

View File

@ -1341,9 +1341,9 @@ cmd_show_threads_done(struct bird_thread_syncer *sync)
}
for (uint i = 0; i < tsd->line_pos - 1; i++)
cli_printf(tsd->cli, -1026, "%s", tsd->lines[i]);
cli_printf(tsd->cli, -1027, "%s", tsd->lines[i]);
cli_printf(tsd->cli, 1026, "%s", tsd->lines[tsd->line_pos-1]);
cli_printf(tsd->cli, 1027, "%s", tsd->lines[tsd->line_pos-1]);
cli_write_trigger(tsd->cli);
mb_free(tsd);
}