summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/name2id.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-06-29 09:43:27 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-06-29 09:43:27 +0000
commit594757d5f959a472146827a74c37df70dae806f1 (patch)
treeb9f724ee6b9b82a70fa8e500966f6bd069c79992 /usr.sbin/bgpd/name2id.c
parent78885a9a4f071e782047df91843c9f08dfc7b24c (diff)
rtlabel support via filter sets. Just use "set rtlabel foobar" in filters
network and neighbor statements and the routes are labeled accordingly. While doing that fix some mem-leaks by introducing filterset_free() and remove the free on send option of send_filterset(). This took a bit longer because we need to carefully track the rtlabel id refcnts or bad things may happen on reloads. henning@ looks fine
Diffstat (limited to 'usr.sbin/bgpd/name2id.c')
-rw-r--r--usr.sbin/bgpd/name2id.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/name2id.c b/usr.sbin/bgpd/name2id.c
index 03eafdcc1d4..1ee5f50a8f0 100644
--- a/usr.sbin/bgpd/name2id.c
+++ b/usr.sbin/bgpd/name2id.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: name2id.c,v 1.2 2005/06/25 16:26:25 claudio Exp $ */
+/* $OpenBSD: name2id.c,v 1.3 2005/06/29 09:43:25 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -41,6 +41,7 @@ TAILQ_HEAD(n2id_labels, n2id_label);
u_int16_t _name2id(struct n2id_labels *, const char *);
const char *_id2name(struct n2id_labels *, u_int16_t);
void _unref(struct n2id_labels *, u_int16_t);
+void _ref(struct n2id_labels *, u_int16_t);
int _exists(struct n2id_labels *, const char *);
struct n2id_labels rt_labels = TAILQ_HEAD_INITIALIZER(rt_labels);
@@ -64,6 +65,12 @@ rtlabel_unref(u_int16_t id)
_unref(&rt_labels, id);
}
+void
+rtlabel_ref(u_int16_t id)
+{
+ _ref(&rt_labels, id);
+}
+
u_int16_t
_name2id(struct n2id_labels *head, const char *name)
{
@@ -119,7 +126,7 @@ _id2name(struct n2id_labels *head, u_int16_t id)
{
struct n2id_label *label;
- if (!id)
+ if (id == 0)
return ("");
TAILQ_FOREACH(label, head, entry)
@@ -150,6 +157,21 @@ _unref(struct n2id_labels *head, u_int16_t id)
}
}
+void
+_ref(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *label;
+
+ if (id == 0)
+ return;
+
+ TAILQ_FOREACH(label, head, entry)
+ if (label->id == id) {
+ ++label->ref;
+ break;
+ }
+}
+
int
_exists(struct n2id_labels *head, const char *name)
{