mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Implements generalized export limits.
And also fixes some minor bugs in limits.
This commit is contained in:
30
nest/proto.c
30
nest/proto.c
@@ -406,13 +406,14 @@ proto_reconfigure(struct proto *p, struct proto_config *oc, struct proto_config
|
||||
if (p->proto->multitable)
|
||||
return 1;
|
||||
|
||||
/* Update filters in the main announce hook */
|
||||
/* Update filters and limits in the main announce hook
|
||||
Note that this also resets limit state */
|
||||
if (p->main_ahook)
|
||||
{
|
||||
p->main_ahook->in_filter = nc->in_filter;
|
||||
p->main_ahook->out_filter = nc->out_filter;
|
||||
p->main_ahook->in_limit = nc->in_limit;
|
||||
// p->main_ahook->out_limit = nc->out_limit;
|
||||
p->main_ahook->out_limit = nc->out_limit;
|
||||
}
|
||||
|
||||
/* Update routes when filters changed. If the protocol in not UP,
|
||||
@@ -774,9 +775,16 @@ proto_schedule_feed(struct proto *p, int initial)
|
||||
p->core_state = FS_FEEDING;
|
||||
p->refeeding = !initial;
|
||||
|
||||
/* Hack: reset exp_routes during refeed, and do not decrease it later */
|
||||
/* FIXME: This should be changed for better support of multitable protos */
|
||||
if (!initial)
|
||||
p->stats.exp_routes = 0;
|
||||
{
|
||||
struct announce_hook *ah;
|
||||
for (ah = p->ahooks; ah; ah = ah->next)
|
||||
proto_reset_limit(ah->out_limit);
|
||||
|
||||
/* Hack: reset exp_routes during refeed, and do not decrease it later */
|
||||
p->stats.exp_routes = 0;
|
||||
}
|
||||
|
||||
/* Connect protocol to routing table */
|
||||
if (initial && !p->proto->multitable)
|
||||
@@ -785,9 +793,9 @@ proto_schedule_feed(struct proto *p, int initial)
|
||||
p->main_ahook->in_filter = p->cf->in_filter;
|
||||
p->main_ahook->out_filter = p->cf->out_filter;
|
||||
p->main_ahook->in_limit = p->cf->in_limit;
|
||||
p->main_ahook->out_limit = p->cf->out_limit;
|
||||
proto_reset_limit(p->main_ahook->in_limit);
|
||||
// p->main_ahook->out_limit = p->cf->out_limit;
|
||||
// proto_reset_limit(p->main_ahook->out_limit);
|
||||
proto_reset_limit(p->main_ahook->out_limit);
|
||||
}
|
||||
|
||||
proto_relink(p);
|
||||
@@ -872,6 +880,8 @@ proto_schedule_flush(struct proto *p)
|
||||
proto_schedule_flush_loop();
|
||||
}
|
||||
|
||||
/* Temporary hack to propagate restart to BGP */
|
||||
int proto_restart;
|
||||
|
||||
static void
|
||||
proto_shutdown_loop(struct timer *t UNUSED)
|
||||
@@ -881,11 +891,11 @@ proto_shutdown_loop(struct timer *t UNUSED)
|
||||
WALK_LIST_DELSAFE(p, p_next, active_proto_list)
|
||||
if (p->down_sched)
|
||||
{
|
||||
int restart = (p->down_sched == PDS_RESTART);
|
||||
proto_restart = (p->down_sched == PDS_RESTART);
|
||||
|
||||
p->disabled = 1;
|
||||
proto_rethink_goal(p);
|
||||
if (restart)
|
||||
if (proto_restart)
|
||||
{
|
||||
p->disabled = 0;
|
||||
proto_rethink_goal(p);
|
||||
@@ -970,7 +980,8 @@ proto_notify_limit(struct announce_hook *ah, struct proto_limit *l, u32 rt_count
|
||||
if (l->state == PLS_BLOCKED)
|
||||
return;
|
||||
|
||||
if (rt_count == l->limit)
|
||||
/* For warning action, we want the log message every time we hit the limit */
|
||||
if (!l->state || ((l->action == PLA_WARN) && (rt_count == l->limit)))
|
||||
log(L_WARN "Protocol %s hits route %s limit (%d), action: %s",
|
||||
p->name, dir ? "import" : "export", l->limit, proto_limit_name(l));
|
||||
|
||||
@@ -1118,6 +1129,7 @@ proto_show_basic_info(struct proto *p)
|
||||
cli_msg(-1006, " Output filter: %s", filter_name(p->cf->out_filter));
|
||||
|
||||
proto_show_limit(p->cf->in_limit, "Import limit:");
|
||||
proto_show_limit(p->cf->out_limit, "Export limit:");
|
||||
|
||||
if (p->proto_state != PS_DOWN)
|
||||
proto_show_stats(&p->stats);
|
||||
|
Reference in New Issue
Block a user