diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-26 18:07:34 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-26 18:07:34 +0000 |
commit | 813e6af054fdcbfbf7a2222b80c873ba29a90e6e (patch) | |
tree | a866d018b981329f2a548dde61687e4de4e5ba57 /usr.sbin/bgpd | |
parent | 4af14c2d6f67af52937f1107de654c59989429ed (diff) |
when this project started and i added the fatal() function, I made it take
the error number as parameter instead of accessing errno, because in one
place the error number was not in errno but fetched from a socket.
now, of course it makes much more sense to just set errno to the error number
just fecthed in this one place instead of having hundreds of fatal() calls
all transfer the errno round and round and round...
fix this, and also provide a fatalx, which does not care for errno and doesn't
invoke strerror.
oh, btw, in the place where we fetch the err # from the socket, we don't
call fatal anymore anyway...
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 14 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/config.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/imsg.c | 16 | ||||
-rw-r--r-- | usr.sbin/bgpd/log.c | 27 | ||||
-rw-r--r-- | usr.sbin/bgpd/mrt.c | 34 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 28 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 44 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_prefix.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 16 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 32 |
12 files changed, 119 insertions, 111 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index b372beaa1f4..a48b6270e97 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.37 2003/12/26 17:47:04 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.38 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -156,20 +156,20 @@ main(int argc, char *argv[]) logit(LOG_INFO, "startup"); if (pipe(pipe_m2s) == -1) - fatal("pipe", errno); + fatal("pipe"); if (fcntl(pipe_m2s[0], F_SETFL, O_NONBLOCK) == -1 || fcntl(pipe_m2s[1], F_SETFL, O_NONBLOCK) == -1) - fatal("fcntl", errno); + fatal("fcntl"); if (pipe(pipe_m2r) == -1) - fatal("pipe", errno); + fatal("pipe"); if (fcntl(pipe_m2r[0], F_SETFL, O_NONBLOCK) == -1 || fcntl(pipe_m2r[1], F_SETFL, O_NONBLOCK) == -1) - fatal("fcntl", errno); + fatal("fcntl"); if (pipe(pipe_s2r) == -1) - fatal("pipe", errno); + fatal("pipe"); if (fcntl(pipe_s2r[0], F_SETFL, O_NONBLOCK) == -1 || fcntl(pipe_s2r[1], F_SETFL, O_NONBLOCK) == -1) - fatal("fcntl", errno); + fatal("fcntl"); /* fork children */ rde_main(&conf, pipe_m2r, pipe_s2r); diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index b2705007be4..b716b25be3c 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.37 2003/12/26 17:47:04 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.38 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -282,7 +282,8 @@ void vlog(int, const char *, va_list); void log_peer_err(struct peer *, const char *, ...); void log_peer_errx(struct peer *, const char *, ...); void log_err(const char *, ...); -void fatal(const char *, int); +void fatal(const char *); +void fatalx(const char *); void fatal_ensure(const char *, int, const char *); void log_statechange(struct peer *, enum session_state, enum session_events); diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index 667b7e121b7..a7f6172fc18 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.7 2003/12/25 17:35:53 henning Exp $ */ +/* $OpenBSD: config.c,v 1.8 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -108,7 +108,7 @@ get_bgpid(void) localnet = inet_addr("127.0.0.0"); if (getifaddrs(&ifap) == -1) - fatal("getifaddrs", errno); + fatal("getifaddrs"); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family != AF_INET) diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c index fbaa7c1a55e..7d8995a928d 100644 --- a/usr.sbin/bgpd/imsg.c +++ b/usr.sbin/bgpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.9 2003/12/24 13:28:02 henning Exp $ */ +/* $OpenBSD: imsg.c,v 1.10 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -55,7 +55,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) if ((n = read(ibuf->sock, ibuf->r.wptr, ibuf->r.pkt_len - ibuf->r.read_len)) == -1) { if (errno != EAGAIN && errno != EINTR) - fatal("pipe read error", errno); + fatal("pipe read error"); return (0); } read_total += n; @@ -69,7 +69,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) ibuf->r.peerid = hdr->peerid; if (hdr->len < IMSG_HEADER_SIZE || hdr->len > MAX_IMSGSIZE) - fatal("wrong imsg header len", 0); + fatalx("wrong imsg header len"); ibuf->r.seen_hdr = 1; } else { /* we got the full packet */ imsg->hdr.type = ibuf->r.type; @@ -78,7 +78,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) datalen = ibuf->r.pkt_len - IMSG_HEADER_SIZE; rptr = ibuf->r.buf + IMSG_HEADER_SIZE; if ((imsg->data = malloc(datalen)) == NULL) - fatal("get_imsg malloc", errno); + fatal("get_imsg malloc"); memcpy(imsg->data, rptr, datalen); n = 0; /* give others a chance */ imsg_init_readbuf(ibuf); @@ -105,14 +105,14 @@ imsg_compose(struct imsgbuf *ibuf, int type, u_int32_t peerid, void *data, hdr.peerid = peerid; wbuf = buf_open(hdr.len); if (wbuf == NULL) - fatal("imsg_compose: buf_open error", 0); + fatalx("imsg_compose: buf_open error"); if (buf_add(wbuf, &hdr, sizeof(hdr)) == -1) - fatal("imsg_compose: buf_add error", 0); + fatalx("imsg_compose: buf_add error"); if (datalen) if (buf_add(wbuf, data, datalen) == -1) - fatal("imsg_compose: buf_add error", 0); + fatalx("imsg_compose: buf_add error"); if ((n = buf_close(&ibuf->w, wbuf)) < 0) - fatal("imsg_compose: buf_close error", errno); + fatal("imsg_compose: buf_close error"); return (n); } diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c index 3128848f022..07eb2170305 100644 --- a/usr.sbin/bgpd/log.c +++ b/usr.sbin/bgpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.9 2003/12/26 16:48:07 henning Exp $ */ +/* $OpenBSD: log.c,v 1.10 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -121,10 +121,10 @@ log_fmt_peer(struct peer *peer) if (peer->conf.descr[0]) { if (asprintf(&pfmt, "neighbor %s (%s)", ip, peer->conf.descr) == -1) - fatal(NULL, errno); + fatal(NULL); } else { if (asprintf(&pfmt, "neighbor %s", ip) == -1) - fatal(NULL, errno); + fatal(NULL); } return (pfmt); } @@ -168,11 +168,11 @@ log_peer_err(struct peer *peer, const char *emsg, ...) p = log_fmt_peer(peer); if (emsg == NULL) { if (asprintf(&nfmt, "%s: %s", p, strerror(errno)) == -1) - fatal(NULL, errno); + fatal(NULL); } else { if (asprintf(&nfmt, "%s: %s: %s", p, emsg, strerror(errno)) == -1) - fatal(NULL, errno); + fatal(NULL); } va_start(ap, emsg); vlog(LOG_CRIT, nfmt, ap); @@ -188,7 +188,7 @@ log_peer_errx(struct peer *peer, const char *emsg, ...) p = log_fmt_peer(peer); if (asprintf(&nfmt, "%s: %s", p, emsg) == -1) - fatal(NULL, errno); + fatal(NULL); va_start(ap, emsg); vlog(LOG_CRIT, nfmt, ap); va_end(ap); @@ -219,15 +219,15 @@ log_err(const char *emsg, ...) } void -fatal(const char *emsg, int error) +fatal(const char *emsg) { if (emsg == NULL) logit(LOG_CRIT, "fatal in %s: %s", procnames[bgpd_process], - strerror(error)); + strerror(errno)); else - if (error) + if (errno) logit(LOG_CRIT, "fatal in %s: %s: %s", - procnames[bgpd_process], emsg, strerror(error)); + procnames[bgpd_process], emsg, strerror(errno)); else logit(LOG_CRIT, "fatal in %s: %s", procnames[bgpd_process], emsg); @@ -239,6 +239,13 @@ fatal(const char *emsg, int error) } void +fatalx(const char *emsg) +{ + errno = 0; + fatal(emsg); +} + +void fatal_ensure(const char *file, int line, const char *cond) { logit(LOG_CRIT, "ENSURE (%s) failed in file %s on line %d", diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index d1d730b63c7..c50c9a971aa 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.12 2003/12/26 00:34:01 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.13 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2003 Claudio Jeker <claudio@openbsd.org> @@ -47,7 +47,7 @@ static int mrt_open(struct mrtdump_config *); do { \ u_char t = (b); \ if (buf_add((x), &t, sizeof(t)) == -1) \ - fatal("buf_add error", 0); \ + fatalx("buf_add error"); \ } while (0) #define DUMP_SHORT(x, s) \ @@ -55,7 +55,7 @@ static int mrt_open(struct mrtdump_config *); u_int16_t t; \ t = htons((s)); \ if (buf_add((x), &t, sizeof(t)) == -1) \ - fatal("buf_add error", 0); \ + fatalx("buf_add error"); \ } while (0) #define DUMP_LONG(x, l) \ @@ -63,14 +63,14 @@ static int mrt_open(struct mrtdump_config *); u_int32_t t; \ t = htonl((l)); \ if (buf_add((x), &t, sizeof(t)) == -1) \ - fatal("buf_add error", 0); \ + fatalx("buf_add error"); \ } while (0) #define DUMP_NLONG(x, l) \ do { \ u_int32_t t = (l); \ if (buf_add((x), &t, sizeof(t)) == -1) \ - fatal("buf_add error", 0); \ + fatalx("buf_add error"); \ } while (0) int @@ -89,9 +89,9 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen, int type, hdr.peerid = mrt->id; buf = buf_open(hdr.len); if (buf == NULL) - fatal("mrt_dump_bgp_msg", errno); + fatal("mrt_dump_bgp_msg"); if (buf_add(buf, &hdr, sizeof(hdr)) == -1) - fatal("buf_add error", 0); + fatalx("buf_add error"); mrt_dump_header(buf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE, len); @@ -111,10 +111,10 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen, int type, } if (buf_add(buf, pkg, pkglen) == -1) - fatal("buf_add error", 0); + fatalx("buf_add error"); if ((n = buf_close(mrt->msgbuf, buf)) < 0) - fatal("buf_close error", 0); + fatalx("buf_close error"); return (n); } @@ -137,9 +137,9 @@ mrt_dump_entry(struct mrt *mrt, struct prefix *p, u_int16_t snum, hdr.peerid = mrt->id; buf = buf_open(hdr.len); if (buf == NULL) - fatal("mrt_dump_entry", errno); + fatal("mrt_dump_entry"); if (buf_add(buf, &hdr, sizeof(hdr)) == -1) - fatal("buf_add error", 0); + fatalx("buf_add error"); mrt_dump_header(buf, MSG_TABLE_DUMP, AFI_IPv4, len); @@ -154,13 +154,13 @@ mrt_dump_entry(struct mrt *mrt, struct prefix *p, u_int16_t snum, DUMP_SHORT(buf, attr_len); if ((bptr = buf_reserve(buf, attr_len)) == NULL) - fatal("buf_reserve error", 0); + fatalx("buf_reserve error"); if (attr_dump(bptr, attr_len, &p->aspath->flags) == -1) - fatal("attr_dump error", 0); + fatalx("attr_dump error"); if ((n = buf_close(mrt->msgbuf, buf)) < 0) - fatal("buf_close error", 0); + fatalx("buf_close error"); return (n); } @@ -203,7 +203,7 @@ mrt_dump_header(struct buf *buf, u_int16_t type, u_int16_t subtype, mrt.length = htonl(len); if (buf_add(buf, &mrt, sizeof(mrt)) == -1) - fatal("buf_add error", 0); + fatalx("buf_add error"); } static int @@ -399,7 +399,7 @@ mrt_mergeconfig(struct mrt_config *xconf, struct mrt_config *conf) /* NEW */ if ((xm = calloc(1, sizeof(struct mrtdump_config))) == NULL) - fatal("mrt_mergeconfig", errno); + fatal("mrt_mergeconfig"); memcpy(xm, m, sizeof(struct mrtdump_config)); xm->id = max_id++; if (xm->ReopenTimerInterval != 0) { @@ -413,7 +413,7 @@ mrt_mergeconfig(struct mrt_config *xconf, struct mrt_config *conf) /* MERGE */ if (strlcpy(xm->name, m->name, sizeof(xm->name)) > sizeof(xm->name)) - fatal("mrt_mergeconfig: strlcpy", 0); + fatalx("mrt_mergeconfig: strlcpy"); xm->ReopenTimerInterval = m->ReopenTimerInterval; if (xm->ReopenTimerInterval != 0) { xm->ReopenTimer = now + xm->ReopenTimerInterval; diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 5e12c1d5e7a..f2dedab8e22 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.18 2003/12/25 23:23:51 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.19 2003/12/26 18:07:32 henning Exp $ */ /* * Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org> @@ -115,7 +115,7 @@ number : STRING { string : string STRING { if (asprintf(&$$, "%s %s", $1, $2) == -1) - fatal("string: asprintf", errno); + fatal("string: asprintf"); free($1); free($2); } @@ -126,7 +126,7 @@ varset : STRING '=' string { if (conf->opts & BGPD_OPT_VERBOSE) printf("%s = \"%s\"\n", $1, $3); if (symset($1, $3, 0) == -1) - fatal("cannot store variable", errno); + fatal("cannot store variable"); } ; @@ -287,7 +287,7 @@ yyerror(const char *fmt, ...) errors = 1; va_start(ap, fmt); if (asprintf(&nfmt, "%s:%d: %s", infile, yylval.lineno, fmt) == -1) - fatal("yyerror asprintf", 0); + fatal("yyerror asprintf"); vlog(LOG_CRIT, nfmt, ap); va_end(ap); free(nfmt); @@ -492,7 +492,7 @@ top: } yylval.v.string = strdup(buf); if (yylval.v.string == NULL) - fatal("yylex: strdup", errno); + fatal("yylex: strdup"); return (STRING); } @@ -515,7 +515,7 @@ top: token = lookup(buf); yylval.v.string = strdup(buf); if (yylval.v.string == NULL) - fatal("yylex: strdup", errno); + fatal("yylex: strdup"); return (token); } if (c == '\n') { @@ -534,9 +534,9 @@ parse_config(char *filename, struct bgpd_config *xconf, struct sym *sym, *next; if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL) - fatal(NULL, errno); + fatal(NULL); if ((mrtconf = calloc(1, sizeof(struct mrt_config))) == NULL) - fatal(NULL, errno); + fatal(NULL); LIST_INIT(mrtconf); curpeer = NULL; @@ -634,7 +634,7 @@ cmdline_symset(char *s) return (-1); if ((sym = malloc(strlen(s) - strlen(val) + 1)) == NULL) - fatal("cmdline_symset: malloc", errno); + fatal("cmdline_symset: malloc"); strlcpy(sym, s, strlen(s) - strlen(val) + 1); @@ -679,16 +679,16 @@ new_peer(void) struct peer *p; if ((p = calloc(1, sizeof(struct peer))) == NULL) - fatal("new_peer", errno); + fatal("new_peer"); if (curgroup != NULL) { memcpy(p, curgroup, sizeof(struct peer)); if (strlcpy(p->conf.group, curgroup->conf.group, sizeof(p->conf.group)) > sizeof(p->conf.group)) - fatal("new_peer strlcpy", 0); + fatalx("new_peer strlcpy"); if (strlcpy(p->conf.descr, curgroup->conf.descr, sizeof(p->conf.descr)) > sizeof(p->conf.descr)) - fatal("new_peer strlcpy", 0); + fatalx("new_peer strlcpy"); } p->state = STATE_NONE; p->next = NULL; @@ -705,7 +705,7 @@ new_group(void) struct peer *p; if ((p = calloc(1, sizeof(struct peer))) == NULL) - fatal("new_group", errno); + fatal("new_group"); return (p); } @@ -723,7 +723,7 @@ add_mrtconfig(enum mrtdump_type type, char *name, time_t timeout) } if ((n = calloc(1, sizeof(struct mrtdump_config))) == NULL) - fatal("add_mrtconfig", errno); + fatal("add_mrtconfig"); n->type = MRT_TABLE_DUMP; n->msgbuf.sock = -1; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index cbecc69fe20..12b7f98375b 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.31 2003/12/25 23:41:23 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.32 2003/12/26 18:07:33 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -79,7 +79,7 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) switch (pid = fork()) { case -1: - fatal("cannot fork", errno); + fatal("cannot fork"); case 0: break; default: @@ -89,10 +89,10 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) conf = config; if ((pw = getpwnam(BGPD_USER)) == NULL) - fatal("getpwnam", errno); + fatal("getpwnam"); if (chroot(pw->pw_dir) == -1) - fatal("chroot failed", errno); + fatal("chroot failed"); chdir("/"); setproctitle("route decision engine"); @@ -101,7 +101,7 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) { - fatal("can't drop privileges", errno); + fatal("can't drop privileges"); } endpwent(); @@ -135,7 +135,7 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) if ((nfds = poll(pfd, 2, INFTIM)) == -1) if (errno != EINTR) - fatal("poll error", errno); + fatal("poll error"); if (nfds > 0 && pfd[PFD_PIPE_MAIN].revents & POLLIN) rde_dispatch_imsg(&ibuf_main, PFD_PIPE_MAIN); @@ -147,14 +147,14 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) ibuf_main.w.queued) { nfds--; if ((n = msgbuf_write(&ibuf_main.w)) < 0) - fatal("pipe write error", errno); + fatal("pipe write error"); } if (nfds > 0 && (pfd[PFD_PIPE_SESSION].revents & POLLOUT) && ibuf_se.w.queued) { nfds--; if ((n = msgbuf_write(&ibuf_se.w)) < 0) - fatal("pipe write error", errno); + fatal("pipe write error"); } } @@ -175,16 +175,16 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx) switch (imsg.hdr.type) { case IMSG_RECONF_CONF: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatalx("reconf request not from parent"); if ((nconf = malloc(sizeof(struct bgpd_config))) == NULL) - fatal(NULL, errno); + fatal(NULL); memcpy(nconf, imsg.data, sizeof(struct bgpd_config)); nconf->peers = NULL; break; case IMSG_RECONF_PEER: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatalx("reconf request not from parent"); pconf = imsg.data; p = peer_get(pconf->id); /* will always fail atm */ if (p == NULL) @@ -196,9 +196,9 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx) break; case IMSG_RECONF_DONE: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatalx("reconf request not from parent"); if (nconf == NULL) - fatal("got IMSG_RECONF_DONE but no config", 0); + fatalx("got IMSG_RECONF_DONE but no config"); for (p = LIST_FIRST(&peerlist); p != LIST_END(&peerlist); p = np) { @@ -222,37 +222,37 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx) break; case IMSG_UPDATE: if (idx != PFD_PIPE_SESSION) - fatal("update msg not from session engine", 0); + fatalx("update msg not from session engine"); rde_update_dispatch(&imsg); break; case IMSG_SESSION_UP: if (idx != PFD_PIPE_SESSION) - fatal("session msg not from session engine", 0); + fatalx("session msg not from session engine"); if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(rid)) - fatal("incorrect size of session request", 0); + fatalx("incorrect size of session request"); memcpy(&rid, imsg.data, sizeof(rid)); peer_up(imsg.hdr.peerid, rid); break; case IMSG_SESSION_DOWN: if (idx != PFD_PIPE_SESSION) - fatal("session msg not from session engine", 0); + fatalx("session msg not from session engine"); peer_down(imsg.hdr.peerid); break; case IMSG_NEXTHOP_UPDATE: if (idx != PFD_PIPE_MAIN) - fatal("nexthop response not from parent", 0); + fatalx("nexthop response not from parent"); nexthop_update(imsg.data); break; case IMSG_MRT_REQ: if (idx != PFD_PIPE_MAIN) - fatal("mrt request not from parent", 0); + fatalx("mrt request not from parent"); mrtdump.id = imsg.hdr.peerid; mrtdump.msgbuf = &ibuf_main.w; pt_dump(mrt_dump_upcall, &mrtdump); /* FALLTHROUGH */ case IMSG_MRT_END: if (idx != PFD_PIPE_MAIN) - fatal("mrt request not from parent", 0); + fatalx("mrt request not from parent"); /* ignore end message because a dump is atomic */ imsg_compose(&ibuf_main, IMSG_MRT_END, imsg.hdr.peerid, NULL, 0); @@ -563,7 +563,7 @@ peer_init(struct bgpd_config *bgpconf, u_long hashsize) ; peertable.peer_hashtbl = calloc(hs, sizeof(struct rde_peer_head)); if (peertable.peer_hashtbl == NULL) - fatal("peer_init", errno); + fatal("peer_init"); for (i = 0; i < hs; i++) LIST_INIT(&peertable.peer_hashtbl[i]); @@ -606,7 +606,7 @@ peer_add(u_int32_t id, struct peer_config *p_conf) peer = calloc(1, sizeof(struct rde_peer)); if (peer == NULL) - fatal("peer_add", errno); + fatal("peer_add"); LIST_INIT(&peer->path_h); memcpy(&peer->conf, p_conf, sizeof(struct peer_config)); diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index af779875a44..6f79342ea96 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide.c,v 1.4 2003/12/24 11:39:43 henning Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.5 2003/12/26 18:07:33 henning Exp $ */ /* * Copyright (c) 2003 Claudio Jeker <claudio@openbsd.org> @@ -170,7 +170,7 @@ prefix_cmp(struct prefix *p1, struct prefix *p2) return (p2->peer->conf.remote_addr.sin_addr.s_addr - p1->peer->conf.remote_addr.sin_addr.s_addr); - fatal("Uh, oh a politician in the decision process", 0); + fatalx("Uh, oh a politician in the decision process"); /* NOTREACHED */ return 0; } diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index a8866e82a89..28573328418 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.4 2003/12/24 11:39:43 henning Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.5 2003/12/26 18:07:33 henning Exp $ */ /* * Copyright (c) 2003 Claudio Jeker <cjeker@diehard.n-r-g.com> @@ -106,7 +106,7 @@ pt_init(void) pttable[i].pt_hashtbl = calloc(pthashsize[i], sizeof(struct pt_entryhead)); if (pttable[i].pt_hashtbl == NULL) - fatal("pt_init", errno); + fatal("pt_init"); for (j = 0; j < pthashsize[i]; j++) LIST_INIT(&pttable[i].pt_hashtbl[j]); @@ -222,7 +222,7 @@ pt_alloc(void) PT_STAT(pt_alloc); p = calloc(1, sizeof(*p)); if (p == NULL) - fatal("pt_alloc", errno); + fatal("pt_alloc"); return p; } diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index eb93ec810e1..b7115a2c6e0 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.8 2003/12/25 23:41:23 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.9 2003/12/26 18:07:33 henning Exp $ */ /* * Copyright (c) 2003 Claudio Jeker <claudio@openbsd.org> @@ -270,7 +270,7 @@ aspath_create(void *data, u_int16_t len) /* The aspath must already have been checked for correctness. */ aspath = malloc(ASPATH_HEADER_SIZE + len); if (aspath == NULL) - fatal("aspath_create", errno); + fatal("aspath_create"); aspath->hdr.len = len; memcpy(aspath->data, data, len); @@ -332,7 +332,7 @@ aspath_neighbour(struct aspath *aspath) */ if (aspath->hdr.len < 2) - fatal("aspath_neighbour: aspath has no data", 0); + fatalx("aspath_neighbour: aspath has no data"); if (aspath->data[1] > 0) return aspath_extract(aspath->data, 0); @@ -399,7 +399,7 @@ path_init(u_long hashsize) ; pathtable.path_hashtbl = calloc(hs, sizeof(struct aspath_head)); if (pathtable.path_hashtbl == NULL) - fatal("path_init", errno); + fatal("path_init"); for (i = 0; i < hs; i++) LIST_INIT(&pathtable.path_hashtbl[i]); @@ -576,7 +576,7 @@ path_alloc(void) asp = calloc(1, sizeof(*asp)); if (asp == NULL) - fatal("path_alloc", errno); + fatal("path_alloc"); LIST_INIT(&asp->prefix_h); return asp; } @@ -859,7 +859,7 @@ prefix_alloc(void) p = calloc(1, sizeof(*p)); if (p == NULL) - fatal("prefix_alloc", errno); + fatal("prefix_alloc"); return p; } @@ -928,7 +928,7 @@ nexthop_init(u_long hashsize) ; nexthoptable.nexthop_hashtbl = calloc(hs, sizeof(struct aspath_head)); if (nexthoptable.nexthop_hashtbl == NULL) - fatal("nextop_init", errno); + fatal("nextop_init"); for (i = 0; i < hs; i++) LIST_INIT(&nexthoptable.nexthop_hashtbl[i]); @@ -1029,7 +1029,7 @@ nexthop_alloc(void) nh = calloc(1, sizeof(*nh)); if (nh == NULL) - fatal("nexthop_alloc", errno); + fatal("nexthop_alloc"); return nh; } diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 39f9753bd59..5e5508cc6eb 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.44 2003/12/26 16:37:04 henning Exp $ */ +/* $OpenBSD: session.c,v 1.45 2003/12/26 18:07:33 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -143,7 +143,7 @@ session_main(struct bgpd_config *config, int pipe_m2s[2], int pipe_s2r[2]) switch (pid = fork()) { case -1: - fatal("cannot fork", errno); + fatal("cannot fork"); case 0: break; default: @@ -151,22 +151,22 @@ session_main(struct bgpd_config *config, int pipe_m2s[2], int pipe_s2r[2]) } if ((pw = getpwnam(BGPD_USER)) == NULL) - fatal(NULL, errno); + fatal(NULL); if (chroot(pw->pw_dir) == -1) - fatal("chroot failed", errno); + fatal("chroot failed"); chdir("/"); setproctitle("session engine"); bgpd_process = PROC_SE; if ((sock = setup_listener()) == -1) - fatal("listener setup failed", 0); + fatal("listener setup failed"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) - fatal("can't drop privileges", errno); + fatal("can't drop privileges"); endpwent(); @@ -275,7 +275,7 @@ session_main(struct bgpd_config *config, int pipe_m2s[2], int pipe_s2r[2]) if (nfds > 0 && pfd[PFD_PIPE_ROUTE].revents & POLLOUT) if (msgbuf_write(&ibuf_rde.w) < 0) - fatal("pipe write error", errno); + fatal("pipe write error"); if (nfds > 0 && pfd[PFD_PIPE_ROUTE].revents & POLLIN) { nfds--; @@ -329,7 +329,7 @@ bgp_fsm(struct peer *peer, enum session_events event) /* allocate read buffer */ peer->rbuf = calloc(1, sizeof(struct peer_buf_read)); if (peer->rbuf == NULL) - fatal(NULL, errno); + fatal(NULL); peer->rbuf->wpos = 0; /* init write buffer */ @@ -755,7 +755,7 @@ session_socket_blockmode(int fd, enum blockmodes bm) int flags; if ((flags = fcntl(fd, F_GETFL, 0)) == -1) - fatal("fnctl F_GETFL", errno); + fatal("fnctl F_GETFL"); if (bm == BM_NONBLOCK) flags |= O_NONBLOCK; @@ -763,7 +763,7 @@ session_socket_blockmode(int fd, enum blockmodes bm) flags &= ~O_NONBLOCK; if ((flags = fcntl(fd, F_SETFL, flags)) == -1) - fatal("fnctl F_SETFL", errno); + fatal("fnctl F_SETFL"); } void @@ -1240,10 +1240,10 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) switch (imsg.hdr.type) { case IMSG_RECONF_CONF: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatal("reconf request not from parent"); if ((nconf = malloc(sizeof(struct bgpd_config))) == NULL) - fatal(NULL, errno); + fatal(NULL); memcpy(nconf, imsg.data, sizeof(struct bgpd_config)); nconf->peers = NULL; init_conf(nconf); @@ -1251,13 +1251,13 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) break; case IMSG_RECONF_PEER: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatal("reconf request not from parent"); pconf = imsg.data; p = getpeerbyip(pconf->remote_addr.sin_addr.s_addr); if (p == NULL) { if ((p = calloc(1, sizeof(struct peer))) == NULL) - fatal("new_peer", errno); + fatal("new_peer"); p->state = STATE_NONE; p->sock = -1; p->next = nconf->peers; @@ -1298,9 +1298,9 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) break; case IMSG_RECONF_DONE: if (idx != PFD_PIPE_MAIN) - fatal("reconf request not from parent", 0); + fatal("reconf request not from parent"); if (nconf == NULL) - fatal("got IMSG_RECONF_DONE but no config", 0); + fatal("got IMSG_RECONF_DONE but no config"); conf->as = nconf->as; conf->holdtime = nconf->holdtime; conf->bgpid = nconf->bgpid; |