thanks for both this and your httpd diff, both commited.
Hiltjo Posthuma([email protected]) on 2017.05.07 20:56:25 +0200:
> Hey,
>
> This replaces the prefix in log messages to __func__. Some older code had
> the prefix still set to another name. Patch below:
>
>
> diff --git a/usr.sbin/relayd/ca.c b/usr.sbin/relayd/ca.c
> index 45bd5f3224b..de002488d9c 100644
> --- a/usr.sbin/relayd/ca.c
> +++ b/usr.sbin/relayd/ca.c
> @@ -96,11 +96,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;
> @@ -119,11 +119,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;
> @@ -181,21 +181,18 @@ 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_id)) == 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 id %d", __func__, __LINE__, cko.cko_id);
>
> 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:
> @@ -294,16 +291,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..cc98d258280 100644
> --- a/usr.sbin/relayd/check_icmp.c
> +++ b/usr.sbin/relayd/check_icmp.c
> @@ -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..a97c91e10b2 100644
> --- a/usr.sbin/relayd/check_script.c
> +++ b/usr.sbin/relayd/check_script.c
> @@ -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 bbf3258f70c..36f614c1a06 100644
> --- a/usr.sbin/relayd/check_tcp.c
> +++ b/usr.sbin/relayd/check_tcp.c
> @@ -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 33cc9ee2a45..7b2d3b78aaa 100644
> --- a/usr.sbin/relayd/hce.c
> +++ b/usr.sbin/relayd/hce.c
> @@ -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
> @@ -159,7 +159,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)
> @@ -203,10 +203,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) {
> @@ -293,7 +293,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;
> @@ -303,7 +303,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;
> @@ -311,7 +311,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;
> @@ -319,7 +319,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..d8baa5faa33 100644
> --- a/usr.sbin/relayd/pfe.c
> +++ b/usr.sbin/relayd/pfe.c
> @@ -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..a925190f89e 100644
> --- a/usr.sbin/relayd/pfe_filter.c
> +++ b/usr.sbin/relayd/pfe_filter.c
> @@ -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..4cd0bc1afd9 100644
> --- a/usr.sbin/relayd/pfe_route.c
> +++ b/usr.sbin/relayd/pfe_route.c
> @@ -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..e88383997fb 100644
> --- a/usr.sbin/relayd/proc.c
> +++ b/usr.sbin/relayd/proc.c
> @@ -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 3ed127553b9..7fae20c2af7 100644
> --- a/usr.sbin/relayd/relay.c
> +++ b/usr.sbin/relayd/relay.c
> @@ -427,7 +427,7 @@ relay_launch(void)
> TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) {
> if ((rlay->rl_conf.flags & (F_TLS|F_TLSCLIENT)) &&
> (rlay->rl_ssl_ctx = relay_tls_ctx_create(rlay)) == NULL)
> - fatal("relay_init: failed to create TLS context");
> + fatal("%s: failed to create TLS context", __func__);
>
> TAILQ_FOREACH(rlt, &rlay->rl_tables, rlt_entry) {
> /*
> @@ -441,8 +441,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;
> }
> @@ -708,7 +708,7 @@ relay_connected(int fd, short sig, void *arg)
> /* Use defaults */
> break;
> default:
> - fatalx("relay_connected: unknown protocol");
> + fatalx("%s: unknown protocol", __func__);
> }
>
> /*
> @@ -723,7 +723,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 */
> @@ -764,7 +764,7 @@ relay_input(struct rsession *con)
> /* Use defaults */
> break;
> default:
> - fatalx("relay_input: unknown protocol");
> + fatalx("%s: unknown protocol", __func__);
> }
>
> /*
> @@ -1288,7 +1288,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) {
> @@ -1339,7 +1339,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)
> @@ -1463,7 +1463,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;
> }
>
> @@ -1471,7 +1471,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);
>
> @@ -1785,10 +1785,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;
> @@ -1797,14 +1797,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)
> @@ -1813,7 +1813,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)
> @@ -1823,18 +1823,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,
> diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c
> index 4082ab35af0..c24085fb889 100644
> --- a/usr.sbin/relayd/relay_http.c
> +++ b/usr.sbin/relayd/relay_http.c
> @@ -1597,7 +1597,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..3e94c17d019 100644
> --- a/usr.sbin/relayd/relay_udp.c
> +++ b/usr.sbin/relayd/relay_udp.c
> @@ -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 53996b21b30..ae11ed75d0a 100644
> --- a/usr.sbin/relayd/relayd.c
> +++ b/usr.sbin/relayd/relayd.c
> @@ -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);
> @@ -1478,7 +1477,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);
>
> /*
> @@ -1490,7 +1489,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 *
> @@ -1640,7 +1639,7 @@ parent_tls_ticket_rekey(int fd, short events, void *arg)
> struct timeval tv;
> struct tls_ticket key;
>
> - log_debug("relayd_tls_ticket_rekey: rekeying tickets");
> + log_debug("%s: rekeying tickets", __func__);
>
> arc4random_buf(key.tt_key_name, sizeof(key.tt_key_name));
> arc4random_buf(key.tt_hmac_key, sizeof(key.tt_hmac_key));
> diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c
> index 719f470a002..8654dc4c874 100644
> --- a/usr.sbin/relayd/snmp.c
> +++ b/usr.sbin/relayd/snmp.c
> @@ -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 f5dad7e36f0..8fb991c985b 100644
> --- a/usr.sbin/relayd/ssl.c
> +++ b/usr.sbin/relayd/ssl.c
> @@ -88,7 +88,7 @@ ssl_read(int s, short event, void *arg)
> return;
> }
> if (ibuf_add(cte->buf, rbuf, ret) == -1)
> - fatal("ssl_read: buf_add error");
> + fatal("%s: buf_add error", __func__);
> if (cte->validate_read != NULL) {
> if (cte->validate_read(cte) != 0)
> goto retry;
> @@ -141,7 +141,7 @@ ssl_write(int s, short event, void *arg)
> }
> }
> if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL)
> - fatalx("ssl_write: cannot create dynamic buffer");
> + fatalx("%s: cannot create dynamic buffer", __func__);
>
> event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, ssl_read,
> &cte->tv_start, &cte->table->conf.timeout, cte);
> @@ -198,7 +198,7 @@ ssl_connect(int s, short event, void *arg)
> }
>
> if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL)
> - fatalx("ssl_connect: cannot create dynamic buffer");
> + fatalx("%s: cannot create dynamic buffer", __func__);
> event_again(&cte->ev, cte->s, EV_TIMEOUT|EV_READ, ssl_read,
> &cte->tv_start, &cte->table->conf.timeout, cte);
> return;
>
> --
> Kind regards,
> Hiltjo
>