0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Merge commit 'db1eb46664d4c76d56dc55a63ce7abe853fc6862' into HEAD

This commit is contained in:
Maria Matejka 2023-12-08 11:33:43 +01:00
commit 8c19f8a209
7 changed files with 66 additions and 168 deletions

View File

@ -35,6 +35,7 @@ struct config {
u32 proto_default_debug; /* Default protocol debug mask */ u32 proto_default_debug; /* Default protocol debug mask */
u32 proto_default_mrtdump; /* Default protocol mrtdump mask */ u32 proto_default_mrtdump; /* Default protocol mrtdump mask */
u32 channel_default_debug; /* Default channel debug mask */ u32 channel_default_debug; /* Default channel debug mask */
u32 table_default_debug; /* Default table debug mask */
u16 filter_vstk, filter_estk; /* Filter stack depth */ u16 filter_vstk, filter_estk; /* Filter stack depth */
struct timeformat tf_route; /* Time format for 'show route' */ struct timeformat tf_route; /* Time format for 'show route' */
struct timeformat tf_proto; /* Time format for 'show protocol' */ struct timeformat tf_proto; /* Time format for 'show protocol' */
@ -45,7 +46,6 @@ struct config {
int cli_debug; /* Tracing of CLI connections and commands */ int cli_debug; /* Tracing of CLI connections and commands */
int latency_debug; /* I/O loop tracks duration of each event */ int latency_debug; /* I/O loop tracks duration of each event */
int table_debug; /* Track route propagation through tables */
u32 latency_limit; /* Events with longer duration are logged (us) */ u32 latency_limit; /* Events with longer duration are logged (us) */
u32 watchdog_warning; /* I/O loop watchdog limit for warning (us) */ u32 watchdog_warning; /* I/O loop watchdog limit for warning (us) */
u32 watchdog_timeout; /* Watchdog timeout (in seconds, 0 = disabled) */ u32 watchdog_timeout; /* Watchdog timeout (in seconds, 0 = disabled) */

View File

@ -85,6 +85,7 @@ struct rte_owner {
const char *name; const char *name;
u32 hash_key; u32 hash_key;
u32 uc; u32 uc;
u32 debug;
event_list *list; event_list *list;
event *prune; event *prune;
event *stop; event *stop;

View File

@ -152,7 +152,7 @@ proto_call_cmd_reload(struct proto_spec ps, int dir, const struct f_trie *trie)
CF_DECLS CF_DECLS
CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT, PIPE) CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT, PIPE)
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, TABLES, STATES, ROUTES, FILTERS)
CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS) CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS)
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED, RPKI) CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED, RPKI)
CF_KEYWORDS(PASSWORD, KEY, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, CHANNELS, INTERFACES) CF_KEYWORDS(PASSWORD, KEY, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, CHANNELS, INTERFACES)
@ -269,6 +269,7 @@ table_sorted:
table_opt: table_opt:
SORTED bool { this_table->sorted = $2; } SORTED bool { this_table->sorted = $2; }
| DEBUG debug_mask { this_table->debug = $2; }
| TRIE bool { | TRIE bool {
if (!net_val_match(this_table->addr_type, NB_IP | NB_VPN | NB_ROA | NB_IP6_SADR)) if (!net_val_match(this_table->addr_type, NB_IP | NB_VPN | NB_ROA | NB_IP6_SADR))
cf_error("Trie option not supported for %s table", net_label[this_table->addr_type]); cf_error("Trie option not supported for %s table", net_label[this_table->addr_type]);
@ -282,7 +283,6 @@ table_opt:
this_table->cork_threshold.high = $4; } this_table->cork_threshold.high = $4; }
| EXPORT SETTLE TIME settle { this_table->export_settle = $4; } | EXPORT SETTLE TIME settle { this_table->export_settle = $4; }
| ROUTE REFRESH EXPORT SETTLE TIME settle { this_table->export_rr_settle = $6; } | ROUTE REFRESH EXPORT SETTLE TIME settle { this_table->export_rr_settle = $6; }
| DEBUG bool { this_table->debug = $2; }
; ;
table_opts: table_opts:
@ -443,8 +443,8 @@ conf: debug_default ;
debug_default: debug_default:
DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; } DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
| DEBUG CHANNELS debug_mask { new_config->channel_default_debug = $3; } | DEBUG CHANNELS debug_mask { new_config->channel_default_debug = $3; }
| DEBUG TABLES debug_mask { new_config->table_default_debug = $3; }
| DEBUG COMMANDS expr { new_config->cli_debug = $3; } | DEBUG COMMANDS expr { new_config->cli_debug = $3; }
| DEBUG TABLES debug_mask { new_config->table_debug = $3; }
; ;
/* MRTDUMP PROTOCOLS is in systep/unix/config.Y */ /* MRTDUMP PROTOCOLS is in systep/unix/config.Y */

