summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-05-30 22:06:15 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-05-30 22:06:15 +0000
commit5bc3fb6c03f4b58eeb1e8d3415ba237c038012ef (patch)
tree5fcde6511e5c6684bc93463d43a9a3351bb33cc4 /usr.sbin
parent7c64d3e8bc5fd64282ed43449546709d46d85ab4 (diff)
Now that rtlabels are accessable via sysctl we can use route lables to
define which routes should be redistributed via OSPF. So now you can define the export list on a fine graded basis. More to come... OK norby@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ospfd/Makefile4
-rw-r--r--usr.sbin/ospfd/kroute.c47
-rw-r--r--usr.sbin/ospfd/name2id.c173
-rw-r--r--usr.sbin/ospfd/ospfd.c38
-rw-r--r--usr.sbin/ospfd/ospfd.h31
-rw-r--r--usr.sbin/ospfd/parse.y60
-rw-r--r--usr.sbin/ospfd/printconf.c47
-rw-r--r--usr.sbin/ospfd/rde.c8
8 files changed, 348 insertions, 60 deletions
diff --git a/usr.sbin/ospfd/Makefile b/usr.sbin/ospfd/Makefile
index 213d238d281..32711d92990 100644
--- a/usr.sbin/ospfd/Makefile
+++ b/usr.sbin/ospfd/Makefile
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.4 2005/05/26 18:46:15 norby Exp $
+# $OpenBSD: Makefile,v 1.5 2006/05/30 22:06:14 claudio Exp $
PROG= ospfd
SRCS= area.c auth.c buffer.c control.c database.c hello.c \
imsg.c in_cksum.c interface.c iso_cksum.c kroute.c lsack.c \
lsreq.c lsupdate.c log.c neighbor.c ospfd.c ospfe.c packet.c \
- parse.y printconf.c rde.c rde_lsdb.c rde_spf.c
+ parse.y printconf.c rde.c rde_lsdb.c rde_spf.c name2id.c
MAN= ospfd.8 ospfd.conf.5
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index 1cbf4c94653..c9de2511234 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.32 2006/05/27 19:28:20 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.33 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -177,6 +177,8 @@ kr_change(struct kroute *kroute)
action = RTM_CHANGE;
kr->r.flags = kroute->flags | F_OSPFD_INSERTED;
kr->r.ifindex = 0;
+ rtlabel_unref(kr->r.rtlabel);
+ kr->r.rtlabel = 0;
}
}
@@ -221,7 +223,6 @@ kr_delete(struct kroute *kroute)
if (kr->r.flags & F_KERNEL) {
/* remove F_OSPFD_INSERTED flag, route still exists in kernel */
kr->r.flags &= ~F_OSPFD_INSERTED;
- kr->r.ifindex = 0; /* ifindex is no longer relevant */
return (0);
}
@@ -345,11 +346,12 @@ kr_redistribute(int type, struct kroute *kr)
if (type == IMSG_NETWORK_DEL) {
+dont_redistribute:
/* was the route redistributed? */
if (kr->flags & F_REDISTRIBUTED) {
- /* remove redistributed flag */
+ /* remove redistributed flag and inform the RDE */
kr->flags &= ~F_REDISTRIBUTED;
- main_imsg_compose_rde(type, 0, kr,
+ main_imsg_compose_rde(IMSG_NETWORK_DEL, 0, kr,
sizeof(struct kroute));
}
return;
@@ -357,15 +359,15 @@ kr_redistribute(int type, struct kroute *kr)
/* Only non-ospfd routes are considered for redistribution. */
if (!(kr->flags & F_KERNEL))
- return;
+ goto dont_redistribute;
/* Dynamic routes are not redistributable. */
if (kr->flags & F_DYNAMIC)
- return;
+ goto dont_redistribute;
/* interface is not up and running so don't announce */
if (kr->flags & F_DOWN)
- return;
+ goto dont_redistribute;
/*
* We consider the loopback net, multicast and experimental addresses
@@ -374,16 +376,16 @@ kr_redistribute(int type, struct kroute *kr)
a = ntohl(kr->prefix.s_addr);
if (IN_MULTICAST(a) || IN_BADCLASS(a) ||
(a >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET)
- return;
+ goto dont_redistribute;
/*
* Consider networks with nexthop loopback as not redistributable.
*/
if (kr->nexthop.s_addr == htonl(INADDR_LOOPBACK))
- return;
+ goto dont_redistribute;
/* Should we redistrubute this route? */
if (!ospf_redistribute(kr))
- return;
+ goto dont_redistribute;
/* Does not matter if we resend the kr, the RDE will cope. */
kr->flags |= F_REDISTRIBUTED;
@@ -459,6 +461,7 @@ kroute_remove(struct kroute_node *kr)
}
kr_redistribute(IMSG_NETWORK_DEL, &kr->r);
+ rtlabel_unref(kr->r.rtlabel);
free(kr);
return (0);
@@ -780,6 +783,7 @@ fetchtable(void)
struct rt_msghdr *rtm;
struct sockaddr *sa, *rti_info[RTAX_MAX];
struct sockaddr_in *sa_in;
+ struct sockaddr_rtlabel *label;
struct kroute_node *kr;
mib[0] = CTL_NET;
@@ -870,8 +874,13 @@ fetchtable(void)
if (rtm->rtm_flags & RTF_PROTO2) {
send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
free(kr);
- } else
+ } else {
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL)
+ kr->r.rtlabel =
+ rtlabel_name2id(label->sr_label);
kroute_insert(kr);
+ }
}
free(buf);
@@ -963,6 +972,7 @@ dispatch_rtmsg(void)
struct if_msghdr ifm;
struct sockaddr *sa, *rti_info[RTAX_MAX];
struct sockaddr_in *sa_in;
+ struct sockaddr_rtlabel *label;
struct kroute_node *kr;
struct in_addr prefix, nexthop;
u_int8_t prefixlen;
@@ -1057,10 +1067,19 @@ dispatch_rtmsg(void)
/* pref is not checked because this is forced */
if (kr->r.flags & F_OSPFD_INSERTED)
flags |= F_OSPFD_INSERTED;
+ if (kr->r.flags & F_REDISTRIBUTED)
+ flags |= F_REDISTRIBUTED;
kr->r.nexthop.s_addr = nexthop.s_addr;
kr->r.flags = flags;
kr->r.ifindex = ifindex;
+ rtlabel_unref(kr->r.rtlabel);
+ kr->r.rtlabel = 0;
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL)
+ kr->r.rtlabel =
+ rtlabel_name2id(label->sr_label);
+
if (kif_validate(kr->r.ifindex))
kr->r.flags &= ~F_DOWN;
else
@@ -1080,6 +1099,11 @@ dispatch_rtmsg(void)
kr->r.flags = flags;
kr->r.ifindex = ifindex;
+ if ((label = (struct sockaddr_rtlabel *)
+ rti_info[RTAX_LABEL]) != NULL)
+ kr->r.rtlabel =
+ rtlabel_name2id(label->sr_label);
+
kroute_insert(kr);
}
break;
@@ -1092,6 +1116,7 @@ dispatch_rtmsg(void)
if (kr->r.flags & F_OSPFD_INSERTED)
main_imsg_compose_rde(IMSG_KROUTE_GET, 0,
&kr->r, sizeof(struct kroute));
+ rtlabel_unref(kr->r.rtlabel);
if (kroute_remove(kr) == -1)
return (-1);
break;
diff --git a/usr.sbin/ospfd/name2id.c b/usr.sbin/ospfd/name2id.c
new file mode 100644
index 00000000000..e72dfce0f86
--- /dev/null
+++ b/usr.sbin/ospfd/name2id.c
@@ -0,0 +1,173 @@
+/* $OpenBSD: name2id.c,v 1.1 2006/05/30 22:06:14 claudio Exp $ */
+
+/*
+ * Copyright (c) 2004, 2005 Henning Brauer <henning@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/route.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ospfd.h"
+
+#define IDVAL_MAX 50000
+
+struct n2id_label {
+ TAILQ_ENTRY(n2id_label) entry;
+ char *name;
+ u_int16_t id;
+ int ref;
+};
+
+TAILQ_HEAD(n2id_labels, n2id_label);
+
+u_int16_t _name2id(struct n2id_labels *, const char *);
+const char *_id2name(struct n2id_labels *, u_int16_t);
+void _unref(struct n2id_labels *, u_int16_t);
+void _ref(struct n2id_labels *, u_int16_t);
+
+struct n2id_labels rt_labels = TAILQ_HEAD_INITIALIZER(rt_labels);
+
+u_int16_t
+rtlabel_name2id(const char *name)
+{
+ return (_name2id(&rt_labels, name));
+}
+
+const char *
+rtlabel_id2name(u_int16_t id)
+{
+ return (_id2name(&rt_labels, id));
+}
+
+void
+rtlabel_unref(u_int16_t id)
+{
+ _unref(&rt_labels, id);
+}
+
+/*
+void
+rtlabel_ref(u_int16_t id)
+{
+ _ref(&rt_labels, id);
+}
+*/
+
+u_int16_t
+_name2id(struct n2id_labels *head, const char *name)
+{
+ struct n2id_label *label, *p = NULL;
+ u_int16_t new_id = 1;
+
+ if (!name[0]) {
+ errno = EINVAL;
+ return (0);
+ }
+
+ TAILQ_FOREACH(label, head, entry)
+ if (strcmp(name, label->name) == 0) {
+ label->ref++;
+ return (label->id);
+ }
+
+ /*
+ * to avoid fragmentation, we do a linear search from the beginning
+ * and take the first free slot we find. if there is none or the list
+ * is empty, append a new entry at the end.
+ */
+
+ if (!TAILQ_EMPTY(head))
+ for (p = TAILQ_FIRST(head); p != NULL &&
+ p->id == new_id; p = TAILQ_NEXT(p, entry))
+ new_id = p->id + 1;
+
+ if (new_id > IDVAL_MAX) {
+ errno = ERANGE;
+ return (0);
+ }
+
+ if ((label = calloc(1, sizeof(struct n2id_label))) == NULL)
+ return (0);
+ if ((label->name = strdup(name)) == NULL) {
+ free(label);
+ return (0);
+ }
+ label->id = new_id;
+ label->ref++;
+
+ if (p != NULL) /* insert new entry before p */
+ TAILQ_INSERT_BEFORE(p, label, entry);
+ else /* either list empty or no free slot in between */
+ TAILQ_INSERT_TAIL(head, label, entry);
+
+ return (label->id);
+}
+
+const char *
+_id2name(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *label;
+
+ if (id == 0)
+ return ("");
+
+ TAILQ_FOREACH(label, head, entry)
+ if (label->id == id)
+ return (label->name);
+
+ return ("");
+}
+
+void
+_unref(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *p, *next;
+
+ if (id == 0)
+ return;
+
+ for (p = TAILQ_FIRST(head); p != NULL; p = next) {
+ next = TAILQ_NEXT(p, entry);
+ if (id == p->id) {
+ if (--p->ref == 0) {
+ TAILQ_REMOVE(head, p, entry);
+ free(p->name);
+ free(p);
+ }
+ break;
+ }
+ }
+}
+
+void
+_ref(struct n2id_labels *head, u_int16_t id)
+{
+ struct n2id_label *label;
+
+ if (id == 0)
+ return;
+
+ TAILQ_FOREACH(label, head, entry)
+ if (label->id == id) {
+ ++label->ref;
+ break;
+ }
+}
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 8c695b0185e..fd07d6bb078 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.31 2006/03/27 11:57:24 claudio Exp $ */
+/* $OpenBSD: ospfd.c,v 1.32 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -489,6 +489,8 @@ imsg_event_add(struct imsgbuf *ibuf)
int
ospf_redistribute(struct kroute *kr)
{
+ struct redistribute *r;
+
/* stub area router? */
if ((conf->options & OSPF_OPTION_E) == 0)
return (0);
@@ -497,12 +499,32 @@ ospf_redistribute(struct kroute *kr)
if (kr->prefix.s_addr == INADDR_ANY && kr->prefixlen == 0)
return (0);
- if ((conf->redistribute_flags & REDISTRIBUTE_STATIC) &&
- (kr->flags & F_STATIC))
- return (1);
- if ((conf->redistribute_flags & REDISTRIBUTE_CONNECTED) &&
- (kr->flags & F_CONNECTED))
- return (1);
+ SIMPLEQ_FOREACH(r, &conf->redist_list, entry) {
+ switch (r->type) {
+ case REDIST_LABEL:
+ if (kr->rtlabel == r->label)
+ return (1);
+ break;
+ case REDIST_STATIC:
+ /*
+ * Dynamic routes are not redistributable. Placed here
+ * so that link local addresses can be redistributed
+ * via a rtlabel.
+ */
+ if (kr->flags & F_DYNAMIC)
+ continue;
+ if (kr->flags & F_STATIC)
+ return (1);
+ case REDIST_CONNECTED:
+ if (kr->flags & F_DYNAMIC)
+ continue;
+ if (kr->flags & F_CONNECTED)
+ return (1);
+ case REDIST_ADDR:
+ /* ignore */
+ break;
+ }
+ }
return (0);
}
@@ -513,7 +535,7 @@ ospf_redistribute_default(int type)
struct kroute kr;
bzero(&kr, sizeof(kr));
- if (conf->redistribute_flags & REDISTRIBUTE_DEFAULT)
+ if (conf->redistribute & REDISTRIBUTE_DEFAULT)
main_imsg_compose_rde(type, 0, &kr, sizeof(struct kroute));
}
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 51dd18c9049..e513c0d7af9 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.57 2006/04/25 08:22:14 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.58 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -57,9 +57,8 @@
#define F_DYNAMIC 0x0040
#define F_REDISTRIBUTED 0x0100
-#define REDISTRIBUTE_STATIC 0x01
-#define REDISTRIBUTE_CONNECTED 0x02
-#define REDISTRIBUTE_DEFAULT 0x04
+#define REDISTRIBUTE_ON 0x01
+#define REDISTRIBUTE_DEFAULT 0x02
/* buffer */
struct buf {
@@ -362,11 +361,27 @@ enum {
PROC_RDE_ENGINE
} ospfd_process;
+enum redist_types {
+ REDIST_CONNECTED,
+ REDIST_STATIC,
+ REDIST_LABEL,
+ REDIST_ADDR
+};
+
+struct redistribute {
+ SIMPLEQ_ENTRY(redistribute) entry;
+ struct in_addr addr;
+ struct in_addr mask;
+ u_int16_t label;
+ enum redist_types type;
+};
+
struct ospfd_conf {
struct event ev;
struct in_addr rtr_id;
LIST_HEAD(, area) area_list;
LIST_HEAD(, vertex) cand_list;
+ SIMPLEQ_HEAD(, redistribute) redist_list;
u_int32_t opts;
#define OSPFD_OPT_VERBOSE 0x00000001
@@ -377,10 +392,10 @@ struct ospfd_conf {
int spf_state;
int ospf_socket;
int flags;
- int redistribute_flags;
int options; /* OSPF options */
u_int8_t rfc1583compat;
u_int8_t border;
+ u_int8_t redistribute;
};
/* kroute */
@@ -388,6 +403,7 @@ struct kroute {
struct in_addr prefix;
struct in_addr nexthop;
u_int16_t flags;
+ u_int16_t rtlabel;
u_short ifindex;
u_int8_t prefixlen;
};
@@ -553,6 +569,11 @@ const char *if_auth_name(enum auth_type);
const char *dst_type_name(enum dst_type);
const char *path_type_name(enum path_type);
+/* name2id.c */
+u_int16_t rtlabel_name2id(const char *);
+const char *rtlabel_id2name(u_int16_t);
+void rtlabel_unref(u_int16_t);
+
/* ospfd.c */
void main_imsg_compose_ospfe(int, pid_t, void *, u_int16_t);
void main_imsg_compose_rde(int, pid_t, void *, u_int16_t);
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index 0f09a733c09..be15aa0244f 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.30 2006/05/26 01:06:12 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.31 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -106,7 +106,7 @@ typedef struct {
%}
-%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE
+%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL
%token RFC1583COMPAT SPFDELAY SPFHOLDTIME
%token AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
%token METRIC PASSIVE
@@ -191,23 +191,42 @@ conf_main : ROUTERID STRING {
conf->flags &= ~OSPFD_FLAG_NO_FIB_UPDATE;
}
| REDISTRIBUTE STRING {
- if (!strcmp($2, "static"))
- conf->redistribute_flags |=
- REDISTRIBUTE_STATIC;
- else if (!strcmp($2, "connected"))
- conf->redistribute_flags |=
- REDISTRIBUTE_CONNECTED;
- else if (!strcmp($2, "default"))
- conf->redistribute_flags |=
- REDISTRIBUTE_DEFAULT;
- else if (!strcmp($2, "none"))
- conf->redistribute_flags = 0;
+ struct redistribute *r;
+
+ if (!strcmp($2, "default"))
+ conf->redistribute |= REDISTRIBUTE_DEFAULT;
else {
- yyerror("unknown redistribute type");
+ if ((r = calloc(1, sizeof(*r))) == NULL)
+ fatal(NULL);
+ if (!strcmp($2, "static"))
+ r->type = REDIST_STATIC;
+ else if (!strcmp($2, "connected"))
+ r->type = REDIST_CONNECTED;
+ else {
+ yyerror("unknown redistribute type");
+ free($2);
+ free(r);
+ YYERROR;
+ }
free($2);
- YYERROR;
+
+ SIMPLEQ_INSERT_TAIL(&conf->redist_list, r,
+ entry);
}
- free($2);
+ conf->redistribute |= REDISTRIBUTE_ON;
+
+ }
+ | REDISTRIBUTE RTLABEL STRING {
+ struct redistribute *r;
+
+ if ((r = calloc(1, sizeof(*r))) == NULL)
+ fatal(NULL);
+ r->type = REDIST_LABEL;
+ r->label = rtlabel_name2id($3);
+ free($3);
+
+ SIMPLEQ_INSERT_TAIL(&conf->redist_list, r, entry);
+ conf->redistribute |= REDISTRIBUTE_ON;
}
| RFC1583COMPAT yesno {
conf->rfc1583compat = $2;
@@ -484,6 +503,7 @@ lookup(char *s)
{"router-dead-time", ROUTERDEADTIME},
{"router-id", ROUTERID},
{"router-priority", ROUTERPRIORITY},
+ {"rtlabel", RTLABEL},
{"spf-delay", SPFDELAY},
{"spf-holdtime", SPFHOLDTIME},
{"transmit-delay", TRANSMITDELAY}
@@ -694,10 +714,8 @@ parse_config(char *filename, int opts)
{
struct sym *sym, *next;
- if ((conf = calloc(1, sizeof(struct ospfd_conf))) == NULL) {
- errx(1, "parse_config calloc");
- return (NULL);
- }
+ if ((conf = calloc(1, sizeof(struct ospfd_conf))) == NULL)
+ fatal("parse_config");
bzero(&globaldefs, sizeof(globaldefs));
defs = &globaldefs;
@@ -723,6 +741,8 @@ parse_config(char *filename, int opts)
conf->opts = opts;
LIST_INIT(&conf->area_list);
+ LIST_INIT(&conf->cand_list);
+ SIMPLEQ_INIT(&conf->redist_list);
if (!(conf->opts & OSPFD_OPT_NOACTION))
if (check_file_secrecy(fileno(fin), filename)) {
diff --git a/usr.sbin/ospfd/printconf.c b/usr.sbin/ospfd/printconf.c
index 025b7653632..2960f9fc38c 100644
--- a/usr.sbin/ospfd/printconf.c
+++ b/usr.sbin/ospfd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.2 2005/10/19 22:00:37 stevesk Exp $ */
+/* $OpenBSD: printconf.c,v 1.3 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -28,38 +28,59 @@
#include "ospfd.h"
#include "ospfe.h"
-void print_mainconf(struct ospfd_conf *);
-void print_iface(struct iface *);
+void print_mainconf(struct ospfd_conf *);
+void print_redistribute(struct ospfd_conf *);
+void print_iface(struct iface *);
void
print_mainconf(struct ospfd_conf *conf)
{
+ printf("router-id %s\n", inet_ntoa(conf->rtr_id));
+
if (conf->flags |= OSPFD_FLAG_NO_FIB_UPDATE)
printf("fib-update yes\n");
else
printf("fib-update no\n");
- if (conf->redistribute_flags & REDISTRIBUTE_STATIC)
- printf("redistribute static\n");
- if (conf->redistribute_flags & REDISTRIBUTE_CONNECTED)
- printf("redistribute connected\n");
- if (conf->redistribute_flags & REDISTRIBUTE_DEFAULT)
- printf("redistribute default\n");
- if (conf->redistribute_flags == 0)
- printf("redistribute none\n");
-
if (conf->rfc1583compat)
printf("rfc1583compat yes\n");
else
printf("rfc1583compat no\n");
- printf("router-id %s\n", inet_ntoa(conf->rtr_id));
+ print_redistribute(conf);
printf("spf-delay %u\n", conf->spf_delay);
printf("spf-holdtime %u\n", conf->spf_hold_time);
}
void
+print_redistribute(struct ospfd_conf *conf)
+{
+ struct redistribute *r;
+
+ if (conf->redistribute & REDISTRIBUTE_DEFAULT)
+ printf("redistribute default\n");
+
+ SIMPLEQ_FOREACH(r, &conf->redist_list, entry) {
+ switch (r->type) {
+ case REDIST_STATIC:
+ printf("redistribute static\n");
+ break;
+ case REDIST_CONNECTED:
+ printf("redistribute connected\n");
+ break;
+ case REDIST_LABEL:
+ printf("redistribute rtlabel %s\n",
+ rtlabel_id2name(r->label));
+ break;
+ case REDIST_ADDR:
+ /* ignore for now */
+ break;
+ }
+ }
+}
+
+void
print_iface(struct iface *iface)
{
struct auth_md *md;
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 584f6e911c7..9ef7fc6e195 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.45 2006/05/29 16:50:36 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.46 2006/05/30 22:06:14 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -92,6 +92,7 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2],
int pipe_parent2ospfe[2])
{
struct passwd *pw;
+ struct redistribute *r;
struct event ev_sigint, ev_sigterm;
pid_t pid;
@@ -160,6 +161,11 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2],
cand_list_init();
rt_init();
+ while ((r = SIMPLEQ_FIRST(&rdeconf->redist_list)) != NULL) {
+ SIMPLEQ_REMOVE_HEAD(&rdeconf->redist_list, entry);
+ free(r);
+ }
+
event_dispatch();
rde_shutdown();