summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2008-01-31 09:33:39 +0000
committerreyk <reyk@openbsd.org>2008-01-31 09:33:39 +0000
commit35d10c307ce9ef755e17c9c9e85b77b5743a79c1 (patch)
tree6149179fe49a2fde81d0f67c2eb94169188eb6dd
parentrecognize the BCM5755 C0 ASIC revision. (diff)
downloadwireguard-openbsd-35d10c307ce9ef755e17c9c9e85b77b5743a79c1.tar.xz
wireguard-openbsd-35d10c307ce9ef755e17c9c9e85b77b5743a79c1.zip
add prefixes to names of structure elements to make it easier to grep
for code, start with struct relayd. finally. ok thib@
-rw-r--r--usr.sbin/relayd/check_icmp.c46
-rw-r--r--usr.sbin/relayd/control.c4
-rw-r--r--usr.sbin/relayd/hce.c52
-rw-r--r--usr.sbin/relayd/parse.y168
-rw-r--r--usr.sbin/relayd/pfe.c82
-rw-r--r--usr.sbin/relayd/pfe_filter.c64
-rw-r--r--usr.sbin/relayd/relay.c44
-rw-r--r--usr.sbin/relayd/relay_udp.c4
-rw-r--r--usr.sbin/relayd/relayd.c140
-rw-r--r--usr.sbin/relayd/relayd.h62
10 files changed, 333 insertions, 333 deletions
diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c
index e0dc68b7a90..f16e9bd3d61 100644
--- a/usr.sbin/relayd/check_icmp.c
+++ b/usr.sbin/relayd/check_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: check_icmp.c,v 1.22 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: check_icmp.c,v 1.23 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -65,11 +65,11 @@ icmp_setup(struct relayd *env, struct ctl_icmp_event *cie, int af)
void
icmp_init(struct relayd *env)
{
- icmp_setup(env, &env->icmp_send, AF_INET);
- icmp_setup(env, &env->icmp_recv, AF_INET);
- icmp_setup(env, &env->icmp6_send, AF_INET6);
- icmp_setup(env, &env->icmp6_recv, AF_INET6);
- env->id = getpid() & 0xffff;
+ icmp_setup(env, &env->sc_icmp_send, AF_INET);
+ icmp_setup(env, &env->sc_icmp_recv, AF_INET);
+ icmp_setup(env, &env->sc_icmp6_send, AF_INET6);
+ icmp_setup(env, &env->sc_icmp6_recv, AF_INET6);
+ env->sc_id = getpid() & 0xffff;
}
void
@@ -79,9 +79,9 @@ schedule_icmp(struct relayd *env, struct host *host)
host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE);
if (((struct sockaddr *)&host->conf.ss)->sa_family == AF_INET)
- env->has_icmp = 1;
+ env->sc_has_icmp = 1;
else
- env->has_icmp6 = 1;
+ env->sc_has_icmp6 = 1;
}
void
@@ -92,7 +92,7 @@ check_icmp_add(struct ctl_icmp_event *cie, int flags, struct timeval *start,
if (start != NULL)
bcopy(start, &cie->tv_start, sizeof(cie->tv_start));
- bcopy(&cie->env->timeout, &tv, sizeof(tv));
+ bcopy(&cie->env->sc_timeout, &tv, sizeof(tv));
if (gettimeofday(&cie->tv_start, NULL))
fatal("check_icmp_add: gettimeofday");
event_del(&cie->ev);
@@ -103,13 +103,13 @@ check_icmp_add(struct ctl_icmp_event *cie, int flags, struct timeval *start,
void
check_icmp(struct relayd *env, struct timeval *tv)
{
- if (env->has_icmp) {
- check_icmp_add(&env->icmp_recv, EV_READ, tv, recv_icmp);
- check_icmp_add(&env->icmp_send, EV_WRITE, tv, send_icmp);
+ if (env->sc_has_icmp) {
+ check_icmp_add(&env->sc_icmp_recv, EV_READ, tv, recv_icmp);
+ check_icmp_add(&env->sc_icmp_send, EV_WRITE, tv, send_icmp);
}
- if (env->has_icmp6) {
- check_icmp_add(&env->icmp6_recv, EV_READ, tv, recv_icmp);
- check_icmp_add(&env->icmp6_send, EV_WRITE, tv, send_icmp);
+ if (env->sc_has_icmp6) {
+ check_icmp_add(&env->sc_icmp6_recv, EV_READ, tv, recv_icmp);
+ check_icmp_add(&env->sc_icmp6_send, EV_WRITE, tv, send_icmp);
}
}
@@ -119,7 +119,7 @@ icmp_checks_done(struct ctl_icmp_event *cie)
struct table *table;
struct host *host;
- TAILQ_FOREACH(table, cie->env->tables, entry) {
+ TAILQ_FOREACH(table, cie->env->sc_tables, entry) {
if (table->conf.flags & F_DISABLE ||
table->conf.check != CHECK_ICMP)
continue;
@@ -140,7 +140,7 @@ icmp_checks_timeout(struct ctl_icmp_event *cie, const char *msg)
struct table *table;
struct host *host;
- TAILQ_FOREACH(table, cie->env->tables, entry) {
+ TAILQ_FOREACH(table, cie->env->sc_tables, entry) {
if (table->conf.flags & F_DISABLE ||
table->conf.check != CHECK_ICMP)
continue;
@@ -181,18 +181,18 @@ send_icmp(int s, short event, void *arg)
if (cie->af == AF_INET) {
icp->icmp_type = ICMP_ECHO;
icp->icmp_code = 0;
- icp->icmp_id = htons(cie->env->id);
+ icp->icmp_id = htons(cie->env->sc_id);
icp->icmp_cksum = 0;
slen = sizeof(struct sockaddr_in);
} else {
icp6->icmp6_type = ICMP6_ECHO_REQUEST;
icp6->icmp6_code = 0;
icp6->icmp6_cksum = 0;
- icp6->icmp6_id = htons(cie->env->id);
+ icp6->icmp6_id = htons(cie->env->sc_id);
slen = sizeof(struct sockaddr_in6);
}
- TAILQ_FOREACH(table, cie->env->tables, entry) {
+ TAILQ_FOREACH(table, cie->env->sc_tables, entry) {
if (table->conf.check != CHECK_ICMP ||
table->conf.flags & F_DISABLE)
continue;
@@ -236,7 +236,7 @@ send_icmp(int s, short event, void *arg)
retry:
event_again(&cie->ev, s, EV_TIMEOUT|EV_WRITE, send_icmp,
- &cie->tv_start, &cie->env->timeout, cie);
+ &cie->tv_start, &cie->env->sc_timeout, cie);
}
void
@@ -278,7 +278,7 @@ recv_icmp(int s, short event, void *arg)
icpid = ntohs(icp6->icmp6_id);
memcpy(&id, packet + sizeof(*icp6), sizeof(id));
}
- if (icpid != cie->env->id)
+ if (icpid != cie->env->sc_id)
goto retry;
host = host_find(cie->env, id);
if (host == NULL) {
@@ -299,7 +299,7 @@ recv_icmp(int s, short event, void *arg)
retry:
event_again(&cie->ev, s, EV_TIMEOUT|EV_READ, recv_icmp,
- &cie->tv_start, &cie->env->timeout, cie);
+ &cie->tv_start, &cie->env->sc_timeout, cie);
}
/* in_cksum from ping.c --
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c
index e0790ed3dc7..d0c7258fe7d 100644
--- a/usr.sbin/relayd/control.c
+++ b/usr.sbin/relayd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.24 2008/01/29 16:32:29 reyk Exp $ */
+/* $OpenBSD: control.c,v 1.25 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -326,7 +326,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
case IMSG_CTL_RELOAD:
- if (env->prefork_relay > 0) {
+ if (env->sc_prefork_relay > 0) {
imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
break;
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index 0642bf5f86d..2aad94c9eba 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.38 2007/12/08 20:36:36 pyr Exp $ */
+/* $OpenBSD: hce.c,v 1.39 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -147,7 +147,7 @@ hce(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
close(pipe_parent2hce[0]);
close(pipe_parent2pfe[0]);
close(pipe_parent2pfe[1]);
- for (i = 0; i < env->prefork_relay; i++) {
+ for (i = 0; i < env->sc_prefork_relay; i++) {
close(pipe_parent2relay[i][0]);
close(pipe_parent2relay[i][1]);
close(pipe_pfe2relay[i][0]);
@@ -167,15 +167,15 @@ hce_setup_events(void)
struct timeval tv;
struct table *table;
- if (!TAILQ_EMPTY(env->tables)) {
- evtimer_set(&env->ev, hce_launch_checks, env);
+ if (!TAILQ_EMPTY(env->sc_tables)) {
+ evtimer_set(&env->sc_ev, hce_launch_checks, env);
bzero(&tv, sizeof(tv));
- evtimer_add(&env->ev, &tv);
+ evtimer_add(&env->sc_ev, &tv);
}
- if (env->flags & F_SSL) {
+ if (env->sc_flags & F_SSL) {
ssl_init(env);
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
if (!(table->conf.flags & F_SSL))
continue;
table->ssl_ctx = ssl_ctx_create(env);
@@ -189,20 +189,20 @@ hce_disable_events(void)
struct table *table;
struct host *host;
- evtimer_del(&env->ev);
- TAILQ_FOREACH(table, env->tables, entry) {
+ evtimer_del(&env->sc_ev);
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
TAILQ_FOREACH(host, &table->hosts, entry) {
event_del(&host->cte.ev);
close(host->cte.s);
}
}
- if (env->has_icmp) {
- event_del(&env->icmp_send.ev);
- event_del(&env->icmp_recv.ev);
+ if (env->sc_has_icmp) {
+ event_del(&env->sc_icmp_send.ev);
+ event_del(&env->sc_icmp_recv.ev);
}
- if (env->has_icmp6) {
- event_del(&env->icmp6_send.ev);
- event_del(&env->icmp6_recv.ev);
+ if (env->sc_has_icmp6) {
+ event_del(&env->sc_icmp6_send.ev);
+ event_del(&env->sc_icmp6_recv.ev);
}
}
@@ -217,7 +217,7 @@ hce_launch_checks(int fd, short event, void *arg)
* notify pfe checks are done and schedule next check
*/
imsg_compose(ibuf_pfe, IMSG_SYNC, 0, 0, -1, NULL, 0);
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
TAILQ_FOREACH(host, &table->hosts, entry) {
host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE);
event_del(&host->cte.ev);
@@ -227,7 +227,7 @@ hce_launch_checks(int fd, short event, void *arg)
if (gettimeofday(&tv, NULL))
fatal("hce_launch_checks: gettimeofday");
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
if (table->conf.flags & F_DISABLE)
continue;
if (table->conf.skip_cnt) {
@@ -264,8 +264,8 @@ hce_launch_checks(int fd, short event, void *arg)
}
check_icmp(env, &tv);
- bcopy(&env->interval, &tv, sizeof(tv));
- evtimer_add(&env->ev, &tv);
+ bcopy(&env->sc_interval, &tv, sizeof(tv));
+ evtimer_add(&env->sc_ev, &tv);
}
void
@@ -314,7 +314,7 @@ hce_notify_done(struct host *host, const char *msg)
if ((table = table_find(env, host->conf.tableid)) == NULL)
fatalx("hce_notify_done: invalid table id");
- if (env->opts & logopt) {
+ if (env->sc_opts & logopt) {
log_info("host %s, check %s%s (%lums), state %s -> %s, "
"availability %s",
host->conf.name, table_check(table->conf.check),
@@ -403,8 +403,8 @@ hce_dispatch_imsg(int fd, short event, void *ptr)
host->up = HOST_UNKNOWN;
break;
case IMSG_CTL_POLL:
- evtimer_del(&env->ev);
- TAILQ_FOREACH(table, env->tables, entry)
+ evtimer_del(&env->sc_ev);
+ TAILQ_FOREACH(table, env->sc_tables, entry)
table->skipped = 0;
hce_launch_checks(-1, EV_TIMEOUT, env);
break;
@@ -475,18 +475,18 @@ hce_dispatch_parent(int fd, short event, void * ptr)
purge_config(env, PURGE_TABLES);
merge_config(env, (struct relayd *)imsg.data);
- env->tables = calloc(1, sizeof(*env->tables));
- if (env->tables == NULL)
+ env->sc_tables = calloc(1, sizeof(*env->sc_tables));
+ if (env->sc_tables == NULL)
fatal(NULL);
- TAILQ_INIT(env->tables);
+ TAILQ_INIT(env->sc_tables);
break;
case IMSG_RECONF_TABLE:
if ((table = calloc(1, sizeof(*table))) == NULL)
fatal(NULL);
memcpy(&table->conf, imsg.data, sizeof(table->conf));
TAILQ_INIT(&table->hosts);
- TAILQ_INSERT_TAIL(env->tables, table, entry);
+ TAILQ_INSERT_TAIL(env->sc_tables, table, entry);
break;
case IMSG_RECONF_SENDBUF:
len = imsg.hdr.len - IMSG_HEADER_SIZE;
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index 24ac3d40be9..6a0a84d1d66 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.101 2008/01/29 10:30:10 pyr Exp $ */
+/* $OpenBSD: parse.y,v 1.102 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -272,14 +272,14 @@ sendbuf : NOTHING {
;
main : INTERVAL NUMBER {
- if ((conf->interval.tv_sec = $2) < 0) {
+ if ((conf->sc_interval.tv_sec = $2) < 0) {
yyerror("invalid interval: %d", $2);
YYERROR;
}
}
- | LOG loglevel { conf->opts |= $2; }
+ | LOG loglevel { conf->sc_opts |= $2; }
| TIMEOUT timeout {
- bcopy(&$2, &conf->timeout, sizeof(struct timeval));
+ bcopy(&$2, &conf->sc_timeout, sizeof(struct timeval));
}
| PREFORK NUMBER {
if ($2 <= 0 || $2 > RELAY_MAXPROC) {
@@ -287,21 +287,21 @@ main : INTERVAL NUMBER {
"relays: %d", $2);
YYERROR;
}
- conf->prefork_relay = $2;
+ conf->sc_prefork_relay = $2;
}
| DEMOTE STRING {
- conf->flags |= F_DEMOTE;
- if (strlcpy(conf->demote_group, $2,
- sizeof(conf->demote_group))
- >= sizeof(conf->demote_group)) {
+ conf->sc_flags |= F_DEMOTE;
+ if (strlcpy(conf->sc_demote_group, $2,
+ sizeof(conf->sc_demote_group))
+ >= sizeof(conf->sc_demote_group)) {
yyerror("yyparse: demote group name too long");
free($2);
YYERROR;
}
free($2);
- if (carp_demote_init(conf->demote_group, 1) == -1) {
+ if (carp_demote_init(conf->sc_demote_group, 1) == -1) {
yyerror("yyparse: error initializing group %s",
- conf->demote_group);
+ conf->sc_demote_group);
YYERROR;
}
}
@@ -314,7 +314,7 @@ loglevel : UPDATES { $$ = RELAYD_OPT_LOGUPDATE; }
rdr : REDIRECT STRING {
struct rdr *srv;
- TAILQ_FOREACH(srv, conf->rdrs, entry)
+ TAILQ_FOREACH(srv, conf->sc_rdrs, entry)
if (!strcmp(srv->conf.name, $2))
break;
if (srv != NULL) {
@@ -351,11 +351,11 @@ rdr : REDIRECT STRING {
rdr->conf.name);
YYERROR;
}
- conf->rdrcount++;
+ conf->sc_rdrcount++;
if (rdr->backup == NULL) {
rdr->conf.backup_id =
- conf->empty_table.conf.id;
- rdr->backup = &conf->empty_table;
+ conf->sc_empty_table.conf.id;
+ rdr->backup = &conf->sc_empty_table;
} else if (rdr->backup->conf.port !=
rdr->table->conf.port) {
yyerror("redirection %s uses two different "
@@ -365,7 +365,7 @@ rdr : REDIRECT STRING {
}
if (!(rdr->conf.flags & F_DISABLE))
rdr->conf.flags |= F_ADD;
- TAILQ_INSERT_HEAD(conf->rdrs, rdr, entry);
+ TAILQ_INSERT_HEAD(conf->sc_rdrs, rdr, entry);
tableport = 0;
rdr = NULL;
}
@@ -378,12 +378,12 @@ rdropts_l : rdropts_l rdroptsl nl
rdroptsl : FORWARD TO tablespec {
if ($3->conf.check == CHECK_NOCHECK) {
yyerror("table %s has no check", $3->conf.name);
- purge_table(conf->tables, $3);
+ purge_table(conf->sc_tables, $3);
YYERROR;
}
if (rdr->backup) {
yyerror("only one backup table is allowed");
- purge_table(conf->tables, $3);
+ purge_table(conf->sc_tables, $3);
YYERROR;
}
if (rdr->table) {
@@ -438,7 +438,7 @@ table : '<' STRING '>' {
tabledef : TABLE table {
struct table *tb;
- TAILQ_FOREACH(tb, conf->tables, entry)
+ TAILQ_FOREACH(tb, conf->sc_tables, entry)
if (!strcmp(tb->conf.name, $2))
break;
if (tb != NULL) {
@@ -454,7 +454,7 @@ tabledef : TABLE table {
free($2);
tb->conf.id = last_table_id++;
- bcopy(&conf->timeout, &tb->conf.timeout,
+ bcopy(&conf->sc_timeout, &tb->conf.timeout,
sizeof(struct timeval));
if (last_table_id == INT_MAX) {
yyerror("too many tables defined");
@@ -468,8 +468,8 @@ tabledef : TABLE table {
table->conf.name);
YYERROR;
}
- conf->tablecount++;
- TAILQ_INSERT_HEAD(conf->tables, table, entry);
+ conf->sc_tablecount++;
+ TAILQ_INSERT_HEAD(conf->sc_tables, table, entry);
}
;
@@ -538,13 +538,13 @@ tableopts : CHECK tablecheck
}
}
| INTERVAL NUMBER {
- if ($2 < conf->interval.tv_sec ||
- $2 % conf->interval.tv_sec) {
+ if ($2 < conf->sc_interval.tv_sec ||
+ $2 % conf->sc_interval.tv_sec) {
yyerror("table interval must be "
"divisible by global interval");
YYERROR;
}
- table->conf.skip_cnt = ($2 / conf->interval.tv_sec) - 1;
+ table->conf.skip_cnt = ($2 / conf->sc_interval.tv_sec) - 1;
}
| MODE dstmode {
switch ($2) {
@@ -568,12 +568,12 @@ tablecheck : ICMP { table->conf.check = CHECK_ICMP; }
| TCP { table->conf.check = CHECK_TCP; }
| SSL {
table->conf.check = CHECK_TCP;
- conf->flags |= F_SSL;
+ conf->sc_flags |= F_SSL;
table->conf.flags |= F_SSL;
}
| http_type STRING hostname CODE NUMBER {
if ($1) {
- conf->flags |= F_SSL;
+ conf->sc_flags |= F_SSL;
table->conf.flags |= F_SSL;
}
table->conf.check = CHECK_HTTP_CODE;
@@ -594,7 +594,7 @@ tablecheck : ICMP { table->conf.check = CHECK_ICMP; }
}
| http_type STRING hostname digest {
if ($1) {
- conf->flags |= F_SSL;
+ conf->sc_flags |= F_SSL;
table->conf.flags |= F_SSL;
}
table->conf.check = CHECK_HTTP_DIGEST;
@@ -614,7 +614,7 @@ tablecheck : ICMP { table->conf.check = CHECK_ICMP; }
| SEND sendbuf EXPECT STRING optssl {
table->conf.check = CHECK_SEND_EXPECT;
if ($5) {
- conf->flags |= F_SSL;
+ conf->sc_flags |= F_SSL;
table->conf.flags |= F_SSL;
}
if (strlcpy(table->conf.exbuf, $4,
@@ -662,9 +662,9 @@ proto : proto_type PROTO STRING {
struct protocol *p;
if (strcmp($3, "default") == 0) {
- p = &conf->proto_default;
+ p = &conf->sc_proto_default;
} else {
- TAILQ_FOREACH(p, conf->protos, entry)
+ TAILQ_FOREACH(p, conf->sc_protos, entry)
if (!strcmp(p->name, $3))
break;
}
@@ -701,14 +701,14 @@ proto : proto_type PROTO STRING {
RB_INIT(&p->response_tree);
proto = p;
} protopts_n {
- conf->protocount++;
+ conf->sc_protocount++;
if ((proto->sslflags & SSLFLAG_VERSION) == 0) {
yyerror("invalid SSL protocol");
YYERROR;
}
- TAILQ_INSERT_HEAD(conf->protos, proto, entry);
+ TAILQ_INSERT_HEAD(conf->sc_protos, proto, entry);
}
;
@@ -1096,7 +1096,7 @@ sslcache : NUMBER {
relay : RELAY STRING {
struct relay *r;
- TAILQ_FOREACH(r, conf->relays, entry)
+ TAILQ_FOREACH(r, conf->sc_relays, entry)
if (!strcmp(r->conf.name, $2))
break;
if (r != NULL) {
@@ -1140,17 +1140,17 @@ relay : RELAY STRING {
YYERROR;
}
if (rlay->conf.proto == EMPTY_ID) {
- rlay->proto = &conf->proto_default;
- rlay->conf.proto = conf->proto_default.id;
+ rlay->proto = &conf->sc_proto_default;
+ rlay->conf.proto = conf->sc_proto_default.id;
}
if (relay_load_certfiles(rlay) == -1) {
yyerror("cannot load certificates for relay %s",
rlay->conf.name);
YYERROR;
}
- conf->relaycount++;
+ conf->sc_relaycount++;
SPLAY_INIT(&rlay->sessions);
- TAILQ_INSERT_HEAD(conf->relays, rlay, entry);
+ TAILQ_INSERT_HEAD(conf->sc_relays, rlay, entry);
tableport = 0;
rlay = NULL;
}
@@ -1182,7 +1182,7 @@ relayoptsl : LISTEN ON STRING port optssl {
rlay->conf.port = h->port;
if ($5) {
rlay->conf.flags |= F_SSL;
- conf->flags |= F_SSL;
+ conf->sc_flags |= F_SSL;
}
tableport = h->port;
}
@@ -1196,7 +1196,7 @@ relayoptsl : LISTEN ON STRING port optssl {
| PROTO STRING {
struct protocol *p;
- TAILQ_FOREACH(p, conf->protos, entry)
+ TAILQ_FOREACH(p, conf->sc_protos, entry)
if (!strcmp(p->name, $2))
break;
if (p == NULL) {
@@ -1216,7 +1216,7 @@ relayoptsl : LISTEN ON STRING port optssl {
forwardspec : tablespec {
if (rlay->dsttable) {
yyerror("table already specified");
- purge_table(conf->tables, $1);
+ purge_table(conf->sc_tables, $1);
YYERROR;
}
@@ -1762,10 +1762,10 @@ parse_config(const char *filename, int opts)
struct host *h;
if ((conf = calloc(1, sizeof(*conf))) == NULL ||
- (conf->tables = calloc(1, sizeof(*conf->tables))) == NULL ||
- (conf->relays = calloc(1, sizeof(*conf->relays))) == NULL ||
- (conf->protos = calloc(1, sizeof(*conf->protos))) == NULL ||
- (conf->rdrs = calloc(1, sizeof(*conf->rdrs))) == NULL) {
+ (conf->sc_tables = calloc(1, sizeof(*conf->sc_tables))) == NULL ||
+ (conf->sc_relays = calloc(1, sizeof(*conf->sc_relays))) == NULL ||
+ (conf->sc_protos = calloc(1, sizeof(*conf->sc_protos))) == NULL ||
+ (conf->sc_rdrs = calloc(1, sizeof(*conf->sc_rdrs))) == NULL) {
log_warn("cannot allocate memory");
return (NULL);
}
@@ -1779,34 +1779,34 @@ parse_config(const char *filename, int opts)
rlay = NULL;
proto = NULL;
- TAILQ_INIT(conf->rdrs);
- TAILQ_INIT(conf->tables);
- TAILQ_INIT(conf->protos);
- TAILQ_INIT(conf->relays);
-
- memset(&conf->empty_table, 0, sizeof(conf->empty_table));
- conf->empty_table.conf.id = EMPTY_TABLE;
- conf->empty_table.conf.flags |= F_DISABLE;
- (void)strlcpy(conf->empty_table.conf.name, "empty",
- sizeof(conf->empty_table.conf.name));
-
- bzero(&conf->proto_default, sizeof(conf->proto_default));
- conf->proto_default.flags = F_USED;
- conf->proto_default.cache = RELAY_CACHESIZE;
- conf->proto_default.type = RELAY_PROTO_TCP;
- (void)strlcpy(conf->proto_default.name, "default",
- sizeof(conf->proto_default.name));
- RB_INIT(&conf->proto_default.request_tree);
- RB_INIT(&conf->proto_default.response_tree);
-
- conf->timeout.tv_sec = CHECK_TIMEOUT / 1000;
- conf->timeout.tv_usec = (CHECK_TIMEOUT % 1000) * 1000;
- conf->interval.tv_sec = CHECK_INTERVAL;
- conf->interval.tv_usec = 0;
- conf->prefork_relay = RELAY_NUMPROC;
- conf->statinterval.tv_sec = RELAY_STATINTERVAL;
- conf->opts = opts;
- conf->confpath = filename;
+ TAILQ_INIT(conf->sc_rdrs);
+ TAILQ_INIT(conf->sc_tables);
+ TAILQ_INIT(conf->sc_protos);
+ TAILQ_INIT(conf->sc_relays);
+
+ memset(&conf->sc_empty_table, 0, sizeof(conf->sc_empty_table));
+ conf->sc_empty_table.conf.id = EMPTY_TABLE;
+ conf->sc_empty_table.conf.flags |= F_DISABLE;
+ (void)strlcpy(conf->sc_empty_table.conf.name, "empty",
+ sizeof(conf->sc_empty_table.conf.name));
+
+ bzero(&conf->sc_proto_default, sizeof(conf->sc_proto_default));
+ conf->sc_proto_default.flags = F_USED;
+ conf->sc_proto_default.cache = RELAY_CACHESIZE;
+ conf->sc_proto_default.type = RELAY_PROTO_TCP;
+ (void)strlcpy(conf->sc_proto_default.name, "default",
+ sizeof(conf->sc_proto_default.name));
+ RB_INIT(&conf->sc_proto_default.request_tree);
+ RB_INIT(&conf->sc_proto_default.response_tree);
+
+ conf->sc_timeout.tv_sec = CHECK_TIMEOUT / 1000;
+ conf->sc_timeout.tv_usec = (CHECK_TIMEOUT % 1000) * 1000;
+ conf->sc_interval.tv_sec = CHECK_INTERVAL;
+ conf->sc_interval.tv_usec = 0;
+ conf->sc_prefork_relay = RELAY_NUMPROC;
+ conf->sc_statinterval.tv_sec = RELAY_STATINTERVAL;
+ conf->sc_opts = opts;
+ conf->sc_confpath = filename;
if ((file = pushfile(filename, 0)) == NULL) {
free(conf);
@@ -1823,7 +1823,7 @@ parse_config(const char *filename, int opts)
/* Free macros and check which have not been used. */
for (sym = TAILQ_FIRST(&symhead); sym != NULL; sym = next) {
next = TAILQ_NEXT(sym, entry);
- if ((conf->opts & RELAYD_OPT_VERBOSE) && !sym->used)
+ if ((conf->sc_opts & RELAYD_OPT_VERBOSE) && !sym->used)
fprintf(stderr, "warning: macro '%s' not "
"used\n", sym->nam);
if (!sym->persist) {
@@ -1834,25 +1834,25 @@ parse_config(const char *filename, int opts)
}
}
- if (TAILQ_EMPTY(conf->rdrs) && TAILQ_EMPTY(conf->relays)) {
+ if (TAILQ_EMPTY(conf->sc_rdrs) && TAILQ_EMPTY(conf->sc_relays)) {
log_warnx("no redirections, nothing to do");
errors++;
}
- if (TAILQ_EMPTY(conf->relays))
- conf->prefork_relay = 0;
+ if (TAILQ_EMPTY(conf->sc_relays))
+ conf->sc_prefork_relay = 0;
- if (timercmp(&conf->timeout, &conf->interval, >=)) {
+ if (timercmp(&conf->sc_timeout, &conf->sc_interval, >=)) {
log_warnx("global timeout exceeds interval");
errors++;
}
/* Verify that every table is used */
- for (table = TAILQ_FIRST(conf->tables); table != NULL;
+ for (table = TAILQ_FIRST(conf->sc_tables); table != NULL;
table = nexttb) {
nexttb = TAILQ_NEXT(table, entry);
if (table->conf.port == 0) {
- TAILQ_REMOVE(conf->tables, table, entry);
+ TAILQ_REMOVE(conf->sc_tables, table, entry);
while ((h = TAILQ_FIRST(&table->hosts)) != NULL) {
TAILQ_REMOVE(&table->hosts, h, entry);
free(h);
@@ -1866,7 +1866,7 @@ parse_config(const char *filename, int opts)
log_warnx("unused table: %s", table->conf.name);
errors++;
}
- if (timercmp(&table->conf.timeout, &conf->interval, >=)) {
+ if (timercmp(&table->conf.timeout, &conf->sc_interval, >=)) {
log_warnx("table timeout exceeds interval: %s",
table->conf.name);
errors++;
@@ -1874,7 +1874,7 @@ parse_config(const char *filename, int opts)
}
/* Verify that every non-default protocol is used */
- TAILQ_FOREACH(proto, conf->protos, entry) {
+ TAILQ_FOREACH(proto, conf->sc_protos, entry) {
if (!(proto->flags & F_USED)) {
log_warnx("unused protocol: %s", proto->name);
}
@@ -2153,8 +2153,8 @@ table_inherit(struct table *tb)
TAILQ_INSERT_HEAD(&tb->hosts, h, entry);
}
- conf->tablecount++;
- TAILQ_INSERT_HEAD(conf->tables, tb, entry);
+ conf->sc_tablecount++;
+ TAILQ_INSERT_HEAD(conf->sc_tables, tb, entry);
return (tb);
}
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index a8d1cf5c31a..edcff4a8179 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.46 2007/12/20 20:15:43 reyk Exp $ */
+/* $OpenBSD: pfe.c,v 1.47 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -129,7 +129,7 @@ pfe(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
close(pipe_parent2pfe[0]);
close(pipe_parent2hce[0]);
close(pipe_parent2hce[1]);
- for (i = 0; i < env->prefork_relay; i++) {
+ for (i = 0; i < env->sc_prefork_relay; i++) {
close(pipe_parent2relay[i][0]);
close(pipe_parent2relay[i][1]);
close(pipe_pfe2relay[i][0]);
@@ -137,13 +137,13 @@ pfe(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
size = sizeof(struct imsgbuf);
if ((ibuf_hce = calloc(1, size)) == NULL ||
- (ibuf_relay = calloc(env->prefork_relay, size)) == NULL ||
+ (ibuf_relay = calloc(env->sc_prefork_relay, size)) == NULL ||
(ibuf_main = calloc(1, size)) == NULL)
fatal("pfe");
imsg_init(ibuf_hce, pipe_pfe2hce[1], pfe_dispatch_imsg);
imsg_init(ibuf_main, pipe_parent2pfe[1], pfe_dispatch_parent);
- for (i = 0; i < env->prefork_relay; i++)
+ for (i = 0; i < env->sc_prefork_relay; i++)
imsg_init(&ibuf_relay[i], pipe_pfe2relay[i][1],
pfe_dispatch_relay);
@@ -188,7 +188,7 @@ pfe_setup_events(void)
ibuf_hce->handler, ibuf_hce);
event_add(&ibuf_hce->ev, NULL);
- for (i = 0; i < env->prefork_relay; i++) {
+ for (i = 0; i < env->sc_prefork_relay; i++) {
ibuf = &ibuf_relay[i];
ibuf->events = EV_READ;
@@ -198,9 +198,9 @@ pfe_setup_events(void)
}
/* Schedule statistics timer */
- evtimer_set(&env->statev, pfe_statistics, NULL);
- bcopy(&env->statinterval, &tv, sizeof(tv));
- evtimer_add(&env->statev, &tv);
+ evtimer_set(&env->sc_statev, pfe_statistics, NULL);
+ bcopy(&env->sc_statinterval, &tv, sizeof(tv));
+ evtimer_add(&env->sc_statev, &tv);
}
void
@@ -210,10 +210,10 @@ pfe_disable_events(void)
event_del(&ibuf_hce->ev);
- for (i = 0; i < env->prefork_relay; i++)
+ for (i = 0; i < env->sc_prefork_relay; i++)
event_del(&ibuf_relay[i].ev);
- event_del(&env->statev);
+ event_del(&env->sc_statev);
}
void
@@ -280,7 +280,7 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
break;
/* Forward to relay engine(s) */
- for (n = 0; n < env->prefork_relay; n++)
+ for (n = 0; n < env->sc_prefork_relay; n++)
imsg_compose(&ibuf_relay[n],
IMSG_HOST_STATUS, 0, 0, -1, &st,
sizeof(st));
@@ -374,23 +374,23 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
/*
* no relays when reconfiguring yet.
*/
- env->relays = NULL;
- env->protos = NULL;
+ env->sc_relays = NULL;
+ env->sc_protos = NULL;
- env->tables = calloc(1, sizeof(*env->tables));
- env->rdrs = calloc(1, sizeof(*env->rdrs));
- if (env->tables == NULL || env->rdrs == NULL)
+ env->sc_tables = calloc(1, sizeof(*env->sc_tables));
+ env->sc_rdrs = calloc(1, sizeof(*env->sc_rdrs));
+ if (env->sc_tables == NULL || env->sc_rdrs == NULL)
fatal(NULL);
- TAILQ_INIT(env->tables);
- TAILQ_INIT(env->rdrs);
+ TAILQ_INIT(env->sc_tables);
+ TAILQ_INIT(env->sc_rdrs);
break;
case IMSG_RECONF_TABLE:
if ((table = calloc(1, sizeof(*table))) == NULL)
fatal(NULL);
memcpy(&table->conf, imsg.data, sizeof(table->conf));
TAILQ_INIT(&table->hosts);
- TAILQ_INSERT_TAIL(env->tables, table, entry);
+ TAILQ_INSERT_TAIL(env->sc_tables, table, entry);
break;
case IMSG_RECONF_HOST:
if ((host = calloc(1, sizeof(*host))) == NULL)
@@ -407,7 +407,7 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
rdr->table = table_find(env,
rdr->conf.table_id);
if (rdr->conf.backup_id == EMPTY_TABLE)
- rdr->backup = &env->empty_table;
+ rdr->backup = &env->sc_empty_table;
else
rdr->backup = table_find(env,
rdr->conf.backup_id);
@@ -419,7 +419,7 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
log_debug("pfe_dispatch_parent: rdr->backup: %s",
rdr->backup->conf.name);
TAILQ_INIT(&rdr->virts);
- TAILQ_INSERT_TAIL(env->rdrs, rdr, entry);
+ TAILQ_INSERT_TAIL(env->sc_rdrs, rdr, entry);
break;
case IMSG_RECONF_VIRT:
if ((virt = calloc(1, sizeof(*virt))) == NULL)
@@ -484,7 +484,7 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(cnl))
fatalx("invalid imsg header len");
bcopy(imsg.data, &cnl, sizeof(cnl));
- if (cnl.proc > env->prefork_relay)
+ if (cnl.proc > env->sc_prefork_relay)
fatalx("pfe_dispatch_relay: "
"invalid relay proc");
if (natlook(env, &cnl) != 0)
@@ -496,14 +496,14 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(crs))
fatalx("invalid imsg header len");
bcopy(imsg.data, &crs, sizeof(crs));
- if (crs.proc > env->prefork_relay)
+ if (crs.proc > env->sc_prefork_relay)
fatalx("pfe_dispatch_relay: "
"invalid relay proc");
if ((rlay = relay_find(env, crs.id)) == NULL)
fatalx("pfe_dispatch_relay: invalid relay id");
bcopy(&crs, &rlay->stats[crs.proc], sizeof(crs));
rlay->stats[crs.proc].interval =
- env->statinterval.tv_sec;
+ env->sc_statinterval.tv_sec;
break;
default:
log_debug("pfe_dispatch_relay: unexpected imsg %d",
@@ -522,9 +522,9 @@ show(struct ctl_conn *c)
struct host *host;
struct relay *rlay;
- if (env->rdrs == NULL)
+ if (env->sc_rdrs == NULL)
goto relays;
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
imsg_compose(&c->ibuf, IMSG_CTL_RDR, 0, 0, -1,
rdr, sizeof(*rdr));
if (rdr->conf.flags & F_DISABLE)
@@ -550,10 +550,10 @@ show(struct ctl_conn *c)
host, sizeof(*host));
}
relays:
- if (env->relays == NULL)
+ if (env->sc_relays == NULL)
goto end;
- TAILQ_FOREACH(rlay, env->relays, entry) {
- rlay->stats[env->prefork_relay].id = EMPTY_ID;
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
+ rlay->stats[env->sc_prefork_relay].id = EMPTY_ID;
imsg_compose(&c->ibuf, IMSG_CTL_RELAY, 0, 0, -1,
rlay, sizeof(*rlay));
imsg_compose(&c->ibuf, IMSG_CTL_RELAY_STATS, 0, 0, -1,
@@ -578,7 +578,7 @@ show_sessions(struct ctl_conn *c)
int n, proc, done;
struct imsg imsg;
- for (proc = 0; proc < env->prefork_relay; proc++) {
+ for (proc = 0; proc < env->sc_prefork_relay; proc++) {
/*
* Request all the running sessions from the process
*/
@@ -783,7 +783,7 @@ disable_host(struct ctl_conn *c, struct ctl_id *id)
imsg_compose(ibuf_hce, IMSG_HOST_DISABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
/* Forward to relay engine(s) */
- for (n = 0; n < env->prefork_relay; n++)
+ for (n = 0; n < env->sc_prefork_relay; n++)
imsg_compose(&ibuf_relay[n],
IMSG_HOST_DISABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
@@ -817,7 +817,7 @@ enable_host(struct ctl_conn *c, struct ctl_id *id)
imsg_compose(ibuf_hce, IMSG_HOST_ENABLE, 0, 0, -1,
&host->conf.id, sizeof (host->conf.id));
/* Forward to relay engine(s) */
- for (n = 0; n < env->prefork_relay; n++)
+ for (n = 0; n < env->sc_prefork_relay; n++)
imsg_compose(&ibuf_relay[n],
IMSG_HOST_ENABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
@@ -838,7 +838,7 @@ pfe_sync(void)
bzero(&id, sizeof(id));
bzero(&imsg, sizeof(imsg));
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
rdr->conf.flags &= ~(F_BACKUP);
rdr->conf.flags &= ~(F_DOWN);
@@ -889,7 +889,7 @@ pfe_sync(void)
}
}
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
/*
* clean up change flag.
*/
@@ -933,7 +933,7 @@ pfe_statistics(int fd, short events, void *arg)
if (gettimeofday(&tv_now, NULL))
fatal("pfe_statistics: gettimeofday");
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
cnt = check_table(env, rdr, rdr->table);
if (rdr->conf.backup_id != EMPTY_TABLE)
cnt += check_table(env, rdr, rdr->backup);
@@ -947,12 +947,12 @@ pfe_statistics(int fd, short events, void *arg)
cur->tick++;
cur->avg = (cur->last + cur->avg) / 2;
cur->last_hour += cur->last;
- if ((cur->tick % (3600 / env->statinterval.tv_sec)) == 0) {
+ if ((cur->tick % (3600 / env->sc_statinterval.tv_sec)) == 0) {
cur->avg_hour = (cur->last_hour + cur->avg_hour) / 2;
resethour++;
}
cur->last_day += cur->last;
- if ((cur->tick % (86400 / env->statinterval.tv_sec)) == 0) {
+ if ((cur->tick % (86400 / env->sc_statinterval.tv_sec)) == 0) {
cur->avg_day = (cur->last_day + cur->avg_day) / 2;
resethour++;
}
@@ -961,11 +961,11 @@ pfe_statistics(int fd, short events, void *arg)
if (resetday)
cur->last_day = 0;
- rdr->stats.interval = env->statinterval.tv_sec;
+ rdr->stats.interval = env->sc_statinterval.tv_sec;
}
/* Schedule statistics timer */
- evtimer_set(&env->statev, pfe_statistics, NULL);
- bcopy(&env->statinterval, &tv, sizeof(tv));
- evtimer_add(&env->statev, &tv);
+ evtimer_set(&env->sc_statev, pfe_statistics, NULL);
+ bcopy(&env->sc_statinterval, &tv, sizeof(tv));
+ evtimer_add(&env->sc_statev, &tv);
}
diff --git a/usr.sbin/relayd/pfe_filter.c b/usr.sbin/relayd/pfe_filter.c
index 64a0dd18c8e..1c7c48bd299 100644
--- a/usr.sbin/relayd/pfe_filter.c
+++ b/usr.sbin/relayd/pfe_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe_filter.c,v 1.22 2007/12/20 20:15:43 reyk Exp $ */
+/* $OpenBSD: pfe_filter.c,v 1.23 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -54,11 +54,11 @@ init_filter(struct relayd *env)
{
struct pf_status status;
- if ((env->pf = calloc(1, sizeof(*(env->pf)))) == NULL)
+ if ((env->sc_pf = calloc(1, sizeof(*(env->sc_pf)))) == NULL)
fatal("calloc");
- if ((env->pf->dev = open(PF_SOCKET, O_RDWR)) == -1)
+ if ((env->sc_pf->dev = open(PF_SOCKET, O_RDWR)) == -1)
fatal("init_filter: cannot open pf socket");
- if (ioctl(env->pf->dev, DIOCGETSTATUS, &status) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCGETSTATUS, &status) == -1)
fatal("init_filter: DIOCGETSTATUS");
if (!status.running)
fatalx("init_filter: pf is disabled");
@@ -73,11 +73,11 @@ init_tables(struct relayd *env)
struct pfr_table *tables;
struct pfioc_table io;
- if ((tables = calloc(env->rdrcount, sizeof(*tables))) == NULL)
+ if ((tables = calloc(env->sc_rdrcount, sizeof(*tables))) == NULL)
fatal("calloc");
i = 0;
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
if (strlcpy(tables[i].pfrt_anchor, RELAYD_ANCHOR "/",
sizeof(tables[i].pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
@@ -91,27 +91,27 @@ init_tables(struct relayd *env)
tables[i].pfrt_flags |= PFR_TFLAG_PERSIST;
i++;
}
- if (i != env->rdrcount)
+ if (i != env->sc_rdrcount)
fatalx("init_tables: table count modified");
memset(&io, 0, sizeof(io));
- io.pfrio_size = env->rdrcount;
+ io.pfrio_size = env->sc_rdrcount;
io.pfrio_esize = sizeof(*tables);
io.pfrio_buffer = tables;
- if (ioctl(env->pf->dev, DIOCRADDTABLES, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRADDTABLES, &io) == -1)
fatal("init_tables: cannot create tables");
log_debug("init_tables: created %d tables", io.pfrio_nadd);
free(tables);
- if (io.pfrio_nadd == env->rdrcount)
+ if (io.pfrio_nadd == env->sc_rdrcount)
return;
/*
* clear all tables, since some already existed
*/
- TAILQ_FOREACH(rdr, env->rdrs, entry)
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry)
flush_table(env, rdr);
return;
@@ -126,14 +126,14 @@ kill_tables(struct relayd *env) {
struct rdr *rdr;
memset(&io, 0, sizeof(io));
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
if (strlcpy(io.pfrio_table.pfrt_anchor, RELAYD_ANCHOR "/",
sizeof(io.pfrio_table.pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
if (strlcat(io.pfrio_table.pfrt_anchor, rdr->conf.name,
sizeof(io.pfrio_table.pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (ioctl(env->pf->dev, DIOCRCLRTABLES, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRCLRTABLES, &io) == -1)
fatal("kill_tables: ioctl faile: ioctl failed");
}
log_debug("kill_tables: deleted %d tables", io.pfrio_ndel);
@@ -209,7 +209,7 @@ sync_table(struct relayd *env, struct rdr *rdr, struct table *table)
if (i != table->up)
fatalx("sync_table: desynchronized");
- if (ioctl(env->pf->dev, DIOCRSETADDRS, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRSETADDRS, &io) == -1)
fatal("sync_table: cannot set address list");
free(addlist);
@@ -239,9 +239,9 @@ flush_table(struct relayd *env, struct rdr *rdr)
sizeof(io.pfrio_table.pfrt_name)) >=
sizeof(io.pfrio_table.pfrt_name))
goto toolong;
- if (ioctl(env->pf->dev, DIOCRCLRADDRS, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRCLRADDRS, &io) == -1)
fatal("flush_table: cannot flush table addresses");
- if (ioctl(env->pf->dev, DIOCRCLRTSTATS, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRCLRTSTATS, &io) == -1)
fatal("flush_table: cannot flush table stats");
log_debug("flush_table: flushed table %s", rdr->conf.name);
return;
@@ -253,15 +253,15 @@ flush_table(struct relayd *env, struct rdr *rdr)
int
transaction_init(struct relayd *env, const char *anchor)
{
- env->pf->pft.size = 1;
- env->pf->pft.esize = sizeof env->pf->pfte;
- env->pf->pft.array = &env->pf->pfte;
+ env->sc_pf->pft.size = 1;
+ env->sc_pf->pft.esize = sizeof env->sc_pf->pfte;
+ env->sc_pf->pft.array = &env->sc_pf->pfte;
- memset(&env->pf->pfte, 0, sizeof env->pf->pfte);
- (void)strlcpy(env->pf->pfte.anchor, anchor, PF_ANCHOR_NAME_SIZE);
- env->pf->pfte.rs_num = PF_RULESET_RDR;
+ memset(&env->sc_pf->pfte, 0, sizeof env->sc_pf->pfte);
+ (void)strlcpy(env->sc_pf->pfte.anchor, anchor, PF_ANCHOR_NAME_SIZE);
+ env->sc_pf->pfte.rs_num = PF_RULESET_RDR;
- if (ioctl(env->pf->dev, DIOCXBEGIN, &env->pf->pft) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCXBEGIN, &env->sc_pf->pft) == -1)
return (-1);
return (0);
}
@@ -269,7 +269,7 @@ transaction_init(struct relayd *env, const char *anchor)
int
transaction_commit(struct relayd *env)
{
- if (ioctl(env->pf->dev, DIOCXCOMMIT, &env->pf->pft) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCXCOMMIT, &env->sc_pf->pft) == -1)
return (-1);
return (0);
}
@@ -310,8 +310,8 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
memset(&pio, 0, sizeof(pio));
(void)strlcpy(rio.anchor, anchor, sizeof(rio.anchor));
- rio.ticket = env->pf->pfte.ticket;
- if (ioctl(env->pf->dev, DIOCBEGINADDRS, &pio) == -1)
+ rio.ticket = env->sc_pf->pfte.ticket;
+ if (ioctl(env->sc_pf->dev, DIOCBEGINADDRS, &pio) == -1)
fatal("sync_ruleset: cannot initialise address pool");
rio.pool_ticket = pio.ticket;
@@ -351,7 +351,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
sizeof(pio.addr.addr.v.tblname)) >=
sizeof(pio.addr.addr.v.tblname))
fatal("sync_ruleset: table name too long");
- if (ioctl(env->pf->dev, DIOCADDADDR, &pio) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCADDADDR, &pio) == -1)
fatal("sync_ruleset: cannot add address to pool");
rio.rule.rpool.proxy_port[0] = ntohs(rdr->table->conf.port);
@@ -360,7 +360,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
if (rdr->conf.flags & F_STICKY)
rio.rule.rpool.opts |= PF_POOL_STICKYADDR;
- if (ioctl(env->pf->dev, DIOCADDRULE, &rio) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCADDRULE, &rio) == -1)
fatal("cannot add rule");
log_debug("sync_ruleset: rule added");
}
@@ -379,7 +379,7 @@ flush_rulesets(struct relayd *env)
char anchor[PF_ANCHOR_NAME_SIZE];
kill_tables(env);
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
if (strlcpy(anchor, RELAYD_ANCHOR "/", sizeof(anchor)) >=
PF_ANCHOR_NAME_SIZE)
goto toolong;
@@ -438,10 +438,10 @@ natlook(struct relayd *env, struct ctl_natlook *cnl)
pnl.direction = PF_IN;
cnl->in = 1;
- if (ioctl(env->pf->dev, DIOCNATLOOK, &pnl) == -1) {
+ if (ioctl(env->sc_pf->dev, DIOCNATLOOK, &pnl) == -1) {
pnl.direction = PF_OUT;
cnl->in = 0;
- if (ioctl(env->pf->dev, DIOCNATLOOK, &pnl) == -1) {
+ if (ioctl(env->sc_pf->dev, DIOCNATLOOK, &pnl) == -1) {
log_debug("natlook: error");
return (-1);
}
@@ -503,7 +503,7 @@ check_table(struct relayd *env, struct rdr *rdr, struct table *table)
sizeof(io.pfrio_table.pfrt_name))
goto toolong;
- if (ioctl(env->pf->dev, DIOCRGETTSTATS, &io) == -1)
+ if (ioctl(env->sc_pf->dev, DIOCRGETTSTATS, &io) == -1)
fatal("sync_table: cannot get table stats");
return (tstats.pfrts_match);
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index c8904c53a29..cd8b5c54630 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.77 2007/12/08 20:36:36 pyr Exp $ */
+/* $OpenBSD: relay.c,v 1.78 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -204,7 +204,7 @@ relay(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
#endif
/* Fork child handlers */
- for (i = 1; i < env->prefork_relay; i++) {
+ for (i = 1; i < env->sc_prefork_relay; i++) {
if (fork() == 0) {
proc_id = i;
break;
@@ -230,7 +230,7 @@ relay(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
close(pipe_parent2hce[1]);
close(pipe_parent2pfe[0]);
close(pipe_parent2pfe[1]);
- for (i = 0; i < env->prefork_relay; i++) {
+ for (i = 0; i < env->sc_prefork_relay; i++) {
if (i == proc_id)
continue;
close(pipe_parent2relay[i][0]);
@@ -272,7 +272,7 @@ relay_shutdown(void)
struct session *con;
struct relay *rlay;
- TAILQ_FOREACH(rlay, env->relays, entry) {
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
if (rlay->conf.flags & F_DISABLE)
continue;
close(rlay->s);
@@ -415,10 +415,10 @@ relay_privinit(void)
struct relay *rlay;
extern int debug;
- if (env->flags & F_SSL)
+ if (env->sc_flags & F_SSL)
ssl_init(env);
- TAILQ_FOREACH(rlay, env->relays, entry) {
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
log_debug("relay_privinit: adding relay %s", rlay->conf.name);
if (debug)
@@ -465,7 +465,7 @@ relay_init(void)
if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
fatal("relay_init: failed to set resource limit");
- TAILQ_FOREACH(rlay, env->relays, entry) {
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
if ((rlay->conf.flags & F_SSL) &&
(rlay->ssl_ctx = relay_ssl_ctx_create(rlay)) == NULL)
fatal("relay_init: failed to create SSL context");
@@ -499,9 +499,9 @@ relay_init(void)
}
/* Schedule statistics timer */
- evtimer_set(&env->statev, relay_statistics, NULL);
- bcopy(&env->statinterval, &tv, sizeof(tv));
- evtimer_add(&env->statev, &tv);
+ evtimer_set(&env->sc_statev, relay_statistics, NULL);
+ bcopy(&env->sc_statinterval, &tv, sizeof(tv));
+ evtimer_add(&env->sc_statev, &tv);
}
void
@@ -522,7 +522,7 @@ relay_statistics(int fd, short events, void *arg)
if (gettimeofday(&tv_now, NULL))
fatal("relay_init: gettimeofday");
- TAILQ_FOREACH(rlay, env->relays, entry) {
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
bzero(&crs, sizeof(crs));
resethour = resetday = 0;
@@ -531,12 +531,12 @@ relay_statistics(int fd, short events, void *arg)
cur->tick++;
cur->avg = (cur->last + cur->avg) / 2;
cur->last_hour += cur->last;
- if ((cur->tick % (3600 / env->statinterval.tv_sec)) == 0) {
+ if ((cur->tick % (3600 / env->sc_statinterval.tv_sec)) == 0) {
cur->avg_hour = (cur->last_hour + cur->avg_hour) / 2;
resethour++;
}
cur->last_day += cur->last;
- if ((cur->tick % (86400 / env->statinterval.tv_sec)) == 0) {
+ if ((cur->tick % (86400 / env->sc_statinterval.tv_sec)) == 0) {
cur->avg_day = (cur->last_day + cur->avg_day) / 2;
resethour++;
}
@@ -564,9 +564,9 @@ relay_statistics(int fd, short events, void *arg)
}
/* Schedule statistics timer */
- evtimer_set(&env->statev, relay_statistics, NULL);
- bcopy(&env->statinterval, &tv, sizeof(tv));
- evtimer_add(&env->statev, &tv);
+ evtimer_set(&env->sc_statev, relay_statistics, NULL);
+ bcopy(&env->sc_statinterval, &tv, sizeof(tv));
+ evtimer_add(&env->sc_statev, &tv);
}
void
@@ -575,7 +575,7 @@ relay_launch(void)
struct relay *rlay;
void (*callback)(int, short, void *);
- TAILQ_FOREACH(rlay, env->relays, entry) {
+ TAILQ_FOREACH(rlay, env->sc_relays, entry) {
log_debug("relay_launch: running relay %s", rlay->conf.name);
rlay->up = HOST_UP;
@@ -2165,7 +2165,7 @@ relay_connect(struct session *con)
if (errno == EINPROGRESS)
event_again(&con->ev, con->out.s, EV_WRITE|EV_TIMEOUT,
- relay_connected, &con->tv_start, &env->timeout, con);
+ relay_connected, &con->tv_start, &env->sc_timeout, con);
else
relay_connected(con->out.s, EV_WRITE, con);
@@ -2186,7 +2186,7 @@ relay_close(struct session *con, const char *msg)
if (con->out.bev != NULL)
bufferevent_disable(con->out.bev, EV_READ|EV_WRITE);
- if (env->opts & RELAYD_OPT_LOGUPDATE) {
+ if (env->sc_opts & RELAYD_OPT_LOGUPDATE) {
bzero(&ibuf, sizeof(ibuf));
bzero(&obuf, sizeof(obuf));
(void)print_host(&con->in.ss, ibuf, sizeof(ibuf));
@@ -2359,7 +2359,7 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
evtimer_add(&con->ev, &tv);
break;
case IMSG_CTL_SESSION:
- TAILQ_FOREACH(rlay, env->relays, entry)
+ TAILQ_FOREACH(rlay, env->sc_relays, entry)
SPLAY_FOREACH(con, session_tree,
&rlay->sessions)
imsg_compose(ibuf, IMSG_CTL_SESSION,
@@ -2501,7 +2501,7 @@ relay_ssl_transaction(struct session *con)
con->in.ssl = ssl;
event_again(&con->ev, con->in.s, EV_TIMEOUT|EV_READ,
- relay_ssl_accept, &con->tv_start, &env->timeout, con);
+ relay_ssl_accept, &con->tv_start, &env->sc_timeout, con);
return;
err:
@@ -2566,7 +2566,7 @@ retry:
DPRINTF("relay_ssl_accept: session %d: scheduling on %s", con->id,
(retry_flag == EV_READ) ? "EV_READ" : "EV_WRITE");
event_again(&con->ev, fd, EV_TIMEOUT|retry_flag, relay_ssl_accept,
- &con->tv_start, &env->timeout, con);
+ &con->tv_start, &env->sc_timeout, con);
}
void
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index 6b2e5666408..5595228e5a6 100644
--- a/usr.sbin/relayd/relay_udp.c
+++ b/usr.sbin/relayd/relay_udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_udp.c,v 1.4 2008/01/29 16:36:04 reyk Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.5 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org>
@@ -433,7 +433,7 @@ relay_dns_request(struct session *con)
}
event_again(&con->ev, con->out.s, EV_TIMEOUT,
- relay_udp_timeout, &con->tv_start, &env->timeout, con);
+ relay_udp_timeout, &con->tv_start, &env->sc_timeout, con);
return (0);
}
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index 7a6afba86f1..94ced9edf41 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.66 2008/01/29 17:36:08 thib Exp $ */
+/* $OpenBSD: relayd.c,v 1.67 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -166,12 +166,12 @@ main(int argc, char *argv[])
exit(1);
relayd_env = env;
- if (env->opts & RELAYD_OPT_NOACTION) {
+ if (env->sc_opts & RELAYD_OPT_NOACTION) {
fprintf(stderr, "configuration OK\n");
exit(0);
}
if (debug)
- env->opts |= RELAYD_OPT_LOGUPDATE;
+ env->sc_opts |= RELAYD_OPT_LOGUPDATE;
if (geteuid())
errx(1, "need root privileges");
@@ -197,7 +197,7 @@ main(int argc, char *argv[])
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC,
pipe_pfe2hce) == -1)
fatal("socketpair");
- for (c = 0; c < env->prefork_relay; c++) {
+ for (c = 0; c < env->sc_prefork_relay; c++) {
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC,
pipe_parent2relay[c]) == -1)
fatal("socketpair");
@@ -221,7 +221,7 @@ main(int argc, char *argv[])
pipe_parent2relay, pipe_pfe2hce, pipe_pfe2relay);
hce_pid = hce(env, pipe_parent2pfe, pipe_parent2hce,
pipe_parent2relay, pipe_pfe2hce, pipe_pfe2relay);
- if (env->prefork_relay > 0)
+ if (env->sc_prefork_relay > 0)
relay_pid = relay(env, pipe_parent2pfe, pipe_parent2hce,
pipe_parent2relay, pipe_pfe2hce, pipe_pfe2relay);
@@ -243,7 +243,7 @@ main(int argc, char *argv[])
close(pipe_parent2hce[1]);
close(pipe_pfe2hce[0]);
close(pipe_pfe2hce[1]);
- for (c = 0; c < env->prefork_relay; c++) {
+ for (c = 0; c < env->sc_prefork_relay; c++) {
close(pipe_pfe2relay[c][0]);
close(pipe_pfe2relay[c][1]);
close(pipe_parent2relay[c][0]);
@@ -253,15 +253,15 @@ main(int argc, char *argv[])
(ibuf_hce = calloc(1, sizeof(struct imsgbuf))) == NULL)
fatal(NULL);
- if (env->prefork_relay > 0) {
- if ((ibuf_relay = calloc(env->prefork_relay,
+ if (env->sc_prefork_relay > 0) {
+ if ((ibuf_relay = calloc(env->sc_prefork_relay,
sizeof(struct imsgbuf))) == NULL)
fatal(NULL);
}
imsg_init(ibuf_pfe, pipe_parent2pfe[0], main_dispatch_pfe);
imsg_init(ibuf_hce, pipe_parent2hce[0], main_dispatch_hce);
- for (c = 0; c < env->prefork_relay; c++) {
+ for (c = 0; c < env->sc_prefork_relay; c++) {
ibuf = &ibuf_relay[c];
imsg_init(ibuf, pipe_parent2relay[c][1], main_dispatch_relay);
ibuf->events = EV_READ;
@@ -280,8 +280,8 @@ main(int argc, char *argv[])
ibuf_hce->handler, ibuf_hce);
event_add(&ibuf_hce->ev, NULL);
- if (env->flags & F_DEMOTE)
- carp_demote_reset(env->demote_group, 0);
+ if (env->sc_flags & F_DEMOTE)
+ carp_demote_reset(env->sc_demote_group, 0);
event_dispatch();
@@ -308,8 +308,8 @@ main_shutdown(struct relayd *env)
control_cleanup();
carp_demote_shutdown();
- if (env->flags & F_DEMOTE)
- carp_demote_reset(env->demote_group, 128);
+ if (env->sc_flags & F_DEMOTE)
+ carp_demote_reset(env->sc_demote_group, 128);
log_info("terminating");
exit(0);
}
@@ -343,7 +343,7 @@ send_all(struct relayd *env, enum imsg_type type, void *buf, u_int16_t len)
return (-1);
if (imsg_compose(ibuf_hce, type, 0, 0, -1, buf, len) == -1)
return (-1);
- for (i = 0; i < env->prefork_relay; i++) {
+ for (i = 0; i < env->sc_prefork_relay; i++) {
if (imsg_compose(&ibuf_relay[i], type, 0, 0, -1, buf, len)
== -1)
return (-1);
@@ -354,28 +354,28 @@ send_all(struct relayd *env, enum imsg_type type, void *buf, u_int16_t len)
void
merge_config(struct relayd *env, struct relayd *new_env)
{
- env->opts = new_env->opts;
- env->flags = new_env->flags;
- env->confpath = new_env->confpath;
- env->tablecount = new_env->tablecount;
- env->rdrcount = new_env->rdrcount;
- env->protocount = new_env->protocount;
- env->relaycount = new_env->relaycount;
-
- memcpy(&env->interval, &new_env->interval, sizeof(env->interval));
- memcpy(&env->timeout, &new_env->timeout, sizeof(env->timeout));
- memcpy(&env->empty_table, &new_env->empty_table,
- sizeof(env->empty_table));
- memcpy(&env->proto_default, &new_env->proto_default,
- sizeof(env->proto_default));
- env->prefork_relay = new_env->prefork_relay;
- (void)strlcpy(env->demote_group, new_env->demote_group,
- sizeof(env->demote_group));
-
- env->tables = new_env->tables;
- env->rdrs = new_env->rdrs;
- env->relays = new_env->relays;
- env->protos = new_env->protos;
+ env->sc_opts = new_env->sc_opts;
+ env->sc_flags = new_env->sc_flags;
+ env->sc_confpath = new_env->sc_confpath;
+ env->sc_tablecount = new_env->sc_tablecount;
+ env->sc_rdrcount = new_env->sc_rdrcount;
+ env->sc_protocount = new_env->sc_protocount;
+ env->sc_relaycount = new_env->sc_relaycount;
+
+ memcpy(&env->sc_interval, &new_env->sc_interval, sizeof(env->sc_interval));
+ memcpy(&env->sc_timeout, &new_env->sc_timeout, sizeof(env->sc_timeout));
+ memcpy(&env->sc_empty_table, &new_env->sc_empty_table,
+ sizeof(env->sc_empty_table));
+ memcpy(&env->sc_proto_default, &new_env->sc_proto_default,
+ sizeof(env->sc_proto_default));
+ env->sc_prefork_relay = new_env->sc_prefork_relay;
+ (void)strlcpy(env->sc_demote_group, new_env->sc_demote_group,
+ sizeof(env->sc_demote_group));
+
+ env->sc_tables = new_env->sc_tables;
+ env->sc_rdrs = new_env->sc_rdrs;
+ env->sc_relays = new_env->sc_relays;
+ env->sc_protos = new_env->sc_protos;
}
@@ -390,7 +390,7 @@ reconfigure(void)
struct host *host;
log_info("reloading configuration");
- if ((new_env = parse_config(env->confpath, env->opts)) == NULL) {
+ if ((new_env = parse_config(env->sc_confpath, env->sc_opts)) == NULL) {
log_warnx("configuration reloading FAILED");
return;
}
@@ -404,7 +404,7 @@ reconfigure(void)
* first reconfigure pfe
*/
imsg_compose(ibuf_pfe, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
imsg_compose(ibuf_pfe, IMSG_RECONF_TABLE, 0, 0, -1,
&table->conf, sizeof(table->conf));
TAILQ_FOREACH(host, &table->hosts, entry) {
@@ -412,7 +412,7 @@ reconfigure(void)
&host->conf, sizeof(host->conf));
}
}
- TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
imsg_compose(ibuf_pfe, IMSG_RECONF_RDR, 0, 0, -1,
&rdr->conf, sizeof(rdr->conf));
TAILQ_FOREACH(virt, &rdr->virts, entry)
@@ -425,7 +425,7 @@ reconfigure(void)
* then reconfigure hce
*/
imsg_compose(ibuf_hce, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
imsg_compose(ibuf_hce, IMSG_RECONF_TABLE, 0, 0, -1,
&table->conf, sizeof(table->conf));
if (table->sendbuf != NULL)
@@ -449,29 +449,29 @@ purge_config(struct relayd *env, u_int8_t what)
struct relay *rly;
struct session *sess;
- if (what & PURGE_TABLES && env->tables != NULL) {
- while ((table = TAILQ_FIRST(env->tables)) != NULL)
- purge_table(env->tables, table);
- free(env->tables);
- env->tables = NULL;
+ if (what & PURGE_TABLES && env->sc_tables != NULL) {
+ while ((table = TAILQ_FIRST(env->sc_tables)) != NULL)
+ purge_table(env->sc_tables, table);
+ free(env->sc_tables);
+ env->sc_tables = NULL;
}
- if (what & PURGE_RDRS && env->rdrs != NULL) {
- while ((rdr = TAILQ_FIRST(env->rdrs)) != NULL) {
- TAILQ_REMOVE(env->rdrs, rdr, entry);
+ if (what & PURGE_RDRS && env->sc_rdrs != NULL) {
+ while ((rdr = TAILQ_FIRST(env->sc_rdrs)) != NULL) {
+ TAILQ_REMOVE(env->sc_rdrs, rdr, entry);
while ((virt = TAILQ_FIRST(&rdr->virts)) != NULL) {
TAILQ_REMOVE(&rdr->virts, virt, entry);
free(virt);
}
free(rdr);
}
- free(env->rdrs);
- env->rdrs = NULL;
+ free(env->sc_rdrs);
+ env->sc_rdrs = NULL;
}
- if (what & PURGE_RELAYS && env->relays != NULL) {
- while ((rly = TAILQ_FIRST(env->relays)) != NULL) {
- TAILQ_REMOVE(env->relays, rly, entry);
+ if (what & PURGE_RELAYS && env->sc_relays != NULL) {
+ while ((rly = TAILQ_FIRST(env->sc_relays)) != NULL) {
+ TAILQ_REMOVE(env->sc_relays, rly, entry);
while ((sess = SPLAY_ROOT(&rly->sessions)) != NULL) {
SPLAY_REMOVE(session_tree,
&rly->sessions, sess);
@@ -485,21 +485,21 @@ purge_config(struct relayd *env, u_int8_t what)
SSL_CTX_free(rly->ssl_ctx);
free(rly);
}
- free(env->relays);
- env->relays = NULL;
+ free(env->sc_relays);
+ env->sc_relays = NULL;
}
- if (what & PURGE_PROTOS && env->protos != NULL) {
- while ((proto = TAILQ_FIRST(env->protos)) != NULL) {
- TAILQ_REMOVE(env->protos, proto, entry);
+ if (what & PURGE_PROTOS && env->sc_protos != NULL) {
+ while ((proto = TAILQ_FIRST(env->sc_protos)) != NULL) {
+ TAILQ_REMOVE(env->sc_protos, proto, entry);
purge_tree(&proto->request_tree);
purge_tree(&proto->response_tree);
if (proto->style != NULL)
free(proto->style);
free(proto);
}
- free(env->protos);
- env->protos = NULL;
+ free(env->sc_protos);
+ env->sc_protos = NULL;
}
}
@@ -728,7 +728,7 @@ host_find(struct relayd *env, objid_t id)
struct table *table;
struct host *host;
- TAILQ_FOREACH(table, env->tables, entry)
+ TAILQ_FOREACH(table, env->sc_tables, entry)
TAILQ_FOREACH(host, &table->hosts, entry)
if (host->conf.id == id)
return (host);
@@ -740,7 +740,7 @@ table_find(struct relayd *env, objid_t id)
{
struct table *table;
- TAILQ_FOREACH(table, env->tables, entry)
+ TAILQ_FOREACH(table, env->sc_tables, entry)
if (table->conf.id == id)
return (table);
return (NULL);
@@ -751,7 +751,7 @@ rdr_find(struct relayd *env, objid_t id)
{
struct rdr *rdr;
- TAILQ_FOREACH(rdr, env->rdrs, entry)
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry)
if (rdr->conf.id == id)
return (rdr);
return (NULL);
@@ -762,7 +762,7 @@ relay_find(struct relayd *env, objid_t id)
{
struct relay *rlay;
- TAILQ_FOREACH(rlay, env->relays, entry)
+ TAILQ_FOREACH(rlay, env->sc_relays, entry)
if (rlay->conf.id == id)
return (rlay);
return (NULL);
@@ -774,7 +774,7 @@ session_find(struct relayd *env, objid_t id)
struct relay *rlay;
struct session *con;
- TAILQ_FOREACH(rlay, env->relays, entry)
+ TAILQ_FOREACH(rlay, env->sc_relays, entry)
SPLAY_FOREACH(con, session_tree, &rlay->sessions)
if (con->id == id)
return (con);
@@ -787,7 +787,7 @@ host_findbyname(struct relayd *env, const char *name)
struct table *table;
struct host *host;
- TAILQ_FOREACH(table, env->tables, entry)
+ TAILQ_FOREACH(table, env->sc_tables, entry)
TAILQ_FOREACH(host, &table->hosts, entry)
if (strcmp(host->conf.name, name) == 0)
return (host);
@@ -799,7 +799,7 @@ table_findbyname(struct relayd *env, const char *name)
{
struct table *table;
- TAILQ_FOREACH(table, env->tables, entry)
+ TAILQ_FOREACH(table, env->sc_tables, entry)
if (strcmp(table->conf.name, name) == 0)
return (table);
return (NULL);
@@ -815,7 +815,7 @@ table_findbyconf(struct relayd *env, struct table *tb)
a.id = a.rdrid = 0;
a.flags &= ~(F_USED|F_BACKUP);
- TAILQ_FOREACH(table, env->tables, entry) {
+ TAILQ_FOREACH(table, env->sc_tables, entry) {
bcopy(&table->conf, &b, sizeof(b));
b.id = b.rdrid = 0;
b.flags &= ~(F_USED|F_BACKUP);
@@ -838,7 +838,7 @@ rdr_findbyname(struct relayd *env, const char *name)
{
struct rdr *rdr;
- TAILQ_FOREACH(rdr, env->rdrs, entry)
+ TAILQ_FOREACH(rdr, env->sc_rdrs, entry)
if (strcmp(rdr->conf.name, name) == 0)
return (rdr);
return (NULL);
@@ -849,7 +849,7 @@ relay_findbyname(struct relayd *env, const char *name)
{
struct relay *rlay;
- TAILQ_FOREACH(rlay, env->relays, entry)
+ TAILQ_FOREACH(rlay, env->sc_relays, entry)
if (strcmp(rlay->conf.name, name) == 0)
return (rlay);
return (NULL);
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index 671bb466264..3306379c7f7 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.90 2007/12/20 20:15:43 reyk Exp $ */
+/* $OpenBSD: relayd.h,v 1.91 2008/01/31 09:33:39 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -597,36 +597,36 @@ enum {
} relayd_process;
struct relayd {
- u_int8_t opts;
- u_int32_t flags;
- const char *confpath;
- struct pfdata *pf;
- int tablecount;
- int rdrcount;
- int protocount;
- int relaycount;
- struct timeval interval;
- struct timeval timeout;
- struct table empty_table;
- struct protocol proto_default;
- struct event ev;
- struct tablelist *tables;
- struct rdrlist *rdrs;
- struct protolist *protos;
- struct relaylist *relays;
- u_int16_t prefork_relay;
- char demote_group[IFNAMSIZ];
- u_int16_t id;
-
- struct event statev;
- struct timeval statinterval;
-
- int has_icmp;
- int has_icmp6;
- struct ctl_icmp_event icmp_send;
- struct ctl_icmp_event icmp_recv;
- struct ctl_icmp_event icmp6_send;
- struct ctl_icmp_event icmp6_recv;
+ u_int8_t sc_opts;
+ u_int32_t sc_flags;
+ const char *sc_confpath;
+ struct pfdata *sc_pf;
+ int sc_tablecount;
+ int sc_rdrcount;
+ int sc_protocount;
+ int sc_relaycount;
+ struct timeval sc_interval;
+ struct timeval sc_timeout;
+ struct table sc_empty_table;
+ struct protocol sc_proto_default;
+ struct event sc_ev;
+ struct tablelist *sc_tables;
+ struct rdrlist *sc_rdrs;
+ struct protolist *sc_protos;
+ struct relaylist *sc_relays;
+ u_int16_t sc_prefork_relay;
+ char sc_demote_group[IFNAMSIZ];
+ u_int16_t sc_id;
+
+ struct event sc_statev;
+ struct timeval sc_statinterval;
+
+ int sc_has_icmp;
+ int sc_has_icmp6;
+ struct ctl_icmp_event sc_icmp_send;
+ struct ctl_icmp_event sc_icmp_recv;
+ struct ctl_icmp_event sc_icmp6_send;
+ struct ctl_icmp_event sc_icmp6_recv;
};
#define RELAYD_OPT_VERBOSE 0x01