1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Code cleanup. No functional change.

OK norby@
This commit is contained in:
michele 2008-10-21 20:20:00 +00:00
parent 231b3e6d54
commit 869c07297e
2 changed files with 17 additions and 23 deletions

View File

@ -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 *);

View File

@ -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);