From e9c1bd19fc1d465ccab245e1368e92d44b983bdc Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Tue, 29 May 2007 22:08:26 +0000 Subject: Demote support for ospfd. It is possible to specify a demote group on interfaces and areas. With this carp setups using ospfd are more reliable because we can fail over if the OSPF connectivity is (partially) lost. OK norby@ --- usr.sbin/ospfd/ospfd.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'usr.sbin/ospfd/ospfd.c') diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index d27330b1094..e71744f1119 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.45 2007/03/25 15:48:54 claudio Exp $ */ +/* $OpenBSD: ospfd.c,v 1.46 2007/05/29 22:08:25 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -117,7 +117,7 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-dnv] [-f file]\n", __progname); + fprintf(stderr, "usage: %s [-cdnv] [-f file]\n", __progname); exit(1); } @@ -135,8 +135,11 @@ main(int argc, char *argv[]) conffile = CONF_FILE; ospfd_process = PROC_MAIN; - while ((ch = getopt(argc, argv, "df:nv")) != -1) { + while ((ch = getopt(argc, argv, "cdf:nv")) != -1) { switch (ch) { + case 'c': + opts |= OSPFD_OPT_FORCE_DEMOTE; + break; case 'd': debug = 1; break; @@ -295,6 +298,7 @@ ospfd_shutdown(void) control_cleanup(); kr_shutdown(); + carp_demote_shutdown(); do { if ((pid = wait(NULL)) == -1 && @@ -339,6 +343,7 @@ main_dispatch_ospfe(int fd, short event, void *bula) { struct imsgbuf *ibuf = bula; struct imsg imsg; + struct demote_msg dmsg; ssize_t n; switch (event) { @@ -389,6 +394,12 @@ main_dispatch_ospfe(int fd, short event, void *bula) else log_warnx("IFINFO request with wrong len"); break; + case IMSG_DEMOTE: + if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(dmsg)) + fatalx("invalid size of OE request"); + memcpy(&dmsg, imsg.data, sizeof(dmsg)); + carp_demote_set(dmsg.demote_group, dmsg.level); + break; default: log_debug("main_dispatch_ospfe: error handling imsg %d", imsg.hdr.type); @@ -667,6 +678,7 @@ merge_config(struct ospfd_conf *conf, struct ospfd_conf *xconf) LIST_INSERT_HEAD(&conf->area_list, xa, entry); if (ospfd_process == PROC_OSPF_ENGINE) { /* start interfaces */ + ospfe_demote_area(xa, 0); LIST_FOREACH(iface, &xa->iface_list, entry) { if_init(conf, iface); if (if_fsm(iface, IF_EVT_UP)) { -- cgit v1.2.3