diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-04-25 11:31:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-04-25 11:31:51 +0000 |
commit | 687b02bffd46cde3974e52e407655e55d0b8dd91 (patch) | |
tree | 420b889c54622b64f320de28a283848b6f91e0dc /usr.sbin/ospfd/interface.c | |
parent | 8a3e37bbfebdb078dce3df9a3f6397b5f95ac75d (diff) |
Call if_init() later and for each interface separately.
Move code from if_act_start() to if_init() that needs to be called only
once per interface. Especially event_set should be called only once as it
initializes struct event and so may cause corruption of the event queue if
called twice.
Diffstat (limited to 'usr.sbin/ospfd/interface.c')
-rw-r--r-- | usr.sbin/ospfd/interface.c | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index ffa8654624e..f8fdeac424b 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.19 2005/04/25 09:55:18 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.20 2005/04/25 11:31:50 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -236,35 +236,34 @@ if_del(struct iface *iface) return (-1); } -int -if_init(struct ospfd_conf *xconf) +void +if_init(struct ospfd_conf *xconf, struct iface *iface) { - struct area *area = NULL; - struct iface *iface = NULL; - - LIST_FOREACH(area, &xconf->area_list, entry) { - LIST_FOREACH(iface, &area->iface_list, entry) { - switch (iface->type) { - case IF_TYPE_POINTOPOINT: - iface->fd = xconf->ospf_socket; - break; - case IF_TYPE_BROADCAST: - /* all bcast interfaces use the same socket */ - iface->fd = xconf->ospf_socket; - break; - case IF_TYPE_NBMA: - break; - case IF_TYPE_POINTOMULTIPOINT: - break; - case IF_TYPE_VIRTUALLINK: - break; - default: - fatalx("if_init: unknown interface type"); - } - } - } + /* init the dummy local neighbor */ + iface->self = nbr_new(ospfe_router_id(), iface, 1); - return (0); + /* set event handlers for interface */ + evtimer_set(&iface->lsack_tx_timer, ls_ack_tx_timer, iface); + evtimer_set(&iface->hello_timer, if_hello_timer, iface); + evtimer_set(&iface->wait_timer, if_wait_timer, iface); + + switch (iface->type) { + case IF_TYPE_POINTOPOINT: + iface->fd = xconf->ospf_socket; + break; + case IF_TYPE_BROADCAST: + /* all bcast interfaces use the same socket */ + iface->fd = xconf->ospf_socket; + break; + case IF_TYPE_NBMA: + break; + case IF_TYPE_POINTOMULTIPOINT: + break; + case IF_TYPE_VIRTUALLINK: + break; + default: + fatalx("if_init: unknown interface type"); + } } int @@ -352,15 +351,6 @@ if_act_start(struct iface *iface) return (0); } - /* init the dummy local neighbor */ - if (iface->self == NULL) - iface->self = nbr_new(ospfe_router_id(), iface, 1); - - /* set event handlers for interface */ - evtimer_set(&iface->lsack_tx_timer, ls_ack_tx_timer, iface); - evtimer_set(&iface->hello_timer, if_hello_timer, iface); - evtimer_set(&iface->wait_timer, if_wait_timer, iface); - switch (iface->type) { case IF_TYPE_POINTOPOINT: inet_aton(AllSPFRouters, &addr); |