summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-10-11 19:02:48 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-10-11 19:02:48 +0000
commitdeb1254f305c711065855299168d55d33b866098 (patch)
tree1fa060d968a5621c7675df28433805cb21ea1bb2 /usr.sbin/ospf6d
parentc21299fb858339f872a81938f9e140b59c1f620d (diff)
From ospfd:
Bye bye global ospf options. OSPF options are per area (at least the one flag that we set). So introduce a area_ospf_options() function that will return the correct flags for each area. This makes stub area support a lot easier. Don't check for OSPF_OPTION_E in the parent. OSPF_OPTION_E is per area and so the parent process has no way to know if it should redistribute or not.
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/area.c13
-rw-r--r--usr.sbin/ospf6d/database.c4
-rw-r--r--usr.sbin/ospf6d/hello.c14
-rw-r--r--usr.sbin/ospf6d/ospf6d.c6
-rw-r--r--usr.sbin/ospf6d/ospf6d.h6
-rw-r--r--usr.sbin/ospf6d/ospfe.c4
-rw-r--r--usr.sbin/ospf6d/parse.y3
-rw-r--r--usr.sbin/ospf6d/rde.c8
8 files changed, 32 insertions, 26 deletions
diff --git a/usr.sbin/ospf6d/area.c b/usr.sbin/ospf6d/area.c
index 31e09e6a030..c05fd1ece31 100644
--- a/usr.sbin/ospf6d/area.c
+++ b/usr.sbin/ospf6d/area.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: area.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: area.c,v 1.2 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -115,3 +115,14 @@ area_border_router(struct ospfd_conf *conf)
return (active > 1);
}
+
+u_int32_t
+area_ospf_options(struct area *area)
+{
+ u_int32_t opt = OSPF_OPTION_V6 | OSPF_OPTION_R;
+
+ if (area && !area->stub)
+ opt |= OSPF_OPTION_E;
+
+ return (opt);
+}
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index 3179ade15c0..5096edb8841 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.3 2007/10/11 18:43:42 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.4 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -134,7 +134,7 @@ send_db_description(struct nbr *nbr)
fatalx("send_db_description: unknown interface type");
}
- dd_hdr.opts = oeconf->options;
+ dd_hdr.opts = area_ospf_options(nbr->iface->area);
dd_hdr.bits = bits;
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c
index 26e93bd596a..4bd442298d6 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.4 2007/10/10 14:09:25 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.5 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -43,6 +43,7 @@ send_hello(struct iface *iface)
struct nbr *nbr;
struct buf *buf;
int ret;
+ u_int32_t opts;
switch (iface->type) {
case IF_TYPE_POINTOPOINT:
@@ -73,10 +74,10 @@ send_hello(struct iface *iface)
hello.iface_id = iface->ifindex;
hello.rtr_priority = iface->priority;
- /* XXX options */
- hello.opts1 = 0;
- hello.opts2 = 0;
- hello.opts3 = OSPF_OPTION_V6 | OSPF_OPTION_E | OSPF_OPTION_R; /* XXX */
+ opts = area_ospf_options(iface->area);
+ hello.opts1 = (opts >> 16) & 0xff;
+ hello.opts2 = (opts >> 8) & 0xff;
+ hello.opts3 = opts & 0xff;
hello.hello_interval = htons(iface->hello_interval);
hello.rtr_dead_interval = htons(iface->dead_interval);
@@ -204,9 +205,8 @@ XXX
}
/* actually the neighbor address shouldn't be stored on virtual links */
-//XXX nbr->addr.s_addr = src.s_addr;
nbr->addr = *src;
- nbr->options = hello.opts3; /* XXX */
+ nbr->options = (hello.opts1 << 16) | (hello.opts2 << 8) | hello.opts3;
nbr_fsm(nbr, NBR_EVT_HELLO_RCVD);
diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c
index c8a5d576f11..86d5cc1fd18 100644
--- a/usr.sbin/ospf6d/ospf6d.c
+++ b/usr.sbin/ospf6d/ospf6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */
+/* $OpenBSD: ospf6d.c,v 1.2 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -530,10 +530,6 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
{
struct redistribute *r;
- /* stub area router? */
- if ((ospfd_conf->options & OSPF_OPTION_E) == 0)
- return (0);
-
/* only allow 0.0.0.0/0 via REDISTRIBUTE_DEFAULT */
if (kr->prefix.s_addr == INADDR_ANY && kr->prefixlen == 0)
return (0);
diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h
index a3d093934cb..074d7c2d8a4 100644
--- a/usr.sbin/ospf6d/ospf6d.h
+++ b/usr.sbin/ospf6d/ospf6d.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.h,v 1.2 2007/10/09 06:12:04 claudio Exp $ */
+/* $OpenBSD: ospf6d.h,v 1.3 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org>
@@ -388,7 +388,6 @@ struct ospfd_conf {
int spf_state;
int ospf_socket;
int flags;
- int options; /* OSPF options */
u_int8_t border;
u_int8_t redistribute;
};
@@ -484,10 +483,10 @@ struct ctl_nbr {
u_int32_t ls_req_lst_cnt;
u_int32_t ls_retrans_lst_cnt;
u_int32_t state_chng_cnt;
+ u_int32_t options;
int nbr_state;
int iface_state;
u_int8_t priority;
- u_int8_t options;
};
struct ctl_rt {
@@ -532,6 +531,7 @@ int area_del(struct area *);
struct area *area_find(struct ospfd_conf *, struct in_addr);
void area_track(struct area *, int);
int area_border_router(struct ospfd_conf *);
+u_int32_t area_ospf_options(struct area *);
/* buffer.c */
struct buf *buf_open(size_t);
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 05f3efca95d..7f36c76f7dc 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.2 2007/10/09 06:17:40 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.3 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -892,7 +892,7 @@ XXX*/
* Set the E bit as soon as an as-ext lsa may be redistributed, only
* setting it in case we redistribute something is not worth the fuss.
*/
- if (oeconf->redistribute && (oeconf->options & OSPF_OPTION_E))
+ if (oeconf->redistribute && !area->stub)
lsa_rtr.flags |= OSPF_RTR_E;
border = (area_border_router(oeconf) != 0);
diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y
index fee8e559749..79abf355f27 100644
--- a/usr.sbin/ospf6d/parse.y
+++ b/usr.sbin/ospf6d/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.3 2007/10/11 14:39:17 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.4 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -844,7 +844,6 @@ parse_config(char *filename, int opts)
defs->metric = DEFAULT_METRIC;
defs->priority = DEFAULT_PRIORITY;
- conf->options = OSPF_OPTION_E;
conf->spf_delay = DEFAULT_SPF_DELAY;
conf->spf_hold_time = DEFAULT_SPF_HOLDTIME;
conf->spf_state = SPF_IDLE;
diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c
index 61a0ece00b4..e34c1b268d2 100644
--- a/usr.sbin/ospf6d/rde.c
+++ b/usr.sbin/ospf6d/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.1 2007/10/08 10:44:51 norby Exp $ */
+/* $OpenBSD: rde.c,v 1.2 2007/10/11 19:02:47 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -60,7 +60,7 @@ struct lsa *rde_asext_get(struct rroute *);
struct lsa *rde_asext_put(struct rroute *);
struct lsa *orig_asext_lsa(struct rroute *, u_int16_t);
-struct lsa *orig_sum_lsa(struct rt_node *, u_int8_t, int);
+struct lsa *orig_sum_lsa(struct rt_node *, struct area *, u_int8_t, int);
struct ospfd_conf *rdeconf = NULL, *nconf = NULL;
struct imsgbuf *ibuf_ospfe;
@@ -1076,7 +1076,7 @@ rde_summary_update(struct rt_node *rte, struct area *area)
/* update lsa but only if it was changed */
v = lsa_find(area, type, rte->prefix.s_addr, rde_router_id());
- lsa = orig_sum_lsa(rte, type, rte->invalid);
+ lsa = orig_sum_lsa(rte, area, type, rte->invalid);
lsa_merge(rde_nbr_self(area), lsa, v);
if (v == NULL)
@@ -1140,7 +1140,7 @@ orig_asext_lsa(struct rroute *rr, u_int16_t age)
}
struct lsa *
-orig_sum_lsa(struct rt_node *rte, u_int8_t type, int invalid)
+orig_sum_lsa(struct rt_node *rte, struct area *area, u_int8_t type, int invalid)
{
struct lsa *lsa;
u_int16_t len;