diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-03 20:18:00 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-03 20:18:00 +0000 |
commit | 2c12ceb51f0559dc43be19c78ec2096cdde262cf (patch) | |
tree | 4704ef9f2730326a8cb3a3ca999be43b021cdaa3 /usr.sbin/bgpd | |
parent | 4b3c52aa7b4bb2974dbb7149a6198da8d06e802a (diff) |
Better way to allocate new RIBs.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde.h | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 21 |
2 files changed, 7 insertions, 18 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 22f7418fa09..fc469950e44 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.114 2009/06/02 00:09:02 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.115 2009/06/03 20:17:59 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -346,7 +346,7 @@ extern u_int16_t rib_size; extern struct rib *ribs; void rib_init(void); -u_int16_t rib_new(char *); +u_int16_t rib_new(u_int16_t, char *, u_int16_t); void rib_free(struct rib *); struct rib_entry *rib_get(struct rib *, struct bgpd_addr *, int); struct rib_entry *rib_lookup(struct rib *, struct bgpd_addr *); diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 1f1b0a952d6..b637d2949dc 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.109 2009/06/03 19:54:53 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.110 2009/06/03 20:17:59 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -52,27 +52,15 @@ RB_GENERATE(rib_tree, rib_entry, rib_e, rib_compare); void rib_init(void) { - if ((ribs = calloc(1, sizeof(struct rib))) == NULL) - fatal("rib_init"); - rib_new("DEFAULT"); - - /* XXX we need to create Adj-RIB-In by hand */ - bzero(&ribs[0], sizeof(struct rib)); - RB_INIT(&ribs[0].rib); - ribs[0].state = RIB_ACTIVE; - ribs[0].id = 0; - strlcpy(ribs[0].name, "Adj-RIB-In", sizeof("Adj-RIB-In")); - ribs[0].flags = F_RIB_NOEVALUATE; + rib_new(1, "DEFAULT", 0); + rib_new(0, "Adj-RIB-In", F_RIB_NOEVALUATE); } u_int16_t -rib_new(char *name) +rib_new(u_int16_t id, char *name, u_int16_t flags) { struct rib *xribs; size_t newsize; - u_int16_t id; - - id = rib_name2id(name); if (id >= rib_size) { newsize = sizeof(struct rib) * (id + 1); @@ -89,6 +77,7 @@ rib_new(char *name) RB_INIT(&ribs[id].rib); ribs[id].state = RIB_ACTIVE; ribs[id].id = id; + ribs[id].flags = flags; return (id); } |