diff options
Diffstat (limited to 'usr.sbin/ospf6d/rde_lsdb.c')
-rw-r--r-- | usr.sbin/ospf6d/rde_lsdb.c | 32 |
1 files changed, 31 insertions, 1 deletions
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) |