View File

@ -1856,7 +1856,7 @@ proto_reconfigure(struct proto *p, struct proto_config *oc, struct proto_config
return 0; return 0;
p->sources.name = p->name = nc->name; p->sources.name = p->name = nc->name;
p->debug = nc->debug; p->sources.debug = p->debug = nc->debug;
p->mrtdump = nc->mrtdump; p->mrtdump = nc->mrtdump;
reconfigure_type = type; reconfigure_type = type;
@ -2599,6 +2599,8 @@ proto_do_start(struct proto *p)
if (!p->sources.class) if (!p->sources.class)
p->sources.class = &default_rte_owner_class; p->sources.class = &default_rte_owner_class;
p->sources.debug = p->debug;
if (!p->cf->late_if_feed) if (!p->cf->late_if_feed)
iface_subscribe(&p->iface_sub); iface_subscribe(&p->iface_sub);
} }

View File

@ -62,9 +62,9 @@ struct rtable_config {
uint addr_type; /* Type of address data stored in table (NET_*) */ uint addr_type; /* Type of address data stored in table (NET_*) */
uint gc_threshold; /* Maximum number of operations before GC is run */ uint gc_threshold; /* Maximum number of operations before GC is run */
uint gc_period; /* Approximate time between two consecutive GC runs */ uint gc_period; /* Approximate time between two consecutive GC runs */
u32 debug; /* Debugging flags (D_*) */
byte sorted; /* Routes of network are sorted according to rte_better() */ byte sorted; /* Routes of network are sorted according to rte_better() */
byte trie_used; /* Rtable has attached trie */ byte trie_used; /* Rtable has attached trie */
byte debug; /* Whether to log */
struct rt_cork_threshold cork_threshold; /* Cork threshold values */ struct rt_cork_threshold cork_threshold; /* Cork threshold values */
struct settle_config export_settle; /* Export announcement settler */ struct settle_config export_settle; /* Export announcement settler */
struct settle_config export_rr_settle;/* Export announcement settler config valid when any struct settle_config export_rr_settle;/* Export announcement settler config valid when any
@ -122,6 +122,7 @@ struct rtable_private {
struct f_trie *trie; /* Trie of prefixes defined in fib */ struct f_trie *trie; /* Trie of prefixes defined in fib */
int use_count; /* Number of protocols using this table */ int use_count; /* Number of protocols using this table */
u32 rt_count; /* Number of routes in the table */ u32 rt_count; /* Number of routes in the table */
u32 debug; /* Debugging flags (D_*) */
list imports; /* Registered route importers */ list imports; /* Registered route importers */
struct rt_table_exporter exporter; /* Exporter API structure */ struct rt_table_exporter exporter; /* Exporter API structure */

View File

@ -257,8 +257,8 @@ rt_get_source_o(struct rte_owner *p, u32 id)
p->uc++; p->uc++;
HASH_INSERT2(p->hash, RSH, rta_pool, src); HASH_INSERT2(p->hash, RSH, rta_pool, src);
if (config->table_debug) if (p->debug & D_ROUTES)
log(L_TRACE "Allocated new rte_src for %s, ID %luL %uG, have %u sources now", log(L_TRACE "%s: new rte_src ID %luL %uG, have %u sources now",
p->name, src->private_id, src->global_id, p->uc); p->name, src->private_id, src->global_id, p->uc);
uint gm = atomic_load_explicit(&rte_src_global_max, memory_order_relaxed); uint gm = atomic_load_explicit(&rte_src_global_max, memory_order_relaxed);
@ -334,6 +334,10 @@ rt_prune_sources(void *data)
{ {
o->uc--; o->uc--;
if (o->debug & D_ROUTES)
log(L_TRACE "%s: freed rte_src ID %luL %uG, have %u sources now",
o->name, src->private_id, src->global_id, o->uc);
HASH_DO_REMOVE(o->hash, RSH, sp); HASH_DO_REMOVE(o->hash, RSH, sp);
RTA_LOCK; RTA_LOCK;
@ -354,8 +358,8 @@ rt_prune_sources(void *data)
rfree(o->prune); rfree(o->prune);
RTA_UNLOCK; RTA_UNLOCK;
if (config->table_debug) if (o->debug & D_EVENTS)
log(L_TRACE "All rte_src's for %s pruned, scheduling stop event", o->name); log(L_TRACE "%s: all rte_src's pruned, scheduling stop event", o->name);
rt_done_sources(o); rt_done_sources(o);
} }
@ -399,6 +403,8 @@ rt_init_sources(struct rte_owner *o, const char *name, event_list *list)
o->stop = NULL; o->stop = NULL;
o->list = list; o->list = list;
RTA_UNLOCK; RTA_UNLOCK;
if (o->debug & D_EVENTS)
log(L_TRACE "%s: initialized rte_src owner", o->name);
} }
void void
@ -408,8 +414,8 @@ rt_destroy_sources(struct rte_owner *o, event *done)
if (!o->uc) if (!o->uc)
{ {
if (config->table_debug) if (o->debug & D_EVENTS)
log(L_TRACE "Source owner %s destroy requested. All rte_src's already pruned, scheduling stop event", o->name); log(L_TRACE "%s: rte_src owner destroy requested, already clean, scheduling stop event", o->name);
RTA_LOCK; RTA_LOCK;
rfree(o->prune); rfree(o->prune);
@ -418,8 +424,8 @@ rt_destroy_sources(struct rte_owner *o, event *done)
rt_done_sources(o); rt_done_sources(o);
} }
else else
if (config->table_debug) if (o->debug & D_EVENTS)
log(L_TRACE "Source owner %s destroy requested. Remaining %u rte_src's to prune.", o->name, o->uc); log(L_TRACE "%s: rte_src owner destroy requested, remaining %u rte_src's to prune.", o->name, o->uc);
} }
/* /*

View File

@ -225,66 +225,6 @@ net_init_with_trie(struct fib *f, void *N)
trie_add_prefix(tab->trie_new, n->n.addr, n->n.addr->pxlen, n->n.addr->pxlen); trie_add_prefix(tab->trie_new, n->n.addr, n->n.addr->pxlen, n->n.addr->pxlen);
} }
static inline net *
net_route_ip4_trie(struct rtable_private *t, const net_addr_ip4 *n0)
{
TRIE_WALK_TO_ROOT_IP4(t->trie, n0, n)
{
net *r;
if (r = net_find_valid(t, (net_addr *) &n))
return r;
}
TRIE_WALK_TO_ROOT_END;
return NULL;
}
static inline net *
net_route_vpn4_trie(struct rtable_private *t, const net_addr_vpn4 *n0)
{
TRIE_WALK_TO_ROOT_IP4(t->trie, (const net_addr_ip4 *) n0, px)
{
net_addr_vpn4 n = NET_ADDR_VPN4(px.prefix, px.pxlen, n0->rd);
net *r;
if (r = net_find_valid(t, (net_addr *) &n))
return r;
}
TRIE_WALK_TO_ROOT_END;
return NULL;
}
static inline net *
net_route_ip6_trie(struct rtable_private *t, const net_addr_ip6 *n0)
{
TRIE_WALK_TO_ROOT_IP6(t->trie, n0, n)
{
net *r;
if (r = net_find_valid(t, (net_addr *) &n))
return r;
}
TRIE_WALK_TO_ROOT_END;
return NULL;
}
static inline net *
net_route_vpn6_trie(struct rtable_private *t, const net_addr_vpn6 *n0)
{
TRIE_WALK_TO_ROOT_IP6(t->trie, (const net_addr_ip6 *) n0, px)
{
net_addr_vpn6 n = NET_ADDR_VPN6(px.prefix, px.pxlen, n0->rd);
net *r;
if (r = net_find_valid(t, (net_addr *) &n))
return r;
}
TRIE_WALK_TO_ROOT_END;
return NULL;
}
static inline void * static inline void *
net_route_ip6_sadr_trie(struct rtable_private *t, const net_addr_ip6_sadr *n0) net_route_ip6_sadr_trie(struct rtable_private *t, const net_addr_ip6_sadr *n0)
{ {
@ -318,69 +258,6 @@ net_route_ip6_sadr_trie(struct rtable_private *t, const net_addr_ip6_sadr *n0)
return NULL; return NULL;
} }
static inline net *
net_route_ip4_fib(struct rtable_private *t, const net_addr_ip4 *n0)
{
net_addr_ip4 n;
net_copy_ip4(&n, n0);
net *r;
while (r = net_find_valid(t, (net_addr *) &n), (!r) && (n.pxlen > 0))
{
n.pxlen--;
ip4_clrbit(&n.prefix, n.pxlen);
}
return r;
}
static inline net *
net_route_vpn4_fib(struct rtable_private *t, const net_addr_vpn4 *n0)
{
net_addr_vpn4 n;
net_copy_vpn4(&n, n0);
net *r;
while (r = net_find_valid(t, (net_addr *) &n), (!r) && (n.pxlen > 0))
{
n.pxlen--;
ip4_clrbit(&n.prefix, n.pxlen);
}
return r;
}
static inline net *
net_route_ip6_fib(struct rtable_private *t, const net_addr_ip6 *n0)
{
net_addr_ip6 n;
net_copy_ip6(&n, n0);
net *r;
while (r = net_find_valid(t, (net_addr *) &n), (!r) && (n.pxlen > 0))
{
n.pxlen--;
ip6_clrbit(&n.prefix, n.pxlen);
}
return r;
}
static inline net *
net_route_vpn6_fib(struct rtable_private *t, const net_addr_vpn6 *n0)
{
net_addr_vpn6 n;
net_copy_vpn6(&n, n0);
net *r;
while (r = net_find_valid(t, (net_addr *) &n), (!r) && (n.pxlen > 0))
{
n.pxlen--;
ip6_clrbit(&n.prefix, n.pxlen);
}
return r;
}
static inline void * static inline void *
net_route_ip6_sadr_fib(struct rtable_private *t, const net_addr_ip6_sadr *n0) net_route_ip6_sadr_fib(struct rtable_private *t, const net_addr_ip6_sadr *n0)
@ -426,42 +303,51 @@ net *
net_route(struct rtable_private *tab, const net_addr *n) net_route(struct rtable_private *tab, const net_addr *n)
{ {
ASSERT(tab->addr_type == n->type); ASSERT(tab->addr_type == n->type);
net_addr_union *nu = SKIP_BACK(net_addr_union, n, n);
switch (n->type) #define TW(ipv, what) \
{ TRIE_WALK_TO_ROOT_IP##ipv(tab->trie, &(nu->ip##ipv), var) \
case NET_IP4: { what(ipv, var); } \
if (tab->trie) TRIE_WALK_TO_ROOT_END; return NULL;
return net_route_ip4_trie(tab, (net_addr_ip4 *) n);
else
return net_route_ip4_fib (tab, (net_addr_ip4 *) n);
case NET_VPN4: #define FW(ipv, what) do { \
if (tab->trie) net_addr_union nuc; net_copy(&nuc.n, n); \
return net_route_vpn4_trie(tab, (net_addr_vpn4 *) n); while (1) { \
else what(ipv, nuc.ip##ipv); if (!nuc.n.pxlen) return NULL; \
return net_route_vpn4_fib (tab, (net_addr_vpn4 *) n); nuc.n.pxlen--; ip##ipv##_clrbit(&nuc.ip##ipv.prefix, nuc.ip##ipv.pxlen); \
} \
} while(0); return NULL;
case NET_IP6: #define FVR_IP(ipv, var) \
if (tab->trie) net *r; if (r = net_find_valid(tab, (net_addr *) &var)) return r;
return net_route_ip6_trie(tab, (net_addr_ip6 *) n);
else
return net_route_ip6_fib (tab, (net_addr_ip6 *) n);
case NET_VPN6: #define FVR_VPN(ipv, var) \
if (tab->trie) net_addr_vpn##ipv _var0 = NET_ADDR_VPN##ipv(var.prefix, var.pxlen, nu->vpn##ipv.rd); FVR_IP(ipv, _var0);
return net_route_vpn6_trie(tab, (net_addr_vpn6 *) n);
else
return net_route_vpn6_fib (tab, (net_addr_vpn6 *) n);
case NET_IP6_SADR: if (tab->trie)
if (tab->trie) switch (n->type) {
return net_route_ip6_sadr_trie(tab, (net_addr_ip6_sadr *) n); case NET_IP4: TW(4, FVR_IP);
else case NET_VPN4: TW(4, FVR_VPN);
return net_route_ip6_sadr_fib (tab, (net_addr_ip6_sadr *) n); case NET_IP6: TW(6, FVR_IP);
case NET_VPN6: TW(6, FVR_VPN);
default: case NET_IP6_SADR:
return NULL; return net_route_ip6_sadr_trie(tab, (net_addr_ip6_sadr *) n);
} default:
return NULL;
}
else
switch (n->type) {
case NET_IP4: FW(4, FVR_IP);
case NET_VPN4: FW(4, FVR_VPN);
case NET_IP6: FW(6, FVR_IP);
case NET_VPN6: FW(6, FVR_VPN);
case NET_IP6_SADR:
return net_route_ip6_sadr_fib (tab, (net_addr_ip6_sadr *) n);
default:
return NULL;
}
} }
@ -2942,6 +2828,7 @@ rt_setup(pool *pp, struct rtable_config *cf)
t->name = cf->name; t->name = cf->name;
t->config = cf; t->config = cf;
t->addr_type = cf->addr_type; t->addr_type = cf->addr_type;
t->debug = cf->debug;
t->id = idm_alloc(&rtable_idm); t->id = idm_alloc(&rtable_idm);
if (t->id >= rtable_max_id) if (t->id >= rtable_max_id)
rtable_max_id = t->id + 1; rtable_max_id = t->id + 1;
@ -4092,7 +3979,7 @@ rt_new_table(struct symbol *s, uint addr_type)
.min = 100 MS, .min = 100 MS,
.max = 3 S, .max = 3 S,
}; };
c->debug = new_config->table_debug; c->debug = new_config->table_default_debug;
add_tail(&new_config->tables, &c->n); add_tail(&new_config->tables, &c->n);
@ -4206,6 +4093,7 @@ rt_reconfigure(struct rtable_private *tab, struct rtable_config *new, struct rta
new->table = RT_PUB(tab); new->table = RT_PUB(tab);
tab->name = new->name; tab->name = new->name;
tab->config = new; tab->config = new;
tab->debug = new->debug;
if (tab->hostcache) if (tab->hostcache)
tab->hostcache->req.trace_routes = new->debug; tab->hostcache->req.trace_routes = new->debug;