summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2008-10-21 20:20:01 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2008-10-21 20:20:01 +0000
commitf045bd5b7001e8aca052aa1d368fa0fe55c0c302 (patch)
treeda65509cf84319024d9f04c813cd9ca372b544d1 /usr.sbin
parent3900c6b3d33ae96b2923486a9790e356e64c87d9 (diff)
Code cleanup. No functional change.
OK norby@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dvmrpd/rde.h4
-rw-r--r--usr.sbin/dvmrpd/rde_srt.c36
2 files changed, 17 insertions, 23 deletions
diff --git a/usr.sbin/dvmrpd/rde.h b/usr.sbin/dvmrpd/rde.h
index dd3f8f2e756..255dcbdb682 100644
--- a/usr.sbin/dvmrpd/rde.h
+++ b/usr.sbin/dvmrpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.3 2007/03/21 19:33:48 michele Exp $ */
+/* $OpenBSD: rde.h,v 1.4 2008/10/21 20:20:00 michele Exp $ */
/*
* Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -90,7 +90,7 @@ void mfc_delete(struct mfc *);
void rt_init(void);
int rt_compare(struct rt_node *, struct rt_node *);
struct rt_node *rt_find(in_addr_t, u_int8_t);
-struct rt_node *rr_new_rt(struct route_report *, int, int);
+struct rt_node *rr_new_rt(struct route_report *, u_int32_t, int);
int rt_insert(struct rt_node *);
void rt_update(struct rt_node *);
int rt_remove(struct rt_node *);
diff --git a/usr.sbin/dvmrpd/rde_srt.c b/usr.sbin/dvmrpd/rde_srt.c
index 995a485cafd..a1f30e6ff4e 100644
--- a/usr.sbin/dvmrpd/rde_srt.c
+++ b/usr.sbin/dvmrpd/rde_srt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_srt.c,v 1.7 2007/04/10 09:37:25 michele Exp $ */
+/* $OpenBSD: rde_srt.c,v 1.8 2008/10/21 20:20:00 michele Exp $ */
/*
* Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -54,7 +54,7 @@ struct ds *srt_find_ds(struct src_node *, u_int32_t);
void srt_delete_ds(struct src_node *, struct rt_node *, struct ds *,
struct iface *);
struct src_node *srt_find_src(struct in_addr, struct in_addr);
-struct src_node *srt_add_src(struct in_addr, struct in_addr);
+struct src_node *srt_add_src(struct in_addr, struct in_addr, u_int32_t);
void srt_delete_src(struct src_node *);
RB_HEAD(rt_tree, rt_node) rt;
@@ -143,7 +143,7 @@ rt_find(in_addr_t prefix, u_int8_t prefixlen)
}
struct rt_node *
-rr_new_rt(struct route_report *rr, int adj_metric, int connected)
+rr_new_rt(struct route_report *rr, u_int32_t adj_metric, int connected)
{
struct timespec now;
struct rt_node *rn;
@@ -309,12 +309,12 @@ srt_check_route(struct route_report *rr, int connected)
/* If the route is new and the Adjusted Metric is less than infinity,
the route should be added. */
- if ((rn = rt_find(rr->net.s_addr, mask2prefixlen(rr->mask.s_addr)))
- == NULL) {
+ rn = rt_find(rr->net.s_addr, mask2prefixlen(rr->mask.s_addr));
+ if (rn == NULL) {
if (adj_metric < INFINITY_METRIC) {
rn = rr_new_rt(rr, adj_metric, connected);
rt_insert(rn);
- src = srt_add_src(rr->net, rr->mask);
+ src = srt_add_src(rr->net, rr->mask, adj_metric);
}
return (0);
}
@@ -391,6 +391,7 @@ void
srt_current_forwarder(struct src_node *src_node, struct rt_node *rn,
struct iface *iface, u_int32_t metric, u_int32_t nbr_report)
{
+ /* If it is our designated forwarder */
if (nbr_report == src_node->adv_rtr[iface->ifindex].addr.s_addr) {
if (metric > rn->cost || (metric == rn->cost &&
iface->addr.s_addr < nbr_report)) {
@@ -419,7 +420,7 @@ srt_update_ds_forwarders(struct src_node *src_node, struct rt_node *rn,
struct iface *iface, u_int32_t nbr_report)
{
struct iface *ifa;
- int i;
+ int i;
for (i = 0; i < MAXVIFS; i++) {
if (src_node->adv_rtr[i].addr.s_addr &&
@@ -427,12 +428,7 @@ srt_update_ds_forwarders(struct src_node *src_node, struct rt_node *rn,
(rn->cost == src_node->adv_rtr[i].metric &&
iface->addr.s_addr < nbr_report))) {
ifa = if_find_index(i);
- src_node->adv_rtr[i].metric = rn->cost;
- src_node->adv_rtr[i].addr.s_addr = iface->addr.s_addr;
-
- /* XXX: check if there are groups with this source */
- if (group_list_empty(ifa))
- rn->ttls[i] = 1;
+ srt_set_forwarder_self(src_node, ifa, rn);
}
}
}
@@ -513,7 +509,7 @@ srt_find_src(struct in_addr net, struct in_addr mask)
}
struct src_node *
-srt_add_src(struct in_addr net, struct in_addr mask)
+srt_add_src(struct in_addr net, struct in_addr mask, u_int32_t adj_metric)
{
struct src_node *src_node;
struct iface *iface;
@@ -530,13 +526,11 @@ srt_add_src(struct in_addr net, struct in_addr mask)
src_node->ds_cnt[i] = 0;
}
- LIST_FOREACH(iface, &rdeconf->iface_list, entry)
- for (i = 0; i < MAXVIFS; i++)
- if (iface->ifindex == i) {
- src_node->adv_rtr[i].addr.s_addr =
- iface->addr.s_addr;
- break;
- }
+ LIST_FOREACH(iface, &rdeconf->iface_list, entry) {
+ src_node->adv_rtr[iface->ifindex].addr.s_addr =
+ iface->addr.s_addr;
+ src_node->adv_rtr[iface->ifindex].metric = adj_metric;
+ }
LIST_INIT(&src_node->ds_list);
RB_INSERT(src_head, &rdeconf->src_list, src_node);