summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2009-03-29 19:25:50 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2009-03-29 19:25:50 +0000
commitda4d40d6c22707b68be6a4b9db6be84251be45e9 (patch)
tree76ebb7941a9b6c43b36984a7e8ddd5c6b2c95553 /usr.sbin/ospf6d
parent66f1f2214ce8c2d9ee2fc7bb1d4f7ea55d43c191 (diff)
Because get_rtr_link() forgot to increment the buffer offset
it was always returning the first link in the LSA, no matter which link was requested. Fix this bug. Also, decrease the number of local variables while here, and convert the idx argument to unsigned int. Adjust one caller to pass an unsigned int, other callers will be handled in follow-up commits. ok claudio@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/rde.h4
-rw-r--r--usr.sbin/ospf6d/rde_spf.c19
2 files changed, 11 insertions, 12 deletions
diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h
index 1e42020c72b..fa26b649198 100644
--- a/usr.sbin/ospf6d/rde.h
+++ b/usr.sbin/ospf6d/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.14 2009/03/29 19:18:20 stsp Exp $ */
+/* $OpenBSD: rde.h,v 1.15 2009/03/29 19:25:49 stsp Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -178,7 +178,7 @@ int rt_remove(struct rt_node *);
void rt_clear(void);
void rt_dump(struct in_addr, pid_t, u_int8_t);
-struct lsa_rtr_link *get_rtr_link(struct vertex *, int);
+struct lsa_rtr_link *get_rtr_link(struct vertex *, unsigned int);
struct lsa_net_link *get_net_link(struct vertex *, int);
RB_PROTOTYPE(lsa_tree, vertex, entry, lsa_compare)
diff --git a/usr.sbin/ospf6d/rde_spf.c b/usr.sbin/ospf6d/rde_spf.c
index 35ad84c6960..0d46ab4751d 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.7 2009/03/10 17:37:45 stsp Exp $ */
+/* $OpenBSD: rde_spf.c,v 1.8 2009/03/29 19:25:49 stsp Exp $ */
/*
* Copyright (c) 2005 Esben Norby <norby@openbsd.org>
@@ -56,7 +56,7 @@ spf_calc(struct area *area)
struct lsa_rtr_link *rtr_link = NULL;
struct lsa_net_link *net_link;
u_int32_t d;
- int i;
+ unsigned int i;
struct in_addr addr;
/* clear SPF tree */
@@ -988,23 +988,22 @@ rt_lookup(enum dst_type type, struct in6_addr *addr)
/* router LSA links */
struct lsa_rtr_link *
-get_rtr_link(struct vertex *v, int idx)
+get_rtr_link(struct vertex *v, unsigned int idx)
{
struct lsa_rtr_link *rtr_link = NULL;
char *buf = (char *)v->lsa;
- u_int16_t i, off, nlinks;
+ unsigned int i;
if (v->type != LSA_TYPE_ROUTER)
fatalx("get_rtr_link: invalid LSA type");
- off = sizeof(v->lsa->hdr) + sizeof(struct lsa_rtr);
-
- /* nlinks validated earlier by lsa_check() */
- nlinks = lsa_num_links(v);
- for (i = 0; i < nlinks; i++) {
- rtr_link = (struct lsa_rtr_link *)(buf + off);
+ /* number of links validated earlier by lsa_check() */
+ rtr_link = (struct lsa_rtr_link *)(buf + sizeof(v->lsa->hdr) +
+ sizeof(struct lsa_rtr));
+ for (i = 0; i < lsa_num_links(v); i++) {
if (i == idx)
return (rtr_link);
+ rtr_link++;
}
return (NULL);