1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Explicit definition structures of route attributes

Changes in internal API:

* Every route attribute must be defined as struct ea_class somewhere.
* Registration of route attributes known at startup must be done by
  ea_register_init() from protocol build functions.
* Every attribute has now its symbol registered in a global symbol table
  defined as SYM_ATTRIBUTE
* All attribute ID's are dynamically allocated.
* Attribute value custom formatting hook is defined in the ea_class.
* Attribute names are the same for display and filters, always prefixed
  by protocol name.

Also added some unit testing code for filters with route attributes.
This commit is contained in:
Maria Matejka
2022-03-19 16:23:42 +01:00
parent 165156beeb
commit 17f91f9e6e
54 changed files with 1056 additions and 878 deletions

View File

@@ -232,7 +232,6 @@ kif_copy_config(struct proto_config *dest, struct proto_config *src)
struct protocol proto_unix_iface = {
.name = "Device",
.template = "device%d",
.class = PROTOCOL_DEVICE,
.proto_size = sizeof(struct kif_proto),
.config_size = sizeof(struct kif_config),
.preconfig = kif_preconfig,
@@ -287,7 +286,7 @@ static struct tbf rl_alien = TBF_DEFAULT_LOG_LIMITS;
static inline u32
krt_metric(rte *a)
{
eattr *ea = ea_find(a->attrs->eattrs, EA_KRT_METRIC);
eattr *ea = ea_find(a->attrs->eattrs, &ea_krt_metric);
return ea ? ea->u.data : 0;
}
@@ -1133,24 +1132,15 @@ krt_copy_config(struct proto_config *dest, struct proto_config *src)
krt_sys_copy_config(d, s);
}
static int
krt_get_attr(const eattr *a, byte *buf, int buflen)
{
switch (a->id)
{
case EA_KRT_SOURCE:
bsprintf(buf, "source");
return GA_NAME;
case EA_KRT_METRIC:
bsprintf(buf, "metric");
return GA_NAME;
default:
return krt_sys_get_attr(a, buf, buflen);
}
}
struct ea_class ea_krt_source = {
.name = "krt_source",
.type = T_INT,
};
struct ea_class ea_krt_metric = {
.name = "krt_metric",
.type = T_INT,
};
#ifdef CONFIG_IP6_SADR_KERNEL
#define MAYBE_IP6_SADR NB_IP6_SADR
@@ -1167,7 +1157,6 @@ krt_get_attr(const eattr *a, byte *buf, int buflen)
struct protocol proto_unix_kernel = {
.name = "Kernel",
.template = "kernel%d",
.class = PROTOCOL_KERNEL,
.preference = DEF_PREF_INHERITED,
.channel_mask = NB_IP | MAYBE_IP6_SADR | MAYBE_MPLS,
.proto_size = sizeof(struct krt_proto),
@@ -1179,7 +1168,6 @@ struct protocol proto_unix_kernel = {
.shutdown = krt_shutdown,
.reconfigure = krt_reconfigure,
.copy_config = krt_copy_config,
.get_attr = krt_get_attr,
#ifdef KRT_ALLOW_LEARN
.dump = krt_dump,
#endif
@@ -1189,4 +1177,9 @@ void
krt_build(void)
{
proto_build(&proto_unix_kernel);
EA_REGISTER_ALL(
&ea_krt_source,
&ea_krt_metric,
);
}