summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authordenis <denis@openbsd.org>2019-12-23 07:33:49 +0000
committerdenis <denis@openbsd.org>2019-12-23 07:33:49 +0000
commit77fbfa19a8cee18aa3acb3e4a9ddee17335f1f53 (patch)
treeaa3417effbbd1e1a4c5daeb331c224879c07bdbb /usr.sbin/ospf6d
parentTeach gdb that the trap frame should be used for alltraps_kern_meltdown(). (diff)
downloadwireguard-openbsd-77fbfa19a8cee18aa3acb3e4a9ddee17335f1f53.tar.xz
wireguard-openbsd-77fbfa19a8cee18aa3acb3e4a9ddee17335f1f53.zip
Area is now part of struct iface
OK remi@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/area.c31
-rw-r--r--usr.sbin/ospf6d/database.c5
-rw-r--r--usr.sbin/ospf6d/hello.c6
-rw-r--r--usr.sbin/ospf6d/interface.c5
-rw-r--r--usr.sbin/ospf6d/neighbor.c8
-rw-r--r--usr.sbin/ospf6d/ospf6d.h7
-rw-r--r--usr.sbin/ospf6d/ospfe.c25
-rw-r--r--usr.sbin/ospf6d/packet.c6
-rw-r--r--usr.sbin/ospf6d/parse.y4
-rw-r--r--usr.sbin/ospf6d/rde.c35
-rw-r--r--usr.sbin/ospf6d/rde_lsdb.c8
11 files changed, 73 insertions, 67 deletions
diff --git a/usr.sbin/ospf6d/area.c b/usr.sbin/ospf6d/area.c
index 257fc43e637..7fa231f6304 100644
--- a/usr.sbin/ospf6d/area.c
+++ b/usr.sbin/ospf6d/area.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: area.c,v 1.4 2008/12/28 20:08:31 claudio Exp $ */
+/* $OpenBSD: area.c,v 1.5 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -88,19 +88,24 @@ area_find(struct ospfd_conf *conf, struct in_addr area_id)
}
void
-area_track(struct area *area, int state)
+area_track(struct area *area)
{
- int old = area->active;
-
- if (state & NBR_STA_FULL)
- area->active++;
- else if (area->active == 0)
- fatalx("area_track: area already inactive");
- else
- area->active--;
+ int old = area->active;
+ struct iface *iface;
+
+ area->active = 0;
+ LIST_FOREACH(iface, &area->iface_list, entry) {
+ if (iface->state & IF_STA_DOWN)
+ continue;
+ area->active = 1;
+ break;
+ }
- if (area->active == 0 || old == 0)
+ if (area->active != old) {
+ ospfe_imsg_compose_rde(IMSG_AREA_CHANGE, area->id.s_addr, 0,
+ &area->active, sizeof(area->active));
ospfe_demote_area(area, old == 0);
+ }
}
int
@@ -110,7 +115,7 @@ area_border_router(struct ospfd_conf *conf)
int active = 0;
LIST_FOREACH(area, &conf->area_list, entry)
- if (area->active > 0)
+ if (area->active)
active++;
return (active > 1);
@@ -124,5 +129,5 @@ area_ospf_options(struct area *area)
if (area && !area->stub)
opt |= OSPF_OPTION_E;
- return opt;
+ return (opt);
}
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index d8dc8558d4b..ca13c510766 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.17 2019/12/11 21:33:56 denis Exp $ */
+/* $OpenBSD: database.c,v 1.18 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -134,8 +134,7 @@ send_db_description(struct nbr *nbr)
fatalx("send_db_description: unknown interface type");
}
- dd_hdr.opts = htonl(area_ospf_options(area_find(oeconf,
- nbr->iface->area_id)));
+ dd_hdr.opts = htonl(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 186af93895c..0ba35897213 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.19 2019/12/11 21:33:56 denis Exp $ */
+/* $OpenBSD: hello.c,v 1.20 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -72,7 +72,7 @@ send_hello(struct iface *iface)
/* hello header */
hello.iface_id = htonl(iface->ifindex);
LSA_24_SETHI(hello.opts, iface->priority);
- opts = area_ospf_options(area_find(oeconf, iface->area_id));
+ opts = area_ospf_options(iface->area);
LSA_24_SETLO(hello.opts, opts);
hello.opts = htonl(hello.opts);
@@ -148,7 +148,7 @@ recv_hello(struct iface *iface, struct in6_addr *src, u_int32_t rtr_id,
return;
}
- if ((area = area_find(oeconf, iface->area_id)) == NULL)
+ if ((area = iface->area) == NULL)
fatalx("interface lost area");
opts = LSA_24_GETLO(ntohl(hello.opts));
diff --git a/usr.sbin/ospf6d/interface.c b/usr.sbin/ospf6d/interface.c
index c2c34986c88..ad0fb9f1df5 100644
--- a/usr.sbin/ospf6d/interface.c
+++ b/usr.sbin/ospf6d/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.26 2019/12/22 15:34:52 denis Exp $ */
+/* $OpenBSD: interface.c,v 1.27 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -143,6 +143,7 @@ if_fsm(struct iface *iface, enum iface_event event)
iface->state = new_state;
if (iface->state != old_state) {
+ area_track(iface->area);
orig_rtr_lsa(iface);
orig_link_lsa(iface);
@@ -649,7 +650,7 @@ if_to_ctl(struct iface *iface)
memcpy(ictl.name, iface->name, sizeof(ictl.name));
memcpy(&ictl.addr, &iface->addr, sizeof(ictl.addr));
ictl.rtr_id.s_addr = ospfe_router_id();
- memcpy(&ictl.area, &iface->area_id, sizeof(ictl.area));
+ memcpy(&ictl.area, &iface->area->id, sizeof(ictl.area));
if (iface->dr) {
memcpy(&ictl.dr_id, &iface->dr->id, sizeof(ictl.dr_id));
memcpy(&ictl.dr_addr, &iface->dr->addr, sizeof(ictl.dr_addr));
diff --git a/usr.sbin/ospf6d/neighbor.c b/usr.sbin/ospf6d/neighbor.c
index d7e639a6eab..df8564f4b1f 100644
--- a/usr.sbin/ospf6d/neighbor.c
+++ b/usr.sbin/ospf6d/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.14 2018/02/09 03:53:37 claudio Exp $ */
+/* $OpenBSD: neighbor.c,v 1.15 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -202,8 +202,6 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
* neighbor changed from/to FULL
* originate new rtr and net LSA
*/
- area_track(area_find(oeconf, nbr->iface->area_id),
- nbr->state);
orig_rtr_lsa(nbr->iface);
if (nbr->iface->state & IF_STA_DR)
orig_net_lsa(nbr->iface);
@@ -319,7 +317,7 @@ nbr_new(u_int32_t nbr_id, struct iface *iface, u_int32_t iface_id, int self,
if (addr)
rn.addr = *addr;
rn.id.s_addr = nbr->id.s_addr;
- rn.area_id.s_addr = nbr->iface->area_id.s_addr;
+ rn.area_id.s_addr = nbr->iface->area->id.s_addr;
rn.ifindex = nbr->iface->ifindex;
rn.iface_id = nbr->iface_id;
rn.state = nbr->state;
@@ -660,7 +658,7 @@ nbr_to_ctl(struct nbr *nbr)
memcpy(&nctl.addr, &nbr->addr, sizeof(nctl.addr));
memcpy(&nctl.dr, &nbr->dr, sizeof(nctl.dr));
memcpy(&nctl.bdr, &nbr->bdr, sizeof(nctl.bdr));
- memcpy(&nctl.area, &nbr->iface->area_id, sizeof(nctl.area));
+ memcpy(&nctl.area, &nbr->iface->area->id, sizeof(nctl.area));
/* this list is 99% of the time empty so that's OK for now */
nctl.db_sum_lst_cnt = 0;
diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h
index 27efdea1f77..f9263fa2f5c 100644
--- a/usr.sbin/ospf6d/ospf6d.h
+++ b/usr.sbin/ospf6d/ospf6d.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.h,v 1.41 2019/12/16 08:28:33 denis Exp $ */
+/* $OpenBSD: ospf6d.h,v 1.42 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org>
@@ -112,6 +112,7 @@ enum imsg_type {
IMSG_NEIGHBOR_CHANGE,
IMSG_NETWORK_ADD,
IMSG_NETWORK_DEL,
+ IMSG_AREA_CHANGE,
IMSG_DD,
IMSG_DD_END,
IMSG_DB_SNAPSHOT,
@@ -304,10 +305,10 @@ struct iface {
struct in6_addr addr;
struct in6_addr dst;
struct in_addr abr_id;
- struct in_addr area_id;
struct nbr *dr; /* designated router */
struct nbr *bdr; /* backup designated router */
struct nbr *self;
+ struct area *area;
u_int64_t baudrate;
u_int32_t ls_ack_cnt;
@@ -511,7 +512,7 @@ struct demote_msg {
struct area *area_new(void);
int area_del(struct area *);
struct area *area_find(struct ospfd_conf *, struct in_addr);
-void area_track(struct area *, int);
+void area_track(struct area *);
int area_border_router(struct ospfd_conf *);
u_int32_t area_ospf_options(struct area *);
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index db7018deadf..85f352a4add 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.57 2019/12/22 15:34:52 denis Exp $ */
+/* $OpenBSD: ospfe.c,v 1.58 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -341,8 +341,8 @@ ospfe_dispatch_main(int fd, short event, void *bula)
TAILQ_INIT(&iface->ls_ack_list);
RB_INIT(&iface->lsa_tree);
- area = area_find(oeconf, iface->area_id);
- LIST_INSERT_HEAD(&area->iface_list, iface, entry);
+ LIST_INSERT_HEAD(&iface->area->iface_list, iface,
+ entry);
break;
case IMSG_IFDELETE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
@@ -600,10 +600,10 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
* flood on all area interfaces on
* area 0.0.0.0 include also virtual links.
*/
- if ((area = area_find(oeconf,
- nbr->iface->area_id)) == NULL)
+ if (nbr->iface->area == NULL)
fatalx("interface lost area");
- LIST_FOREACH(iface, &area->iface_list, entry) {
+ LIST_FOREACH(iface,
+ &nbr->iface->area->iface_list, entry) {
noack += lsa_flood(iface, nbr,
&lsa_hdr, imsg.data);
}
@@ -777,11 +777,8 @@ find_vlink(struct abr_rtr *ar)
LIST_FOREACH(iface, &area->iface_list, entry)
if (iface->abr_id.s_addr == ar->abr_id.s_addr &&
iface->type == IF_TYPE_VIRTUALLINK &&
-//XXX iface->area->id.s_addr == ar->area.s_addr) {
- iface->area_id.s_addr == ar->area.s_addr) {
-//XXX iface->dst.s_addr = ar->dst_ip.s_addr;
+ iface->area->id.s_addr == ar->area.s_addr) {
iface->dst = ar->dst_ip;
-//XXX iface->addr.s_addr = ar->addr.s_addr;
iface->addr = ar->addr;
iface->metric = ar->metric;
@@ -808,11 +805,9 @@ orig_rtr_lsa_all(struct area *area)
void
orig_rtr_lsa(struct iface *iface)
{
- struct area *area;
-
- if ((area = area_find(oeconf, iface->area_id)) == NULL)
+ if (iface->area == NULL)
fatalx("interface lost area");
- orig_rtr_lsa_area(area);
+ orig_rtr_lsa_area(iface->area);
}
void
@@ -1155,7 +1150,7 @@ orig_link_lsa(struct iface *iface)
/* LSA link header (lladdr has already been filled in above) */
LSA_24_SETHI(lsa_link.opts, iface->priority);
- options = area_ospf_options(area_find(oeconf, iface->area_id));
+ options = area_ospf_options(iface->area);
LSA_24_SETLO(lsa_link.opts, options);
lsa_link.opts = htonl(lsa_link.opts);
lsa_link.numprefix = htonl(num_prefix);
diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c
index 8c30b41cdba..08d8e4e7ae1 100644
--- a/usr.sbin/ospf6d/packet.c
+++ b/usr.sbin/ospf6d/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.16 2019/12/11 21:33:56 denis Exp $ */
+/* $OpenBSD: packet.c,v 1.17 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -52,7 +52,7 @@ gen_ospf_hdr(struct ibuf *buf, struct iface *iface, u_int8_t type)
ospf_hdr.type = type;
ospf_hdr.rtr_id = ospfe_router_id();
if (iface->type != IF_TYPE_VIRTUALLINK)
- ospf_hdr.area_id = iface->area_id.s_addr;
+ ospf_hdr.area_id = iface->area->id.s_addr;
ospf_hdr.instance = DEFAULT_INSTANCE_ID;
ospf_hdr.zero = 0; /* must be zero */
@@ -270,7 +270,7 @@ ospf_hdr_sanity_check(struct ospf_hdr *ospf_hdr, u_int16_t len,
}
if (iface->type != IF_TYPE_VIRTUALLINK) {
- if (ospf_hdr->area_id != iface->area_id.s_addr) {
+ if (ospf_hdr->area_id != iface->area->id.s_addr) {
id.s_addr = ospf_hdr->area_id;
log_debug("recv_packet: invalid area ID %s, "
"interface %s", inet_ntoa(id), iface->name);
diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y
index 47e90db25f8..2ac7d9b64f6 100644
--- a/usr.sbin/ospf6d/parse.y
+++ b/usr.sbin/ospf6d/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.46 2019/12/16 08:28:33 denis Exp $ */
+/* $OpenBSD: parse.y,v 1.47 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -537,7 +537,7 @@ interface : INTERFACE STRING {
YYERROR;
}
free($2);
- iface->area_id.s_addr = area->id.s_addr;
+ iface->area = area;
LIST_INSERT_HEAD(&area->iface_list, iface, entry);
memcpy(&ifacedefs, defs, sizeof(ifacedefs));
diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c
index ce080bec411..b2d58eb2cc9 100644
--- a/usr.sbin/ospf6d/rde.c
+++ b/usr.sbin/ospf6d/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.80 2019/06/11 05:00:09 remi Exp $ */
+/* $OpenBSD: rde.c,v 1.81 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -319,7 +319,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
(nbr->state & NBR_STA_FULL ||
state & NBR_STA_FULL)) {
nbr->state = state;
- area_track(nbr->area, state);
+ area_track(nbr->area);
orig_intra_area_prefix_lsas(nbr->area);
}
@@ -327,6 +327,19 @@ rde_dispatch_imsg(int fd, short event, void *bula)
if (nbr->state & NBR_STA_FULL)
rde_req_list_free(nbr);
break;
+ case IMSG_AREA_CHANGE:
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(state))
+ fatalx("invalid size of OE request");
+
+ LIST_FOREACH(area, &rdeconf->area_list, entry) {
+ if (area->id.s_addr == imsg.hdr.peerid)
+ break;
+ }
+ if (area == NULL)
+ break;
+ memcpy(&state, imsg.data, sizeof(state));
+ area->active = state;
+ break;
case IMSG_DB_SNAPSHOT:
nbr = rde_nbr_find(imsg.hdr.peerid);
if (nbr == NULL)
@@ -740,10 +753,9 @@ rde_dispatch_parent(int fd, short event, void *bula)
if (prev_link_ok == link_ok)
break;
- area = area_find(rdeconf, iface->area_id);
- if (!area)
+ if (iface->area == NULL)
fatalx("interface lost area");
- orig_intra_area_prefix_lsas(area);
+ orig_intra_area_prefix_lsas(iface->area);
break;
case IMSG_IFADD:
@@ -755,8 +767,7 @@ rde_dispatch_parent(int fd, short event, void *bula)
TAILQ_INIT(&iface->ls_ack_list);
RB_INIT(&iface->lsa_tree);
- area = area_find(rdeconf, iface->area_id);
- LIST_INSERT_HEAD(&area->iface_list, iface, entry);
+ LIST_INSERT_HEAD(&iface->area->iface_list, iface, entry);
break;
case IMSG_IFDELETE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
@@ -789,9 +800,8 @@ rde_dispatch_parent(int fd, short event, void *bula)
ia->prefixlen = ifc->prefixlen;
TAILQ_INSERT_TAIL(&iface->ifa_list, ia, entry);
- area = area_find(rdeconf, iface->area_id);
- if (area)
- orig_intra_area_prefix_lsas(area);
+ if (iface->area)
+ orig_intra_area_prefix_lsas(iface->area);
break;
case IMSG_IFADDRDEL:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
@@ -815,9 +825,8 @@ rde_dispatch_parent(int fd, short event, void *bula)
break;
}
}
- area = area_find(rdeconf, iface->area_id);
- if (area)
- orig_intra_area_prefix_lsas(area);
+ if (iface->area)
+ orig_intra_area_prefix_lsas(iface->area);
break;
case IMSG_RECONF_CONF:
if ((nconf = malloc(sizeof(struct ospfd_conf))) ==
diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c
index f5cce0d3061..1a53efff680 100644
--- a/usr.sbin/ospf6d/rde_lsdb.c
+++ b/usr.sbin/ospf6d/rde_lsdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_lsdb.c,v 1.39 2019/12/22 11:19:06 denis Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.40 2019/12/23 07:33:49 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -574,11 +574,9 @@ lsa_find(struct iface *iface, u_int16_t type, u_int32_t ls_id,
if (LSA_IS_SCOPE_AS(ntohs(type)))
tree = &asext_tree;
else if (LSA_IS_SCOPE_AREA(ntohs(type))) {
- struct area *area;
-
- if ((area = area_find(rdeconf, iface->area_id)) == NULL)
+ if (iface->area == NULL)
fatalx("interface lost area");
- tree = &area->lsa_tree;
+ tree = &iface->area->lsa_tree;
} else if (LSA_IS_SCOPE_LLOCAL(ntohs(type)))
tree = &iface->lsa_tree;
else