summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2008-07-17 16:12:05 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2008-07-17 16:12:05 +0000
commite7dcd9ec1372281856df75dd07c184abfb7d08b1 (patch)
treeb4142e613497cc9812d121f427ae7f8c51afaee7 /usr.sbin/relayd
parent2f946403c43dc6f8eac947347e117ef63717edfc (diff)
give sane ids to hosts, tables, redirections, relays, etc. - start
counting at 1 and do not assign an id before inheriting a real table. makes more sense in the relayctl output. ok pyr@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/parse.y26
1 files changed, 8 insertions, 18 deletions
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index fad5025f208..6509421efc3 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.116 2008/07/17 15:10:15 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.117 2008/07/17 16:12:04 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -336,7 +336,7 @@ rdr : REDIRECT STRING {
YYERROR;
}
free($2);
- srv->conf.id = last_rdr_id++;
+ srv->conf.id = ++last_rdr_id;
srv->conf.timeout.tv_sec = RELAY_TIMEOUT;
if (last_rdr_id == INT_MAX) {
yyerror("too many redirections defined");
@@ -492,14 +492,9 @@ tabledef : TABLE table {
(void)strlcpy(tb->conf.name, $2, sizeof(tb->conf.name));
free($2);
- tb->conf.id = last_table_id++;
+ tb->conf.id = 0; /* will be set later */
bcopy(&conf->sc_timeout, &tb->conf.timeout,
sizeof(struct timeval));
- if (last_table_id == INT_MAX) {
- yyerror("too many tables defined");
- free(tb);
- YYERROR;
- }
table = tb;
} tabledefopts_l {
if (TAILQ_EMPTY(&table->hosts)) {
@@ -722,7 +717,7 @@ proto : proto_type PROTO STRING {
YYERROR;
}
free($3);
- p->id = last_proto_id++;
+ p->id = ++last_proto_id;
p->type = $1;
p->cache = RELAY_CACHESIZE;
p->tcpflags = TCPFLAG_DEFAULT;
@@ -1067,7 +1062,7 @@ relay : RELAY STRING {
YYERROR;
}
free($2);
- r->rl_conf.id = last_relay_id++;
+ r->rl_conf.id = ++last_relay_id;
r->rl_conf.timeout.tv_sec = RELAY_TIMEOUT;
r->rl_proto = NULL;
r->rl_conf.proto = EMPTY_ID;
@@ -1268,13 +1263,8 @@ host : STRING retry {
YYERROR;
}
free($1);
- $$->conf.id = last_host_id++;
+ $$->conf.id = 0; /* will be set later */
$$->conf.retry = $2;
- if (last_host_id == INT_MAX) {
- yyerror("too many hosts defined");
- free($$);
- YYERROR;
- }
}
;
@@ -2115,7 +2105,7 @@ table_inherit(struct table *tb)
return (oldtb);
/* Create a new table */
- tb->conf.id = last_table_id++;
+ tb->conf.id = ++last_table_id;
if (last_table_id == INT_MAX) {
yyerror("too many tables defined");
purge_table(NULL, tb);
@@ -2136,7 +2126,7 @@ table_inherit(struct table *tb)
calloc(1, sizeof (*h))) == NULL)
fatal("out of memory");
bcopy(dsth, h, sizeof(*h));
- h->conf.id = last_host_id++;
+ h->conf.id = ++last_host_id;
if (last_host_id == INT_MAX) {
yyerror("too many hosts defined");
purge_table(NULL, tb);