diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-01-20 16:40:18 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-01-20 16:40:18 +0000 |
commit | ad734e764da5e0f0ac1392f062613e006ec7fc62 (patch) | |
tree | 51ad370846cd3167254e3957f3311d76a960978e /usr.sbin/bgpd/rde_rib.c | |
parent | 2c6ae5dfa161e80aa3aaf37f645d217f8ce714bd (diff) |
Proactively fix prefix counters. Currently only F_LOCAL prefixes exist but
as soon as F_ORIGINAL come the counters would no longer be correct and in the
end max-prefix would no longer work. Add additinal counters for F_ORIGINAL
prefixes and bump the correct conter depending on the prefix flags.
OK henning@
Diffstat (limited to 'usr.sbin/bgpd/rde_rib.c')
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 2ac4b7854b1..33d488f2619 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.79 2006/01/20 16:06:12 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.80 2006/01/20 16:40:17 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -34,6 +34,15 @@ * This is achieved by heavily linking the different parts together. */ +/* used to bump correct prefix counters */ +#define PREFIX_COUNT(x, f, op) \ + do { \ + if (f & F_LOCAL) \ + (x)->prefix_cnt += (op); \ + if (f & F_ORIGINAL) \ + (x)->adjrib_cnt += (op); \ + } while (0) + /* path specific functions */ static void path_link(struct rde_aspath *, struct rde_peer *); @@ -202,7 +211,8 @@ void path_destroy(struct rde_aspath *asp) { /* path_destroy can only unlink and free empty rde_aspath */ - if (asp->prefix_cnt != 0 || asp->active_cnt != 0) + if (asp->prefix_cnt != 0 || asp->active_cnt != 0 || + asp->adjrib_cnt != 0) log_warnx("path_destroy: prefix count out of sync"); nexthop_unlink(asp); @@ -422,7 +432,7 @@ prefix_move(struct rde_aspath *asp, struct prefix *p, u_int32_t flags) /* add to new as path */ LIST_INSERT_HEAD(&asp->prefix_h, np, path_l); - asp->prefix_cnt++; + PREFIX_COUNT(asp, flags, 1); /* * no need to update the peer prefix count because we are only moving * the prefix without changing the peer. @@ -439,7 +449,7 @@ prefix_move(struct rde_aspath *asp, struct prefix *p, u_int32_t flags) "prefix is not part of desired RIB"); p->flags &= ~flags; - p->aspath->prefix_cnt--; + PREFIX_COUNT(p->aspath, flags, -1); /* as before peer count needs no update because of move */ /* redo the route decision for p */ @@ -469,7 +479,7 @@ prefix_move(struct rde_aspath *asp, struct prefix *p, u_int32_t flags) /* remove old prefix node */ oasp = p->aspath; LIST_REMOVE(p, path_l); - oasp->prefix_cnt--; + PREFIX_COUNT(oasp, flags, -1); /* as before peer count needs no update because of move */ /* destroy all references to other objects and free the old prefix */ @@ -638,8 +648,8 @@ prefix_link(struct prefix *pref, struct pt_entry *pte, struct rde_aspath *asp, u_int32_t flags) { LIST_INSERT_HEAD(&asp->prefix_h, pref, path_l); - asp->prefix_cnt++; - asp->peer->prefix_cnt++; + PREFIX_COUNT(asp, flags, 1); + PREFIX_COUNT(asp->peer, flags, 1); pref->aspath = asp; pref->prefix = pte; @@ -661,8 +671,8 @@ prefix_unlink(struct prefix *pref) prefix_evaluate(NULL, pref->prefix); LIST_REMOVE(pref, path_l); - pref->aspath->prefix_cnt--; - pref->aspath->peer->prefix_cnt--; + PREFIX_COUNT(pref->aspath, pref->flags, -1); + PREFIX_COUNT(pref->aspath->peer, pref->flags, -1); /* destroy all references to other objects */ pref->aspath = NULL; |