diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-19 20:52:10 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-19 20:52:10 +0000 |
commit | 0fd5df12a7233037049be6f7471650a5e81749bd (patch) | |
tree | db8b43c152edcc5806a2c0b801a88532ed423bd9 /usr.sbin/dvmrpd | |
parent | a2d295712f129c32550a08fe7ee8a84dbf3f6b03 (diff) |
Cleanup the functions related to the election of the designated
forwarder.
ok norby@
Diffstat (limited to 'usr.sbin/dvmrpd')
-rw-r--r-- | usr.sbin/dvmrpd/rde_srt.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/usr.sbin/dvmrpd/rde_srt.c b/usr.sbin/dvmrpd/rde_srt.c index 29a1677426f..0f2a81b2be0 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.13 2009/01/19 20:40:31 michele Exp $ */ +/* $OpenBSD: rde_srt.c,v 1.14 2009/01/19 20:52:09 michele Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -436,28 +436,24 @@ void srt_current_forwarder(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 == rn->adv_rtr[iface->ifindex].addr.s_addr) { + struct adv_rtr *adv = &rn->adv_rtr[iface->ifindex]; + + if (nbr_report == adv->addr.s_addr) { if (metric > rn->cost || (metric == rn->cost && - iface->addr.s_addr < nbr_report)) { - rn->adv_rtr[iface->ifindex].addr.s_addr = - iface->addr.s_addr; - rn->adv_rtr[iface->ifindex].metric = rn->cost; - - /* XXX: check if there are groups with this source */ - if (group_list_empty(iface)) - rn->ttls[iface->ifindex] = 1; - } - } else if (metric < rn->adv_rtr[iface->ifindex].metric || - (metric == rn->adv_rtr[iface->ifindex].metric && - nbr_report < rn->adv_rtr[iface->ifindex].addr.s_addr)) { - if (rn->adv_rtr[iface->ifindex].addr.s_addr == - iface->addr.s_addr && !rn->ds_cnt[iface->ifindex]) - rn->ttls[iface->ifindex] = 0; - - rn->adv_rtr[iface->ifindex].addr.s_addr = nbr_report; - rn->adv_rtr[iface->ifindex].metric = metric; + iface->addr.s_addr < nbr_report)) + srt_set_forwarder_self(rn, iface); + + } else { + if (metric < adv->metric || + (metric == adv->metric && nbr_report < adv->addr.s_addr)) + if (adv->addr.s_addr == iface->addr.s_addr) + rn->ttls[iface->ifindex] = 0; + + adv->addr.s_addr = nbr_report; + adv->metric = metric; } + + /* XXX: update the kernel */ } void @@ -476,6 +472,8 @@ srt_update_ds_forwarders(struct rt_node *rn, struct iface *iface, srt_set_forwarder_self(rn, ifa); } } + + /* XXX: update the kernel */ } void @@ -483,10 +481,9 @@ srt_set_forwarder_self(struct rt_node *rn, struct iface *iface) { rn->adv_rtr[iface->ifindex].addr.s_addr = iface->addr.s_addr; rn->adv_rtr[iface->ifindex].metric = rn->cost; + rn->ttls[iface->ifindex] = 1; - /* XXX: check if there are groups with this source */ - if (group_list_empty(iface)) - rn->ttls[iface->ifindex] = 1; + /* XXX: update the kernel */ } void |