0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-31 14:11:54 +00:00

Fixed displaying BGP and RIP attributes after recent reworks

This commit is contained in:
Maria Matejka 2022-06-27 12:14:05 +02:00
parent 0f2f5ac58c
commit d2142ad405
5 changed files with 29 additions and 23 deletions

View File

@ -1470,11 +1470,7 @@ bool t;
bgp_community = -empty-; bgp_community = -empty-;
bgp_originator_id = 9.7.5.3; bgp_originator_id = 9.7.5.3;
bgp_cluster_list = -empty-; bgp_cluster_list = -empty-;
t = defined(bgp_mp_reach_nlri);
t = defined(bgp_mp_unreach_nlri);
bgp_ext_community = --empty--; bgp_ext_community = --empty--;
bgp_as4_path = +empty+;
t = defined(bgp_as4_aggregator);
t = defined(bgp_aigp); t = defined(bgp_aigp);
bgp_large_community = ---empty---; bgp_large_community = ---empty---;
t = defined(bgp_mpls_label_stack); t = defined(bgp_mpls_label_stack);

View File

@ -172,6 +172,7 @@ struct ea_class {
btype type; /* Data type ID */ \ btype type; /* Data type ID */ \
uint readonly:1; /* This attribute can't be changed by filters */ \ uint readonly:1; /* This attribute can't be changed by filters */ \
uint conf:1; /* Requested by config */ \ uint conf:1; /* Requested by config */ \
uint hidden:1; /* Technical attribute, do not show, do not expose to filters */ \
void (*format)(const eattr *ea, byte *buf, uint size); \ void (*format)(const eattr *ea, byte *buf, uint size); \
void (*stored)(const eattr *ea); /* When stored into global hash */ \ void (*stored)(const eattr *ea); /* When stored into global hash */ \
void (*freed)(const eattr *ea); /* When released from global hash */ \ void (*freed)(const eattr *ea); /* When released from global hash */ \

View File

@ -436,7 +436,8 @@ ea_class_free(struct ea_class *cl)
/* No more ea class references. Unregister the attribute. */ /* No more ea class references. Unregister the attribute. */
idm_free(&ea_class_idm, cl->id); idm_free(&ea_class_idm, cl->id);
ea_class_global[cl->id] = NULL; ea_class_global[cl->id] = NULL;
ea_lex_unregister(cl); if (!cl->hidden)
ea_lex_unregister(cl);
} }
static void static void
@ -492,7 +493,8 @@ ea_register(pool *p, struct ea_class *def)
ASSERT_DIE(def->id < ea_class_max); ASSERT_DIE(def->id < ea_class_max);
ea_class_global[def->id] = def; ea_class_global[def->id] = def;
ea_lex_register(def); if (!def->hidden)
ea_lex_register(def);
return ea_ref_class(p, def); return ea_ref_class(p, def);
} }
@ -1017,37 +1019,40 @@ opaque_format(const struct adata *ad, byte *buf, uint size)
} }
static inline void static inline void
ea_show_int_set(struct cli *c, const struct adata *ad, int way, byte *pos, byte *buf, byte *end) ea_show_int_set(struct cli *c, const char *name, const struct adata *ad, int way, byte *buf)
{ {
int i = int_set_format(ad, way, 0, pos, end - pos); int nlen = strlen(name);
cli_printf(c, -1012, "\t%s", buf); int i = int_set_format(ad, way, 0, buf, CLI_MSG_SIZE - nlen - 3);
cli_printf(c, -1012, "\t%s: %s", name, buf);
while (i) while (i)
{ {
i = int_set_format(ad, way, i, buf, end - buf - 1); i = int_set_format(ad, way, i, buf, CLI_MSG_SIZE - 1);
cli_printf(c, -1012, "\t\t%s", buf); cli_printf(c, -1012, "\t\t%s", buf);
} }
} }
static inline void static inline void
ea_show_ec_set(struct cli *c, const struct adata *ad, byte *pos, byte *buf, byte *end) ea_show_ec_set(struct cli *c, const char *name, const struct adata *ad, byte *buf)
{ {
int i = ec_set_format(ad, 0, pos, end - pos); int nlen = strlen(name);
cli_printf(c, -1012, "\t%s", buf); int i = ec_set_format(ad, 0, buf, CLI_MSG_SIZE - nlen - 3);
cli_printf(c, -1012, "\t%s: %s", name, buf);
while (i) while (i)
{ {
i = ec_set_format(ad, i, buf, end - buf - 1); i = ec_set_format(ad, i, buf, CLI_MSG_SIZE - 1);
cli_printf(c, -1012, "\t\t%s", buf); cli_printf(c, -1012, "\t\t%s", buf);
} }
} }
static inline void static inline void
ea_show_lc_set(struct cli *c, const struct adata *ad, byte *pos, byte *buf, byte *end) ea_show_lc_set(struct cli *c, const char *name, const struct adata *ad, byte *buf)
{ {
int i = lc_set_format(ad, 0, pos, end - pos); int nlen = strlen(name);
cli_printf(c, -1012, "\t%s", buf); int i = lc_set_format(ad, 0, buf, CLI_MSG_SIZE - nlen - 3);
cli_printf(c, -1012, "\t%s: %s", name, buf);
while (i) while (i)
{ {
i = lc_set_format(ad, i, buf, end - buf - 1); i = lc_set_format(ad, i, buf, CLI_MSG_SIZE - 1);
cli_printf(c, -1012, "\t\t%s", buf); cli_printf(c, -1012, "\t\t%s", buf);
} }
} }
@ -1075,7 +1080,7 @@ ea_show(struct cli *c, const eattr *e)
struct ea_class *cls = ea_class_global[e->id]; struct ea_class *cls = ea_class_global[e->id];
ASSERT_DIE(cls); ASSERT_DIE(cls);
if (e->undef) if (e->undef || cls->hidden)
return; return;
else if (cls->format) else if (cls->format)
cls->format(e, buf, end - buf); cls->format(e, buf, end - buf);
@ -1098,13 +1103,13 @@ ea_show(struct cli *c, const eattr *e)
as_path_format(ad, pos, end - pos); as_path_format(ad, pos, end - pos);
break; break;
case T_CLIST: case T_CLIST:
ea_show_int_set(c, ad, 1, pos, buf, end); ea_show_int_set(c, cls->name, ad, 1, buf);
return; return;
case T_ECLIST: case T_ECLIST:
ea_show_ec_set(c, ad, pos, buf, end); ea_show_ec_set(c, cls->name, ad, buf);
return; return;
case T_LCLIST: case T_LCLIST:
ea_show_lc_set(c, ad, pos, buf, end); ea_show_lc_set(c, cls->name, ad, buf);
return; return;
default: default:
bsprintf(pos, "<type %02x>", e->type); bsprintf(pos, "<type %02x>", e->type);

