summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-06-01 21:20:18 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-06-01 21:20:18 +0000
commitc9e1b6461cf04c9ebc4a50f03aa77891458f12bc (patch)
treeb86e5f5313053c22cce2d0c897aca92d9d4c5988 /usr.sbin/bgpd
parentfe82eb306641b97ed1723d9c849bb57c37701252 (diff)
Instead of storing a pointer to the RIB head in the RIB element use that
space for a flags field and the RIB id. In the end bgpd will be able to lock RIB elements and therefore make it possible to interrupt all tree walks.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/rde.h10
-rw-r--r--usr.sbin/bgpd/rde_decide.c4
-rw-r--r--usr.sbin/bgpd/rde_rib.c11
3 files changed, 15 insertions, 10 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index c84f7ecf880..9b7f825dbbf 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.110 2009/05/27 06:58:15 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.111 2009/06/01 21:20:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -256,7 +256,8 @@ struct rib_entry {
struct prefix_head prefix_h;
struct prefix *active; /* for fast access */
struct pt_entry *prefix;
- struct rib *rib;
+ u_int16_t ribid;
+ u_int16_t flags;
};
enum rib_state {
@@ -270,10 +271,13 @@ struct rib {
struct rib_tree rib;
LIST_HEAD(, rib_context) ctxts;
enum rib_state state;
+ u_int16_t flags;
u_int16_t id;
- u_char noevaluate;
};
+#define F_RIB_ENTRYLOCK 0x0001
+#define F_RIB_NOEVALUATE 0x0002
+
struct prefix {
LIST_ENTRY(prefix) rib_l, path_l;
struct rde_aspath *aspath;
diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c
index b580bb46b76..58d6b05ec33 100644
--- a/usr.sbin/bgpd/rde_decide.c
+++ b/usr.sbin/bgpd/rde_decide.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_decide.c,v 1.54 2009/05/21 15:47:03 claudio Exp $ */
+/* $OpenBSD: rde_decide.c,v 1.55 2009/06/01 21:20:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -217,7 +217,7 @@ prefix_evaluate(struct prefix *p, struct rib_entry *re)
{
struct prefix *xp;
- if (re->rib->noevaluate || rde_noevaluate()) {
+ if (re->flags & F_RIB_NOEVALUATE || rde_noevaluate()) {
/* decision process is turned off */
if (p != NULL)
LIST_INSERT_HEAD(&re->prefix_h, p, rib_l);
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index a4bd6b4a3f7..aa3b2d1eaaf 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.103 2009/05/27 06:58:15 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.104 2009/06/01 21:20:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -60,7 +60,7 @@ rib_init(void)
ribs[0].state = RIB_ACTIVE;
ribs[0].id = 0;
strlcpy(ribs[0].name, "Adj-RIB-In", sizeof("Adj-RIB-In"));
- ribs[0].noevaluate = 1;
+ ribs[0].flags = F_RIB_NOEVALUATE;
}
u_int16_t
@@ -160,7 +160,8 @@ rib_add(struct rib *rib, struct bgpd_addr *prefix, int prefixlen)
LIST_INIT(&re->prefix_h);
re->prefix = pte;
- re->rib = rib;
+ re->flags = rib->flags;
+ re->ribid = rib->id;
if (RB_INSERT(rib_tree, &rib->rib, re) != NULL) {
log_warnx("rib_add: insert failed");
@@ -184,7 +185,7 @@ rib_remove(struct rib_entry *re)
if (pt_empty(re->prefix))
pt_remove(re->prefix);
- if (RB_REMOVE(rib_tree, &re->rib->rib, re) == NULL)
+ if (RB_REMOVE(rib_tree, &ribs[re->ribid].rib, re) == NULL)
log_warnx("rib_remove: remove failed.");
free(re);
@@ -813,7 +814,7 @@ prefix_updateall(struct rde_aspath *asp, enum nexthop_state state,
/*
* skip non local-RIBs or RIBs that are flagged as noeval.
*/
- if (p->rib->rib->noevaluate)
+ if (p->rib->flags & F_RIB_NOEVALUATE)
continue;
if (oldstate == state && state == NEXTHOP_REACH) {