summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-11-15 17:02:02 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-11-15 17:02:02 +0000
commit078d3190e12948613291c79f4c84c0f6eed75e1b (patch)
tree3df5a4f8f42afeea5b985c4b4119cd660798dbc9
parentfec1cc02a9de09489cf0c4e7579cd82a2a234e6e (diff)
Do not insert proto_default inside the dynamically alloced protocol queue.
Handle it as a special case in the one place where it actually matters instead.
-rw-r--r--usr.sbin/hoststated/hoststated.c4
-rw-r--r--usr.sbin/hoststated/parse.y13
-rw-r--r--usr.sbin/hoststated/pfe.c9
-rw-r--r--usr.sbin/relayd/parse.y13
-rw-r--r--usr.sbin/relayd/pfe.c9
-rw-r--r--usr.sbin/relayd/relayd.c4
6 files changed, 32 insertions, 20 deletions
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c
index 12a3a5c32c0..523c404f9fe 100644
--- a/usr.sbin/hoststated/hoststated.c
+++ b/usr.sbin/hoststated/hoststated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hoststated.c,v 1.50 2007/11/14 11:01:52 pyr Exp $ */
+/* $OpenBSD: hoststated.c,v 1.51 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -498,8 +498,6 @@ purge_config(struct hoststated *env, u_int8_t what)
if (what & PURGE_PROTOS && env->protos != NULL) {
while ((proto = TAILQ_FIRST(env->protos)) != NULL) {
TAILQ_REMOVE(env->protos, proto, entry);
- if (strcmp(proto->name, "default") == 0)
- continue;
while ((pnode = RB_ROOT(&proto->request_tree))
!= NULL) {
RB_REMOVE(proto_tree, &proto->request_tree,
diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y
index e2b1652ffad..d32f2c0e868 100644
--- a/usr.sbin/hoststated/parse.y
+++ b/usr.sbin/hoststated/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.79 2007/11/14 15:58:04 pyr Exp $ */
+/* $OpenBSD: parse.y,v 1.80 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -583,9 +583,13 @@ tableoptsl : host {
proto : PROTO STRING {
struct protocol *p;
- TAILQ_FOREACH(p, conf->protos, entry)
- if (!strcmp(p->name, $2))
- break;
+ if (strcmp($2, "default") == 0) {
+ p = &conf->proto_default;
+ } else {
+ TAILQ_FOREACH(p, conf->protos, entry)
+ if (!strcmp(p->name, $2))
+ break;
+ }
if (p != NULL) {
yyerror("protocol %s defined twice", $2);
free($2);
@@ -1623,7 +1627,6 @@ parse_config(const char *filename, int opts)
sizeof(conf->proto_default.name));
RB_INIT(&conf->proto_default.request_tree);
RB_INIT(&conf->proto_default.response_tree);
- TAILQ_INSERT_TAIL(conf->protos, &conf->proto_default, entry);
conf->timeout.tv_sec = CHECK_TIMEOUT / 1000;
conf->timeout.tv_usec = (CHECK_TIMEOUT % 1000) * 1000;
diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c
index 522607d9971..465763103da 100644
--- a/usr.sbin/hoststated/pfe.c
+++ b/usr.sbin/hoststated/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.40 2007/11/14 15:25:26 pyr Exp $ */
+/* $OpenBSD: pfe.c,v 1.41 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -361,8 +361,13 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
sizeof(struct hoststated) + IMSG_HEADER_SIZE)
fatalx("corrupted reload data");
pfe_disable_events();
- purge_config(env, PURGE_EVERYTHING);
+ purge_config(env, PURGE_SERVICES|PURGE_TABLES);
merge_config(env, (struct hoststated *)imsg.data);
+ /*
+ * no relays when reconfiguring yet.
+ */
+ env->relays = NULL;
+ env->protos = NULL;
env->tables = calloc(1, sizeof(*env->tables));
env->services = calloc(1, sizeof(*env->services));
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index e2b1652ffad..d32f2c0e868 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.79 2007/11/14 15:58:04 pyr Exp $ */
+/* $OpenBSD: parse.y,v 1.80 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -583,9 +583,13 @@ tableoptsl : host {
proto : PROTO STRING {
struct protocol *p;
- TAILQ_FOREACH(p, conf->protos, entry)
- if (!strcmp(p->name, $2))
- break;
+ if (strcmp($2, "default") == 0) {
+ p = &conf->proto_default;
+ } else {
+ TAILQ_FOREACH(p, conf->protos, entry)
+ if (!strcmp(p->name, $2))
+ break;
+ }
if (p != NULL) {
yyerror("protocol %s defined twice", $2);
free($2);
@@ -1623,7 +1627,6 @@ parse_config(const char *filename, int opts)
sizeof(conf->proto_default.name));
RB_INIT(&conf->proto_default.request_tree);
RB_INIT(&conf->proto_default.response_tree);
- TAILQ_INSERT_TAIL(conf->protos, &conf->proto_default, entry);
conf->timeout.tv_sec = CHECK_TIMEOUT / 1000;
conf->timeout.tv_usec = (CHECK_TIMEOUT % 1000) * 1000;
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index 522607d9971..465763103da 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.40 2007/11/14 15:25:26 pyr Exp $ */
+/* $OpenBSD: pfe.c,v 1.41 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -361,8 +361,13 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
sizeof(struct hoststated) + IMSG_HEADER_SIZE)
fatalx("corrupted reload data");
pfe_disable_events();
- purge_config(env, PURGE_EVERYTHING);
+ purge_config(env, PURGE_SERVICES|PURGE_TABLES);
merge_config(env, (struct hoststated *)imsg.data);
+ /*
+ * no relays when reconfiguring yet.
+ */
+ env->relays = NULL;
+ env->protos = NULL;
env->tables = calloc(1, sizeof(*env->tables));
env->services = calloc(1, sizeof(*env->services));
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index 13a53393b17..c8d181e07ac 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.50 2007/11/14 11:01:52 pyr Exp $ */
+/* $OpenBSD: relayd.c,v 1.51 2007/11/15 17:02:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -498,8 +498,6 @@ purge_config(struct hoststated *env, u_int8_t what)
if (what & PURGE_PROTOS && env->protos != NULL) {
while ((proto = TAILQ_FIRST(env->protos)) != NULL) {
TAILQ_REMOVE(env->protos, proto, entry);
- if (strcmp(proto->name, "default") == 0)
- continue;
while ((pnode = RB_ROOT(&proto->request_tree))
!= NULL) {
RB_REMOVE(proto_tree, &proto->request_tree,