View File

@ -1122,12 +1122,14 @@ static union bgp_attr_desc bgp_attr_table[BGP_ATTR_MAX] = {
[BA_MP_REACH_NLRI] = { [BA_MP_REACH_NLRI] = {
.name = "bgp_mp_reach_nlri", .name = "bgp_mp_reach_nlri",
.type = T_OPAQUE, .type = T_OPAQUE,
.hidden = 1,
.flags = BAF_OPTIONAL, .flags = BAF_OPTIONAL,
.decode = bgp_decode_mp_reach_nlri, .decode = bgp_decode_mp_reach_nlri,
}, },
[BA_MP_UNREACH_NLRI] = { [BA_MP_UNREACH_NLRI] = {
.name = "bgp_mp_unreach_nlri", .name = "bgp_mp_unreach_nlri",
.type = T_OPAQUE, .type = T_OPAQUE,
.hidden = 1,
.flags = BAF_OPTIONAL, .flags = BAF_OPTIONAL,
.decode = bgp_decode_mp_unreach_nlri, .decode = bgp_decode_mp_unreach_nlri,
}, },
@ -1142,6 +1144,7 @@ static union bgp_attr_desc bgp_attr_table[BGP_ATTR_MAX] = {
[BA_AS4_PATH] = { [BA_AS4_PATH] = {
.name = "bgp_as4_path", .name = "bgp_as4_path",
.type = T_PATH, .type = T_PATH,
.hidden = 1,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE, .flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.encode = bgp_encode_raw, .encode = bgp_encode_raw,
.decode = bgp_decode_as4_path, .decode = bgp_decode_as4_path,
@ -1149,6 +1152,7 @@ static union bgp_attr_desc bgp_attr_table[BGP_ATTR_MAX] = {
[BA_AS4_AGGREGATOR] = { [BA_AS4_AGGREGATOR] = {
.name = "bgp_as4_aggregator", .name = "bgp_as4_aggregator",
.type = T_OPAQUE, .type = T_OPAQUE,
.hidden = 1,
.flags = BAF_OPTIONAL | BAF_TRANSITIVE, .flags = BAF_OPTIONAL | BAF_TRANSITIVE,
.encode = bgp_encode_raw, .encode = bgp_encode_raw,
.decode = bgp_decode_as4_aggregator, .decode = bgp_decode_as4_aggregator,

View File

@ -1240,7 +1240,7 @@ rip_get_route_info(rte *rte, byte *buf)
static void static void
rip_tag_format(const eattr *a, byte *buf, uint buflen) rip_tag_format(const eattr *a, byte *buf, uint buflen)
{ {
bsnprintf(buf, buflen, "tag: %04x", a->u.data); bsnprintf(buf, buflen, "%04x", a->u.data);
} }
static struct ea_class ea_rip_metric = { static struct ea_class ea_rip_metric = {