[bgpd] Handle pcount as flags are changed, fixing pcount issues
2006-09-06 Paul Jakma <paul.jakma@sun.com>
* (general) Squash any and all prefix-count issues by
abstracting route flag changes, and maintaining count as and
when flags are modified (rather than relying on explicit
modifications of count being sprinkled in just the right
places throughout the code).
* bgp_route.c: (bgp_pcount_{dec,inc}rement) removed.
(bgp_pcount_adjust) new, update prefix count as
needed for a given route.
(bgp_info_{uns,s}et_flag) set/unset a BGP_INFO route status
flag, calling previous function when appropriate.
(general) Update all set/unsets of flags to use previous.
Remove pcount_{dec,inc}rement calls.
No need to unset BGP_INFO_VALID in places where
bgp_info_delete is called, it does that anyway.
* bgp_{damp,nexthop}.c: Update to use bgp_info_{un,}set_flag.
* bgp_route.h: Export bgp_info_{un,}set_flag.
Add a 'meta' BGP_INFO flag, BGP_INFO_UNUSEABLE.
Move BGP_INFO_HOLDDOWN macro to here from bgpd.h
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index a2163a4..8ba39b6 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -148,12 +148,12 @@
if (bdi->penalty < damp->reuse_limit)
{
/* Reuse the route. */
- UNSET_FLAG (bdi->binfo->flags, BGP_INFO_DAMPED);
+ bgp_info_unset_flag (bdi->rn, bdi->binfo, BGP_INFO_DAMPED);
bdi->suppress_time = 0;
if (bdi->lastrecord == BGP_RECORD_UPDATE)
{
- UNSET_FLAG (bdi->binfo->flags, BGP_INFO_HISTORY);
+ bgp_info_unset_flag (bdi->rn, bdi->binfo, BGP_INFO_HISTORY);
bgp_aggregate_increment (bgp, &bdi->rn->p, bdi->binfo,
bdi->afi, bdi->safi);
bgp_process (bgp, bdi->rn, bdi->afi, bdi->safi);
@@ -223,11 +223,13 @@
bdi->flap++;
}
+ assert ((rn == bdi->rn) && (binfo == bdi->binfo));
+
bdi->lastrecord = BGP_RECORD_WITHDRAW;
bdi->t_updated = t_now;
/* Make this route as historical status. */
- SET_FLAG (binfo->flags, BGP_INFO_HISTORY);
+ bgp_info_set_flag (rn, binfo, BGP_INFO_HISTORY);
/* Remove the route from a reuse list if it is on one. */
if (CHECK_FLAG (bdi->binfo->flags, BGP_INFO_DAMPED))
@@ -245,7 +247,7 @@
insert into reuse_list. */
if (bdi->penalty >= damp->suppress_value)
{
- SET_FLAG (bdi->binfo->flags, BGP_INFO_DAMPED);
+ bgp_info_set_flag (rn, binfo, BGP_INFO_DAMPED);
bdi->suppress_time = t_now;
BGP_DAMP_LIST_DEL (damp, bdi);
bgp_reuse_list_add (bdi);
@@ -267,7 +269,7 @@
return BGP_DAMP_USED;
t_now = time (NULL);
- UNSET_FLAG (binfo->flags, BGP_INFO_HISTORY);
+ bgp_info_unset_flag (rn, binfo, BGP_INFO_HISTORY);
bdi->lastrecord = BGP_RECORD_UPDATE;
bdi->penalty = bgp_damp_decay (t_now - bdi->t_updated, bdi->penalty);
@@ -278,7 +280,7 @@
else if (CHECK_FLAG (bdi->binfo->flags, BGP_INFO_DAMPED)
&& (bdi->penalty < damp->reuse_limit) )
{
- UNSET_FLAG (bdi->binfo->flags, BGP_INFO_DAMPED);
+ bgp_info_unset_flag (rn, binfo, BGP_INFO_DAMPED);
bgp_reuse_list_delete (bdi);
BGP_DAMP_LIST_ADD (damp, bdi);
bdi->suppress_time = 0;
@@ -311,7 +313,7 @@
if (t_diff >= damp->max_suppress_time)
{
- UNSET_FLAG (binfo->flags, BGP_INFO_DAMPED);
+ bgp_info_unset_flag (bdi->rn, binfo, BGP_INFO_DAMPED);
bgp_reuse_list_delete (bdi);
BGP_DAMP_LIST_ADD (damp, bdi);
bdi->penalty = damp->reuse_limit;
@@ -358,8 +360,7 @@
else
BGP_DAMP_LIST_DEL (damp, bdi);
- UNSET_FLAG (binfo->flags, BGP_INFO_DAMPED);
- UNSET_FLAG (binfo->flags, BGP_INFO_HISTORY);
+ bgp_info_unset_flag (bdi->rn, binfo, BGP_INFO_HISTORY|BGP_INFO_DAMPED);
if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw)
bgp_info_delete (bdi->rn, binfo);