summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ripd/interface.c
diff options
context:
space:
mode:
authormichele <michele@openbsd.org>2008-12-17 14:19:39 +0000
committermichele <michele@openbsd.org>2008-12-17 14:19:39 +0000
commit4d8b14b6630665f8df30f467781f65de613391cd (patch)
treef106fc7414e73812fba0b143a896671143b90c39 /usr.sbin/ripd/interface.c
parentchange the name displayed by the c-mode on the mode line to "c", (diff)
downloadwireguard-openbsd-4d8b14b6630665f8df30f467781f65de613391cd.tar.xz
wireguard-openbsd-4d8b14b6630665f8df30f467781f65de613391cd.zip
Add support for demotion counter.
When interfaces go up/down the demotion counter of the specified group is decreased/increased. ok henning@
Diffstat (limited to 'usr.sbin/ripd/interface.c')
-rw-r--r--usr.sbin/ripd/interface.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/ripd/interface.c b/usr.sbin/ripd/interface.c
index dd2a242e6e1..a22fc97c90d 100644
--- a/usr.sbin/ripd/interface.c
+++ b/usr.sbin/ripd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.5 2007/10/24 19:50:33 claudio Exp $ */
+/* $OpenBSD: interface.c,v 1.6 2008/12/17 14:19:39 michele Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -74,6 +74,8 @@ if_init(struct ripd_conf *xconf, struct iface *iface)
{
/* XXX as in ospfd I would like to kill that. This is a design error */
iface->fd = xconf->rip_socket;
+
+ ripe_demote_iface(iface, 0);
}
int
@@ -122,6 +124,11 @@ if_fsm(struct iface *iface, enum iface_event event)
if (new_state != 0)
iface->state = new_state;
+ if (old_state == IF_STA_ACTIVE && iface->state == IF_STA_DOWN)
+ ripe_demote_iface(iface, 0);
+ if (old_state & IF_STA_DOWN && iface->state == IF_STA_ACTIVE)
+ ripe_demote_iface(iface, 1);
+
log_debug("if_fsm: event '%s' resulted in action '%s' and changing "
"state for interface %s from '%s' to '%s'",
if_event_name(event), if_action_name(iface_fsm[i].action),
@@ -440,6 +447,10 @@ if_del(struct iface *iface)
log_debug("if_del: interface %s", iface->name);
+ /* revert the demotion when the interface is deleted */
+ if (iface->state == IF_STA_DOWN)
+ ripe_demote_iface(iface, 1);
+
/* clear lists etc */
while ((nbr = LIST_FIRST(&iface->nbr_list)) != NULL)
nbr_act_del(nbr);