summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2017-09-17 21:20:23 +0000
committerkrw <krw@openbsd.org>2017-09-17 21:20:23 +0000
commitb53f3a4d496600db1316360e7e91181b617ab0cd (patch)
tree3d43ef17870968012885ad7c3140ef82c6bcf1de
parentuse strip directly. The layers if macros are not actually helpful. (diff)
downloadwireguard-openbsd-b53f3a4d496600db1316360e7e91181b617ab0cd.tar.xz
wireguard-openbsd-b53f3a4d496600db1316360e7e91181b617ab0cd.zip
Create global 'log_procname' and set it to '<ifname>' or
'<ifname> [priv]' as appropriate for the process doing the setting. Use it as the prefix in all log_*() output. Makes tracking messages for an interface or a process much easier.
-rw-r--r--sbin/dhclient/bpf.c6
-rw-r--r--sbin/dhclient/clparse.c9
-rw-r--r--sbin/dhclient/dhclient.c142
-rw-r--r--sbin/dhclient/dhcpd.h3
-rw-r--r--sbin/dhclient/dispatch.c44
-rw-r--r--sbin/dhclient/kroute.c61
-rw-r--r--sbin/dhclient/options.c58
-rw-r--r--sbin/dhclient/packet.c23
-rw-r--r--sbin/dhclient/privsep.c35
9 files changed, 215 insertions, 166 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 7106a00937f..e1d7ce12ebc 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.64 2017/09/14 00:10:17 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.65 2017/09/17 21:20:23 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -308,8 +308,8 @@ send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to)
}
if (result == -1)
- log_warn("send_packet");
- return result ;
+ log_warn("%s: send_packet", log_procname);
+ return result;
}
ssize_t
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 28951bc28c7..bb2e477bbb5 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.126 2017/09/14 00:10:17 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.127 2017/09/17 21:20:23 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -189,7 +189,8 @@ read_client_leases(char *name, struct client_lease_tq *tq)
if (token == EOF)
break;
if (token != TOK_LEASE) {
- log_warnx("Corrupt lease file - possible data loss!");
+ log_warnx("%s: corrupt lease file - possible data loss!",
+ log_procname);
break;
}
add_lease(tq, parse_client_lease_statement(cfile, name));
@@ -734,8 +735,8 @@ parse_option_decl(FILE *cfile, struct option_data *options)
dp = cidr;
break;
default:
- log_warnx("Bad format %c in "
- "parse_option_param.", *fmt);
+ log_warnx("%s: bad format %c in "
+ "parse_option_param", log_procname, *fmt);
skip_to_semi(cfile);
return -1;
}
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 51087cefacc..533b6db0cb7 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.501 2017/09/15 11:40:05 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.502 2017/09/17 21:20:23 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -97,6 +97,7 @@
char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
char *path_dhclient_db = NULL;
+char *log_procname;
char path_option_db[PATH_MAX];
@@ -216,7 +217,7 @@ interface_link_forceup(char *name, int ioctlfd)
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (ioctl(ioctlfd, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) {
- log_warn("SIOCGIFFLAGS");
+ log_warn("%s: SIOCGIFFLAGS", log_procname);
return;
}
@@ -224,7 +225,7 @@ interface_link_forceup(char *name, int ioctlfd)
if ((ifr.ifr_flags & IFF_UP) == 0) {
ifr.ifr_flags |= IFF_UP;
if (ioctl(ioctlfd, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) {
- log_warn("SIOCSIFFLAGS");
+ log_warn("%s: SIOCSIFFLAGS", log_procname);
return;
}
}
@@ -345,7 +346,7 @@ routehandler(struct interface_info *ifi, int routefd)
}
break;
case RTM_DESYNC:
- log_warnx("route socket buffer overflow");
+ log_warnx("%s: route socket buffer overflow", log_procname);
break;
case RTM_IFINFO:
ifm = (struct if_msghdr *)rtm;
@@ -358,7 +359,8 @@ routehandler(struct interface_info *ifi, int routefd)
memcpy(&hw, &ifi->hw_address, sizeof(hw));
get_hw_address(ifi);
if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) {
- log_warnx("LLADDR changed; restarting");
+ log_warnx("%s: LLADDR changed; restarting",
+ log_procname);
sendhup();
goto done;
}
@@ -367,7 +369,7 @@ routehandler(struct interface_info *ifi, int routefd)
linkstat = interface_status(ifi->name);
if (linkstat != ifi->linkstat) {
#ifdef DEBUG
- log_debug("link state %s -> %s",
+ log_debug("%s: link state %s -> %s", log_procname,
(ifi->linkstat != 0) ? "up" : "down",
(linkstat != 0) ? "up" : "down");
#endif /* DEBUG */
@@ -501,8 +503,11 @@ main(int argc, char *argv[])
if ((ioctlfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
fatal("socket(AF_INET, SOCK_DGRAM)");
get_ifname(ifi, ioctlfd, argv[0]);
- setproctitle("%s", ifi->name);
- log_procinit(ifi->name);
+ log_procname = strdup(ifi->name);
+ if (log_procname == NULL)
+ fatal("log_procname");
+ setproctitle("%s", log_procname);
+ log_procinit(log_procname);
ifi->index = if_nametoindex(ifi->name);
if (ifi->index == 0)
fatalx("no such interface");
@@ -861,12 +866,13 @@ dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info)
if (ifi->state != S_SELECTING) {
#ifdef DEBUG
- log_debug("Unexpected %s. State #%d.", info, ifi->state);
+ log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ ifi->state);
#endif /* DEBUG */
return;
}
- log_info("%s", info);
+ log_info("%s: %s", log_procname, info);
lease = packet_to_lease(ifi, options);
if (lease != NULL) {
@@ -902,12 +908,13 @@ dhcpack(struct interface_info *ifi, struct option_data *options, char *info)
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
#ifdef DEBUG
- log_debug("Unexpected %s. State #%d", info, ifi->state);
+ log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ ifi->state);
#endif /* DEBUG */
return;
}
- log_info("%s", info);
+ log_info("%s: %s", log_procname, info);
lease = packet_to_lease(ifi, options);
if (lease == NULL) {
@@ -934,19 +941,21 @@ dhcpnak(struct interface_info *ifi, struct option_data *options, char *info)
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
#ifdef DEBUG
- log_debug("Unexpected %s. State #%d", info, ifi->state);
+ log_debug("%s: unexpected %s - state #%d", log_procname, info,
+ ifi->state);
#endif /* DEBUG */
return;
}
if (ifi->active == NULL) {
#ifdef DEBUG
- log_debug("Unexpected %s. No active lease.", info);
+ log_debug("%s: unexpected %s - no active lease", log_procname,
+ info);
#endif /* DEBUG */
return;
}
- log_info("%s", info);
+ log_info("%s: %s", log_procname, info);
delete_address(ifi->active->address);
/* XXX Do we really want to remove a NAK'd lease from the database? */
@@ -1018,7 +1027,7 @@ bind_lease(struct interface_info *ifi)
newlease:
write_resolv_conf();
- log_info("bound to %s -- renewal in %lld seconds.",
+ log_info("%s: bound to %s -- renewal in %lld seconds", log_procname,
inet_ntoa(ifi->active->address),
(long long)(ifi->active->renewal - time(NULL)));
go_daemon(ifi->name);
@@ -1101,7 +1110,7 @@ addressinuse(char *name, struct in_addr address, char *ifname)
int used = 0;
if (getifaddrs(&ifap) != 0) {
- log_warn("addressinuse: getifaddrs");
+ log_warn("%s: addressinuse: getifaddrs", log_procname);
return 0;
}
@@ -1141,7 +1150,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
lease = calloc(1, sizeof(*lease));
if (lease == NULL) {
- log_warnx("lease declined: no memory for lease.");
+ log_warnx("%s: lease declined - no memory for lease",
+ log_procname);
return NULL;
}
@@ -1151,7 +1161,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
continue;
name = code_to_name(i);
if (unknown_ok == 0 && strncmp("option-", name, 7) != 0) {
- log_warnx("lease declined: unknown option %d", i);
+ log_warnx("%s: lease declined - unknown option %d",
+ log_procname, i);
goto decline;
}
pretty = pretty_print_option(i, &options[i], 0);
@@ -1163,8 +1174,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
buf = pretty_print_domain_search(options[i].data,
options[i].len);
if (buf == NULL || res_hnok_list(buf) == 0) {
- log_warnx("Ignoring %s in offer: invalid host "
- "name(s)", name);
+ log_warnx("%s: ignoring %s in offer - invalid "
+ "host name(s)", log_procname, name);
continue;
}
break;
@@ -1176,16 +1187,16 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
* entries in the resolv.conf 'search' statement.
*/
if (res_hnok_list(pretty) == 0) {
- log_warnx("Ignoring %s in offer: invalid host "
- "name(s)", name);
+ log_warnx("%s: ignoring %s in offer - invalid "
+ "host name(s)", log_procname, name);
continue;
}
break;
case DHO_HOST_NAME:
case DHO_NIS_DOMAIN:
if (res_hnok(pretty) == 0) {
- log_warnx("Ignoring %s in offer: invalid host "
- "name", name);
+ log_warnx("%s: ignoring %s in offer - invalid "
+ "host name", log_procname, name);
continue;
}
break;
@@ -1203,8 +1214,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
for (i = 0; i < config->required_option_count; i++) {
if (lease->options[config->required_options[i]].len == 0) {
name = code_to_name(i);
- log_warnx("lease declined: %s required but missing",
- name);
+ log_warnx("%s: lease declined - %s required but "
+ "missing", log_procname, name);
goto decline;
}
}
@@ -1217,8 +1228,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
memset(ifname, 0, sizeof(ifname));
if (addressinuse(ifi->name, lease->address, ifname) != 0 &&
strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) {
- log_warnx("lease declined: %s already configured on %s",
- inet_ntoa(lease->address), ifname);
+ log_warnx("%s: lease declined - %s already configured on %s",
+ log_procname, inet_ntoa(lease->address), ifname);
goto decline;
}
@@ -1231,13 +1242,15 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
packet->sname[0]) {
lease->server_name = malloc(DHCP_SNAME_LEN + 1);
if (lease->server_name == NULL) {
- log_warnx("lease declined:: no memory for SNAME.");
+ log_warnx("%s: lease declined - no memory for SNAME",
+ log_procname);
goto decline;
}
memcpy(lease->server_name, packet->sname, DHCP_SNAME_LEN);
lease->server_name[DHCP_SNAME_LEN] = '\0';
if (res_hnok(lease->server_name) == 0) {
- log_warnx("lease declined: invalid host name in SNAME");
+ log_warnx("%s: lease declined - invalid host name in "
+ "SNAME", log_procname);
goto decline;
}
}
@@ -1249,7 +1262,8 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
/* Don't count on the NUL terminator. */
lease->filename = malloc(DHCP_FILE_LEN + 1);
if (lease->filename == NULL) {
- log_warnx("lease declined: no memory for filename.");
+ log_warnx("%s: lease declined - no memory for filename",
+ log_procname);
goto decline;
}
memcpy(lease->filename, packet->file, DHCP_FILE_LEN);
@@ -1320,12 +1334,12 @@ send_discover(struct interface_info *ifi)
packet->secs = htons(UINT16_MAX);
ifi->secs = packet->secs;
- log_info("DHCPDISCOVER on %s - interval %lld", ifi->name,
+ log_info("%s: DHCPDISCOVER - interval %lld", log_procname,
(long long)ifi->interval);
rslt = send_packet(ifi, inaddr_any, inaddr_broadcast);
if (rslt == -1 && errno == EAFNOSUPPORT) {
- log_warnx("dhclient cannot be used on %s", ifi->name);
+ log_warnx("%s: dhclient cannot be used", log_procname);
quit = INTERNALSIG;
} else
set_timeout(ifi, ifi->interval, send_discover);
@@ -1338,7 +1352,7 @@ send_discover(struct interface_info *ifi)
void
state_panic(struct interface_info *ifi)
{
- log_info("No acceptable DHCPOFFERS received.");
+ log_info("%s: no acceptable DHCPOFFERS received", log_procname);
ifi->offer = get_recorded_lease(ifi);
if (ifi->offer != NULL) {
@@ -1350,7 +1364,8 @@ state_panic(struct interface_info *ifi)
/*
* No leases were available, or what was available didn't work
*/
- log_info("No working leases in persistent database - sleeping.");
+ log_info("%s: no working leases in persistent database - sleeping",
+ log_procname);
ifi->state = S_INIT;
set_timeout(ifi, config->retry_interval, state_init);
go_daemon(ifi->name);
@@ -1451,7 +1466,7 @@ send_request(struct interface_info *ifi)
packet->secs = htons(UINT16_MAX);
}
- log_info("DHCPREQUEST on %s to %s", ifi->name,
+ log_info("%s: DHCPREQUEST to %s", log_procname,
inet_ntoa(destination.sin_addr));
send_packet(ifi, from, destination.sin_addr);
@@ -1462,7 +1477,7 @@ send_request(struct interface_info *ifi)
void
send_decline(struct interface_info *ifi)
{
- log_info("DHCPDECLINE on %s", ifi->name);
+ log_info("%s: DHCPDECLINE", log_procname);
send_packet(ifi, inaddr_any, inaddr_broadcast);
}
@@ -1757,13 +1772,15 @@ rewrite_option_db(char *name, struct client_lease *offered,
if (leasestr != NULL)
fprintf(optionDB, "%s", leasestr);
else
- log_warnx("cannot make offered lease into string");
+ log_warnx("%s: cannot make offered lease into string",
+ log_procname);
leasestr = lease_as_string(name, "effective", effective);
if (leasestr != NULL)
fprintf(optionDB, "%s", leasestr);
else
- log_warnx("cannot make effective lease into string");
+ log_warnx("%s: cannot make effective lease into string",
+ log_procname);
fflush(optionDB);
ftruncate(fileno(optionDB), ftello(optionDB));
@@ -1814,7 +1831,8 @@ lease_as_proposal(struct client_lease *lease)
memcpy(&proposal->rtstatic, opt->data, opt->len);
proposal->addrs |= RTA_STATIC;
} else
- log_warnx("CLASSLESS_STATIC_ROUTES too long");
+ log_warnx("%s: CLASSLESS_STATIC_ROUTES too long",
+ log_procname);
} else if (lease->options[DHO_CLASSLESS_MS_STATIC_ROUTES].len != 0) {
opt = &lease->options[DHO_CLASSLESS_MS_STATIC_ROUTES];
/* XXX */
@@ -1823,7 +1841,8 @@ lease_as_proposal(struct client_lease *lease)
memcpy(&proposal->rtstatic[1], opt->data, opt->len);
proposal->addrs |= RTA_STATIC;
} else
- log_warnx("MS_CLASSLESS_STATIC_ROUTES too long");
+ log_warnx("%s: MS_CLASSLESS_STATIC_ROUTES too long",
+ log_procname);
} else {
opt = &lease->options[DHO_ROUTERS];
if (opt->len >= sizeof(in_addr_t)) {
@@ -1839,7 +1858,8 @@ lease_as_proposal(struct client_lease *lease)
opt = &lease->options[DHO_DOMAIN_SEARCH];
buf = pretty_print_domain_search(opt->data, opt->len);
if (buf == NULL )
- log_warnx("DOMAIN_SEARCH too long");
+ log_warnx("%s: DOMAIN_SEARCH too long",
+ log_procname);
else {
proposal->rtsearch_len = strlen(buf);
memcpy(proposal->rtsearch, buf, proposal->rtsearch_len);
@@ -1852,7 +1872,7 @@ lease_as_proposal(struct client_lease *lease)
memcpy(proposal->rtsearch, opt->data, opt->len);
proposal->addrs |= RTA_SEARCH;
} else
- log_warnx("DOMAIN_NAME too long");
+ log_warnx("%s: DOMAIN_NAME too long", log_procname);
}
if (lease->options[DHO_DOMAIN_NAME_SERVERS].len != 0) {
int servers;
@@ -1973,14 +1993,14 @@ go_daemon(const char *name)
/* Stop logging to stderr. */
log_perror = 0;
log_init(0, LOG_DAEMON);
- log_procinit(name);
+ log_procinit(log_procname);
#ifdef DEBUG
log_setverbose(1);
#else
log_setverbose(0);
#endif /* DEBUG */
- setproctitle("%s", name);
+ setproctitle("%s", log_procname);
signal(SIGHUP, sighdlr);
signal(SIGPIPE, SIG_IGN);
}
@@ -2034,8 +2054,9 @@ res_hnok(const char *name)
} else if (isalnum(ch) == 0 && ch != '-' && ch != '_') {
return 0;
} else if (ch == '_' && warn == 0) {
- log_warnx("warning: hostname %s contains an "
- "underscore which violates RFC 952", name);
+ log_warnx("%s: warning: hostname %s contains an "
+ "underscore which violates RFC 952", log_procname,
+ name);
warn++;
}
pch = ch, ch = nch;
@@ -2082,7 +2103,6 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
{
struct pollfd pfd[1];
struct imsgbuf *priv_ibuf;
- char *privname;
ssize_t n;
int ioctlfd, routefd, nfds, rslt;
@@ -2101,11 +2121,13 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
go_daemon(ifi->name);
- rslt = asprintf(&privname, "%s [priv]", ifi->name);
+ if (log_procname != NULL)
+ free(log_procname);
+ rslt = asprintf(&log_procname, "%s [priv]", ifi->name);
if (rslt == -1)
- fatal("priv process name");
- setproctitle("%s", privname);
- log_procinit(privname);
+ fatal("log_procname");
+ setproctitle("%s", log_procname);
+ log_procinit(log_procname);
close(fd2);
@@ -2115,7 +2137,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
imsg_init(priv_ibuf, fd);
if ((ioctlfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- fatal("socket(AF_INEt, SOCK_DGRAM)");
+ fatal("socket(AF_INET, SOCK_DGRAM)");
if ((routefd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1)
fatal("socket(AF_ROUTE, SOCK_RAW)");
@@ -2127,7 +2149,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
if (nfds == -1) {
if (errno == EINTR)
continue;
- log_warn("priv_ibuf poll");
+ log_warn("%s: priv_ibuf poll", log_procname);
quit = INTERNALSIG;
continue;
}
@@ -2139,7 +2161,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
continue;
if ((n = imsg_read(priv_ibuf)) == -1 && errno != EAGAIN) {
- log_warn("imsg_read(priv_ibuf)");
+ log_warn("%s: imsg_read(priv_ibuf)", log_procname);
quit = INTERNALSIG;
continue;
}
@@ -2159,7 +2181,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
close(fd);
if (quit == SIGHUP) {
- log_warnx("%s; restarting.", strsignal(quit));
+ log_warnx("%s: %s - restarting", log_procname, strsignal(quit));
signal(SIGHUP, SIG_IGN); /* will be restored after exec */
execvp(saved_argv[0], saved_argv);
fatal("execvp(%s)", saved_argv[0]);
@@ -2303,7 +2325,8 @@ apply_defaults(struct client_lease *lease)
}
if (newlease->options[DHO_STATIC_ROUTES].len != 0) {
- log_warnx("DHO_STATIC_ROUTES (option 33) not supported");
+ log_warnx("%s: DHO_STATIC_ROUTES (option 33) not supported",
+ log_procname);
free(newlease->options[DHO_STATIC_ROUTES].data);
newlease->options[DHO_STATIC_ROUTES].data = NULL;
newlease->options[DHO_STATIC_ROUTES].len = 0;
@@ -2409,7 +2432,8 @@ apply_ignore_list(char *ignore_list)
i = name_to_code(p);
if (i == DHO_END) {
- log_info("Invalid option name: '%s'", p);
+ log_info("%s: invalid option name: '%s'", log_procname,
+ p);
return;
}
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 7a6e908dc97..6e4afde9b48 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.226 2017/09/09 15:07:59 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.227 2017/09/17 21:20:23 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -208,6 +208,7 @@ void sendhup(void);
/* dhclient.c */
extern char *path_dhclient_conf;
extern char *path_dhclient_db;
+extern char *log_procname;
extern struct client_config *config;
extern struct imsgbuf *unpriv_ibuf;
extern volatile sig_atomic_t quit;
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 87bfa17f609..263251cc42e 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.141 2017/09/14 00:10:17 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.142 2017/09/17 21:20:23 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -130,23 +130,23 @@ dispatch(struct interface_info *ifi, int routefd)
if (nfds == -1) {
if (errno == EINTR)
continue;
- log_warn("dispatch poll");
+ log_warn("%s: dispatch poll", log_procname);
quit = INTERNALSIG;
continue;
}
if ((fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- log_warnx("bfdesc poll error");
+ log_warnx("%s: bfdesc poll error", log_procname);
quit = INTERNALSIG;
continue;
}
if ((fds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- log_warnx("routefd poll error");
+ log_warnx("%s: routefd poll error", log_procname);
quit = INTERNALSIG;
continue;
}
if ((fds[2].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- log_warnx("unpriv_ibuf poll error");
+ log_warnx("%s: unpriv_ibuf poll error", log_procname);
quit = INTERNALSIG;
continue;
}
@@ -192,7 +192,7 @@ packethandler(struct interface_info *ifi)
fatalx("%s too many receive_packet failures",
ifi->name);
else
- log_warn("%s receive_packet failed", ifi->name);
+ log_warn("%s receive_packet failed", log_procname);
return;
}
ifi->errors = 0;
@@ -204,15 +204,15 @@ packethandler(struct interface_info *ifi)
if (packet->hlen != ETHER_ADDR_LEN) {
#ifdef DEBUG
- log_debug("Discarding packet with hlen != %s (%u)",
- ifi->name, packet->hlen);
+ log_debug("%s: discarding packet with hlen == %u", log_procname,
+ packet->hlen);
#endif /* DEBUG */
return;
} else if (memcmp(&ifi->hw_address, packet->chaddr,
sizeof(ifi->hw_address))) {
#ifdef DEBUG
- log_debug("Discarding packet with chaddr != %s (%s)",
- ifi->name,
+ log_debug("%s: discarding packet with chaddr == %s",
+ log_procname,
ether_ntoa((struct ether_addr *)packet->chaddr));
#endif /* DEBUG */
return;
@@ -220,8 +220,8 @@ packethandler(struct interface_info *ifi)
if (ifi->xid != packet->xid) {
#ifdef DEBUG
- log_debug("Discarding packet with XID != %u (%u)", ifi->xid,
- packet->xid);
+ log_debug("%s: discarding packet with XID != %u (%u)",
+ log_procname, ifi->xid, packet->xid);
#endif /* DEBUG */
return;
}
@@ -229,8 +229,8 @@ packethandler(struct interface_info *ifi)
TAILQ_FOREACH(ap, &config->reject_list, next)
if (ifrom.s_addr == ap->addr.s_addr) {
#ifdef DEBUG
- log_debug("Discarding packet from address on reject "
- "list (%s)", inet_ntoa(ifrom));
+ log_debug("%s: discarding packet from address on reject "
+ "list (%s)", log_procname, inet_ntoa(ifrom));
#endif /* DEBUG */
return;
}
@@ -247,8 +247,8 @@ packethandler(struct interface_info *ifi)
memcmp(options[i].data, config->send_options[i].data,
options[i].len) != 0)) {
#ifdef DEBUG
- log_debug("Discarding packet with client-identifier "
- "'%s'", pretty_print_option(i, &options[i], 0));
+ log_debug("%s: discarding packet with client-identifier %s'",
+ log_procname, pretty_print_option(i, &options[i], 0));
#endif /* DEBUG */
return;
}
@@ -274,8 +274,8 @@ packethandler(struct interface_info *ifi)
break;
default:
#ifdef DEBUG
- log_debug("Discarding DHCP packet of unknown type "
- "(%d)", options[i].data[0]);
+ log_debug("%s: discarding DHCP packet of unknown type "
+ "(%d)", log_procname, options[i].data[0]);
#endif /* DEBUG */
return;
}
@@ -284,7 +284,8 @@ packethandler(struct interface_info *ifi)
type = "BOOTREPLY";
} else {
#ifdef DEBUG
- log_debug("Discarding packet which is neither DHCP nor BOOTP");
+ log_debug("%s: discarding packet which is neither DHCP nor "
+ "BOOTP", log_procname);
#endif /* DEBUG */
return;
}
@@ -313,7 +314,8 @@ flush_unpriv_ibuf(const char *who)
if (quit == 0)
quit = INTERNALSIG;
if (errno != EPIPE && errno != 0)
- log_warn("%s: msgbuf_write", who);
+ log_warn("%s: %s: msgbuf_write", log_procname,
+ who);
break;
}
}
@@ -345,5 +347,5 @@ sendhup(void)
rslt = imsg_compose(unpriv_ibuf, IMSG_HUP, 0, 0, -1, NULL, 0);
if (rslt == -1)
- log_warn("sendhup: imsg_compose");
+ log_warn("%s: sendhup: imsg_compose", log_procname);
}
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 20e5062f6eb..b142171461e 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.148 2017/09/15 15:22:14 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.149 2017/09/17 21:20:23 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -99,7 +99,8 @@ get_routes(int rdomain, size_t *len)
}
if (errmsg != NULL) {
- log_warn("get_routes - %s (msize=%zu)", errmsg, needed);
+ log_warn("%s: get_routes - %s (msize=%zu)", log_procname,
+ errmsg, needed);
free(buf);
buf = NULL;
}
@@ -129,7 +130,7 @@ flush_routes(uint8_t *rtstatic, unsigned int rtstatic_len)
rslt = imsg_compose(unpriv_ibuf, IMSG_FLUSH_ROUTES, 0, 0, -1, &imsg,
sizeof(imsg));
if (rslt == -1)
- log_warn("flush_routes: imsg_compose");
+ log_warn("%s: flush_routes: imsg_compose", log_procname);
}
void
@@ -172,9 +173,10 @@ priv_flush_routes(int index, int routefd, int rdomain,
rlen = write(routefd, (char *)rtm, rtm->rtm_msglen);
if (rlen == -1) {
if (errno != ESRCH)
- log_warn("RTM_DELETE write");
+ log_warn("%s: RTM_DELETE write", log_procname);
} else if (rlen < (int)rtm->rtm_msglen)
- log_warnx("short RTM_DELETE write (%zd)\n", rlen);
+ log_warnx("%s: short RTM_DELETE write (%zd)",
+ log_procname, rlen);
}
free(buf);
@@ -307,7 +309,7 @@ add_route(struct in_addr dest, struct in_addr netmask, struct in_addr gateway,
rslt = imsg_compose(unpriv_ibuf, IMSG_ADD_ROUTE, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warn("add_route: imsg_compose");
+ log_warn("%s: add_route: imsg_compose", log_procname);
}
void
@@ -377,8 +379,9 @@ priv_add_route(char *name, int rdomain, int routefd,
sizeof(destbuf));
strlcpy(maskbuf, inet_ntoa(imsg->netmask),
sizeof(maskbuf));
- log_warn("failed to add route (%s/%s via %s)",
- destbuf, maskbuf, inet_ntoa(imsg->gateway));
+ log_warn("%s: failed to add route (%s/%s via %s)",
+ log_procname, destbuf, maskbuf,
+ inet_ntoa(imsg->gateway));
}
}
}
@@ -441,7 +444,7 @@ delete_address(struct in_addr addr)
rslt = imsg_compose(unpriv_ibuf, IMSG_DELETE_ADDRESS, 0, 0 , -1, &imsg,
sizeof(imsg));
if (rslt == -1)
- log_warn("delete_address: imsg_compose");
+ log_warn("%s: delete_address: imsg_compose", log_procname);
}
void
@@ -465,7 +468,7 @@ priv_delete_address(char *name, int ioctlfd, struct imsg_delete_address *imsg)
/* SIOCDIFADDR will result in a RTM_DELADDR message we must catch! */
if (ioctl(ioctlfd, SIOCDIFADDR, &ifaliasreq) == -1) {
if (errno != EADDRNOTAVAIL)
- log_warn("SIOCDIFADDR failed (%s)",
+ log_warn("%s: SIOCDIFADDR failed (%s)", log_procname,
inet_ntoa(imsg->addr));
}
}
@@ -485,7 +488,7 @@ set_mtu(int inits, uint16_t mtu)
return;
if (mtu < 68) {
- log_warnx("mtu size %u < 68: ignored", mtu);
+ log_warnx("%s: mtu size %u < 68: ignored", log_procname, mtu);
return;
}
imsg.mtu = mtu;
@@ -493,7 +496,7 @@ set_mtu(int inits, uint16_t mtu)
rslt = imsg_compose(unpriv_ibuf, IMSG_SET_MTU, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warn("set_mtu: imsg_compose");
+ log_warn("%s: set_mtu: imsg_compose", log_procname);
}
void
@@ -507,7 +510,7 @@ priv_set_mtu(char *name, int ioctlfd, struct imsg_set_mtu *imsg)
ifr.ifr_mtu = imsg->mtu;
if (ioctl(ioctlfd, SIOCSIFMTU, &ifr) == -1)
- log_warn("SIOCSIFMTU failed (%d)", imsg->mtu);
+ log_warn("%s: SIOCSIFMTU failed (%d)", log_procname, imsg->mtu);
}
/*
@@ -531,7 +534,7 @@ set_address(char *name, struct in_addr addr, struct in_addr netmask)
rslt = imsg_compose(unpriv_ibuf, IMSG_SET_ADDRESS, 0, 0, -1, &imsg,
sizeof(imsg));
if (rslt == -1)
- log_warn("set_address: imsg_compose");
+ log_warn("%s: set_address: imsg_compose", log_procname);
}
void
@@ -558,7 +561,8 @@ priv_set_address(char *name, int ioctlfd, struct imsg_set_address *imsg)
/* No need to set broadcast address. Kernel can figure it out. */
if (ioctl(ioctlfd, SIOCAIFADDR, &ifaliasreq) == -1)
- log_warn("SIOCAIFADDR failed (%s)", inet_ntoa(imsg->addr));
+ log_warn("%s: SIOCAIFADDR failed (%s)", log_procname,
+ inet_ntoa(imsg->addr));
}
/*
@@ -572,7 +576,7 @@ write_resolv_conf(void)
rslt = imsg_compose(unpriv_ibuf, IMSG_WRITE_RESOLV_CONF,
0, 0, -1, NULL, 0);
if (rslt == -1)
- log_warn("write_resolv_conf: imsg_compose");
+ log_warn("%s: write_resolv_conf: imsg_compose", log_procname);
}
void
@@ -590,17 +594,18 @@ priv_write_resolv_conf(char *contents)
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1) {
- log_warn("Couldn't open '%s'", path);
+ log_warn("%s: couldn't open '%s'", log_procname, path);
return;
}
sz = strlen(contents);
n = write(fd, contents, sz);
if (n == -1)
- log_warn("Couldn't write contents to '%s'", path);
+ log_warn("%s: couldn't write contents to '%s'", log_procname,
+ path);
else if ((size_t)n < sz)
- log_warnx("Short contents write to '%s' (%zd vs %zu)",
- path, n, sz);
+ log_warnx("%s: short contents write to '%s' (%zd vs %zu)",
+ log_procname, path, n, sz);
close(fd);
}
@@ -650,7 +655,7 @@ default_route_index(int rdomain, int routefd)
fatal("start time");
if (writev(routefd, iov, 3) == -1) {
- log_warn("RTM_GET of default route");
+ log_warn("%s: RTM_GET of default route", log_procname);
return 0;
}
@@ -663,11 +668,11 @@ default_route_index(int rdomain, int routefd)
if (nfds == -1) {
if (errno == EINTR)
continue;
- log_warn("default route poll");
+ log_warn("%s: default route poll", log_procname);
break;
}
if ((fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- log_warnx("default route revents");
+ log_warnx("%s: default route revents", log_procname);
break;
}
if (nfds == 0 || (fds[0].revents & POLLIN) == 0)
@@ -675,10 +680,11 @@ default_route_index(int rdomain, int routefd)
len = read(routefd, &m_rtmsg, sizeof(m_rtmsg));
if (len == -1) {
- log_warn("get default route read");
+ log_warn("%s: get default route read", log_procname);
break;
} else if (len == 0) {
- log_warnx("no data from default route read");
+ log_warnx("%s: no data from default route read",
+ log_procname);
break;
}
@@ -687,7 +693,8 @@ default_route_index(int rdomain, int routefd)
m_rtmsg.m_rtm.rtm_pid == pid &&
m_rtmsg.m_rtm.rtm_seq == seq) {
if (m_rtmsg.m_rtm.rtm_errno != 0) {
- log_warnx("default route read rtm: %s",
+ log_warnx("%s: route read rtm: %s",
+ log_procname,
strerror(m_rtmsg.m_rtm.rtm_errno));
break;
}
@@ -786,7 +793,7 @@ done:
rslt = imsg_compose(unpriv_ibuf, IMSG_SET_RESOLV_CONF,
0, 0, -1, contents, len);
if (rslt == -1)
- log_warn("set_resolv_conf: imsg_compose");
+ log_warn("%s: resolv_conf: imsg_compose", log_procname);
}
/*
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index a5ec607d6cc..9fc718a0c2f 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.106 2017/09/14 00:10:17 krw Exp $ */
+/* $OpenBSD: options.c,v 1.107 2017/09/17 21:20:23 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -430,12 +430,13 @@ parse_option_buffer(struct option_data *options, unsigned char *buffer,
if (s + 1 + len < end) {
; /* option data is all there. */
} else {
- log_warnx("option %s (%d) larger than buffer.",
- name, len);
+ log_warnx("%s: option %s (%d) larger than "
+ "buffer", log_procname, name, len);
return 0;
}
} else {
- log_warnx("option %s has no length field.", name);
+ log_warnx("%s: option %s has no length field",
+ log_procname, name);
return 0;
}
@@ -642,8 +643,8 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
/* This is a pointer to another list of labels. */
if (i + 1 >= srclen) {
/* The pointer is truncated. */
- log_warnx("Truncated pointer in DHCP Domain "
- "Search option.");
+ log_warnx("%s: truncated pointer in DHCP "
+ "Domain Search option", log_procname);
return -1;
}
@@ -653,8 +654,9 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
* The pointer must indicates a prior
* occurance.
*/
- log_warnx("Invalid forward pointer in DHCP "
- "Domain Search option compression.");
+ log_warnx("%s: invalid forward pointer in DHCP "
+ "Domain Search option compression",
+ log_procname);
return -1;
}
@@ -666,8 +668,8 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
return domain_name_len;
}
if (i + label_len + 1 > srclen) {
- log_warnx("Truncated label in DHCP Domain Search "
- "option.");
+ log_warnx("%s: truncated label in DHCP Domain Search "
+ "option", log_procname);
return -1;
}
/*
@@ -678,7 +680,8 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
if (strlen(domain_search) + domain_name_len >=
DHCP_DOMAIN_SEARCH_LEN) {
- log_warnx("Domain search list too long.");
+ log_warnx("%s: domain search list too long",
+ log_procname);
return -1;
}
@@ -691,7 +694,7 @@ expand_search_domain_name(unsigned char *src, size_t srclen, int *offset,
cursor += label_len + 1;
}
- log_warnx("Truncated DHCP Domain Search option.");
+ log_warnx("%s: truncated DHCP Domain Search option", log_procname);
return -1;
}
@@ -759,7 +762,7 @@ pretty_print_option(unsigned int code, struct option_data *option,
/* Code should be between 0 and 255. */
if (code > 255) {
- log_warnx("pretty_print_option: bad code %d", code);
+ log_warnx("%s: pretty_print_option: bad code %d", log_procname, code);
goto done;
}
@@ -785,8 +788,8 @@ pretty_print_option(unsigned int code, struct option_data *option,
/* Figure out the size of the data. */
for (i = 0; fmt[i]; i++) {
if (numhunk == 0) {
- log_warnx("%s: Excess information in format string: "
- "%s", name, &fmt[i]);
+ log_warnx("%s: %s: Excess information in format "
+ "string: %s", log_procname, name, &fmt[i]);
goto done;
}
numelem++;
@@ -797,8 +800,9 @@ pretty_print_option(unsigned int code, struct option_data *option,
fmtbuf[i] = 0;
numhunk = 0;
if (hunksize == 0) {
- log_warnx("%s: no size indicator before A"
- " in format string: %s", name, fmt);
+ log_warnx("%s: %s: no size indicator before A"
+ " in format string: %s", log_procname,
+ name, fmt);
goto done;
}
break;
@@ -836,22 +840,22 @@ pretty_print_option(unsigned int code, struct option_data *option,
case 'e':
break;
default:
- log_warnx("%s: garbage in format string: %s", name,
- &fmt[i]);
+ log_warnx("%s: %s: garbage in format string: %s",
+ log_procname, name, &fmt[i]);
goto done;
}
}
/* Check for too few bytes. */
if (hunksize > len) {
- log_warnx("%s: expecting at least %d bytes; got %d", name,
- hunksize, len);
+ log_warnx("%s: %s: expecting at least %d bytes; got %d",
+ log_procname, name, hunksize, len);
goto done;
}
/* Check for too many bytes. */
if (numhunk == -1 && hunksize < len) {
- log_warnx("%s: expecting only %d bytes: got %d", name,
- hunksize, len);
+ log_warnx("%s: %s: expecting only %d bytes: got %d",
+ log_procname, name, hunksize, len);
goto done;
}
@@ -860,8 +864,8 @@ pretty_print_option(unsigned int code, struct option_data *option,
numhunk = len / hunksize;
/* See if we got an exact number of hunks. */
if (numhunk > 0 && numhunk * hunksize != len) {
- log_warnx("%s: expecting %d bytes: got %d", name,
- numhunk * hunksize, len);
+ log_warnx("%s: %s: expecting %d bytes: got %d", log_procname,
+ name, numhunk * hunksize, len);
goto done;
}
@@ -918,8 +922,8 @@ pretty_print_option(unsigned int code, struct option_data *option,
dp++;
break;
default:
- log_warnx("Unexpected format code %c",
- fmtbuf[j]);
+ log_warnx("%s: unexpected format code %c",
+ log_procname, fmtbuf[j]);
goto toobig;
}
if (opcount >= opleft || opcount == -1)
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index 0fda00f9034..e20a11623c7 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.40 2017/07/14 16:21:03 krw Exp $ */
+/* $OpenBSD: packet.c,v 1.41 2017/09/17 21:20:23 krw Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -149,8 +149,9 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
ip_packets_bad_checksum++;
if (ip_packets_seen > 4 && ip_packets_bad_checksum != 0 &&
(ip_packets_seen / ip_packets_bad_checksum) < 2) {
- log_info("%d bad IP checksums seen in %d packets",
- ip_packets_bad_checksum, ip_packets_seen);
+ log_info("%s: %d bad IP checksums seen in %d packets",
+ log_procname, ip_packets_bad_checksum,
+ ip_packets_seen);
ip_packets_seen = ip_packets_bad_checksum = 0;
}
return -1;
@@ -160,8 +161,8 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
#ifdef DEBUG
if (ntohs(ip->ip_len) != buflen)
- log_debug("ip length %hu disagrees with bytes received %d.",
- ntohs(ip->ip_len), buflen);
+ log_debug("%s: ip length %hu disagrees with bytes received %d",
+ log_procname, ntohs(ip->ip_len), buflen);
#endif /* DEBUG */
/* Assure that the entire IP packet is within the buffer. */
@@ -192,8 +193,8 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
udp_packets_length_overflow != 0 &&
(udp_packets_length_checked /
udp_packets_length_overflow) < 2) {
- log_info("%d udp packets in %d too long - dropped",
- udp_packets_length_overflow,
+ log_info("%s: %d udp packets in %d too long - dropped",
+ log_procname, udp_packets_length_overflow,
udp_packets_length_checked);
udp_packets_length_overflow =
udp_packets_length_checked = 0;
@@ -202,7 +203,8 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
}
#ifdef DEBUG
if (len + data != buf + buflen)
- log_debug("accepting packet with data after udp payload.");
+ log_debug("%s: accepting packet with data after udp payload",
+ log_procname);
#endif /* DEBUG */
usum = udp->uh_sum;
@@ -218,8 +220,9 @@ decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
udp_packets_bad_checksum++;
if (udp_packets_seen > 4 && udp_packets_bad_checksum != 0 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
- log_info("%d bad udp checksums in %d packets",
- udp_packets_bad_checksum, udp_packets_seen);
+ log_info("%s: %d bad udp checksums in %d packets",
+ log_procname, udp_packets_bad_checksum,
+ udp_packets_seen);
udp_packets_seen = udp_packets_bad_checksum = 0;
}
return -1;
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index fb0cf93f534..414bb475019 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.69 2017/09/15 15:22:14 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.70 2017/09/17 21:20:23 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -51,7 +51,7 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
index = if_nametoindex(name);
if (index == 0) {
- log_warnx("Unknown interface %s", name);
+ log_warnx("%s: unknown interface", log_procname);
quit = INTERNALSIG;
return;
}
@@ -67,7 +67,8 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_DELETE_ADDRESS:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct imsg_delete_address))
- log_warnx("bad IMSG_DELETE_ADDRESS");
+ log_warnx("%s: bad IMSG_DELETE_ADDRESS",
+ log_procname);
else
priv_delete_address(name, ioctlfd, imsg.data);
break;
@@ -75,7 +76,8 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_SET_ADDRESS:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct imsg_set_address))
- log_warnx("bad IMSG_SET_ADDRESS");
+ log_warnx("%s: bad IMSG_SET_ADDRESS",
+ log_procname);
else
priv_set_address(name, ioctlfd, imsg.data);
break;
@@ -83,7 +85,8 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_FLUSH_ROUTES:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct imsg_flush_routes))
- log_warnx("bad IMSG_FLUSH_ROUTES");
+ log_warnx("%s: bad IMSG_FLUSH_ROUTES",
+ log_procname);
else
priv_flush_routes(index, routefd, rdomain,
imsg.data);
@@ -92,7 +95,8 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_ADD_ROUTE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct imsg_add_route))
- log_warnx("bad IMSG_ADD_ROUTE");
+ log_warnx("%s: bad IMSG_ADD_ROUTE",
+ log_procname);
else
priv_add_route(name, rdomain, routefd,
imsg.data);
@@ -101,14 +105,15 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_SET_MTU:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct imsg_set_mtu))
- log_warnx("bad IMSG_SET_MTU");
+ log_warnx("%s: bad IMSG_SET_MTU", log_procname);
else
priv_set_mtu(name, ioctlfd, imsg.data);
break;
case IMSG_SET_RESOLV_CONF:
if (imsg.hdr.len < IMSG_HEADER_SIZE)
- log_warnx("bad IMSG_SET_RESOLV_CONF");
+ log_warnx("%s: bad IMSG_SET_RESOLV_CONF",
+ log_procname);
else {
free(resolv_conf);
resolv_conf = NULL;
@@ -116,8 +121,9 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
if (sz > 0) {
resolv_conf = malloc(sz);
if (resolv_conf == NULL)
- log_warnx("no memory for "
- "resolv_conf");
+ log_warnx("%s: no memory for "
+ "resolv_conf",
+ log_procname);
else
strlcpy(resolv_conf,
imsg.data, sz);
@@ -128,7 +134,8 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_WRITE_RESOLV_CONF:
if (imsg.hdr.len != IMSG_HEADER_SIZE)
- log_warnx("bad IMSG_WRITE_RESOLV_CONF");
+ log_warnx("%s: bad IMSG_WRITE_RESOLV_CONF",
+ log_procname);
else {
retries = 0;
do {
@@ -144,14 +151,14 @@ dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
case IMSG_HUP:
if (imsg.hdr.len != IMSG_HEADER_SIZE)
- log_warnx("bad IMSG_HUP");
+ log_warnx("%s: bad IMSG_HUP", log_procname);
else
quit = SIGHUP;
break;
default:
- log_warnx("received unknown message, code %u",
- imsg.hdr.type);
+ log_warnx("%s: received unknown message, code %u",
+ log_procname, imsg.hdr.type);
}
imsg_free(&imsg);