summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-20 18:32:23 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-20 18:32:23 +0000
commitcdd18f79892d68eee65afb88d3377ad2d958f0b2 (patch)
tree824b77476ff74005409a9d5399aa895108b8bcd0 /usr.sbin
parent5343ef6c9154245825c0d18aae6d26059b7dce1b (diff)
keep track which process we are so fatal() can log in which proc the
condition happened. fatal()s from subsystems used by all 3 processes like the imsg subsystem were hard to track down without knowing in which process the condition happened.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c3
-rw-r--r--usr.sbin/bgpd/bgpd.h8
-rw-r--r--usr.sbin/bgpd/log.c24
-rw-r--r--usr.sbin/bgpd/rde.c4
-rw-r--r--usr.sbin/bgpd/session.c4
5 files changed, 32 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index e73df0b8429..c8ae1c2e6a7 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.3 2003/12/20 14:33:09 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.4 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -100,6 +100,7 @@ main(int argc, char *argv[])
int m2r_writes_queued = 0;
conffile = CONFFILE;
+ bgpd_process = PROC_MAIN;
log_init(1); /* log to stderr until daemonized */
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 7797537f133..7784fbd62c2 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.2 2003/12/20 14:33:09 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.3 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -38,6 +38,12 @@
#define BGPD_OPT_VERBOSE 0x0001
#define BGPD_OPT_VERBOSE2 0x0002
+enum {
+ PROC_MAIN,
+ PROC_SE,
+ PROC_RDE
+} bgpd_process;
+
enum session_state {
STATE_NONE,
STATE_IDLE,
diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c
index b3ee25824e3..60af8d26c8b 100644
--- a/usr.sbin/bgpd/log.c
+++ b/usr.sbin/bgpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.2 2003/12/17 18:11:31 henning Exp $ */
+/* $OpenBSD: log.c,v 1.3 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -101,6 +101,12 @@ static const char *suberr_update_names[] = {
"AS-Path unacceptable"
};
+static const char *procnames[] = {
+ "parent",
+ "SE",
+ "RDE"
+};
+
int debug;
char *log_fmt_peer(struct peer *);
@@ -193,16 +199,20 @@ void
fatal(const char *emsg, int error)
{
if (emsg == NULL)
- logit(LOG_CRIT, "%s", strerror(error));
+ logit(LOG_CRIT, "fatal in %s: %s", procnames[bgpd_process],
+ strerror(error));
else
if (error)
- logit(LOG_CRIT, "%s: %s", emsg, strerror(error));
+ logit(LOG_CRIT, "fatal in %s: %s: %s",
+ procnames[bgpd_process], emsg, strerror(error));
else
- logit(LOG_CRIT, "%s", emsg);
+ logit(LOG_CRIT, "fatal in %s: %s",
+ procnames[bgpd_process], emsg);
- /* XXX check which process we are and notify others! */
- sleep(10);
- _exit(1);
+ if (bgpd_process == PROC_MAIN)
+ exit(1);
+ else /* parent copes via SIGCHLD */
+ _exit(1);
}
void
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 9e10396c2d2..ee5b85d2f24 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.11 2003/12/20 15:09:07 henning Exp $ */
+/* $OpenBSD: rde.c,v 1.12 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -95,7 +95,9 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2])
if (chroot(pw->pw_dir) < 0)
fatal("chroot failed", errno);
chdir("/");
+
setproctitle("route decision engine");
+ bgpd_process = PROC_RDE;
if (setgroups(1, &pw->pw_gid) ||
setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index c31b2965cf0..4dbd1d5bc5b 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.15 2003/12/20 15:06:31 henning Exp $ */
+/* $OpenBSD: session.c,v 1.16 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -156,7 +156,9 @@ session_main(struct bgpd_config *config, int pipe_m2s[2], int pipe_s2r[2])
if (chroot(pw->pw_dir) < 0)
fatal("chroot failed", errno);
chdir("/");
+
setproctitle("session engine");
+ bgpd_process = PROC_SE;
if ((sock = setup_listener()) < 0)
fatal("listener setup failed", 0);