summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authordenis <denis@openbsd.org>2019-12-22 11:19:06 +0000
committerdenis <denis@openbsd.org>2019-12-22 11:19:06 +0000
commit85be3f1a9e4806f1c2528d7190a97527fa62a24f (patch)
treed9b2c654e2e3de25d92923e0c0c6893a49bb69a1 /usr.sbin/ospf6d
parentwe also have "VAR_*" constants in parsevar with totally different meanings. (diff)
downloadwireguard-openbsd-85be3f1a9e4806f1c2528d7190a97527fa62a24f.tar.xz
wireguard-openbsd-85be3f1a9e4806f1c2528d7190a97527fa62a24f.zip
Rename and move calc_nexthop_clear()/calc_nexthop_add()
OK claudio@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/rde.h5
-rw-r--r--usr.sbin/ospf6d/rde_lsdb.c32
-rw-r--r--usr.sbin/ospf6d/rde_spf.c58
3 files changed, 48 insertions, 47 deletions
diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h
index 746cf9b324b..ca7d403c0a1 100644
--- a/usr.sbin/ospf6d/rde.h
+++ b/usr.sbin/ospf6d/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.22 2010/07/01 19:47:04 bluhm Exp $ */
+/* $OpenBSD: rde.h,v 1.23 2019/12/22 11:19:06 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -140,6 +140,9 @@ void orig_intra_area_prefix_lsas(struct area *);
void lsa_init(struct lsa_tree *);
int lsa_compare(struct vertex *, struct vertex *);
void vertex_free(struct vertex *);
+void vertex_nexthop_clear(struct vertex *);
+void vertex_nexthop_add(struct vertex *, struct vertex *,
+ const struct in6_addr *, u_int32_t);
int lsa_newer(struct lsa_hdr *, struct lsa_hdr *);
int lsa_check(struct rde_nbr *, struct lsa *, u_int16_t);
int lsa_self(struct lsa *);
diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c
index c4b2f4df9f7..f5cce0d3061 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.38 2013/10/18 11:16:52 sthen Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.39 2019/12/22 11:19:06 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -99,11 +99,41 @@ void
vertex_free(struct vertex *v)
{
RB_REMOVE(lsa_tree, v->lsa_tree, v);
+
(void)evtimer_del(&v->ev);
+ vertex_nexthop_clear(v);
free(v->lsa);
free(v);
}
+void
+vertex_nexthop_clear(struct vertex *v)
+{
+ struct v_nexthop *vn;
+
+ while ((vn = TAILQ_FIRST(&v->nexthop))) {
+ TAILQ_REMOVE(&v->nexthop, vn, entry);
+ free(vn);
+ }
+}
+
+void
+vertex_nexthop_add(struct vertex *dst, struct vertex *parent,
+ const struct in6_addr *nexthop, u_int32_t ifindex)
+{
+ struct v_nexthop *vn;
+
+ if ((vn = calloc(1, sizeof(*vn))) == NULL)
+ fatal("vertex_nexthop_add");
+
+ vn->prev = parent;
+ if (nexthop)
+ vn->nexthop = *nexthop;
+ vn->ifindex = ifindex;
+
+ TAILQ_INSERT_TAIL(&dst->nexthop, vn, entry);
+}
+
/* returns -1 if a is older, 1 if newer and 0 if equal to b */
int
lsa_newer(struct lsa_hdr *a, struct lsa_hdr *b)
diff --git a/usr.sbin/ospf6d/rde_spf.c b/usr.sbin/ospf6d/rde_spf.c
index 4e2e554447a..50009e27c7f 100644
--- a/usr.sbin/ospf6d/rde_spf.c
+++ b/usr.sbin/ospf6d/rde_spf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_spf.c,v 1.25 2015/12/05 06:45:19 mmcc Exp $ */
+/* $OpenBSD: rde_spf.c,v 1.26 2019/12/22 11:19:07 denis Exp $ */
/*
* Copyright (c) 2005 Esben Norby <norby@openbsd.org>
@@ -36,9 +36,6 @@ RB_PROTOTYPE(rt_tree, rt_node, entry, rt_compare)
RB_GENERATE(rt_tree, rt_node, entry, rt_compare)
struct vertex *spf_root = NULL;
-void calc_nexthop_clear(struct vertex *);
-void calc_nexthop_add(struct vertex *, struct vertex *,
- const struct in6_addr *, u_int32_t);
struct in6_addr *calc_nexthop_lladdr(struct vertex *, struct lsa_rtr_link *,
unsigned int);
void calc_nexthop_transit_nbr(struct vertex *, struct vertex *,
@@ -142,7 +139,7 @@ spf_calc(struct area *area)
continue;
if (d < w->cost) {
w->cost = d;
- calc_nexthop_clear(w);
+ vertex_nexthop_clear(w);
calc_nexthop(w, v, area, rtr_link);
/*
* need to readd to candidate list
@@ -156,7 +153,7 @@ spf_calc(struct area *area)
} else if (w->cost == LS_INFINITY && d < LS_INFINITY) {
w->cost = d;
- calc_nexthop_clear(w);
+ vertex_nexthop_clear(w);
calc_nexthop(w, v, area, rtr_link);
cand_list_add(w);
}
@@ -420,26 +417,25 @@ asext_calc(struct vertex *v)
}
area.s_addr = 0;
- calc_nexthop_clear(v);
+ vertex_nexthop_clear(v);
TAILQ_FOREACH(rn, &r->nexthop, entry) {
if (rn->invalid)
continue;
if (rn->connected && r->d_type == DT_NET) {
if (metric & LSA_ASEXT_F_FLAG)
- calc_nexthop_add(v, NULL, &fw_addr,
+ vertex_nexthop_add(v, NULL, &fw_addr,
rn->ifindex);
else
fatalx("asext_calc: I'm sorry Dave, "
"I'm afraid I can't do that.");
} else
- calc_nexthop_add(v, NULL, &rn->nexthop,
+ vertex_nexthop_add(v, NULL, &rn->nexthop,
rn->ifindex);
}
- rt_update(&addr, prefix->prefixlen,
- &v->nexthop, v->cost, cost2, area, adv_rtr, type,
- DT_NET, 0, ext_tag);
+ rt_update(&addr, prefix->prefixlen, &v->nexthop, v->cost, cost2,
+ area, adv_rtr, type, DT_NET, 0, ext_tag);
break;
default:
fatalx("asext_calc: invalid LSA type");
@@ -454,38 +450,10 @@ spf_tree_clr(struct area *area)
RB_FOREACH(v, lsa_tree, tree) {
v->cost = LS_INFINITY;
- calc_nexthop_clear(v);
+ vertex_nexthop_clear(v);
}
}
-void
-calc_nexthop_clear(struct vertex *v)
-{
- struct v_nexthop *vn;
-
- while ((vn = TAILQ_FIRST(&v->nexthop))) {
- TAILQ_REMOVE(&v->nexthop, vn, entry);
- free(vn);
- }
-}
-
-void
-calc_nexthop_add(struct vertex *dst, struct vertex *parent,
- const struct in6_addr *nexthop, u_int32_t ifindex)
-{
- struct v_nexthop *vn;
-
- if ((vn = calloc(1, sizeof(*vn))) == NULL)
- fatal("calc_nexthop_add");
-
- vn->prev = parent;
- if (nexthop)
- vn->nexthop = *nexthop;
- vn->ifindex = ifindex;
-
- TAILQ_INSERT_TAIL(&dst->nexthop, vn, entry);
-}
-
struct in6_addr *
calc_nexthop_lladdr(struct vertex *dst, struct lsa_rtr_link *rtr_link,
unsigned int ifindex)
@@ -541,7 +509,7 @@ calc_nexthop_transit_nbr(struct vertex *dst, struct vertex *parent,
rtr_link->nbr_rtr_id == parent->lsa->hdr.adv_rtr &&
rtr_link->nbr_iface_id == parent->lsa->hdr.ls_id) {
lladdr = calc_nexthop_lladdr(dst, rtr_link, ifindex);
- calc_nexthop_add(dst, parent, lladdr, ifindex);
+ vertex_nexthop_add(dst, parent, lladdr, ifindex);
}
}
}
@@ -574,7 +542,7 @@ calc_nexthop(struct vertex *dst, struct vertex *parent,
fatalx("calc_nexthop: invalid dst type");
}
- calc_nexthop_add(dst, spf_root, nexthop,
+ vertex_nexthop_add(dst, parent, nexthop,
ntohl(rtr_link->iface_id));
return;
}
@@ -587,7 +555,7 @@ calc_nexthop(struct vertex *dst, struct vertex *parent,
vn->ifindex);
else
/* dst is more than one transit net away */
- calc_nexthop_add(dst, parent, &vn->nexthop,
+ vertex_nexthop_add(dst, parent, &vn->nexthop,
vn->ifindex);
}
return;
@@ -595,7 +563,7 @@ calc_nexthop(struct vertex *dst, struct vertex *parent,
/* case 3 */
TAILQ_FOREACH(vn, &parent->nexthop, entry)
- calc_nexthop_add(dst, parent, &vn->nexthop, vn->ifindex);
+ vertex_nexthop_add(dst, parent, &vn->nexthop, vn->ifindex);
}
/* candidate list */