diff options
author | 2006-01-20 16:40:17 +0000 | |
---|---|---|
committer | 2006-01-20 16:40:17 +0000 | |
commit | bf66846d6c34e31b44a77806ddce1a0a84eab2f2 (patch) | |
tree | d9708017bfaba33a994e2c28cb5a2f026e29cad3 | |
parent | initialize authtype->string in case of RSA to avoid bad free() (diff) | |
download | wireguard-openbsd-bf66846d6c34e31b44a77806ddce1a0a84eab2f2.tar.xz wireguard-openbsd-bf66846d6c34e31b44a77806ddce1a0a84eab2f2.zip |
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@
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 28 |
4 files changed, 31 insertions, 17 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 1b2e05bd62d..9337fd548be 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.186 2006/01/05 17:33:39 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.187 2006/01/20 16:40:17 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -461,8 +461,9 @@ struct ctl_show_rib { time_t lastchange; u_int32_t local_pref; u_int32_t med; - u_int16_t prefix_cnt; - u_int16_t active_cnt; + u_int32_t prefix_cnt; + u_int32_t active_cnt; + u_int32_t adjrib_cnt; u_int16_t aspath_len; u_int16_t flags; u_int8_t prefixlen; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 433ad958357..fc17dfe7b7a 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.194 2006/01/20 14:56:12 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.195 2006/01/20 16:40:17 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1434,6 +1434,7 @@ rde_dump_rib_as(struct prefix *p, pid_t pid) rib.med = p->aspath->med; rib.prefix_cnt = p->aspath->prefix_cnt; rib.active_cnt = p->aspath->active_cnt; + rib.adjrib_cnt = p->aspath->adjrib_cnt; if (p->aspath->nexthop != NULL) memcpy(&rib.nexthop, &p->aspath->nexthop->true_nexthop, sizeof(rib.nexthop)); diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 9f550731f30..d07eb43dd19 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.84 2006/01/20 16:06:12 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.85 2006/01/20 16:40:17 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -61,7 +61,8 @@ struct rde_peer { struct uplist_prefix withdraws6; struct capabilities capa_announced; struct capabilities capa_received; - u_int32_t prefix_cnt; + u_int32_t prefix_cnt; /* # of prefixes */ + u_int32_t adjrib_cnt; /* # of p. in Adj-RIB-In */ u_int32_t remote_bgpid; u_int32_t up_pcnt; u_int32_t up_acnt; @@ -168,11 +169,12 @@ struct rde_aspath { u_int32_t med; /* multi exit disc */ u_int32_t lpref; /* local pref */ u_int32_t weight; /* low prio lpref */ + u_int32_t prefix_cnt; /* # of prefixes */ + u_int32_t active_cnt; /* # of active prefixes */ + u_int32_t adjrib_cnt; /* # of p. in Adj-RIB-In */ u_int16_t rtlabelid; /* route label id */ u_int16_t pftableid; /* pf table id */ u_int16_t flags; /* internally used */ - u_int16_t prefix_cnt; /* # of prefixes */ - u_int16_t active_cnt; /* # of active prefixes */ u_int8_t origin; u_int8_t others_len; }; 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; |