diff options
-rw-r--r-- | usr.sbin/relayd/agentx.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/ca.c | 31 | ||||
-rw-r--r-- | usr.sbin/relayd/check_icmp.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/check_script.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 10 | ||||
-rw-r--r-- | usr.sbin/relayd/hce.c | 18 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe.c | 28 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe_filter.c | 46 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe_route.c | 8 | ||||
-rw-r--r-- | usr.sbin/relayd/proc.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 40 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_http.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_udp.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 17 | ||||
-rw-r--r-- | usr.sbin/relayd/snmp.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/ssl.c | 6 |
16 files changed, 124 insertions, 130 deletions
diff --git a/usr.sbin/relayd/agentx.c b/usr.sbin/relayd/agentx.c index 467a787f170..d25ef15b637 100644 --- a/usr.sbin/relayd/agentx.c +++ b/usr.sbin/relayd/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.13 2015/12/07 04:03:27 mmcc Exp $ */ +/* $OpenBSD: agentx.c,v 1.14 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2013,2014 Bret Stephen Lambert <blambert@openbsd.org> * @@ -328,7 +328,7 @@ snmp_agentx_recv(struct agentx_handle *h) if (h->r == NULL) { if ((h->r = snmp_agentx_pdu_alloc()) == NULL) return (NULL); - h->r->datalen = 0; /* XXX -- force this for receive buffers */ + h->r->datalen = 0; /* XXX force this for receive buffers */ } pdu = h->r; diff --git a/usr.sbin/relayd/ca.c b/usr.sbin/relayd/ca.c index f5cc3be8957..94e80f5c6b2 100644 --- a/usr.sbin/relayd/ca.c +++ b/usr.sbin/relayd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.25 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: ca.c,v 1.26 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -123,7 +123,7 @@ ca_launch(void) NULL, NULL)) == NULL) fatalx("ca_launch: cert"); - if (X509_digest(cert, EVP_sha256(), d, &dlen) != 1) + if (X509_digest(cert, EVP_sha256(), d, &dlen) != 1) fatalx("ca_launch: cert"); hash_string(d, dlen, hash, sizeof(hash)); @@ -136,11 +136,11 @@ ca_launch(void) if (rlay->rl_conf.tls_key_len) { if ((in = BIO_new_mem_buf(rlay->rl_tls_key, rlay->rl_conf.tls_key_len)) == NULL) - fatalx("ca_launch: key"); + fatalx("%s: key", __func__); if ((pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL)) == NULL) - fatalx("ca_launch: PEM"); + fatalx("%s: PEM", __func__); BIO_free(in); rlay->rl_tls_pkey = pkey; @@ -161,7 +161,7 @@ ca_launch(void) NULL, NULL)) == NULL) fatalx("ca_launch: cacert"); - if (X509_digest(cert, EVP_sha256(), d, &dlen) != 1) + if (X509_digest(cert, EVP_sha256(), d, &dlen) != 1) fatalx("ca_launch: cacert"); hash_string(d, dlen, hash, sizeof(hash)); @@ -174,11 +174,11 @@ ca_launch(void) if (rlay->rl_conf.tls_cakey_len) { if ((in = BIO_new_mem_buf(rlay->rl_tls_cakey, rlay->rl_conf.tls_cakey_len)) == NULL) - fatalx("ca_launch: key"); + fatalx("%s: key", __func__); if ((pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL)) == NULL) - fatalx("ca_launch: PEM"); + fatalx("%s: PEM", __func__); BIO_free(in); rlay->rl_tls_capkey = pkey; @@ -231,22 +231,19 @@ ca_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, (&cko)); bcopy(imsg->data, &cko, sizeof(cko)); if (cko.cko_proc > env->sc_conf.prefork_relay) - fatalx("ca_dispatch_relay: " - "invalid relay proc"); + fatalx("%s: invalid relay proc", __func__); if (IMSG_DATA_SIZE(imsg) != (sizeof(cko) + cko.cko_flen)) - fatalx("ca_dispatch_relay: " - "invalid key operation"); + fatalx("%s: invalid key operation", __func__); if ((pkey = pkey_find(env, cko.cko_hash)) == NULL || (rsa = EVP_PKEY_get1_RSA(pkey)) == NULL) - fatalx("ca_dispatch_relay: " - "invalid relay key or id"); + fatalx("%s: invalid relay key or id", __func__); DPRINTF("%s:%d: key hash %s proc %d", __func__, __LINE__, cko.cko_hash, cko.cko_proc); from = (u_char *)imsg->data + sizeof(cko); if ((to = calloc(1, cko.cko_tlen)) == NULL) - fatalx("ca_dispatch_relay: calloc"); + fatalx("%s: calloc", __func__); switch (imsg->hdr.type) { case IMSG_CA_PRIVENC: @@ -345,16 +342,16 @@ rsae_send_imsg(int flen, const u_char *from, u_char *to, RSA *rsa, */ imsg_composev(ibuf, cmd, 0, 0, -1, iov, cnt); if (imsg_flush(ibuf) == -1) - log_warn("rsae_send_imsg: imsg_flush"); + log_warn("%s: imsg_flush", __func__); pfd[0].fd = ibuf->fd; pfd[0].events = POLLIN; while (!done) { switch (poll(pfd, 1, RELAY_TLS_PRIV_TIMEOUT)) { case -1: - fatal("rsae_send_imsg: poll"); + fatal("%s: poll", __func__); case 0: - log_warnx("rsae_send_imsg: poll timeout"); + log_warnx("%s: poll timeout", __func__); break; default: break; diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c index 3ba5179856d..30c690f42b0 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.44 2016/09/02 14:45:51 reyk Exp $ */ +/* $OpenBSD: check_icmp.c,v 1.45 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -53,10 +53,10 @@ icmp_setup(struct relayd *env, struct ctl_icmp_event *cie, int af) if (af == AF_INET6) proto = IPPROTO_ICMPV6; if ((cie->s = socket(af, SOCK_RAW | SOCK_NONBLOCK, proto)) < 0) - fatal("icmp_setup: socket"); + fatal("%s: socket", __func__); val = ICMP_RCVBUF_SIZE; if (setsockopt(cie->s, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) == -1) - fatal("icmp_setup: setsockopt"); + fatal("%s: setsockopt", __func__); cie->env = env; cie->af = af; } diff --git a/usr.sbin/relayd/check_script.c b/usr.sbin/relayd/check_script.c index 9bb494c7275..cf51a835c8f 100644 --- a/usr.sbin/relayd/check_script.c +++ b/usr.sbin/relayd/check_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_script.c,v 1.20 2016/09/02 14:45:51 reyk Exp $ */ +/* $OpenBSD: check_script.c,v 1.21 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -39,7 +39,7 @@ check_script(struct relayd *env, struct host *host) struct table *table; if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("check_script: invalid table id"); + fatalx("%s: invalid table id", __func__); host->last_up = host->up; host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE); @@ -61,7 +61,7 @@ script_done(struct relayd *env, struct ctl_script *scr) struct host *host; if ((host = host_find(env, scr->host)) == NULL) - fatalx("hce_dispatch_parent: invalid host id"); + fatalx("%s: invalid host id", __func__); if (scr->retval < 0) host->up = HOST_UNKNOWN; @@ -121,13 +121,13 @@ script_exec(struct relayd *env, struct ctl_script *scr) signal(SIGCHLD, SIG_DFL); if ((pw = getpwnam(RELAYD_USER)) == NULL) - fatal("script_exec: getpwnam"); + fatal("%s: getpwnam", __func__); if (chdir("/") == -1) - fatal("script_exec: chdir(\"/\")"); + fatal("%s: chdir(\"/\")", __func__); if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) - fatal("script_exec: can't drop privileges"); + fatal("%s: can't drop privileges", __func__); /* * close fds before executing an external program, to diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index cf3a97c3f23..ea0d7fdb4a1 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.53 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.54 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -123,7 +123,7 @@ tcp_write(int s, short event, void *arg) len = sizeof(err); if (getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len)) - fatal("tcp_write: getsockopt"); + fatal("%s: getsockopt", __func__); if (err != 0) { tcp_close(cte, HOST_DOWN); hce_notify_done(cte->host, HCE_TCP_CONNECT_FAIL); @@ -182,7 +182,7 @@ tcp_host_up(struct ctl_tcp_event *cte) } if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) - fatalx("tcp_host_up: cannot create dynamic buffer"); + fatalx("%s: cannot create dynamic buffer", __func__); event_again(&cte->ev, cte->s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->conf.timeout, cte); } @@ -215,7 +215,7 @@ tcp_send_req(int s, short event, void *arg) } while (len > 0); if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) - fatalx("tcp_send_req: cannot create dynamic buffer"); + fatalx("%s: cannot create dynamic buffer", __func__); event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->conf.timeout, cte); return; @@ -259,7 +259,7 @@ tcp_read_buf(int s, short event, void *arg) return; default: if (ibuf_add(cte->buf, rbuf, br) == -1) - fatal("tcp_read_buf: buf_add error"); + fatal("%s: buf_add error", __func__); if (cte->validate_read != NULL) { if (cte->validate_read(cte) != 0) goto retry; diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index 6162c2008eb..5c5ee6f3013 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.76 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: hce.c,v 1.77 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -71,7 +71,7 @@ hce_init(struct privsep *ps, struct privsep_proc *p, void *arg) socket_rlimit(-1); if (pledge("stdio recvfd inet", NULL) == -1) - fatal("hce: pledge"); + fatal("%s: pledge", __func__); } void @@ -161,7 +161,7 @@ hce_launch_checks(int fd, short event, void *arg) continue; } if (table->conf.check == CHECK_NOCHECK) - fatalx("hce_launch_checks: unknown check type"); + fatalx("%s: unknown check type", __func__); TAILQ_FOREACH(host, &table->hosts, entry) { if (host->flags & F_DISABLE || host->conf.parentid) @@ -205,10 +205,10 @@ hce_notify_done(struct host *host, enum host_error he) char *codemsg = NULL; if ((hostnst = host_find(env, host->conf.id)) == NULL) - fatalx("hce_notify_done: desynchronized"); + fatalx("%s: desynchronized", __func__); if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("hce_notify_done: invalid table id"); + fatalx("%s: invalid table id", __func__); if (hostnst->flags & F_DISABLE) { if (env->sc_conf.opts & RELAYD_OPT_LOGUPDATE) { @@ -295,7 +295,7 @@ hce_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_HOST_DISABLE: memcpy(&id, imsg->data, sizeof(id)); if ((host = host_find(env, id)) == NULL) - fatalx("hce_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); host->flags |= F_DISABLE; host->up = HOST_UNKNOWN; host->check_cnt = 0; @@ -305,7 +305,7 @@ hce_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_HOST_ENABLE: memcpy(&id, imsg->data, sizeof(id)); if ((host = host_find(env, id)) == NULL) - fatalx("hce_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); host->flags &= ~(F_DISABLE); host->up = HOST_UNKNOWN; host->he = HCE_NONE; @@ -313,7 +313,7 @@ hce_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_TABLE_DISABLE: memcpy(&id, imsg->data, sizeof(id)); if ((table = table_find(env, id)) == NULL) - fatalx("hce_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); table->conf.flags |= F_DISABLE; TAILQ_FOREACH(host, &table->hosts, entry) host->up = HOST_UNKNOWN; @@ -321,7 +321,7 @@ hce_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_TABLE_ENABLE: memcpy(&id, imsg->data, sizeof(id)); if ((table = table_find(env, id)) == NULL) - fatalx("hce_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); table->conf.flags &= ~(F_DISABLE); TAILQ_FOREACH(host, &table->hosts, entry) host->up = HOST_UNKNOWN; diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index df80dd97d4e..38999e70cd0 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.88 2017/01/24 10:49:14 benno Exp $ */ +/* $OpenBSD: pfe.c,v 1.89 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -56,7 +56,7 @@ static struct privsep_proc procs[] = { void pfe(struct privsep *ps, struct privsep_proc *p) { - int s; + int s; struct pf_status status; env = ps->ps_env; @@ -70,9 +70,9 @@ pfe(struct privsep *ps, struct privsep_proc *p) env->sc_pf->dev = s; } if (ioctl(env->sc_pf->dev, DIOCGETSTATUS, &status) == -1) - fatal("init_filter: DIOCGETSTATUS"); + fatal("%s: DIOCGETSTATUS", __func__); if (!status.running) - fatalx("init_filter: pf is disabled"); + fatalx("%s: pf is disabled", __func__); log_debug("%s: filter init done", __func__); proc_run(ps, p, procs, nitems(procs), pfe_init, NULL); @@ -130,7 +130,7 @@ pfe_dispatch_hce(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, &st); memcpy(&st, imsg->data, sizeof(st)); if ((host = host_find(env, st.id)) == NULL) - fatalx("pfe_dispatch_hce: invalid host id"); + fatalx("%s: invalid host id", __func__); host->he = st.he; if (host->flags & F_DISABLE) break; @@ -143,7 +143,7 @@ pfe_dispatch_hce(int fd, struct privsep_proc *p, struct imsg *imsg) if (host->check_cnt != st.check_cnt) { log_debug("%s: host %d => %d", __func__, host->conf.id, host->up); - fatalx("pfe_dispatch_hce: desynchronized"); + fatalx("%s: desynchronized", __func__); } if (host->up == st.up) @@ -155,7 +155,7 @@ pfe_dispatch_hce(int fd, struct privsep_proc *p, struct imsg *imsg) if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("pfe_dispatch_hce: invalid table id"); + fatalx("%s: invalid table id", __func__); log_debug("%s: state %d for host %u %s", __func__, st.up, host->conf.id, host->conf.name); @@ -261,8 +261,7 @@ pfe_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, &cnl); bcopy(imsg->data, &cnl, sizeof(cnl)); if (cnl.proc > env->sc_conf.prefork_relay) - fatalx("pfe_dispatch_relay: " - "invalid relay proc"); + fatalx("%s: invalid relay proc", __func__); if (natlook(env, &cnl) != 0) cnl.in = -1; proc_compose_imsg(env->sc_ps, PROC_RELAY, cnl.proc, @@ -272,10 +271,9 @@ pfe_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, &crs); bcopy(imsg->data, &crs, sizeof(crs)); if (crs.proc > env->sc_conf.prefork_relay) - fatalx("pfe_dispatch_relay: " - "invalid relay proc"); + fatalx("%s: invalid relay proc", __func__); if ((rlay = relay_find(env, crs.id)) == NULL) - fatalx("pfe_dispatch_relay: invalid relay id"); + fatalx("%s: invalid relay id", __func__); bcopy(&crs, &rlay->rl_stats[crs.proc], sizeof(crs)); rlay->rl_stats[crs.proc].interval = env->sc_conf.statinterval.tv_sec; @@ -523,7 +521,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id) return (-1); id->id = table->conf.id; if (table->conf.rdrid > 0 && rdr_find(env, table->conf.rdrid) == NULL) - fatalx("disable_table: desynchronised"); + fatalx("%s: desynchronised", __func__); if (table->conf.flags & F_DISABLE) return (0); @@ -558,7 +556,7 @@ enable_table(struct ctl_conn *c, struct ctl_id *id) id->id = table->conf.id; if (table->conf.rdrid > 0 && rdr_find(env, table->conf.rdrid) == NULL) - fatalx("enable_table: desynchronised"); + fatalx("%s: desynchronised", __func__); if (!(table->conf.flags & F_DISABLE)) return (0); @@ -600,7 +598,7 @@ disable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host) if (host->up == HOST_UP) { if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("disable_host: invalid table id"); + fatalx("%s: invalid table id", __func__); table->up--; table->conf.flags |= F_CHANGED; } diff --git a/usr.sbin/relayd/pfe_filter.c b/usr.sbin/relayd/pfe_filter.c index 2dd2ddbfd36..347048ece56 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.61 2017/01/24 10:49:14 benno Exp $ */ +/* $OpenBSD: pfe_filter.c,v 1.62 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -74,7 +74,7 @@ init_tables(struct relayd *env) i++; } if (i != env->sc_rdrcount) - fatalx("init_tables: table count modified"); + fatalx("%s: table count modified", __func__); memset(&io, 0, sizeof(io)); io.pfrio_size = env->sc_rdrcount; @@ -82,7 +82,7 @@ init_tables(struct relayd *env) io.pfrio_buffer = tables; if (ioctl(env->sc_pf->dev, DIOCRADDTABLES, &io) == -1) - fatal("init_tables: cannot create tables"); + fatal("%s: cannot create tables", __func__); log_debug("%s: created %d tables", __func__, io.pfrio_nadd); free(tables); @@ -99,7 +99,7 @@ init_tables(struct relayd *env) return; toolong: - fatal("init_tables: name too long"); + fatal("%s: name too long", __func__); } void @@ -121,14 +121,14 @@ kill_tables(struct relayd *env) sizeof(io.pfrio_table.pfrt_anchor)) >= PF_ANCHOR_NAME_SIZE) goto toolong; if (ioctl(env->sc_pf->dev, DIOCRCLRTABLES, &io) == -1) - fatal("kill_tables: ioctl failed"); + fatal("%s: ioctl failed", __func__); cnt += io.pfrio_ndel; } log_debug("%s: deleted %d tables", __func__, cnt); return; toolong: - fatal("kill_tables: name too long"); + fatal("%s: name too long", __func__); } void @@ -192,16 +192,16 @@ sync_table(struct relayd *env, struct rdr *rdr, struct table *table) addlist[i].pfra_net = 128; break; default: - fatalx("sync_table: unknown address family"); + fatalx("%s: unknown address family", __func__); break; } i++; } if (i != table->up) - fatalx("sync_table: desynchronized"); + fatalx("%s: desynchronized", __func__); if (ioctl(env->sc_pf->dev, DIOCRSETADDRS, &io) == -1) - fatal("sync_table: cannot set address list"); + fatal("%s: cannot set address list", __func__); if (rdr->conf.flags & F_STICKY) cnt = kill_srcnodes(env, table); free(addlist); @@ -213,7 +213,7 @@ sync_table(struct relayd *env, struct rdr *rdr, struct table *table) return; toolong: - fatal("sync_table: name too long"); + fatal("%s: name too long", __func__); } int @@ -249,7 +249,7 @@ kill_srcnodes(struct relayd *env, struct table *table) sizeof(psnk.psnk_dst.addr.v.a.addr.v6)); break; default: - fatalx("kill_srcnodes: unknown address family"); + fatalx("%s: unknown address family", __func__); break; } @@ -258,7 +258,7 @@ kill_srcnodes(struct relayd *env, struct table *table) if (ioctl(env->sc_pf->dev, DIOCKILLSRCNODES, &psnk) == -1) - fatal("kill_srcnodes: cannot kill src nodes"); + fatal("%s: cannot kill src nodes", __func__); cnt += psnk.psnk_killed; } @@ -285,19 +285,19 @@ flush_table(struct relayd *env, struct rdr *rdr) sizeof(io.pfrio_table.pfrt_name)) goto toolong; if (ioctl(env->sc_pf->dev, DIOCRCLRADDRS, &io) == -1) - fatal("flush_table: cannot flush table addresses"); + fatal("%s: cannot flush table addresses", __func__); io.pfrio_esize = sizeof(io.pfrio_table); io.pfrio_size = 1; io.pfrio_buffer = &io.pfrio_table; if (ioctl(env->sc_pf->dev, DIOCRCLRTSTATS, &io) == -1) - fatal("flush_table: cannot flush table stats"); + fatal("%s: cannot flush table stats", __func__); log_debug("%s: flushed table %s", __func__, rdr->conf.name); return; toolong: - fatal("flush_table: name too long"); + fatal("%s: name too long", __func__); } int @@ -393,7 +393,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable) rio.rule.rule_flag = PFRULE_STATESLOPPY; break; default: - fatalx("sync_ruleset: invalid forward mode"); + fatalx("%s: invalid forward mode", __func__); /* NOTREACHED */ } @@ -445,7 +445,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable) if (strlcpy(rio.rule.rdr.addr.v.tblname, rdr->conf.name, sizeof(rio.rule.rdr.addr.v.tblname)) >= sizeof(rio.rule.rdr.addr.v.tblname)) - fatal("sync_ruleset: table name too long"); + fatal("%s: table name too long", __func__); if (address->port.op == PF_OP_EQ || rdr->table->conf.flags & F_PORT) { @@ -468,7 +468,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable) rio.rule.rdr.opts = PF_POOL_LEASTSTATES; break; default: - fatalx("sync_ruleset: unsupported mode"); + fatalx("%s: unsupported mode", __func__); /* NOTREACHED */ } if (rdr->conf.flags & F_STICKY) @@ -492,7 +492,7 @@ sync_ruleset(struct relayd *env, struct rdr *rdr, int enable) return; toolong: - fatal("sync_ruleset: name too long"); + fatal("%s: name too long", __func__); } void @@ -528,7 +528,7 @@ flush_rulesets(struct relayd *env) return; toolong: - fatal("flush_rulesets: name too long"); + fatal("%s: name too long", __func__); } int @@ -545,7 +545,7 @@ natlook(struct relayd *env, struct ctl_natlook *cnl) bzero(&pnl, sizeof(pnl)); if ((pnl.af = cnl->src.ss_family) != cnl->dst.ss_family) - fatalx("natlook: illegal address families"); + fatalx("%s: illegal address families", __func__); switch (pnl.af) { case AF_INET: in = (struct sockaddr_in *)&cnl->src; @@ -632,11 +632,11 @@ check_table(struct relayd *env, struct rdr *rdr, struct table *table) goto toolong; if (ioctl(env->sc_pf->dev, DIOCRGETTSTATS, &io) == -1) - fatal("check_table: cannot get table stats"); + fatal("%s: cannot get table stats", __func__); return (tstats.pfrts_match); toolong: - fatal("check_table: name too long"); + fatal("%s: name too long", __func__); return (0); } diff --git a/usr.sbin/relayd/pfe_route.c b/usr.sbin/relayd/pfe_route.c index f7382ef514c..b968a340ec4 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.11 2016/09/02 14:45:51 reyk Exp $ */ +/* $OpenBSD: pfe_route.c,v 1.12 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2009 - 2011 Reyk Floeter <reyk@openbsd.org> @@ -59,12 +59,12 @@ init_routes(struct relayd *env) return; if ((env->sc_rtsock = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) - fatal("init_routes: failed to open routing socket"); + fatal("%s: failed to open routing socket", __func__); rtfilter = ROUTE_FILTER(0); if (setsockopt(env->sc_rtsock, AF_ROUTE, ROUTE_MSGFILTER, &rtfilter, sizeof(rtfilter)) == -1) - fatal("init_routes: ROUTE_MSGFILTER"); + fatal("%s: ROUTE_MSGFILTER", __func__); } void @@ -196,7 +196,7 @@ pfe_route(struct relayd *env, struct ctl_netroute *crt) } else if (crt->nr.prefixlen < 0) rm.rm_hdr.rtm_flags |= RTF_HOST; } else - fatal("pfe_route: invalid address family"); + fatal("%s: invalid address family", __func__); retry: if (write(env->sc_rtsock, &rm, len) == -1) { diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 3f135d3e360..4577476b8af 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.38 2017/01/09 14:49:21 reyk Exp $ */ +/* $OpenBSD: proc.c,v 1.39 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -208,7 +208,7 @@ proc_init(struct privsep *ps, struct privsep_proc *procs, unsigned int nproc, proc_setup(ps, procs, nproc); /* - * Create the children sockets so we can use them + * Create the children sockets so we can use them * to distribute the rest of the socketpair()s using * proc_connect() later. */ @@ -505,7 +505,7 @@ proc_sig_handler(int sig, short event, void *arg) /* ignore */ break; default: - fatalx("proc_sig_handler: unexpected signal"); + fatalx("%s: unexpected signal", __func__); /* NOTREACHED */ } } @@ -545,9 +545,9 @@ proc_run(struct privsep *ps, struct privsep_proc *p, root = pw->pw_dir; if (chroot(root) == -1) - fatal("proc_run: chroot"); + fatal("%s: chroot", __func__); if (chdir("/") == -1) - fatal("proc_run: chdir(\"/\")"); + fatal("%s: chdir(\"/\")", __func__); privsep_process = p->p_id; @@ -556,7 +556,7 @@ proc_run(struct privsep *ps, struct privsep_proc *p, if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) - fatal("proc_run: cannot drop privileges"); + fatal("%s: cannot drop privileges", __func__); event_init(); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 4b36e4a8a31..c6ff55446ad 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.220 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: relay.c,v 1.221 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -419,7 +419,7 @@ relay_launch(void) TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) { if ((rlay->rl_conf.flags & (F_TLS|F_TLSCLIENT)) && relay_tls_ctx_create(rlay) == -1) - fatalx("relay_launch: failed to create TLS context"); + fatalx("%s: failed to create TLS context", __func__); TAILQ_FOREACH(rlt, &rlay->rl_tables, rlt_entry) { /* @@ -433,8 +433,8 @@ relay_launch(void) rlt->rlt_nhosts = 0; TAILQ_FOREACH(host, &rlt->rlt_table->hosts, entry) { if (rlt->rlt_nhosts >= RELAY_MAXHOSTS) - fatal("relay_init: " - "too many hosts in table"); + fatal("%s: too many hosts in table", + __func__); host->idx = rlt->rlt_nhosts; rlt->rlt_host[rlt->rlt_nhosts++] = host; } @@ -700,7 +700,7 @@ relay_connected(int fd, short sig, void *arg) /* Use defaults */ break; default: - fatalx("relay_connected: unknown protocol"); + fatalx("%s: unknown protocol", __func__); } /* @@ -715,7 +715,7 @@ relay_connected(int fd, short sig, void *arg) evbuffer_free(bev->output); bev->output = con->se_out.output; if (bev->output == NULL) - fatal("relay_connected: invalid output buffer"); + fatal("%s: invalid output buffer", __func__); con->se_out.bev = bev; /* Initialize the TLS wrapper */ @@ -756,7 +756,7 @@ relay_input(struct rsession *con) /* Use defaults */ break; default: - fatalx("relay_input: unknown protocol"); + fatalx("%s: unknown protocol", __func__); } /* @@ -1280,7 +1280,7 @@ relay_from_table(struct rsession *con) rlay->rl_conf.port); break; default: - fatalx("relay_from_table: unsupported mode"); + fatalx("%s: unsupported mode", __func__); /* NOTREACHED */ } if (idx == -1) { @@ -1331,7 +1331,7 @@ relay_from_table(struct rsession *con) } /* Should not happen */ - fatalx("relay_from_table: no active hosts, desynchronized"); + fatalx("%s: no active hosts, desynchronized", __func__); found: if (rlt->rlt_mode == RELAY_DSTMODE_ROUNDROBIN) @@ -1455,7 +1455,7 @@ relay_connect_retry(int fd, short sig, void *arg) int bnds = -1; if (relay_inflight < 1) { - log_warnx("relay_connect_retry: no connection in flight"); + log_warnx("%s: no connection in flight", __func__); relay_inflight = 1; } @@ -1463,7 +1463,7 @@ relay_connect_retry(int fd, short sig, void *arg) con->se_retrycount, con->se_retry, relay_inflight); if (sig != EV_TIMEOUT) - fatalx("relay_connect_retry: called without timeout"); + fatalx("%s: called without timeout", __func__); evtimer_del(&con->se_inflightevt); @@ -1768,10 +1768,10 @@ relay_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_HOST_DISABLE: memcpy(&id, imsg->data, sizeof(id)); if ((host = host_find(env, id)) == NULL) - fatalx("relay_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("relay_dispatch_pfe: invalid table id"); + fatalx("%s: invalid table id", __func__); if (host->up == HOST_UP) table->up--; host->flags |= F_DISABLE; @@ -1780,14 +1780,14 @@ relay_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_HOST_ENABLE: memcpy(&id, imsg->data, sizeof(id)); if ((host = host_find(env, id)) == NULL) - fatalx("relay_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); host->flags &= ~(F_DISABLE); host->up = HOST_UNKNOWN; break; case IMSG_TABLE_DISABLE: memcpy(&id, imsg->data, sizeof(id)); if ((table = table_find(env, id)) == NULL) - fatalx("relay_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); table->conf.flags |= F_DISABLE; table->up = 0; TAILQ_FOREACH(host, &table->hosts, entry) @@ -1796,7 +1796,7 @@ relay_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_TABLE_ENABLE: memcpy(&id, imsg->data, sizeof(id)); if ((table = table_find(env, id)) == NULL) - fatalx("relay_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); table->conf.flags &= ~(F_DISABLE); table->up = 0; TAILQ_FOREACH(host, &table->hosts, entry) @@ -1806,18 +1806,18 @@ relay_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, &st); memcpy(&st, imsg->data, sizeof(st)); if ((host = host_find(env, st.id)) == NULL) - fatalx("relay_dispatch_pfe: invalid host id"); + fatalx("%s: invalid host id", __func__); if (host->flags & F_DISABLE) break; if (host->up == st.up) { log_debug("%s: host %d => %d", __func__, host->conf.id, host->up); - fatalx("relay_dispatch_pfe: desynchronized"); + fatalx("%s: desynchronized", __func__); } if ((table = table_find(env, host->conf.tableid)) == NULL) - fatalx("relay_dispatch_pfe: invalid table id"); + fatalx("%s: invalid table id", __func__); DPRINTF("%s: [%d] state %d for " "host %u %s", __func__, p->p_ps->ps_instance, st.up, @@ -2023,7 +2023,7 @@ relay_tls_ctx_create_proto(struct protocol *proto, struct tls_config *tls_cfg) /* * This function is not publicy exported because it is a hack until libtls - * has a proper privsep setup + * has a proper privsep setup */ void tls_config_skip_private_key_check(struct tls_config *config); diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index 7141fcf4bcc..90ad49d63c7 100644 --- a/usr.sbin/relayd/relay_http.c +++ b/usr.sbin/relayd/relay_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_http.c,v 1.65 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: relay_http.c,v 1.66 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -1592,7 +1592,7 @@ relay_apply_actions(struct ctl_relay_event *cre, struct kvlist *actions) /* perform this later */ break; default: - fatalx("relay_action: invalid action"); + fatalx("%s: invalid action", __func__); /* NOTREACHED */ } diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c index 2589e51de79..1410baf7f0f 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.45 2017/01/09 14:49:21 reyk Exp $ */ +/* $OpenBSD: relay_udp.c,v 1.46 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org> @@ -519,7 +519,7 @@ relay_dns_result(struct rsession *con, u_int8_t *buf, size_t len) socklen_t slen; if (priv == NULL) - fatalx("relay_dns_result: response to invalid session"); + fatalx("%s: response to invalid session", __func__); if (log_getverbose() > 1) relay_dns_log(con, buf, len); @@ -547,7 +547,7 @@ relay_dns_cmp(struct rsession *a, struct rsession *b) struct relay_dns_priv *bp = b->se_priv; if (ap == NULL || bp == NULL) - fatalx("relay_dns_cmp: invalid session"); + fatalx("%s: invalid session", __func__); return (memcmp(&ap->dp_inkey, &bp->dp_inkey, sizeof(u_int16_t))); } diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index e3b443eb42d..a6472af10b7 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.167 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: relayd.c,v 1.168 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2007 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -475,15 +475,14 @@ parent_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg) IMSG_SIZE_CHECK(imsg, &bnd); bcopy(imsg->data, &bnd, sizeof(bnd)); if (bnd.bnd_proc > env->sc_conf.prefork_relay) - fatalx("pfe_dispatch_relay: " - "invalid relay proc"); + fatalx("%s: invalid relay proc", __func__); switch (bnd.bnd_proto) { case IPPROTO_TCP: case IPPROTO_UDP: break; default: - fatalx("pfe_dispatch_relay: requested socket " - "for invalid protocol"); + fatalx("%s: requested socket " + "for invalid protocol", __func__); /* NOTREACHED */ } s = bindany(&bnd); @@ -1188,7 +1187,7 @@ pkey_add(struct relayd *env, EVP_PKEY *pkey, char *hash) if (strlcpy(ca_pkey->pkey_hash, hash, sizeof(ca_pkey->pkey_hash)) >= sizeof(ca_pkey->pkey_hash)) return (NULL); - + TAILQ_INSERT_TAIL(env->sc_pkeys, ca_pkey, pkey_entry); return (ca_pkey); @@ -1477,7 +1476,7 @@ socket_rlimit(int maxfd) struct rlimit rl; if (getrlimit(RLIMIT_NOFILE, &rl) == -1) - fatal("socket_rlimit: failed to get resource limit"); + fatal("%s: failed to get resource limit", __func__); log_debug("%s: max open files %llu", __func__, rl.rlim_max); /* @@ -1489,7 +1488,7 @@ socket_rlimit(int maxfd) else rl.rlim_cur = MAXIMUM(rl.rlim_max, (rlim_t)maxfd); if (setrlimit(RLIMIT_NOFILE, &rl) == -1) - fatal("socket_rlimit: failed to set resource limit"); + fatal("%s: failed to set resource limit", __func__); } char * @@ -1639,7 +1638,7 @@ parent_tls_ticket_rekey(int fd, short events, void *arg) struct timeval tv; struct relay_ticket_key key; - log_debug("relayd_tls_ticket_rekey: rekeying tickets"); + log_debug("%s: rekeying tickets", __func__); key.tt_keyrev = arc4random(); arc4random_buf(key.tt_key, sizeof(key.tt_key)); diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c index 719f470a002..54618ca1a41 100644 --- a/usr.sbin/relayd/snmp.c +++ b/usr.sbin/relayd/snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmp.c,v 1.28 2016/09/02 16:14:09 reyk Exp $ */ +/* $OpenBSD: snmp.c,v 1.29 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2008 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -172,9 +172,9 @@ snmp_getsock(struct relayd *env, struct imsg *imsg) log_debug("%s: got new snmp socket %d", __func__, imsg->fd); if ((snmp_agentx = snmp_agentx_alloc(env->sc_snmp)) == NULL) - fatal("snmp_getsock: agentx alloc"); + fatal("%s: agentx alloc", __func__); if ((pdu = snmp_agentx_open_pdu(snmp_agentx, "relayd", NULL)) == NULL) - fatal("snmp_getsock: agentx pdu"); + fatal("%s: agentx pdu", __func__); (void)snmp_agentx_send(snmp_agentx, pdu); snmp_event_add(env, EV_WRITE); diff --git a/usr.sbin/relayd/ssl.c b/usr.sbin/relayd/ssl.c index 1ff423f5866..cf576fbb359 100644 --- a/usr.sbin/relayd/ssl.c +++ b/usr.sbin/relayd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.32 2017/05/27 08:33:25 claudio Exp $ */ +/* $OpenBSD: ssl.c,v 1.33 2017/05/28 10:39:15 benno Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -127,7 +127,7 @@ ssl_update_certificate(const uint8_t *oldcert, size_t oldlen, EVP_PKEY *pkey, uint8_t *newcert = NULL, *foo = NULL; /* XXX BIO_new_mem_buf is not using const so work around this */ - if ((foo = malloc(oldlen)) == NULL) { + if ((foo = malloc(oldlen)) == NULL) { log_warn("%s: malloc", __func__); return (NULL); } @@ -322,6 +322,6 @@ fail: EVP_PKEY_free(pkey); if (x509 != NULL) X509_free(x509); - + return (ret); } |