summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2011-05-05 12:01:45 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2011-05-05 12:01:45 +0000
commita3fd6084d44ed453397a1d4ee24f6c1150d1ffd0 (patch)
tree0b12db01bbbf4519d8733ef974c07b7874a89f09 /usr.sbin/relayd
parent1715270e901acc0c8439e0337a5cdf7e37b87b83 (diff)
Update all logging and debug functions to use the __func__ macro
instead of static function names. __func__ is C99 and perfectly fine to use. It also avoids printing errors; for example if a statement log_debug("foo:"..) was moved or copied from function foo() to bar() and the log message was not updated...
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/carp.c31
-rw-r--r--usr.sbin/relayd/check_icmp.c8
-rw-r--r--usr.sbin/relayd/check_tcp.c24
-rw-r--r--usr.sbin/relayd/control.c31
-rw-r--r--usr.sbin/relayd/hce.c14
-rw-r--r--usr.sbin/relayd/parse.y25
-rw-r--r--usr.sbin/relayd/pfe.c40
-rw-r--r--usr.sbin/relayd/pfe_filter.c33
-rw-r--r--usr.sbin/relayd/pfe_route.c11
-rw-r--r--usr.sbin/relayd/relay.c150
-rw-r--r--usr.sbin/relayd/relay_udp.c14
-rw-r--r--usr.sbin/relayd/relayd.c34
-rw-r--r--usr.sbin/relayd/snmp.c10
13 files changed, 214 insertions, 211 deletions
diff --git a/usr.sbin/relayd/carp.c b/usr.sbin/relayd/carp.c
index b4de6936992..c9d9c95e011 100644
--- a/usr.sbin/relayd/carp.c
+++ b/usr.sbin/relayd/carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: carp.c,v 1.7 2009/09/30 12:22:03 claudio Exp $ */
+/* $OpenBSD: carp.c,v 1.8 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@@ -65,11 +65,11 @@ carp_demote_init(char *group, int force)
if ((c = carp_group_find(group)) == NULL) {
if ((c = calloc(1, sizeof(struct carpgroup))) == NULL) {
- log_warn("carp_demote_init calloc");
+ log_warn("%s: calloc", __func__);
return (-1);
}
if ((c->group = strdup(group)) == NULL) {
- log_warn("carp_demote_init strdup");
+ log_warn("%s: strdup, __func__");
free(c);
return (-1);
}
@@ -111,22 +111,23 @@ carp_demote_get(char *group)
struct ifgroupreq ifgr;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- log_warn("carp_demote_get: socket");
+ log_warn("%s: socket", __func__);
return (-1);
}
bzero(&ifgr, sizeof(ifgr));
if (strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)) >=
sizeof(ifgr.ifgr_name)) {
- log_warn("carp_demote_get: invalid group");
+ log_warn("%s: invalid group", __func__);
return (-1);
}
if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1) {
if (errno == ENOENT)
- log_warnx("group \"%s\" does not exist", group);
+ log_warnx("%s: group \"%s\" does not exist",
+ __func__, group);
else
- log_warn("carp_demote_get: ioctl");
+ log_warn("%s: ioctl", __func__);
close(s);
return (-1);
}
@@ -141,12 +142,12 @@ carp_demote_set(char *group, int demote)
struct carpgroup *c;
if ((c = carp_group_find(group)) == NULL) {
- log_warnx("carp_group_find for %s returned NULL?!", group);
+ log_warnx("%s: carp group %s not found", __func__, group);
return (-1);
}
if (c->changed_by + demote < 0) {
- log_warnx("carp_demote_set: changed_by + demote < 0");
+ log_warnx("%s: changed_by + demote < 0", __func__);
return (-1);
}
@@ -169,7 +170,7 @@ carp_demote_reset(char *group, int value)
int demote = 0;
if (value < 0) {
- log_warnx("carp_demote_reset: value < 0");
+ log_warnx("%s: value < 0", __func__);
return (-1);
}
@@ -194,22 +195,22 @@ carp_demote_ioctl(char *group, int demote)
struct ifgroupreq ifgr;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
- log_warn("carp_demote_get: socket");
+ log_warn("%s: socket", __func__);
return (-1);
}
bzero(&ifgr, sizeof(ifgr));
if (strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)) >=
sizeof(ifgr.ifgr_name)) {
- log_warn("carp_demote_ioctl: invalid group");
+ log_warn("%s: invalid group", __func__);
return (-1);
}
ifgr.ifgr_attrib.ifg_carp_demoted = demote;
if ((res = ioctl(s, SIOCSIFGATTR, (caddr_t)&ifgr)) == -1)
- log_warn("unable to %s the demote state "
- "of group '%s'", (demote > 0) ? "increment" : "decrement",
- group);
+ log_warn("%s: unable to %s the demote state "
+ "of group '%s'", __func__,
+ (demote > 0) ? "increment" : "decrement", group);
else
log_info("%s the demote state of group '%s'",
(demote > 0) ? "incremented" : "decremented", group);
diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c
index 70167b4686e..9a399a784c0 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.29 2009/08/14 15:31:23 reyk Exp $ */
+/* $OpenBSD: check_icmp.c,v 1.30 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -284,7 +284,7 @@ recv_icmp(int s, short event, void *arg)
(struct sockaddr *)&ss, &slen);
if (r == -1 || r != ICMP_BUF_SIZE) {
if (r == -1 && errno != EAGAIN && errno != EINTR)
- log_debug("recv_icmp: receive error");
+ log_debug("%s: receive error", __func__);
goto retry;
}
@@ -301,11 +301,11 @@ recv_icmp(int s, short event, void *arg)
goto retry;
host = host_find(cie->env, id);
if (host == NULL) {
- log_warn("recv_icmp: ping for unknown host received");
+ log_warn("%s: ping for unknown host received", __func__);
goto retry;
}
if (bcmp(&ss, &host->conf.ss, slen)) {
- log_warnx("recv_icmp: forged icmp packet?");
+ log_warnx("%s: forged icmp packet?", __func__);
goto retry;
}
diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c
index 11cd66a21f5..92bd2cef6f2 100644
--- a/usr.sbin/relayd/check_tcp.c
+++ b/usr.sbin/relayd/check_tcp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: check_tcp.c,v 1.39 2010/12/20 12:38:06 dhill Exp $ */
+/* $OpenBSD: check_tcp.c,v 1.40 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -201,7 +201,7 @@ tcp_send_req(int s, short event, void *arg)
if (bs == -1) {
if (errno == EAGAIN || errno == EINTR)
goto retry;
- log_warnx("tcp_send_req: cannot send request");
+ log_warnx("%s: cannot send request", __func__);
cte->host->up = HOST_DOWN;
close(cte->s);
hce_notify_done(cte->host, HCE_TCP_WRITE_FAIL);
@@ -325,8 +325,8 @@ check_http_code(struct ctl_tcp_event *cte)
if (strncmp(head, "HTTP/1.1 ", strlen("HTTP/1.1 ")) &&
strncmp(head, "HTTP/1.0 ", strlen("HTTP/1.0 "))) {
- log_debug("check_http_code: %s failed "
- "(cannot parse HTTP version)", host->conf.name);
+ log_debug("%s: %s failed (cannot parse HTTP version)",
+ __func__, host->conf.name);
host->up = HOST_DOWN;
return (1);
}
@@ -338,14 +338,14 @@ check_http_code(struct ctl_tcp_event *cte)
(void)strlcpy(scode, head, sizeof(scode));
code = strtonum(scode, 100, 999, &estr);
if (estr != NULL) {
- log_debug("check_http_code: %s failed "
- "(cannot parse HTTP code)", host->conf.name);
+ log_debug("%s: %s failed (cannot parse HTTP code)",
+ __func__, host->conf.name);
host->up = HOST_DOWN;
return (1);
}
if (code != cte->table->conf.retcode) {
- log_debug("check_http_code: %s failed "
- "(invalid HTTP code returned)", host->conf.name);
+ log_debug("%s: %s failed (invalid HTTP code returned)",
+ __func__, host->conf.name);
host->he = HCE_HTTP_CODE_FAIL;
host->up = HOST_DOWN;
} else {
@@ -376,8 +376,8 @@ check_http_digest(struct ctl_tcp_event *cte)
host->he = HCE_HTTP_DIGEST_ERROR;
if ((head = strstr(head, "\r\n\r\n")) == NULL) {
- log_debug("check_http_digest: %s failed "
- "(no end of headers)", host->conf.name);
+ log_debug("%s: %s failed (no end of headers)",
+ __func__, host->conf.name);
host->up = HOST_DOWN;
return (1);
}
@@ -386,8 +386,8 @@ check_http_digest(struct ctl_tcp_event *cte)
digeststr(cte->table->conf.digest_type, head, strlen(head), digest);
if (strcmp(cte->table->conf.digest, digest)) {
- log_warnx("check_http_digest: %s failed "
- "(wrong digest)", host->conf.name);
+ log_warnx("%s: %s failed (wrong digest)",
+ __func__, host->conf.name);
host->he = HCE_HTTP_DIGEST_FAIL;
host->up = HOST_DOWN;
} else {
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c
index 58bfb506102..8b1d8da936b 100644
--- a/usr.sbin/relayd/control.c
+++ b/usr.sbin/relayd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.36 2010/05/14 11:11:10 reyk Exp $ */
+/* $OpenBSD: control.c,v 1.37 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -54,28 +54,28 @@ control_init(void)
mode_t old_umask;
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
- log_warn("control_init: socket");
+ log_warn("%s: socket", __func__);
return (-1);
}
sun.sun_family = AF_UNIX;
if (strlcpy(sun.sun_path, RELAYD_SOCKET,
sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) {
- log_warn("control_init: %s name too long", RELAYD_SOCKET);
+ log_warn("%s: %s name too long", __func__, RELAYD_SOCKET);
close(fd);
return (-1);
}
if (unlink(RELAYD_SOCKET) == -1)
if (errno != ENOENT) {
- log_warn("control_init: unlink %s", RELAYD_SOCKET);
+ log_warn("%s: unlink %s", __func__, RELAYD_SOCKET);
close(fd);
return (-1);
}
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
- log_warn("control_init: bind: %s", RELAYD_SOCKET);
+ log_warn("%s: bind: %s", __func__, RELAYD_SOCKET);
close(fd);
(void)umask(old_umask);
return (-1);
@@ -83,7 +83,7 @@ control_init(void)
(void)umask(old_umask);
if (chmod(RELAYD_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
- log_warn("control_init: chmod");
+ log_warn("%s: chmod", __func__);
close(fd);
(void)unlink(RELAYD_SOCKET);
return (-1);
@@ -105,7 +105,7 @@ control_listen(struct relayd *env, struct imsgev *i_main,
iev_hce = i_hce;
if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
- log_warn("control_listen: listen");
+ log_warn("%s: listen", __func__);
return (-1);
}
@@ -136,7 +136,7 @@ control_accept(int listenfd, short event, void *arg)
if ((connfd = accept(listenfd,
(struct sockaddr *)&sun, &len)) == -1) {
if (errno != EWOULDBLOCK && errno != EINTR)
- log_warn("control_accept: accept");
+ log_warn("%s: accept", __func__);
return;
}
@@ -144,7 +144,7 @@ control_accept(int listenfd, short event, void *arg)
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
close(connfd);
- log_warn("control_accept");
+ log_warn("%s: calloc", __func__);
return;
}
@@ -176,7 +176,7 @@ control_close(int fd)
struct ctl_conn *c;
if ((c = control_connbyfd(fd)) == NULL) {
- log_warn("control_close: fd %d: not found", fd);
+ log_warn("%s: fd %d not found", __func__, fd);
return;
}
@@ -200,7 +200,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
struct relayd *env = arg;
if ((c = control_connbyfd(fd)) == NULL) {
- log_warn("control_dispatch_imsg: fd %d: not found", fd);
+ log_warn("%s: fd %d not found", __func__, fd);
return;
}
@@ -349,8 +349,9 @@ control_dispatch_imsg(int fd, short event, void *arg)
break;
case IMSG_CTL_NOTIFY:
if (c->flags & CTL_CONN_NOTIFY) {
- log_debug("control_dispatch_imsg: "
- "client requested notify more than once");
+ log_debug("%s: "
+ "client requested notify more than once",
+ __func__);
imsg_compose_event(&c->iev, IMSG_CTL_FAIL,
0, 0, -1, NULL, 0);
break;
@@ -374,8 +375,8 @@ control_dispatch_imsg(int fd, short event, void *arg)
log_verbose(verbose);
break;
default:
- log_debug("control_dispatch_imsg: "
- "error handling imsg %d", imsg.hdr.type);
+ log_debug("%s: error handling imsg %d",
+ __func__, imsg.hdr.type);
break;
}
imsg_free(&imsg);
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index a0361602d12..2eb5b0c5542 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.57 2011/02/08 08:52:28 sthen Exp $ */
+/* $OpenBSD: hce.c,v 1.58 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -299,7 +299,7 @@ hce_notify_done(struct host *host, enum host_error he)
host->he = he;
if (host->up == HOST_DOWN && host->retry_cnt) {
- log_debug("hce_notify_done: host %s retry %d",
+ log_debug("%s: host %s retry %d", __func__,
host->conf.name, host->retry_cnt);
host->up = host->last_up;
host->retry_cnt--;
@@ -318,7 +318,7 @@ hce_notify_done(struct host *host, enum host_error he)
host->flags |= (F_CHECK_SENT|F_CHECK_DONE);
msg = host_error(he);
if (msg)
- log_debug("hce_notify_done: %s (%s)", host->conf.name, msg);
+ log_debug("%s: %s (%s)", __func__, host->conf.name, msg);
imsg_compose_event(iev_pfe, IMSG_HOST_STATUS,
0, 0, -1, &st, sizeof(st));
@@ -452,7 +452,7 @@ hce_dispatch_imsg(int fd, short event, void *ptr)
log_verbose(verbose);
break;
default:
- log_debug("hce_dispatch_msg: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -508,7 +508,7 @@ hce_dispatch_parent(int fd, short event, void * ptr)
script_done(env, &scr);
break;
case IMSG_RECONF:
- log_debug("hce: reloading configuration");
+ log_debug("%s: reloading configuration", __func__);
if (imsg.hdr.len !=
sizeof(struct relayd) + IMSG_HEADER_SIZE)
fatalx("corrupted reload data");
@@ -547,11 +547,11 @@ hce_dispatch_parent(int fd, short event, void * ptr)
}
break;
case IMSG_RECONF_END:
- log_warnx("hce: configuration reloaded");
+ log_warnx("%s: configuration reloaded", __func__);
hce_setup_events();
break;
default:
- log_debug("hce_dispatch_parent: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index be62a7a17da..fcb0b55f9c5 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.153 2011/05/05 10:20:24 phessler Exp $ */
+/* $OpenBSD: parse.y,v 1.154 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -2101,16 +2101,16 @@ pushfile(const char *name, int secret)
struct file *nfile;
if ((nfile = calloc(1, sizeof(struct file))) == NULL) {
- log_warn("malloc");
+ log_warn("%s: malloc", __func__);
return (NULL);
}
if ((nfile->name = strdup(name)) == NULL) {
- log_warn("malloc");
+ log_warn("%s: malloc", __func__);
free(nfile);
return (NULL);
}
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
- log_warn("%s", nfile->name);
+ log_warn("%s: %s", __func__, nfile->name);
free(nfile->name);
free(nfile);
return (NULL);
@@ -2169,7 +2169,7 @@ parse_config(const char *filename, int opts)
free(conf->sc_rts);
free(conf);
}
- log_warn("cannot allocate memory");
+ log_warn("%s: cannot allocate memory", __func__);
return (NULL);
}
@@ -2473,7 +2473,7 @@ host_dns(const char *s, struct addresslist *al, int max,
if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME)
return (0);
if (error) {
- log_warnx("host_dns: could not parse \"%s\": %s", s,
+ log_warnx("%s: could not parse \"%s\": %s", __func__, s,
gai_strerror(error));
return (-1);
}
@@ -2490,7 +2490,8 @@ host_dns(const char *s, struct addresslist *al, int max,
if (ifname != NULL) {
if (strlcpy(h->ifname, ifname, sizeof(h->ifname)) >=
sizeof(h->ifname))
- log_warnx("host_dns: interface name truncated");
+ log_warnx("%s: interface name truncated",
+ __func__);
freeaddrinfo(res0);
return (-1);
}
@@ -2514,7 +2515,7 @@ host_dns(const char *s, struct addresslist *al, int max,
cnt++;
}
if (cnt == max && res) {
- log_warnx("host_dns: %s resolves to more than %d hosts",
+ log_warnx("%s: %s resolves to more than %d hosts", __func__,
s, max);
}
freeaddrinfo(res0);
@@ -2553,7 +2554,8 @@ host_if(const char *s, struct addresslist *al, int max,
if (ifname != NULL) {
if (strlcpy(h->ifname, ifname, sizeof(h->ifname)) >=
sizeof(h->ifname))
- log_warnx("host_if: interface name truncated");
+ log_warnx("%s: interface name truncated",
+ __func__);
freeifaddrs(ifap);
return (-1);
}
@@ -2585,7 +2587,7 @@ host_if(const char *s, struct addresslist *al, int max,
}
if (cnt > max) {
- log_warnx("host_if: %s resolves to more than %d hosts",
+ log_warnx("%s: %s resolves to more than %d hosts", __func__,
s, max);
}
freeifaddrs(ifap);
@@ -2610,7 +2612,8 @@ host(const char *s, struct addresslist *al, int max,
if (ifname != NULL) {
if (strlcpy(h->ifname, ifname, sizeof(h->ifname)) >=
sizeof(h->ifname)) {
- log_warnx("host: interface name truncated");
+ log_warnx("%s: interface name truncated",
+ __func__);
return (-1);
}
}
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index 7c93fc6c5f3..a9d376d42e1 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.66 2010/11/16 15:31:01 jsg Exp $ */
+/* $OpenBSD: pfe.c,v 1.67 2011/05/05 12:01:43 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -283,7 +283,7 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
host->up_cnt++;
}
if (host->check_cnt != st.check_cnt) {
- log_debug("pfe_dispatch_imsg: host %d => %d",
+ log_debug("%s: host %d => %d", __func__,
host->conf.id, host->up);
fatalx("pfe_dispatch_imsg: desynchronized");
}
@@ -301,7 +301,7 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
== NULL)
fatalx("pfe_dispatch_imsg: invalid table id");
- log_debug("pfe_dispatch_imsg: state %d for host %u %s",
+ log_debug("%s: state %d for host %u %s", __func__,
st.up, host->conf.id, host->conf.name);
/*
@@ -326,7 +326,7 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
pfe_sync();
break;
default:
- log_debug("pfe_dispatch_imsg: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -376,7 +376,7 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
switch (imsg.hdr.type) {
case IMSG_RECONF:
- log_debug("pfe: reloading configuration");
+ log_debug("%s: reloading configuration", __func__);
if (imsg.hdr.len !=
sizeof(struct relayd) + IMSG_HEADER_SIZE)
fatalx("corrupted reload data");
@@ -431,9 +431,9 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
if (rdr->table == NULL || rdr->backup == NULL)
fatal("pfe_dispatch_parent:"
" corrupted configuration");
- log_debug("pfe_dispatch_parent: rdr->table: %s",
- rdr->table->conf.name);
- log_debug("pfe_dispatch_parent: rdr->backup: %s",
+ log_debug("%s: redirect table %s, backup %s",
+ __func__,
+ rdr->table->conf.name,
rdr->backup->conf.name);
TAILQ_INIT(&rdr->virts);
TAILQ_INSERT_TAIL(env->sc_rdrs, rdr, entry);
@@ -445,13 +445,13 @@ pfe_dispatch_parent(int fd, short event, void * ptr)
TAILQ_INSERT_TAIL(&rdr->virts, virt, entry);
break;
case IMSG_RECONF_END:
- log_warnx("pfe: configuration reloaded");
+ log_warnx("%s: configuration reloaded", __func__);
init_tables(env);
pfe_setup_events();
pfe_sync();
break;
default:
- log_debug("pfe_dispatch_parent: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -523,7 +523,7 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
env->sc_statinterval.tv_sec;
break;
default:
- log_debug("pfe_dispatch_relay: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -694,7 +694,7 @@ disable_rdr(struct ctl_conn *c, struct ctl_id *id)
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);
+ log_debug("%s: redirect %d", __func__, rdr->conf.id);
pfe_sync();
return (0);
}
@@ -719,7 +719,7 @@ enable_rdr(struct ctl_conn *c, struct ctl_id *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);
+ log_debug("%s: redirect %d", __func__, rdr->conf.id);
bzero(&eid, sizeof(eid));
@@ -765,7 +765,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id)
imsg_compose_event(&iev_relay[n],
IMSG_TABLE_DISABLE, 0, 0, -1,
&table->conf.id, sizeof(table->conf.id));
- log_debug("disable_table: disabled table %d", table->conf.id);
+ log_debug("%s: table %d", __func__, table->conf.id);
pfe_sync();
return (0);
}
@@ -802,7 +802,7 @@ enable_table(struct ctl_conn *c, struct ctl_id *id)
imsg_compose_event(&iev_relay[n],
IMSG_TABLE_ENABLE, 0, 0, -1,
&table->conf.id, sizeof(table->conf.id));
- log_debug("enable_table: enabled table %d", table->conf.id);
+ log_debug("%s: table %d", __func__, table->conf.id);
pfe_sync();
return (0);
}
@@ -848,7 +848,7 @@ disable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
imsg_compose_event(&iev_relay[n],
IMSG_HOST_DISABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
- log_debug("disable_host: disabled host %d", host->conf.id);
+ log_debug("%s: host %d", __func__, host->conf.id);
if (!host->conf.parentid) {
/* Disable all children */
@@ -890,7 +890,7 @@ enable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
imsg_compose_event(&iev_relay[n],
IMSG_HOST_ENABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
- log_debug("enable_host: enabled host %d", host->conf.id);
+ log_debug("%s: host %d", __func__, host->conf.id);
if (!host->conf.parentid) {
/* Enable all children */
@@ -944,7 +944,7 @@ pfe_sync(void)
if (rdr->conf.flags & F_DOWN) {
if (rdr->conf.flags & F_ACTIVE_RULESET) {
flush_table(env, rdr);
- log_debug("pfe_sync: disabling ruleset");
+ log_debug("%s: disabling ruleset", __func__);
rdr->conf.flags &= ~(F_ACTIVE_RULESET);
id.id = rdr->conf.id;
imsg.hdr.type = IMSG_CTL_PULL_RULESET;
@@ -954,7 +954,7 @@ pfe_sync(void)
control_imsg_forward(&imsg);
}
} else if (!(rdr->conf.flags & F_ACTIVE_RULESET)) {
- log_debug("pfe_sync: enabling ruleset");
+ log_debug("%s: enabling ruleset", __func__);
rdr->conf.flags |= F_ACTIVE_RULESET;
id.id = rdr->conf.id;
imsg.hdr.type = IMSG_CTL_PUSH_RULESET;
@@ -995,7 +995,7 @@ pfe_sync(void)
}
if (demote.level == 0)
continue;
- log_debug("pfe_sync: demote %d table '%s' group '%s'",
+ log_debug("%s: demote %d table '%s' group '%s'", __func__,
demote.level, table->conf.name, table->conf.demote_group);
(void)strlcpy(demote.group, table->conf.demote_group,
sizeof(demote.group));
diff --git a/usr.sbin/relayd/pfe_filter.c b/usr.sbin/relayd/pfe_filter.c
index 37f91d9598f..2fa53cdd3b8 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.45 2010/10/26 15:04:37 reyk Exp $ */
+/* $OpenBSD: pfe_filter.c,v 1.46 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -68,7 +68,7 @@ init_filter(struct relayd *env)
fatal("init_filter: DIOCGETSTATUS");
if (!status.running)
fatalx("init_filter: pf is disabled");
- log_debug("init_filter: filter init done");
+ log_debug("%s: filter init done", __func__);
}
void
@@ -110,7 +110,7 @@ init_tables(struct relayd *env)
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);
+ log_debug("%s: created %d tables", __func__, io.pfrio_nadd);
free(tables);
@@ -151,7 +151,7 @@ kill_tables(struct relayd *env)
fatal("kill_tables: ioctl failed");
cnt += io.pfrio_ndel;
}
- log_debug("kill_tables: deleted %d tables", cnt);
+ log_debug("%s: deleted %d tables", __func__, cnt);
return;
toolong:
@@ -320,7 +320,7 @@ flush_table(struct relayd *env, struct rdr *rdr)
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);
+ log_debug("%s: flushed table %s", __func__, rdr->conf.name);
return;
toolong:
@@ -377,16 +377,16 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
PF_ANCHOR_NAME_SIZE)
goto toolong;
if (transaction_init(env, anchor) == -1) {
- log_warn("sync_ruleset: transaction init failed");
+ log_warn("%s: transaction init failed", __func__);
return;
}
if (!enable) {
if (transaction_commit(env) == -1)
- log_warn("sync_ruleset: "
- "remove rules transaction failed");
+ log_warn("%s: remove rules transaction failed",
+ __func__);
else
- log_debug("sync_ruleset: rules removed");
+ log_debug("%s: rules removed", __func__);
return;
}
@@ -489,11 +489,10 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable)
if (ioctl(env->sc_pf->dev, DIOCADDRULE, &rio) == -1)
fatal("cannot add rule");
- log_debug("sync_ruleset: rule added to anchor \"%s\"",
- anchor);
+ log_debug("%s: rule added to anchor \"%s\"", __func__, anchor);
}
if (transaction_commit(env) == -1)
- log_warn("sync_ruleset: add rules transaction failed");
+ log_warn("%s: add rules transaction failed", __func__);
return;
toolong:
@@ -519,7 +518,7 @@ flush_rulesets(struct relayd *env)
goto toolong;
if (transaction_init(env, anchor) == -1 ||
transaction_commit(env) == -1)
- log_warn("flush_rulesets: transaction for %s/ failed",
+ log_warn("%s: transaction for %s/ failed", __func__,
RELAYD_ANCHOR);
}
if (strlcpy(anchor, RELAYD_ANCHOR, sizeof(anchor)) >=
@@ -527,9 +526,9 @@ flush_rulesets(struct relayd *env)
goto toolong;
if (transaction_init(env, anchor) == -1 ||
transaction_commit(env) == -1)
- log_warn("flush_rulesets: transaction for %s failed",
+ log_warn("%s: transaction for %s failed", __func__,
RELAYD_ANCHOR);
- log_debug("flush_rulesets: flushed rules");
+ log_debug("%s: flushed rules", __func__);
return;
toolong:
@@ -576,14 +575,14 @@ natlook(struct relayd *env, struct ctl_natlook *cnl)
pnl.direction = PF_OUT;
cnl->in = 0;
if (ioctl(env->sc_pf->dev, DIOCNATLOOK, &pnl) == -1) {
- log_debug("natlook: error: %s", strerror(errno));
+ log_debug("%s: ioctl: %s", __func__, strerror(errno));
return (-1);
}
}
inet_ntop(pnl.af, &pnl.rsaddr, ibuf, sizeof(ibuf));
inet_ntop(pnl.af, &pnl.rdaddr, obuf, sizeof(obuf));
- log_debug("natlook: %s %s:%d -> %s:%d",
+ log_debug("%s: %s %s:%d -> %s:%d", __func__,
pnl.direction == PF_IN ? "in" : "out",
ibuf, ntohs(pnl.rsport), obuf, ntohs(pnl.rdport));
diff --git a/usr.sbin/relayd/pfe_route.c b/usr.sbin/relayd/pfe_route.c
index 9c084b2bf36..ef16d7e4302 100644
--- a/usr.sbin/relayd/pfe_route.c
+++ b/usr.sbin/relayd/pfe_route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe_route.c,v 1.2 2011/05/05 10:20:24 phessler Exp $ */
+/* $OpenBSD: pfe_route.c,v 1.3 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2009 Reyk Floeter <reyk@openbsd.org>
@@ -90,8 +90,9 @@ sync_routes(struct relayd *env, struct router *rt)
if (host->up == HOST_UNKNOWN)
continue;
- log_debug("sync_routes: "
+ log_debug("%s: "
"router %s route %s/%d gateway %s %s priority %d",
+ __func__,
rt->rt_conf.name, buf, nr->nr_conf.prefixlen,
host->conf.name,
HOST_ISUP(host->up) ? "up" : "down",
@@ -123,7 +124,7 @@ pfe_route(struct relayd *env, struct ctl_netroute *crt)
if ((nr = route_find(env, crt->id)) == NULL ||
(host = host_find(env, crt->hostid)) == NULL) {
- log_debug("pfe_route: invalid host or route id");
+ log_debug("%s: invalid host or route id", __func__);
return (-1);
}
@@ -228,13 +229,13 @@ pfe_route(struct relayd *env, struct ctl_netroute *crt)
}
}
- log_debug("pfe_route: gateway %s %s", gwname,
+ log_debug("%s: gateway %s %s", __func__, gwname,
HOST_ISUP(crt->up) ? "added" : "deleted");
return (0);
bad:
- log_debug("pfe_route: failed to %s gateway %s: %d %s",
+ log_debug("%s: failed to %s gateway %s: %d %s", __func__,
HOST_ISUP(crt->up) ? "add" : "delete", gwname,
errno, strerror(errno));
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 7182dcd4903..2fa1a144d74 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.134 2011/04/24 10:07:43 bluhm Exp $ */
+/* $OpenBSD: relay.c,v 1.135 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -435,8 +435,7 @@ relay_privinit(void)
ssl_init(env);
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) {
- log_debug("relay_privinit: adding relay %s",
- rlay->rl_conf.name);
+ log_debug("%s: adding relay %s", __func__, rlay->rl_conf.name);
if (debug)
relay_protodebug(rlay);
@@ -593,7 +592,8 @@ relay_launch(void)
void (*callback)(int, short, void *);
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) {
- log_debug("relay_launch: running relay %s", rlay->rl_conf.name);
+ log_debug("%s: running relay %s", __func__,
+ rlay->rl_conf.name);
rlay->rl_up = HOST_UP;
@@ -793,7 +793,7 @@ relay_connected(int fd, short sig, void *arg)
return;
}
- DPRINTF("relay_connected: session %d: %ssuccessful",
+ DPRINTF("%s: session %d: %ssuccessful", __func__,
con->se_id, rlay->rl_proto->lateconnect ? "late connect " : "");
switch (rlay->rl_proto->type) {
@@ -815,15 +815,15 @@ relay_connected(int fd, short sig, void *arg)
break;
if (setsockopt(con->se_in.s, SOL_SOCKET, SO_SPLICE,
&con->se_out.s, sizeof(int)) == -1) {
- log_debug("relay_connect: session %d: splice forward "
- "failed: %s", con->se_id, strerror(errno));
+ log_debug("%s: session %d: splice forward failed: %s",
+ __func__, con->se_id, strerror(errno));
return;
}
con->se_in.splicelen = 0;
if (setsockopt(con->se_out.s, SOL_SOCKET, SO_SPLICE,
&con->se_in.s, sizeof(int)) == -1) {
- log_debug("relay_connect: session %d: splice backward "
- "failed: %s", con->se_id, strerror(errno));
+ log_debug("%s: session %d: splice backward failed: %s",
+ __func__, con->se_id, strerror(errno));
return;
}
con->se_out.splicelen = 0;
@@ -1006,17 +1006,14 @@ relay_resolve(struct ctl_relay_event *cre,
"failed to modify header", 0);
return (-1);
}
- DPRINTF("relay_resolve: add '%s: %s'",
- pn->key, ptr);
+ DPRINTF("%s: add '%s: %s'", __func__, pn->key, ptr);
break;
case NODE_ACTION_EXPECT:
- DPRINTF("relay_resolve: missing '%s: %s'",
- pn->key, pn->value);
+ DPRINTF("%s: missing '%s: %s'", __func__, pn->key, pn->value);
relay_close_http(con, 403, "incomplete request", pn->label);
return (-1);
case NODE_ACTION_FILTER:
- DPRINTF("relay_resolve: filtered '%s: %s'",
- pn->key, pn->value);
+ DPRINTF("%s: filtered '%s: %s'", __func__, pn->key, pn->value);
relay_close_http(con, 403, "rejecting request", pn->label);
return (-1);
default:
@@ -1142,14 +1139,14 @@ relay_handle_http(struct ctl_relay_event *cre, struct protonode *proot,
relay_bufferevent_print(cre->dst, "\r\n") == -1)
goto fail;
cre->nodes[pn->id] = 1;
- DPRINTF("relay_handle_http: append '%s: %s, %s'",
+ DPRINTF("%s: append '%s: %s, %s'", __func__,
pk->key, pk->value, ptr);
break;
case NODE_ACTION_CHANGE:
case NODE_ACTION_REMOVE:
if (!header)
return (PN_PASS);
- DPRINTF("relay_handle_http: change/remove '%s: %s'",
+ DPRINTF("%s: change/remove '%s: %s'", __func__,
pk->key, pk->value);
break;
case NODE_ACTION_EXPECT:
@@ -1163,7 +1160,7 @@ relay_handle_http(struct ctl_relay_event *cre, struct protonode *proot,
}
/* FALLTHROUGH */
case NODE_ACTION_FILTER:
- DPRINTF("relay_handle_http: %s '%s: %s'",
+ DPRINTF("%s: %s '%s: %s'", __func__,
(pn->action == NODE_ACTION_EXPECT) ? "expect" : "filter",
pn->key, pn->value);
@@ -1188,18 +1185,18 @@ relay_handle_http(struct ctl_relay_event *cre, struct protonode *proot,
cre->nodes[proot->id]++;
break;
case NODE_ACTION_HASH:
- DPRINTF("relay_handle_http: hash '%s: %s'",
+ DPRINTF("%s: hash '%s: %s'", __func__,
pn->key, pk->value);
con->se_hashkey = hash32_str(pk->value, con->se_hashkey);
ret = PN_PASS;
break;
case NODE_ACTION_LOG:
- DPRINTF("relay_handle_http: log '%s: %s'",
+ DPRINTF("%s: log '%s: %s'", __func__,
pn->key, pk->value);
ret = PN_PASS;
break;
case NODE_ACTION_MARK:
- DPRINTF("relay_handle_http: mark '%s: %s'",
+ DPRINTF("%s: mark '%s: %s'", __func__,
pn->key, pk->value);
if (fnmatch(pn->value, pk->value, FNM_CASEFOLD) == 0)
con->se_mark = pn->mark;
@@ -1228,7 +1225,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg)
if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto fail;
size = EVBUFFER_LENGTH(src);
- DPRINTF("relay_read_httpcontent: size %d, to read %d",
+ DPRINTF("%s: size %d, to read %d", __func__,
size, cre->toread);
if (!size)
return;
@@ -1237,7 +1234,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg)
if (size >= cre->toread)
bev->readcb = relay_read_http;
cre->toread -= size;
- DPRINTF("relay_read_httpcontent: done, size %d, to read %d",
+ DPRINTF("%s: done, size %d, to read %d", __func__,
size, cre->toread);
if (con->se_done)
goto done;
@@ -1265,7 +1262,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto fail;
size = EVBUFFER_LENGTH(src);
- DPRINTF("relay_read_httpchunks: size %d, to read %d",
+ DPRINTF("%s: size %d, to read %d", __func__,
size, cre->toread);
if (!size)
return;
@@ -1298,7 +1295,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
/* Last chunk is 0 bytes followed by an empty newline */
if ((cre->toread = lval) == 0) {
- DPRINTF("relay_read_httpchunks: last chunk");
+ DPRINTF("%s: last chunk", __func__);
line = evbuffer_readline(src);
if (line == NULL) {
@@ -1319,7 +1316,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
if (relay_bufferevent_write_chunk(cre->dst, src, size) == -1)
goto fail;
cre->toread -= size;
- DPRINTF("relay_read_httpchunks: done, size %d, to read %d",
+ DPRINTF("%s: done, size %d, to read %d", __func__,
size, cre->toread);
if (cre->toread == 0) {
@@ -1387,7 +1384,7 @@ relay_read_http(struct bufferevent *bev, void *arg)
if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto fail;
size = EVBUFFER_LENGTH(src);
- DPRINTF("relay_read_http: size %d, to read %d", size, cre->toread);
+ DPRINTF("%s: size %d, to read %d", __func__, size, cre->toread);
if (!size) {
if (cre->dir == RELAY_DIR_RESPONSE)
return;
@@ -1424,7 +1421,7 @@ relay_read_http(struct bufferevent *bev, void *arg)
return;
}
- DPRINTF("relay_read_http: request '%s'", line);
+ DPRINTF("%s: request '%s'", __func__, line);
/* Append line to the output buffer */
if (relay_bufferevent_print(cre->dst, line) == -1 ||
relay_bufferevent_print(cre->dst, "\r\n") == -1) {
@@ -1443,7 +1440,7 @@ relay_read_http(struct bufferevent *bev, void *arg)
header = 0;
}
- DPRINTF("relay_read_http: header '%s: %s'", pk.key, pk.value);
+ DPRINTF("%s: header '%s: %s'", __func__, pk.key, pk.value);
/*
* Identify and handle specific HTTP request methods
@@ -1505,8 +1502,8 @@ relay_read_http(struct bufferevent *bev, void *arg)
pkv.type = NODE_TYPE_PATH;
pkv.value = cre->args == NULL ? "" : cre->args;
- DPRINTF("relay_read_http: "
- "lookup path '%s: %s'", pkv.key, pkv.value);
+ DPRINTF("%s: lookup path '%s: %s'",
+ __func__, pkv.key, pkv.value);
if ((proot = RB_FIND(proto_tree,
cre->tree, &pkv)) == NULL)
@@ -1685,7 +1682,7 @@ _relay_lookup_url(struct ctl_relay_event *cre, char *host, char *path,
return (PN_FAIL);
}
- DPRINTF("_relay_lookup_url: %s", val);
+ DPRINTF("%s: %s", __func__, val);
switch (type) {
case DIGEST_SHA1:
@@ -1741,7 +1738,7 @@ relay_lookup_url(struct ctl_relay_event *cre, const char *str,
* developers_guide.html#PerformingLookups
*/
- DPRINTF("relay_lookup_url: host: '%s', path: '%s', query: '%s'",
+ DPRINTF("%s: host: '%s', path: '%s', query: '%s'", __func__,
str, cre->path, cre->args == NULL ? "" : cre->args);
if (canonicalize_host(str, ph, sizeof(ph)) == NULL) {
@@ -2203,7 +2200,7 @@ relay_from_table(struct rsession *con)
int idx = 0;
if (table->conf.check && !table->up && !rlay->rl_backuptable->up) {
- log_debug("relay_from_table: no active hosts");
+ log_debug("%s: no active hosts", __func__);
return (-1);
} else if (!table->up && rlay->rl_backuptable->up) {
table = rlay->rl_backuptable;
@@ -2226,16 +2223,16 @@ relay_from_table(struct rsession *con)
return (-1);
}
host = rlay->rl_dsthost[idx];
- DPRINTF("relay_from_table: host %s, p 0x%08x, idx %d",
+ DPRINTF("%s: host %s, p 0x%08x, idx %d", __func__,
host->conf.name, p, idx);
while (host != NULL) {
- DPRINTF("relay_from_table: host %s", host->conf.name);
+ DPRINTF("%s: host %s", __func__, host->conf.name);
if (!table->conf.check || host->up == HOST_UP)
goto found;
host = TAILQ_NEXT(host, entry);
}
TAILQ_FOREACH(host, &table->hosts, entry) {
- DPRINTF("relay_from_table: next host %s", host->conf.name);
+ DPRINTF("%s: next host %s", __func__, host->conf.name);
if (!table->conf.check || host->up == HOST_UP)
goto found;
}
@@ -2287,8 +2284,7 @@ relay_session(struct rsession *con)
if (bcmp(&rlay->rl_conf.ss, &out->ss, sizeof(out->ss)) == 0 &&
out->port == rlay->rl_conf.port) {
- log_debug("relay_session: session %d: looping",
- con->se_id);
+ log_debug("%s: session %d: looping", __func__, con->se_id);
relay_close(con, "session aborted");
return;
}
@@ -2377,7 +2373,7 @@ relay_connect(struct rsession *con)
if (rlay->rl_conf.fwdmode == FWD_TRANS) {
if (con->se_bnds == -1) {
- log_debug("relay_connect: could not bind any sock");
+ log_debug("%s: could not bind any sock", __func__);
return (-1);
}
bnds = con->se_bnds;
@@ -2394,7 +2390,7 @@ relay_connect(struct rsession *con)
else
ret = 0;
if (ret != 0) {
- log_debug("relay_connect: mapped to invalid address");
+ log_debug("%s: mapped to invalid address", __func__);
return (-1);
}
}
@@ -2404,13 +2400,13 @@ relay_connect(struct rsession *con)
con->se_out.port, rlay->rl_proto, bnds)) == -1) {
if (con->se_retry) {
con->se_retry--;
- log_debug("relay_connect: session %d: "
- "forward failed: %s, %s",
+ log_debug("%s: session %d: "
+ "forward failed: %s, %s", __func__,
con->se_id, strerror(errno),
con->se_retry ? "next retry" : "last retry");
goto retry;
}
- log_debug("relay_connect: session %d: forward failed: %s",
+ log_debug("%s: session %d: forward failed: %s", __func__,
con->se_id, strerror(errno));
return (-1);
}
@@ -2598,7 +2594,7 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
if (host->flags & F_DISABLE)
break;
if (host->up == st.up) {
- log_debug("relay_dispatch_pfe: host %d => %d",
+ log_debug("%s: host %d => %d", __func__,
host->conf.id, host->up);
fatalx("relay_dispatch_pfe: desynchronized");
}
@@ -2607,8 +2603,8 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
== NULL)
fatalx("relay_dispatch_pfe: invalid table id");
- DPRINTF("relay_dispatch_pfe: [%d] state %d for "
- "host %u %s", proc_id, st.up,
+ DPRINTF("%s: [%d] state %d for "
+ "host %u %s", __func__, proc_id, st.up,
host->conf.id, host->conf.name);
if ((st.up == HOST_UNKNOWN && host->up == HOST_DOWN) ||
@@ -2626,8 +2622,8 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
bcopy(imsg.data, &cnl, sizeof(cnl));
if ((con = session_find(env, cnl.id)) == NULL ||
con->se_cnl == NULL) {
- log_debug("relay_dispatch_pfe: "
- "session expired");
+ log_debug("%s: session %d: expired",
+ __func__, cnl.id);
break;
}
bcopy(&cnl, con->se_cnl, sizeof(*con->se_cnl));
@@ -2651,7 +2647,7 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
log_verbose(verbose);
break;
default:
- log_debug("relay_dispatch_msg: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -2700,8 +2696,8 @@ relay_dispatch_parent(int fd, short event, void * ptr)
case IMSG_BINDANY:
bcopy(imsg.data, &id, sizeof(id));
if ((con = session_find(env, id)) == NULL) {
- log_debug("relay_dispatch_parent: "
- "session expired");
+ log_debug("%s: session %d: expired",
+ __func__, id);
break;
}
@@ -2714,7 +2710,7 @@ relay_dispatch_parent(int fd, short event, void * ptr)
evtimer_add(&con->se_ev, &tv);
break;
default:
- log_debug("relay_dispatch_parent: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -2771,12 +2767,12 @@ relay_ssl_ctx_create(struct relay *rlay)
if ((rlay->rl_conf.flags & F_SSL) == 0)
return (ctx);
- log_debug("relay_ssl_ctx_create: loading certificate");
+ log_debug("%s: loading certificate", __func__);
if (!ssl_ctx_use_certificate_chain(ctx,
rlay->rl_ssl_cert, rlay->rl_ssl_cert_len))
goto err;
- log_debug("relay_ssl_ctx_create: loading private key");
+ log_debug("%s: loading private key", __func__);
if (!ssl_ctx_use_private_key(ctx, rlay->rl_ssl_key,
rlay->rl_ssl_key_len))
goto err;
@@ -2886,17 +2882,18 @@ relay_ssl_accept(int fd, short event, void *arg)
#ifdef DEBUG
- log_info("relay %s, session %d established (%d active)",
- rlay->rl_conf.name, con->se_id, relay_sessions);
+ log_info(
#else
- log_debug("relay %s, session %d established (%d active)",
- rlay->rl_conf.name, con->se_id, relay_sessions);
+ log_debug(
#endif
+ "relay %s, session %d established (%d active)",
+ rlay->rl_conf.name, con->se_id, relay_sessions);
+
relay_session(con);
return;
retry:
- DPRINTF("relay_ssl_accept: session %d: scheduling on %s", con->se_id,
+ DPRINTF("%s: session %d: scheduling on %s", __func__, con->se_id,
(retry_flag == EV_READ) ? "EV_READ" : "EV_WRITE");
event_again(&con->se_ev, fd, EV_TIMEOUT|retry_flag, relay_ssl_accept,
&con->se_tv_start, &env->sc_timeout, con);
@@ -2944,17 +2941,18 @@ relay_ssl_connect(int fd, short event, void *arg)
}
#ifdef DEBUG
- log_info("relay %s, session %d connected (%d active)",
- rlay->rl_conf.name, con->se_id, relay_sessions);
+ log_info(
#else
- log_debug("relay %s, session %d connected (%d active)",
- rlay->rl_conf.name, con->se_id, relay_sessions);
+ log_debug(
#endif
+ "relay %s, session %d connected (%d active)",
+ rlay->rl_conf.name, con->se_id, relay_sessions);
+
relay_connected(fd, EV_WRITE, con);
return;
retry:
- DPRINTF("relay_ssl_connect: session %d: scheduling on %s", con->se_id,
+ DPRINTF("%s: session %d: scheduling on %s", __func__, con->se_id,
(retry_flag == EV_READ) ? "EV_READ" : "EV_WRITE");
event_again(&con->se_ev, fd, EV_TIMEOUT|retry_flag, relay_ssl_connect,
&con->se_tv_start, &env->sc_timeout, con);
@@ -3000,12 +2998,12 @@ relay_ssl_readcb(int fd, short event, void *arg)
switch (ssl_err) {
case SSL_ERROR_WANT_READ:
- DPRINTF("relay_ssl_readcb: session %d: "
- "want read", con->se_id);
+ DPRINTF("%s: session %d: want read",
+ __func__, con->se_id);
goto retry;
case SSL_ERROR_WANT_WRITE:
- DPRINTF("relay_ssl_readcb: session %d: "
- "want write", con->se_id);
+ DPRINTF("%s: session %d: want write",
+ __func__, con->se_id);
goto retry;
default:
if (ret == 0)
@@ -3080,12 +3078,12 @@ relay_ssl_writecb(int fd, short event, void *arg)
switch (ssl_err) {
case SSL_ERROR_WANT_READ:
- DPRINTF("relay_ssl_writecb: session %d: "
- "want read", con->se_id);
+ DPRINTF("%s: session %d: want read",
+ __func__, con->se_id);
goto retry;
case SSL_ERROR_WANT_WRITE:
- DPRINTF("relay_ssl_writecb: session %d: "
- "want write", con->se_id);
+ DPRINTF("%s: session %d: want write",
+ __func__, con->se_id);
goto retry;
default:
if (ret == 0)
@@ -3274,7 +3272,7 @@ relay_load_certfiles(struct relay *rlay)
if ((rlay->rl_ssl_ca = relay_load_file(proto->sslca,
&rlay->rl_ssl_ca_len)) == NULL)
return (-1);
- log_debug("relay_load_certfiles: using ca %s", proto->sslca);
+ log_debug("%s: using ca %s", __func__, proto->sslca);
}
if ((rlay->rl_conf.flags & F_SSL) == 0)
@@ -3289,7 +3287,7 @@ relay_load_certfiles(struct relay *rlay)
if ((rlay->rl_ssl_cert = relay_load_file(certfile,
&rlay->rl_ssl_cert_len)) == NULL)
return (-1);
- log_debug("relay_load_certfiles: using certificate %s", certfile);
+ log_debug("%s: using certificate %s", __func__, certfile);
if (snprintf(certfile, sizeof(certfile),
"/etc/ssl/private/%s.key", hbuf) == -1)
@@ -3297,7 +3295,7 @@ relay_load_certfiles(struct relay *rlay)
if ((rlay->rl_ssl_key = relay_load_file(certfile,
&rlay->rl_ssl_key_len)) == NULL)
return (-1);
- log_debug("relay_load_certfiles: using private key %s", certfile);
+ log_debug("%s: using private key %s", __func__, certfile);
return (0);
}
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index 45af8476daf..7c83d795152 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.22 2010/05/26 13:56:08 nicm Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.23 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -384,13 +384,13 @@ relay_dns_log(struct rsession *con, u_int8_t *buf, size_t len)
/* Validate the header length */
if (len < sizeof(*hdr)) {
- log_debug("relay_dns_log: session %d: short dns packet",
+ log_debug("%s: session %d: short dns packet", __func__,
con->se_id);
return;
}
- log_debug("relay_dns_log: session %d: %s id 0x%x "
- "flags 0x%x:0x%x qd %u an %u ns %u ar %u",
+ log_debug("%s: session %d: %s id 0x%x "
+ "flags 0x%x:0x%x qd %u an %u ns %u ar %u", __func__,
con->se_id,
hdr->dns_flags0 & DNS_F0_QR ? "response" : "request",
ntohs(hdr->dns_id),
@@ -497,13 +497,13 @@ relay_dns_request(struct rsession *con)
(struct sockaddr *)&con->se_out.ss, slen) == -1) {
if (con->se_retry) {
con->se_retry--;
- log_debug("relay_dns_request: session %d: "
- "forward failed: %s, %s",
+ log_debug("%s: session %d: "
+ "forward failed: %s, %s", __func__,
con->se_id, strerror(errno),
con->se_retry ? "next retry" : "last retry");
goto retry;
}
- log_debug("relay_dns_request: session %d: forward failed: %s",
+ log_debug("%s: session %d: forward failed: %s", __func__,
con->se_id, strerror(errno));
return (-1);
}
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index 7193eea5350..8194db2ce53 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.100 2011/02/13 13:28:38 okan Exp $ */
+/* $OpenBSD: relayd.c,v 1.101 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -340,12 +340,12 @@ check_child(pid_t pid, const char *pname)
if (waitpid(pid, &status, WNOHANG) > 0) {
if (WIFEXITED(status)) {
- log_warnx("check_child: lost child: %s exited", pname);
+ log_warnx("%s: lost child: %s exited", __func__, pname);
return (1);
}
if (WIFSIGNALED(status)) {
- log_warnx("check_child: lost child: %s terminated; "
- "signal %d", pname, WTERMSIG(status));
+ log_warnx("%s: lost child: %s terminated; "
+ "signal %d", __func__, pname, WTERMSIG(status));
return (1);
}
}
@@ -676,7 +676,7 @@ main_dispatch_pfe(int fd, short event, void *ptr)
log_verbose(verbose);
break;
default:
- log_debug("main_dispatch_pfe: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -736,7 +736,7 @@ main_dispatch_hce(int fd, short event, void * ptr)
(void)snmp_sendsock(iev);
break;
default:
- log_debug("main_dispatch_hce: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -804,7 +804,7 @@ main_dispatch_relay(int fd, short event, void * ptr)
0, 0, s, &bnd.bnd_id, sizeof(bnd.bnd_id));
break;
default:
- log_debug("main_dispatch_relay: unexpected imsg %d",
+ log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
break;
}
@@ -999,7 +999,7 @@ expand_string(char *label, size_t len, const char *srch, const char *repl)
char *p, *q;
if ((tmp = calloc(1, len)) == NULL) {
- log_debug("expand_string: calloc");
+ log_debug("%s: calloc", __func__);
return (-1);
}
p = q = label;
@@ -1007,14 +1007,14 @@ expand_string(char *label, size_t len, const char *srch, const char *repl)
*q = '\0';
if ((strlcat(tmp, p, len) >= len) ||
(strlcat(tmp, repl, len) >= len)) {
- log_debug("expand_string: string too long");
+ log_debug("%s: string too long", __func__);
return (-1);
}
q += strlen(srch);
p = q;
}
if (strlcat(tmp, p, len) >= len) {
- log_debug("expand_string: string too long");
+ log_debug("%s: string too long", __func__);
return (-1);
}
(void)strlcpy(label, tmp, len); /* always fits */
@@ -1136,13 +1136,13 @@ protonode_header(enum direction dir, struct protocol *proto,
if (pn != NULL)
return (pn);
if ((pn = (struct protonode *)calloc(1, sizeof(*pn))) == NULL) {
- log_warn("out of memory");
+ log_warn("%s: calloc", __func__);
return (NULL);
}
pn->key = strdup(pk->key);
if (pn->key == NULL) {
free(pn);
- log_warn("out of memory");
+ log_warn("%s: strdup", __func__);
return (NULL);
}
pn->value = NULL;
@@ -1155,8 +1155,8 @@ protonode_header(enum direction dir, struct protocol *proto,
else
pn->id = proto->request_nodes++;
if (pn->id == INT_MAX) {
- log_warnx("too many protocol "
- "nodes defined");
+ log_warnx("%s: too many protocol "
+ "nodes defined", __func__);
return (NULL);
}
RB_INSERT(proto_tree, tree, pn);
@@ -1176,7 +1176,7 @@ protonode_add(enum direction dir, struct protocol *proto,
tree = &proto->request_tree;
if ((pn = calloc(1, sizeof (*pn))) == NULL) {
- log_warn("out of memory");
+ log_warn("%s: calloc", __func__);
return (-1);
}
bcopy(node, pn, sizeof(*pn));
@@ -1188,7 +1188,7 @@ protonode_add(enum direction dir, struct protocol *proto,
else
pn->id = proto->request_nodes++;
if (pn->id == INT_MAX) {
- log_warnx("too many protocol nodes defined");
+ log_warnx("%s: too many protocol nodes defined", __func__);
free(pn);
return (-1);
}
@@ -1367,7 +1367,7 @@ socket_rlimit(int maxfd)
if (getrlimit(RLIMIT_NOFILE, &rl) == -1)
fatal("socket_rlimit: failed to get resource limit");
- log_debug("socket_rlimit: max open files %d", rl.rlim_max);
+ log_debug("%s: max open files %d", __func__, rl.rlim_max);
/*
* Allow the maximum number of open file descriptors for this
diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c
index 43fa3c91f3b..e8a4ba42860 100644
--- a/usr.sbin/relayd/snmp.c
+++ b/usr.sbin/relayd/snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmp.c,v 1.8 2009/06/09 16:26:03 deraadt Exp $ */
+/* $OpenBSD: snmp.c,v 1.9 2011/05/05 12:01:44 reyk Exp $ */
/*
* Copyright (c) 2008 Reyk Floeter <reyk@openbsd.org>
@@ -141,7 +141,7 @@ snmp_getsock(struct imsgev *iev)
}
if (s != -1) {
- log_debug("snmp_getsock: got new snmp socket %d", s);
+ log_debug("%s: got new snmp socket %d", __func__, s);
if (iev_snmp == NULL && (iev_snmp = (struct imsgev *)
calloc(1, sizeof(struct imsgev))) == NULL)
fatal("snmp_getsock: calloc");
@@ -161,13 +161,13 @@ snmp_sock(int fd, short event, void *arg)
bzero(&tv, sizeof(tv));
goto retry;
case EV_READ:
- log_debug("snmp_sock: snmp socket closed %d", env->sc_snmp);
+ log_debug("%s: snmp socket closed %d", __func__, env->sc_snmp);
(void)close(env->sc_snmp);
break;
}
if ((env->sc_snmp = snmp_getsock(iev_main)) == -1) {
- DPRINTF("snmp_sock: failed to open snmp socket");
+ DPRINTF("%s: failed to open snmp socket", __func__);
goto retry;
}
@@ -189,7 +189,7 @@ snmp_element(const char *oid, enum snmp_type type, void *buf, int64_t val)
u_int64_t l;
struct snmp_imsg sm;
- DPRINTF("snmp_element: oid %s type %d buf %p val %lld",
+ DPRINTF("%s: oid %s type %d buf %p val %lld", __func__,
oid, type, buf, val);
bzero(&iov, sizeof(iov));