summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/relayctl/parser.c24
-rw-r--r--usr.sbin/relayctl/parser.h6
-rw-r--r--usr.sbin/relayctl/relayctl.c32
-rw-r--r--usr.sbin/relayd/control.c10
-rw-r--r--usr.sbin/relayd/hce.c4
-rw-r--r--usr.sbin/relayd/parse.y104
-rw-r--r--usr.sbin/relayd/pfe.c182
-rw-r--r--usr.sbin/relayd/pfe_filter.c66
-rw-r--r--usr.sbin/relayd/relay.c4
-rw-r--r--usr.sbin/relayd/relayd.c62
-rw-r--r--usr.sbin/relayd/relayd.h46
11 files changed, 270 insertions, 270 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c
index a7fa7e5d444..f3316f2569e 100644
--- a/usr.sbin/relayctl/parser.c
+++ b/usr.sbin/relayctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.18 2007/12/08 20:11:48 reyk Exp $ */
+/* $OpenBSD: parser.c,v 1.19 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -45,7 +45,7 @@ enum token_type {
ENDTOKEN,
HOSTID,
TABLEID,
- SERVICEID,
+ RDRID,
KEYWORD
};
@@ -58,10 +58,10 @@ struct token {
static const struct token t_main[];
static const struct token t_show[];
-static const struct token t_service[];
+static const struct token t_rdr[];
static const struct token t_table[];
static const struct token t_host[];
-static const struct token t_service_id[];
+static const struct token t_rdr_id[];
static const struct token t_table_id[];
static const struct token t_host_id[];
@@ -71,7 +71,7 @@ static const struct token t_main[] = {
{KEYWORD, "poll", POLL, NULL},
{KEYWORD, "reload", RELOAD, NULL},
{KEYWORD, "stop", SHUTDOWN, NULL},
- {KEYWORD, "redirect", NONE, t_service},
+ {KEYWORD, "redirect", NONE, t_rdr},
{KEYWORD, "table", NONE, t_table},
{KEYWORD, "host", NONE, t_host},
{ENDTOKEN, "", NONE, NULL}
@@ -85,10 +85,10 @@ static const struct token t_show[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static const struct token t_service[] = {
+static const struct token t_rdr[] = {
{NOTOKEN, "", NONE, NULL},
- {KEYWORD, "disable", SERV_DISABLE, t_service_id},
- {KEYWORD, "enable", SERV_ENABLE, t_service_id},
+ {KEYWORD, "disable", RDR_DISABLE, t_rdr_id},
+ {KEYWORD, "enable", RDR_ENABLE, t_rdr_id},
{ENDTOKEN, "", NONE, NULL}
};
@@ -106,8 +106,8 @@ static const struct token t_host[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static const struct token t_service_id[] = {
- {SERVICEID, "", NONE, NULL},
+static const struct token t_rdr_id[] = {
+ {RDRID, "", NONE, NULL},
{ENDTOKEN, "", NONE, NULL}
};
@@ -203,7 +203,7 @@ match_token(const char *word, const struct token table[])
t = &table[i];
match++;
break;
- case SERVICEID:
+ case RDRID:
if (word == NULL)
break;
res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
@@ -245,7 +245,7 @@ show_valid_args(const struct token table[])
case KEYWORD:
fprintf(stderr, " %s\n", table[i].keyword);
break;
- case SERVICEID:
+ case RDRID:
fprintf(stderr, " <redirectid>\n");
break;
case TABLEID:
diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h
index c9c1e875fd2..32d9f79baeb 100644
--- a/usr.sbin/relayctl/parser.h
+++ b/usr.sbin/relayctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.7 2007/10/19 12:08:55 pyr Exp $ */
+/* $OpenBSD: parser.h,v 1.8 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -22,8 +22,8 @@ enum actions {
SHOW_HOSTS,
SHOW_RELAYS,
SHOW_SESSIONS,
- SERV_DISABLE,
- SERV_ENABLE,
+ RDR_DISABLE,
+ RDR_ENABLE,
TABLE_DISABLE,
TABLE_ENABLE,
HOST_DISABLE,
diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c
index 8d86baab9ea..59a1fdd1c30 100644
--- a/usr.sbin/relayctl/relayctl.c
+++ b/usr.sbin/relayctl/relayctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayctl.c,v 1.29 2007/12/08 20:11:48 reyk Exp $ */
+/* $OpenBSD: relayctl.c,v 1.30 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -47,7 +47,7 @@ __dead void usage(void);
int show_summary_msg(struct imsg *, int);
int show_session_msg(struct imsg *);
int show_command_output(struct imsg *);
-char *print_service_status(int);
+char *print_rdr_status(int);
char *print_host_status(int, int);
char *print_table_status(int, int);
char *print_relay_status(int);
@@ -65,8 +65,8 @@ int monitor(struct imsg *);
struct imsgname imsgs[] = {
{ IMSG_HOST_STATUS, "host_status", monitor_host_status },
- { IMSG_CTL_SERVICE_DISABLE, "ctl_disable_service", monitor_id },
- { IMSG_CTL_SERVICE_ENABLE, "ctl_service_enable", monitor_id },
+ { IMSG_CTL_RDR_DISABLE, "ctl_rdr_disable", monitor_id },
+ { IMSG_CTL_RDR_ENABLE, "ctl_rdr_enable", monitor_id },
{ IMSG_CTL_TABLE_DISABLE, "ctl_table_disable", monitor_id },
{ IMSG_CTL_TABLE_ENABLE, "ctl_table_enable", monitor_id },
{ IMSG_CTL_HOST_DISABLE, "ctl_host_disable", monitor_id },
@@ -151,12 +151,12 @@ main(int argc, char *argv[])
case SHOW_SESSIONS:
imsg_compose(ibuf, IMSG_CTL_SESSION, 0, 0, -1, NULL, 0);
break;
- case SERV_ENABLE:
- imsg_compose(ibuf, IMSG_CTL_SERVICE_ENABLE, 0, 0, -1,
+ case RDR_ENABLE:
+ imsg_compose(ibuf, IMSG_CTL_RDR_ENABLE, 0, 0, -1,
&res->id, sizeof(res->id));
break;
- case SERV_DISABLE:
- imsg_compose(ibuf, IMSG_CTL_SERVICE_DISABLE, 0, 0, -1,
+ case RDR_DISABLE:
+ imsg_compose(ibuf, IMSG_CTL_RDR_DISABLE, 0, 0, -1,
&res->id, sizeof(res->id));
break;
case TABLE_ENABLE:
@@ -213,8 +213,8 @@ main(int argc, char *argv[])
case SHOW_SESSIONS:
done = show_session_msg(&imsg);
break;
- case SERV_DISABLE:
- case SERV_ENABLE:
+ case RDR_DISABLE:
+ case RDR_ENABLE:
case TABLE_DISABLE:
case TABLE_ENABLE:
case HOST_DISABLE:
@@ -306,7 +306,7 @@ monitor(struct imsg *imsg)
int
show_summary_msg(struct imsg *imsg, int type)
{
- struct service *service;
+ struct rdr *rdr;
struct table *table;
struct host *host;
struct relay *rlay;
@@ -314,13 +314,13 @@ show_summary_msg(struct imsg *imsg, int type)
int i;
switch (imsg->hdr.type) {
- case IMSG_CTL_SERVICE:
+ case IMSG_CTL_RDR:
if (type == SHOW_RELAYS)
break;
- service = imsg->data;
+ rdr = imsg->data;
printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n",
- service->conf.id, "redirect", service->conf.name, "",
- print_service_status(service->conf.flags));
+ rdr->conf.id, "redirect", rdr->conf.name, "",
+ print_rdr_status(rdr->conf.flags));
break;
case IMSG_CTL_TABLE:
if (type == SHOW_RELAYS)
@@ -442,7 +442,7 @@ show_command_output(struct imsg *imsg)
}
char *
-print_service_status(int flags)
+print_rdr_status(int flags)
{
if (flags & F_DISABLE) {
return ("disabled");
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c
index e8214b4e72d..d45706740f7 100644
--- a/usr.sbin/relayd/control.c
+++ b/usr.sbin/relayd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.22 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: control.c,v 1.23 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -232,11 +232,11 @@ control_dispatch_imsg(int fd, short event, void *arg)
case IMSG_CTL_SESSION:
show_sessions(c);
break;
- case IMSG_CTL_SERVICE_DISABLE:
+ case IMSG_CTL_RDR_DISABLE:
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(id))
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
- if (disable_service(c, &id))
+ if (disable_rdr(c, &id))
imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
@@ -246,11 +246,11 @@ control_dispatch_imsg(int fd, short event, void *arg)
NULL, 0);
}
break;
- case IMSG_CTL_SERVICE_ENABLE:
+ case IMSG_CTL_RDR_ENABLE:
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(id))
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
- if (enable_service(c, &id))
+ if (enable_rdr(c, &id))
imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index fee3867998f..0642bf5f86d 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.37 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: hce.c,v 1.38 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -90,7 +90,7 @@ hce(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
}
env = x_env;
- purge_config(env, PURGE_SERVICES|PURGE_RELAYS|PURGE_PROTOS);
+ purge_config(env, PURGE_RDRS|PURGE_RELAYS|PURGE_PROTOS);
if ((pw = getpwnam(RELAYD_USER)) == NULL)
fatal("hce: getpwnam");
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index a52eae95e70..addec9b8a95 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.99 2007/12/08 17:14:26 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.100 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -82,13 +82,13 @@ char *symget(const char *);
struct relayd *conf = NULL;
static int errors = 0;
-objid_t last_service_id = 0;
+objid_t last_rdr_id = 0;
objid_t last_table_id = 0;
objid_t last_host_id = 0;
objid_t last_relay_id = 0;
objid_t last_proto_id = 0;
-static struct service *service = NULL;
+static struct rdr *rdr = NULL;
static struct table *table = NULL;
static struct relay *rlay = NULL;
static struct protocol *proto = NULL;
@@ -147,7 +147,7 @@ grammar : /* empty */
| grammar '\n'
| grammar varset '\n'
| grammar main '\n'
- | grammar service '\n'
+ | grammar rdr '\n'
| grammar tabledef '\n'
| grammar relay '\n'
| grammar proto '\n'
@@ -311,10 +311,10 @@ loglevel : UPDATES { $$ = RELAYD_OPT_LOGUPDATE; }
| ALL { $$ = RELAYD_OPT_LOGALL; }
;
-service : REDIRECT STRING {
- struct service *srv;
+rdr : REDIRECT STRING {
+ struct rdr *srv;
- TAILQ_FOREACH(srv, conf->services, entry)
+ TAILQ_FOREACH(srv, conf->rdrs, entry)
if (!strcmp(srv->conf.name, $2))
break;
if (srv != NULL) {
@@ -332,70 +332,70 @@ service : REDIRECT STRING {
YYERROR;
}
free($2);
- srv->conf.id = last_service_id++;
- if (last_service_id == INT_MAX) {
+ srv->conf.id = last_rdr_id++;
+ if (last_rdr_id == INT_MAX) {
yyerror("too many redirections defined");
YYERROR;
}
- service = srv;
- } '{' optnl serviceopts_l '}' {
- if (service->table == NULL) {
+ rdr = srv;
+ } '{' optnl rdropts_l '}' {
+ if (rdr->table == NULL) {
yyerror("redirection %s has no table",
- service->conf.name);
+ rdr->conf.name);
YYERROR;
}
- if (TAILQ_EMPTY(&service->virts)) {
+ if (TAILQ_EMPTY(&rdr->virts)) {
yyerror("redirection %s has no virtual ip",
- service->conf.name);
+ rdr->conf.name);
YYERROR;
}
- conf->servicecount++;
- if (service->backup == NULL) {
- service->conf.backup_id =
+ conf->rdrcount++;
+ if (rdr->backup == NULL) {
+ rdr->conf.backup_id =
conf->empty_table.conf.id;
- service->backup = &conf->empty_table;
- } else if (service->backup->conf.port !=
- service->table->conf.port) {
+ rdr->backup = &conf->empty_table;
+ } else if (rdr->backup->conf.port !=
+ rdr->table->conf.port) {
yyerror("redirection %s uses two different "
"ports for its table and backup table",
- service->conf.name);
+ rdr->conf.name);
YYERROR;
}
- if (!(service->conf.flags & F_DISABLE))
- service->conf.flags |= F_ADD;
- TAILQ_INSERT_HEAD(conf->services, service, entry);
+ if (!(rdr->conf.flags & F_DISABLE))
+ rdr->conf.flags |= F_ADD;
+ TAILQ_INSERT_HEAD(conf->rdrs, rdr, entry);
tableport = 0;
- service = NULL;
+ rdr = NULL;
}
;
-serviceopts_l : serviceopts_l serviceoptsl nl
- | serviceoptsl optnl
+rdropts_l : rdropts_l rdroptsl nl
+ | rdroptsl optnl
;
-serviceoptsl : FORWARD TO tablespec {
+rdroptsl : FORWARD TO tablespec {
if ($3->conf.check == CHECK_NOCHECK) {
yyerror("table %s has no check", $3->conf.name);
purge_table(conf->tables, $3);
YYERROR;
}
- if (service->backup) {
+ if (rdr->backup) {
yyerror("only one backup table is allowed");
purge_table(conf->tables, $3);
YYERROR;
}
- if (service->table) {
- service->backup = $3;
- service->conf.backup_id = $3->conf.id;
+ if (rdr->table) {
+ rdr->backup = $3;
+ rdr->conf.backup_id = $3->conf.id;
} else {
- service->table = $3;
- service->conf.table_id = $3->conf.id;
+ rdr->table = $3;
+ rdr->conf.table_id = $3->conf.id;
}
- $3->conf.serviceid = service->conf.id;
+ $3->conf.rdrid = rdr->conf.id;
$3->conf.flags |= F_USED;
}
| LISTEN ON STRING port interface {
- if (host($3, &service->virts,
+ if (host($3, &rdr->virts,
SRV_MAX_VIRTS, $4, $5) <= 0) {
yyerror("invalid virtual ip: %s", $3);
free($3);
@@ -404,16 +404,16 @@ serviceoptsl : FORWARD TO tablespec {
}
free($3);
free($5);
- if (service->conf.port == 0)
- service->conf.port = $4;
- tableport = service->conf.port;
+ if (rdr->conf.port == 0)
+ rdr->conf.port = $4;
+ tableport = rdr->conf.port;
}
- | DISABLE { service->conf.flags |= F_DISABLE; }
- | STICKYADDR { service->conf.flags |= F_STICKY; }
+ | DISABLE { rdr->conf.flags |= F_DISABLE; }
+ | STICKYADDR { rdr->conf.flags |= F_STICKY; }
| TAG STRING {
- if (strlcpy(service->conf.tag, $2,
- sizeof(service->conf.tag)) >=
- sizeof(service->conf.tag)) {
+ if (strlcpy(rdr->conf.tag, $2,
+ sizeof(rdr->conf.tag)) >=
+ sizeof(rdr->conf.tag)) {
yyerror("redirection tag name truncated");
free($2);
YYERROR;
@@ -547,7 +547,7 @@ tableopts : CHECK tablecheck
switch ($2) {
case RELAY_DSTMODE_LOADBALANCE:
case RELAY_DSTMODE_HASH:
- if (service != NULL) {
+ if (rdr != NULL) {
yyerror("mode not supported "
"for redirections");
YYERROR;
@@ -1127,7 +1127,7 @@ relay : RELAY STRING {
if ((rlay->conf.flags & F_NATLOOK) == 0 &&
rlay->conf.dstss.ss_family == AF_UNSPEC &&
rlay->conf.dsttable == EMPTY_ID) {
- yyerror("relay %s has no target, service, "
+ yyerror("relay %s has no target, rdr, "
"or table", rlay->conf.name);
YYERROR;
}
@@ -1757,21 +1757,21 @@ parse_config(const char *filename, int opts)
(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->services = calloc(1, sizeof(*conf->services))) == NULL) {
+ (conf->rdrs = calloc(1, sizeof(*conf->rdrs))) == NULL) {
log_warn("cannot allocate memory");
return (NULL);
}
errors = 0;
- last_host_id = last_table_id = last_service_id = last_proto_id =
+ last_host_id = last_table_id = last_rdr_id = last_proto_id =
last_relay_id = 0;
- service = NULL;
+ rdr = NULL;
table = NULL;
rlay = NULL;
proto = NULL;
- TAILQ_INIT(conf->services);
+ TAILQ_INIT(conf->rdrs);
TAILQ_INIT(conf->tables);
TAILQ_INIT(conf->protos);
TAILQ_INIT(conf->relays);
@@ -1826,7 +1826,7 @@ parse_config(const char *filename, int opts)
}
}
- if (TAILQ_EMPTY(conf->services) && TAILQ_EMPTY(conf->relays)) {
+ if (TAILQ_EMPTY(conf->rdrs) && TAILQ_EMPTY(conf->relays)) {
log_warnx("no redirections, nothing to do");
errors++;
}
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index b8b3b7ccc7c..b4ae7386390 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.44 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: pfe.c,v 1.45 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -322,7 +322,7 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
struct imsg imsg;
ssize_t n;
- static struct service *service = NULL;
+ static struct rdr *rdr = NULL;
static struct table *table = NULL;
struct host *host;
struct address *virt;
@@ -361,7 +361,7 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
sizeof(struct relayd) + IMSG_HEADER_SIZE)
fatalx("corrupted reload data");
pfe_disable_events();
- purge_config(env, PURGE_SERVICES|PURGE_TABLES);
+ purge_config(env, PURGE_RDRS|PURGE_TABLES);
merge_config(env, (struct relayd *)imsg.data);
/*
* no relays when reconfiguring yet.
@@ -370,12 +370,12 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
env->protos = NULL;
env->tables = calloc(1, sizeof(*env->tables));
- env->services = calloc(1, sizeof(*env->services));
- if (env->tables == NULL || env->services == NULL)
+ env->rdrs = calloc(1, sizeof(*env->rdrs));
+ if (env->tables == NULL || env->rdrs == NULL)
fatal(NULL);
TAILQ_INIT(env->tables);
- TAILQ_INIT(env->services);
+ TAILQ_INIT(env->rdrs);
break;
case IMSG_RECONF_TABLE:
if ((table = calloc(1, sizeof(*table))) == NULL)
@@ -391,33 +391,33 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
host->tablename = table->conf.name;
TAILQ_INSERT_TAIL(&table->hosts, host, entry);
break;
- case IMSG_RECONF_SERVICE:
- if ((service = calloc(1, sizeof(*service))) == NULL)
+ case IMSG_RECONF_RDR:
+ if ((rdr = calloc(1, sizeof(*rdr))) == NULL)
fatal(NULL);
- memcpy(&service->conf, imsg.data,
- sizeof(service->conf));
- service->table = table_find(env,
- service->conf.table_id);
- if (service->conf.backup_id == EMPTY_TABLE)
- service->backup = &env->empty_table;
+ memcpy(&rdr->conf, imsg.data,
+ sizeof(rdr->conf));
+ rdr->table = table_find(env,
+ rdr->conf.table_id);
+ if (rdr->conf.backup_id == EMPTY_TABLE)
+ rdr->backup = &env->empty_table;
else
- service->backup = table_find(env,
- service->conf.backup_id);
- if (service->table == NULL || service->backup == NULL)
+ rdr->backup = table_find(env,
+ rdr->conf.backup_id);
+ if (rdr->table == NULL || rdr->backup == NULL)
fatal("pfe_dispatch_parent:"
" corrupted configuration");
- log_debug("pfe_dispatch_parent: service->table: %s",
- service->table->conf.name);
- log_debug("pfe_dispatch_parent: service->backup: %s",
- service->backup->conf.name);
- TAILQ_INIT(&service->virts);
- TAILQ_INSERT_TAIL(env->services, service, entry);
+ log_debug("pfe_dispatch_parent: rdr->table: %s",
+ rdr->table->conf.name);
+ log_debug("pfe_dispatch_parent: rdr->backup: %s",
+ rdr->backup->conf.name);
+ TAILQ_INIT(&rdr->virts);
+ TAILQ_INSERT_TAIL(env->rdrs, rdr, entry);
break;
case IMSG_RECONF_VIRT:
if ((virt = calloc(1, sizeof(*virt))) == NULL)
fatal(NULL);
memcpy(virt, imsg.data, sizeof(*virt));
- TAILQ_INSERT_TAIL(&service->virts, virt, entry);
+ TAILQ_INSERT_TAIL(&rdr->virts, virt, entry);
break;
case IMSG_RECONF_END:
log_warnx("pfe: configuration reloaded");
@@ -510,31 +510,31 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
void
show(struct ctl_conn *c)
{
- struct service *service;
+ struct rdr *rdr;
struct host *host;
struct relay *rlay;
- if (env->services == NULL)
+ if (env->rdrs == NULL)
goto relays;
- TAILQ_FOREACH(service, env->services, entry) {
- imsg_compose(&c->ibuf, IMSG_CTL_SERVICE, 0, 0, -1,
- service, sizeof(*service));
- if (service->conf.flags & F_DISABLE)
+ TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ imsg_compose(&c->ibuf, IMSG_CTL_RDR, 0, 0, -1,
+ rdr, sizeof(*rdr));
+ if (rdr->conf.flags & F_DISABLE)
continue;
imsg_compose(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
- service->table, sizeof(*service->table));
- if (!(service->table->conf.flags & F_DISABLE))
- TAILQ_FOREACH(host, &service->table->hosts, entry)
+ rdr->table, sizeof(*rdr->table));
+ if (!(rdr->table->conf.flags & F_DISABLE))
+ TAILQ_FOREACH(host, &rdr->table->hosts, entry)
imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
host, sizeof(*host));
- if (service->backup->conf.id == EMPTY_TABLE)
+ if (rdr->backup->conf.id == EMPTY_TABLE)
continue;
imsg_compose(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
- service->backup, sizeof(*service->backup));
- if (!(service->backup->conf.flags & F_DISABLE))
- TAILQ_FOREACH(host, &service->backup->hosts, entry)
+ rdr->backup, sizeof(*rdr->backup));
+ if (!(rdr->backup->conf.flags & F_DISABLE))
+ TAILQ_FOREACH(host, &rdr->backup->hosts, entry)
imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
host, sizeof(*host));
}
@@ -615,61 +615,61 @@ show_sessions(struct ctl_conn *c)
}
int
-disable_service(struct ctl_conn *c, struct ctl_id *id)
+disable_rdr(struct ctl_conn *c, struct ctl_id *id)
{
- struct service *service;
+ struct rdr *rdr;
if (id->id == EMPTY_ID)
- service = service_findbyname(env, id->name);
+ rdr = rdr_findbyname(env, id->name);
else
- service = service_find(env, id->id);
- if (service == NULL)
+ rdr = rdr_find(env, id->id);
+ if (rdr == NULL)
return (-1);
- id->id = service->conf.id;
+ id->id = rdr->conf.id;
- if (service->conf.flags & F_DISABLE)
+ if (rdr->conf.flags & F_DISABLE)
return (0);
- service->conf.flags |= F_DISABLE;
- service->conf.flags &= ~(F_ADD);
- service->conf.flags |= F_DEL;
- service->table->conf.flags |= F_DISABLE;
- log_debug("disable_service: disabled service %d", service->conf.id);
+ rdr->conf.flags |= F_DISABLE;
+ rdr->conf.flags &= ~(F_ADD);
+ rdr->conf.flags |= F_DEL;
+ rdr->table->conf.flags |= F_DISABLE;
+ log_debug("disable_rdr: disabled rdr %d", rdr->conf.id);
pfe_sync();
return (0);
}
int
-enable_service(struct ctl_conn *c, struct ctl_id *id)
+enable_rdr(struct ctl_conn *c, struct ctl_id *id)
{
- struct service *service;
+ struct rdr *rdr;
struct ctl_id eid;
if (id->id == EMPTY_ID)
- service = service_findbyname(env, id->name);
+ rdr = rdr_findbyname(env, id->name);
else
- service = service_find(env, id->id);
- if (service == NULL)
+ rdr = rdr_find(env, id->id);
+ if (rdr == NULL)
return (-1);
- id->id = service->conf.id;
+ id->id = rdr->conf.id;
- if (!(service->conf.flags & F_DISABLE))
+ if (!(rdr->conf.flags & F_DISABLE))
return (0);
- service->conf.flags &= ~(F_DISABLE);
- service->conf.flags &= ~(F_DEL);
- service->conf.flags |= F_ADD;
- log_debug("enable_service: enabled service %d", service->conf.id);
+ rdr->conf.flags &= ~(F_DISABLE);
+ rdr->conf.flags &= ~(F_DEL);
+ rdr->conf.flags |= F_ADD;
+ log_debug("enable_rdr: enabled rdr %d", rdr->conf.id);
bzero(&eid, sizeof(eid));
/* XXX: we're syncing twice */
- eid.id = service->table->conf.id;
+ eid.id = rdr->table->conf.id;
if (enable_table(c, &eid) == -1)
return (-1);
- if (service->backup->conf.id == EMPTY_ID)
+ if (rdr->backup->conf.id == EMPTY_ID)
return (0);
- eid.id = service->backup->conf.id;
+ eid.id = rdr->backup->conf.id;
if (enable_table(c, &eid) == -1)
return (-1);
return (0);
@@ -679,7 +679,7 @@ int
disable_table(struct ctl_conn *c, struct ctl_id *id)
{
struct table *table;
- struct service *service;
+ struct rdr *rdr;
struct host *host;
if (id->id == EMPTY_ID)
@@ -689,7 +689,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id)
if (table == NULL)
return (-1);
id->id = table->conf.id;
- if ((service = service_find(env, table->conf.serviceid)) == NULL)
+ if ((rdr = rdr_find(env, table->conf.rdrid)) == NULL)
fatalx("disable_table: desynchronised");
if (table->conf.flags & F_DISABLE)
@@ -708,7 +708,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id)
int
enable_table(struct ctl_conn *c, struct ctl_id *id)
{
- struct service *service;
+ struct rdr *rdr;
struct table *table;
struct host *host;
@@ -720,7 +720,7 @@ enable_table(struct ctl_conn *c, struct ctl_id *id)
return (-1);
id->id = table->conf.id;
- if ((service = service_find(env, table->conf.serviceid)) == NULL)
+ if ((rdr = rdr_find(env, table->conf.rdrid)) == NULL)
fatalx("enable_table: desynchronised");
if (!(table->conf.flags & F_DISABLE))
@@ -818,7 +818,7 @@ enable_host(struct ctl_conn *c, struct ctl_id *id)
void
pfe_sync(void)
{
- struct service *service;
+ struct rdr *rdr;
struct table *active;
struct table *table;
struct ctl_id id;
@@ -827,53 +827,53 @@ pfe_sync(void)
bzero(&id, sizeof(id));
bzero(&imsg, sizeof(imsg));
- TAILQ_FOREACH(service, env->services, entry) {
- service->conf.flags &= ~(F_BACKUP);
- service->conf.flags &= ~(F_DOWN);
+ TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ rdr->conf.flags &= ~(F_BACKUP);
+ rdr->conf.flags &= ~(F_DOWN);
- if (service->conf.flags & F_DISABLE ||
- (service->table->up == 0 && service->backup->up == 0)) {
- service->conf.flags |= F_DOWN;
+ if (rdr->conf.flags & F_DISABLE ||
+ (rdr->table->up == 0 && rdr->backup->up == 0)) {
+ rdr->conf.flags |= F_DOWN;
active = NULL;
- } else if (service->table->up == 0 && service->backup->up > 0) {
- service->conf.flags |= F_BACKUP;
- active = service->backup;
+ } else if (rdr->table->up == 0 && rdr->backup->up > 0) {
+ rdr->conf.flags |= F_BACKUP;
+ active = rdr->backup;
active->conf.flags |=
- service->table->conf.flags & F_CHANGED;
+ rdr->table->conf.flags & F_CHANGED;
active->conf.flags |=
- service->backup->conf.flags & F_CHANGED;
+ rdr->backup->conf.flags & F_CHANGED;
} else
- active = service->table;
+ active = rdr->table;
if (active != NULL && active->conf.flags & F_CHANGED) {
id.id = active->conf.id;
imsg.hdr.type = IMSG_CTL_TABLE_CHANGED;
imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE;
imsg.data = &id;
- sync_table(env, service, active);
+ sync_table(env, rdr, active);
control_imsg_forward(&imsg);
}
- if (service->conf.flags & F_DOWN) {
- if (service->conf.flags & F_ACTIVE_RULESET) {
- flush_table(env, service);
+ if (rdr->conf.flags & F_DOWN) {
+ if (rdr->conf.flags & F_ACTIVE_RULESET) {
+ flush_table(env, rdr);
log_debug("pfe_sync: disabling ruleset");
- service->conf.flags &= ~(F_ACTIVE_RULESET);
- id.id = service->conf.id;
+ rdr->conf.flags &= ~(F_ACTIVE_RULESET);
+ id.id = rdr->conf.id;
imsg.hdr.type = IMSG_CTL_PULL_RULESET;
imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE;
imsg.data = &id;
- sync_ruleset(env, service, 0);
+ sync_ruleset(env, rdr, 0);
control_imsg_forward(&imsg);
}
- } else if (!(service->conf.flags & F_ACTIVE_RULESET)) {
+ } else if (!(rdr->conf.flags & F_ACTIVE_RULESET)) {
log_debug("pfe_sync: enabling ruleset");
- service->conf.flags |= F_ACTIVE_RULESET;
- id.id = service->conf.id;
+ rdr->conf.flags |= F_ACTIVE_RULESET;
+ id.id = rdr->conf.id;
imsg.hdr.type = IMSG_CTL_PUSH_RULESET;
imsg.hdr.len = sizeof(id) + IMSG_HEADER_SIZE;
imsg.data = &id;
- sync_ruleset(env, service, 1);
+ sync_ruleset(env, rdr, 1);
control_imsg_forward(&imsg);
}
}
diff --git a/usr.sbin/relayd/pfe_filter.c b/usr.sbin/relayd/pfe_filter.c
index d8e4b6a55d3..1d01f98bacd 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.20 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: pfe_filter.c,v 1.21 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -69,33 +69,33 @@ void
init_tables(struct relayd *env)
{
int i;
- struct service *service;
+ struct rdr *rdr;
struct pfr_table *tables;
struct pfioc_table io;
- if ((tables = calloc(env->servicecount, sizeof(*tables))) == NULL)
+ if ((tables = calloc(env->rdrcount, sizeof(*tables))) == NULL)
fatal("calloc");
i = 0;
- TAILQ_FOREACH(service, env->services, entry) {
+ TAILQ_FOREACH(rdr, env->rdrs, entry) {
if (strlcpy(tables[i].pfrt_anchor, RELAYD_ANCHOR "/",
sizeof(tables[i].pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcat(tables[i].pfrt_anchor, service->conf.name,
+ if (strlcat(tables[i].pfrt_anchor, rdr->conf.name,
sizeof(tables[i].pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcpy(tables[i].pfrt_name, service->conf.name,
+ if (strlcpy(tables[i].pfrt_name, rdr->conf.name,
sizeof(tables[i].pfrt_name)) >=
sizeof(tables[i].pfrt_name))
goto toolong;
tables[i].pfrt_flags |= PFR_TFLAG_PERSIST;
i++;
}
- if (i != env->servicecount)
+ if (i != env->rdrcount)
fatalx("init_tables: table count modified");
memset(&io, 0, sizeof(io));
- io.pfrio_size = env->servicecount;
+ io.pfrio_size = env->rdrcount;
io.pfrio_esize = sizeof(*tables);
io.pfrio_buffer = tables;
@@ -105,14 +105,14 @@ init_tables(struct relayd *env)
free(tables);
- if (io.pfrio_nadd == env->servicecount)
+ if (io.pfrio_nadd == env->rdrcount)
return;
/*
* clear all tables, since some already existed
*/
- TAILQ_FOREACH(service, env->services, entry)
- flush_table(env, service);
+ TAILQ_FOREACH(rdr, env->rdrs, entry)
+ flush_table(env, rdr);
return;
@@ -123,14 +123,14 @@ init_tables(struct relayd *env)
void
kill_tables(struct relayd *env) {
struct pfioc_table io;
- struct service *service;
+ struct rdr *rdr;
memset(&io, 0, sizeof(io));
- TAILQ_FOREACH(service, env->services, entry) {
+ TAILQ_FOREACH(rdr, env->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, service->conf.name,
+ 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)
@@ -144,7 +144,7 @@ kill_tables(struct relayd *env) {
}
void
-sync_table(struct relayd *env, struct service *service, struct table *table)
+sync_table(struct relayd *env, struct rdr *rdr, struct table *table)
{
int i;
struct pfioc_table io;
@@ -157,7 +157,7 @@ sync_table(struct relayd *env, struct service *service, struct table *table)
return;
if (table->up == 0) {
- flush_table(env, service);
+ flush_table(env, rdr);
return;
}
@@ -172,10 +172,10 @@ sync_table(struct relayd *env, struct service *service, struct table *table)
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, service->conf.name,
+ if (strlcat(io.pfrio_table.pfrt_anchor, rdr->conf.name,
sizeof(io.pfrio_table.pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcpy(io.pfrio_table.pfrt_name, service->conf.name,
+ if (strlcpy(io.pfrio_table.pfrt_name, rdr->conf.name,
sizeof(io.pfrio_table.pfrt_name)) >=
sizeof(io.pfrio_table.pfrt_name))
goto toolong;
@@ -224,7 +224,7 @@ sync_table(struct relayd *env, struct service *service, struct table *table)
}
void
-flush_table(struct relayd *env, struct service *service)
+flush_table(struct relayd *env, struct rdr *rdr)
{
struct pfioc_table io;
@@ -232,16 +232,16 @@ flush_table(struct relayd *env, struct service *service)
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, service->conf.name,
+ if (strlcat(io.pfrio_table.pfrt_anchor, rdr->conf.name,
sizeof(io.pfrio_table.pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcpy(io.pfrio_table.pfrt_name, service->conf.name,
+ if (strlcpy(io.pfrio_table.pfrt_name, rdr->conf.name,
sizeof(io.pfrio_table.pfrt_name)) >=
sizeof(io.pfrio_table.pfrt_name))
goto toolong;
if (ioctl(env->pf->dev, DIOCRCLRADDRS, &io) == -1)
fatal("flush_table: cannot flush table");
- log_debug("flush_table: flushed table %s", service->conf.name);
+ log_debug("flush_table: flushed table %s", rdr->conf.name);
return;
toolong:
@@ -273,7 +273,7 @@ transaction_commit(struct relayd *env)
}
void
-sync_ruleset(struct relayd *env, struct service *service, int enable)
+sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
{
struct pfioc_rule rio;
struct pfioc_pooladdr pio;
@@ -286,7 +286,7 @@ sync_ruleset(struct relayd *env, struct service *service, int enable)
if (strlcpy(anchor, RELAYD_ANCHOR "/", sizeof(anchor)) >=
PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcat(anchor, service->conf.name, sizeof(anchor)) >=
+ if (strlcat(anchor, rdr->conf.name, sizeof(anchor)) >=
PF_ANCHOR_NAME_SIZE)
goto toolong;
if (transaction_init(env, anchor) == -1) {
@@ -303,7 +303,7 @@ sync_ruleset(struct relayd *env, struct service *service, int enable)
return;
}
- TAILQ_FOREACH(address, &service->virts, entry) {
+ TAILQ_FOREACH(address, &rdr->virts, entry) {
memset(&rio, 0, sizeof(rio));
memset(&pio, 0, sizeof(pio));
(void)strlcpy(rio.anchor, anchor, sizeof(rio.anchor));
@@ -321,8 +321,8 @@ sync_ruleset(struct relayd *env, struct service *service, int enable)
rio.rule.dst.port[0] = address->port;
rio.rule.rtableid = -1; /* stay in the main routing table */
rio.rule.action = PF_RDR;
- if (strlen(service->conf.tag))
- (void)strlcpy(rio.rule.tagname, service->conf.tag,
+ if (strlen(rdr->conf.tag))
+ (void)strlcpy(rio.rule.tagname, rdr->conf.tag,
sizeof(rio.rule.tagname));
if (strlen(address->ifname))
(void)strlcpy(rio.rule.ifname, address->ifname,
@@ -345,17 +345,17 @@ sync_ruleset(struct relayd *env, struct service *service, int enable)
}
pio.addr.addr.type = PF_ADDR_TABLE;
- if (strlcpy(pio.addr.addr.v.tblname, service->conf.name,
+ if (strlcpy(pio.addr.addr.v.tblname, rdr->conf.name,
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)
fatal("sync_ruleset: cannot add address to pool");
- rio.rule.rpool.proxy_port[0] = ntohs(service->table->conf.port);
+ rio.rule.rpool.proxy_port[0] = ntohs(rdr->table->conf.port);
rio.rule.rpool.port_op = PF_OP_EQ;
rio.rule.rpool.opts = PF_POOL_ROUNDROBIN;
- if (service->conf.flags & F_STICKY)
+ if (rdr->conf.flags & F_STICKY)
rio.rule.rpool.opts |= PF_POOL_STICKYADDR;
if (ioctl(env->pf->dev, DIOCADDRULE, &rio) == -1)
@@ -373,15 +373,15 @@ sync_ruleset(struct relayd *env, struct service *service, int enable)
void
flush_rulesets(struct relayd *env)
{
- struct service *service;
+ struct rdr *rdr;
char anchor[PF_ANCHOR_NAME_SIZE];
kill_tables(env);
- TAILQ_FOREACH(service, env->services, entry) {
+ TAILQ_FOREACH(rdr, env->rdrs, entry) {
if (strlcpy(anchor, RELAYD_ANCHOR "/", sizeof(anchor)) >=
PF_ANCHOR_NAME_SIZE)
goto toolong;
- if (strlcat(anchor, service->conf.name, sizeof(anchor)) >=
+ if (strlcat(anchor, rdr->conf.name, sizeof(anchor)) >=
PF_ANCHOR_NAME_SIZE)
goto toolong;
if (transaction_init(env, anchor) == -1 ||
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 8a3230dc3f4..c8904c53a29 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.76 2007/12/08 17:07:09 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.77 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -175,7 +175,7 @@ relay(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
}
env = x_env;
- purge_config(env, PURGE_SERVICES);
+ purge_config(env, PURGE_RDRS);
/* Need root privileges for relay initialization */
relay_privinit();
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index b2c5937e445..f65a25a2b72 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.63 2007/12/08 17:07:09 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.64 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -358,7 +358,7 @@ merge_config(struct relayd *env, struct relayd *new_env)
env->flags = new_env->flags;
env->confpath = new_env->confpath;
env->tablecount = new_env->tablecount;
- env->servicecount = new_env->servicecount;
+ env->rdrcount = new_env->rdrcount;
env->protocount = new_env->protocount;
env->relaycount = new_env->relaycount;
@@ -373,7 +373,7 @@ merge_config(struct relayd *env, struct relayd *new_env)
sizeof(env->demote_group));
env->tables = new_env->tables;
- env->services = new_env->services;
+ env->rdrs = new_env->rdrs;
env->relays = new_env->relays;
env->protos = new_env->protos;
}
@@ -384,7 +384,7 @@ reconfigure(void)
{
struct relayd *env = relayd_env;
struct relayd *new_env;
- struct service *service;
+ struct rdr *rdr;
struct address *virt;
struct table *table;
struct host *host;
@@ -410,10 +410,10 @@ reconfigure(void)
&host->conf, sizeof(host->conf));
}
}
- TAILQ_FOREACH(service, env->services, entry) {
- imsg_compose(ibuf_pfe, IMSG_RECONF_SERVICE, 0, 0, -1,
- &service->conf, sizeof(service->conf));
- TAILQ_FOREACH(virt, &service->virts, entry)
+ TAILQ_FOREACH(rdr, env->rdrs, entry) {
+ imsg_compose(ibuf_pfe, IMSG_RECONF_RDR, 0, 0, -1,
+ &rdr->conf, sizeof(rdr->conf));
+ TAILQ_FOREACH(virt, &rdr->virts, entry)
imsg_compose(ibuf_pfe, IMSG_RECONF_VIRT, 0, 0, -1,
virt, sizeof(*virt));
}
@@ -441,7 +441,7 @@ void
purge_config(struct relayd *env, u_int8_t what)
{
struct table *table;
- struct service *service;
+ struct rdr *rdr;
struct address *virt;
struct protocol *proto;
struct relay *rly;
@@ -454,17 +454,17 @@ purge_config(struct relayd *env, u_int8_t what)
env->tables = NULL;
}
- if (what & PURGE_SERVICES && env->services != NULL) {
- while ((service = TAILQ_FIRST(env->services)) != NULL) {
- TAILQ_REMOVE(env->services, service, entry);
- while ((virt = TAILQ_FIRST(&service->virts)) != NULL) {
- TAILQ_REMOVE(&service->virts, virt, entry);
+ if (what & PURGE_RDRS && env->rdrs != NULL) {
+ while ((rdr = TAILQ_FIRST(env->rdrs)) != NULL) {
+ TAILQ_REMOVE(env->rdrs, rdr, entry);
+ while ((virt = TAILQ_FIRST(&rdr->virts)) != NULL) {
+ TAILQ_REMOVE(&rdr->virts, virt, entry);
free(virt);
}
- free(service);
+ free(rdr);
}
- free(env->services);
- env->services = NULL;
+ free(env->rdrs);
+ env->rdrs = NULL;
}
if (what & PURGE_RELAYS && env->relays != NULL) {
@@ -744,14 +744,14 @@ table_find(struct relayd *env, objid_t id)
return (NULL);
}
-struct service *
-service_find(struct relayd *env, objid_t id)
+struct rdr *
+rdr_find(struct relayd *env, objid_t id)
{
- struct service *service;
+ struct rdr *rdr;
- TAILQ_FOREACH(service, env->services, entry)
- if (service->conf.id == id)
- return (service);
+ TAILQ_FOREACH(rdr, env->rdrs, entry)
+ if (rdr->conf.id == id)
+ return (rdr);
return (NULL);
}
@@ -810,12 +810,12 @@ table_findbyconf(struct relayd *env, struct table *tb)
struct table_config a, b;
bcopy(&tb->conf, &a, sizeof(a));
- a.id = a.serviceid = 0;
+ a.id = a.rdrid = 0;
a.flags &= ~(F_USED|F_BACKUP);
TAILQ_FOREACH(table, env->tables, entry) {
bcopy(&table->conf, &b, sizeof(b));
- b.id = b.serviceid = 0;
+ b.id = b.rdrid = 0;
b.flags &= ~(F_USED|F_BACKUP);
/*
@@ -831,14 +831,14 @@ table_findbyconf(struct relayd *env, struct table *tb)
return (NULL);
}
-struct service *
-service_findbyname(struct relayd *env, const char *name)
+struct rdr *
+rdr_findbyname(struct relayd *env, const char *name)
{
- struct service *service;
+ struct rdr *rdr;
- TAILQ_FOREACH(service, env->services, entry)
- if (strcmp(service->conf.name, name) == 0)
- return (service);
+ TAILQ_FOREACH(rdr, env->rdrs, entry)
+ if (strcmp(rdr->conf.name, name) == 0)
+ return (rdr);
return (NULL);
}
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index f0f682a004d..3791ff97eb1 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.88 2007/12/08 17:07:09 reyk Exp $ */
+/* $OpenBSD: relayd.h,v 1.89 2007/12/08 20:36:36 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -51,7 +51,7 @@
#define ICMP_BUF_SIZE 64
#define PURGE_TABLES 0x01
-#define PURGE_SERVICES 0x02
+#define PURGE_RDRS 0x02
#define PURGE_RELAYS 0x04
#define PURGE_PROTOS 0x08
#define PURGE_EVERYTHING 0xff
@@ -103,7 +103,7 @@ enum imsg_type {
IMSG_CTL_OK, /* answer to relayctl requests */
IMSG_CTL_FAIL,
IMSG_CTL_END,
- IMSG_CTL_SERVICE,
+ IMSG_CTL_RDR,
IMSG_CTL_TABLE,
IMSG_CTL_HOST,
IMSG_CTL_RELAY,
@@ -112,8 +112,8 @@ enum imsg_type {
IMSG_CTL_PULL_RULESET,
IMSG_CTL_PUSH_RULESET,
IMSG_CTL_SHOW_SUM, /* relayctl requests */
- IMSG_CTL_SERVICE_ENABLE,
- IMSG_CTL_SERVICE_DISABLE,
+ IMSG_CTL_RDR_ENABLE,
+ IMSG_CTL_RDR_DISABLE,
IMSG_CTL_TABLE_ENABLE,
IMSG_CTL_TABLE_DISABLE,
IMSG_CTL_HOST_ENABLE,
@@ -123,8 +123,8 @@ enum imsg_type {
IMSG_CTL_POLL,
IMSG_CTL_NOTIFY,
IMSG_CTL_STATISTICS,
- IMSG_SERVICE_ENABLE, /* notifies from pfe to hce */
- IMSG_SERVICE_DISABLE,
+ IMSG_RDR_ENABLE, /* notifies from pfe to hce */
+ IMSG_RDR_DISABLE,
IMSG_TABLE_ENABLE,
IMSG_TABLE_DISABLE,
IMSG_HOST_ENABLE,
@@ -138,7 +138,7 @@ enum imsg_type {
IMSG_RECONF_TABLE,
IMSG_RECONF_SENDBUF,
IMSG_RECONF_HOST,
- IMSG_RECONF_SERVICE,
+ IMSG_RECONF_RDR,
IMSG_RECONF_VIRT,
IMSG_RECONF_PROTO,
IMSG_RECONF_REQUEST_TREE,
@@ -346,7 +346,7 @@ enum digest_type {
struct table_config {
objid_t id;
- objid_t serviceid;
+ objid_t rdrid;
u_int32_t flags;
int check;
char demote_group[IFNAMSIZ];
@@ -383,7 +383,7 @@ enum table_check {
CHECK_SCRIPT = 6
};
-struct service_config {
+struct rdr_config {
objid_t id;
u_int32_t flags;
in_port_t port;
@@ -393,14 +393,14 @@ struct service_config {
char tag[TAG_NAME_SIZE];
};
-struct service {
- TAILQ_ENTRY(service) entry;
- struct service_config conf;
+struct rdr {
+ TAILQ_ENTRY(rdr) entry;
+ struct rdr_config conf;
struct addresslist virts;
struct table *table;
struct table *backup; /* use this if no host up */
};
-TAILQ_HEAD(servicelist, service);
+TAILQ_HEAD(rdrlist, rdr);
struct session {
objid_t id;
@@ -600,7 +600,7 @@ struct relayd {
const char *confpath;
struct pfdata *pf;
int tablecount;
- int servicecount;
+ int rdrcount;
int protocount;
int relaycount;
struct timeval interval;
@@ -609,7 +609,7 @@ struct relayd {
struct protocol proto_default;
struct event ev;
struct tablelist *tables;
- struct servicelist *services;
+ struct rdrlist *rdrs;
struct protolist *protos;
struct relaylist *relays;
u_int16_t prefork_relay;
@@ -714,19 +714,19 @@ pid_t pfe(struct relayd *, int [2], int [2], int [RELAY_MAXPROC][2],
int [2], int [RELAY_MAXPROC][2]);
void show(struct ctl_conn *);
void show_sessions(struct ctl_conn *);
-int enable_service(struct ctl_conn *, struct ctl_id *);
+int enable_rdr(struct ctl_conn *, struct ctl_id *);
int enable_table(struct ctl_conn *, struct ctl_id *);
int enable_host(struct ctl_conn *, struct ctl_id *);
-int disable_service(struct ctl_conn *, struct ctl_id *);
+int disable_rdr(struct ctl_conn *, struct ctl_id *);
int disable_table(struct ctl_conn *, struct ctl_id *);
int disable_host(struct ctl_conn *, struct ctl_id *);
/* pfe_filter.c */
void init_filter(struct relayd *);
void init_tables(struct relayd *);
-void flush_table(struct relayd *, struct service *);
-void sync_table(struct relayd *, struct service *, struct table *);
-void sync_ruleset(struct relayd *, struct service *, int);
+void flush_table(struct relayd *, struct rdr *);
+void sync_table(struct relayd *, struct rdr *, struct table *);
+void sync_ruleset(struct relayd *, struct rdr *, int);
void flush_rulesets(struct relayd *);
int natlook(struct relayd *, struct ctl_natlook *);
@@ -777,11 +777,11 @@ int ssl_ctx_use_certificate_chain(SSL_CTX *, char *, off_t);
/* relayd.c */
struct host *host_find(struct relayd *, objid_t);
struct table *table_find(struct relayd *, objid_t);
-struct service *service_find(struct relayd *, objid_t);
+struct rdr *rdr_find(struct relayd *, objid_t);
struct host *host_findbyname(struct relayd *, const char *);
struct table *table_findbyname(struct relayd *, const char *);
struct table *table_findbyconf(struct relayd *, struct table *);
-struct service *service_findbyname(struct relayd *, const char *);
+struct rdr *rdr_findbyname(struct relayd *, const char *);
void event_again(struct event *, int, short,
void (*)(int, short, void *),
struct timeval *, struct timeval *, void *);