diff options
author | 2007-10-24 19:05:06 +0000 | |
---|---|---|
committer | 2007-10-24 19:05:06 +0000 | |
commit | 2a8226da3c2cae26cb00c3d32b45b8310522dfa8 (patch) | |
tree | b77e441adb085cff2cf437193f8a6a701045a9e8 /usr.sbin/ripd/rde.c | |
parent | Uncomment PECI mode diagnosting bits. (diff) | |
download | wireguard-openbsd-2a8226da3c2cae26cb00c3d32b45b8310522dfa8.tar.xz wireguard-openbsd-2a8226da3c2cae26cb00c3d32b45b8310522dfa8.zip |
Sync a bit more with ospfd. Do not fatal if one of the pipes is closed,
instead do a "nice" shutdown. Ignore SIGHUP in the childs even though we
have no reload support (yet). Remove some redundant code and clean up some
types.
Diffstat (limited to 'usr.sbin/ripd/rde.c')
-rw-r--r-- | usr.sbin/ripd/rde.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c index b7152bf7ec1..1f98731b106 100644 --- a/usr.sbin/ripd/rde.c +++ b/usr.sbin/ripd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.7 2007/10/18 17:00:59 deraadt Exp $ */ +/* $OpenBSD: rde.c,v 1.8 2007/10/24 19:05:06 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -115,6 +115,7 @@ rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2], signal_add(&ev_sigint, NULL); signal_add(&ev_sigterm, NULL); signal(SIGPIPE, SIG_IGN); + signal(SIGHUP, SIG_IGN); /* setup pipes */ close(pipe_ripe2rde[0]); @@ -169,7 +170,6 @@ rde_shutdown(void) _exit(0); } -/* imesg */ int rde_imsg_compose_ripe(int type, u_int32_t peerid, pid_t pid, void *data, u_int16_t datalen) @@ -184,14 +184,15 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct imsgbuf *ibuf = bula; struct rip_route rr; struct imsg imsg; - int n; + ssize_t n; + int shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -265,7 +266,13 @@ rde_dispatch_imsg(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } /* ARGSUSED */ @@ -277,13 +284,14 @@ rde_dispatch_parent(int fd, short event, void *bula) struct kroute kr; struct imsgbuf *ibuf = bula; ssize_t n; + int shut = 0; switch (event) { case EV_READ: if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) /* connection closed */ - fatalx("pipe closed"); + shut = 1; break; case EV_WRITE: if (msgbuf_write(&ibuf->w) == -1) @@ -346,7 +354,13 @@ rde_dispatch_parent(int fd, short event, void *bula) } imsg_free(&imsg); } - imsg_event_add(ibuf); + if (!shut) + imsg_event_add(ibuf); + else { + /* this pipe is dead, so remove the event handler */ + event_del(&ibuf->ev); + event_loopexit(NULL); + } } void @@ -391,11 +405,7 @@ rde_check_route(struct rip_route *e) if ((e->nexthop.s_addr & htonl(IN_CLASSA_NET)) == htonl(INADDR_LOOPBACK & IN_CLASSA_NET) || - (e->nexthop.s_addr == INADDR_ANY)) - return (-1); - - if ((e->address.s_addr & htonl(IN_CLASSA_NET)) == - htonl(INADDR_LOOPBACK & IN_CLASSA_NET)) + e->nexthop.s_addr == INADDR_ANY) return (-1); if ((iface = if_find_index(e->ifindex)) == NULL) |