diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-12-15 20:29:07 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-12-15 20:29:07 +0000 |
commit | d24b45b2a3b07426e88b816f67726f78730c755a (patch) | |
tree | 8e7497a68a0e4b33168644db2823baee7f506309 /usr.sbin | |
parent | 2c20c42db624528a8761a4f1cf52ee08d7f6f1c7 (diff) |
Simpify iface_del() and nbr_del(). make them void funtions as they can not fail
and do not remove a element twice in iface_del(). OK norby@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospfd/interface.c | 12 | ||||
-rw-r--r-- | usr.sbin/ospfd/neighbor.c | 12 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.h | 6 |
3 files changed, 12 insertions, 18 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index c22420c4779..864f87031e9 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.39 2005/12/04 20:49:47 norby Exp $ */ +/* $OpenBSD: interface.c,v 1.40 2005/12/15 20:29:06 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -231,7 +231,7 @@ if_new(struct kif *kif) return (iface); } -int +void if_del(struct iface *iface) { struct nbr *nbr = NULL; @@ -239,17 +239,13 @@ if_del(struct iface *iface) log_debug("if_del: interface %s", iface->name); /* clear lists etc */ - iface->self = NULL; /* trick neighbor.c code to remove self too */ - while ((nbr = LIST_FIRST(&iface->nbr_list)) != NULL) { - LIST_REMOVE(nbr, entry); + while ((nbr = LIST_FIRST(&iface->nbr_list)) != NULL) nbr_del(nbr); - } ls_ack_list_clr(iface); md_list_clr(iface); free(iface->auth_key); - - return (-1); + free(iface); } void diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c index 085fac2f63e..abbdf294538 100644 --- a/usr.sbin/ospfd/neighbor.c +++ b/usr.sbin/ospfd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.25 2005/10/19 21:46:21 claudio Exp $ */ +/* $OpenBSD: neighbor.c,v 1.26 2005/12/15 20:29:06 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -316,12 +316,9 @@ nbr_new(u_int32_t nbr_id, struct iface *iface, int self) return (nbr); } -int +void nbr_del(struct nbr *nbr) { - if (nbr == nbr->iface->self) - return (0); - ospfe_imsg_compose_rde(IMSG_NEIGHBOR_DOWN, nbr->peerid, 0, NULL, 0); /* clear lists */ @@ -333,8 +330,6 @@ nbr_del(struct nbr *nbr) LIST_REMOVE(nbr, hash); free(nbr); - - return (0); } struct nbr * @@ -572,6 +567,9 @@ nbr_act_delete(struct nbr *nbr) { struct timeval tv; + if (nbr == nbr->iface->self) + return (0); + /* stop timers */ if (nbr_stop_itimer(nbr)) { log_warnx("nbr_act_delete: error removing inactivity timer, " diff --git a/usr.sbin/ospfd/ospfe.h b/usr.sbin/ospfd/ospfe.h index 58d9842e99b..436cab69fbd 100644 --- a/usr.sbin/ospfd/ospfe.h +++ b/usr.sbin/ospfd/ospfe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.h,v 1.18 2005/12/04 20:49:47 norby Exp $ */ +/* $OpenBSD: ospfe.h,v 1.19 2005/12/15 20:29:06 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -183,7 +183,7 @@ void orig_net_lsa(struct iface *); int if_fsm(struct iface *, enum iface_event); struct iface *if_new(struct kif *); -int if_del(struct iface *); +void if_del(struct iface *); void if_init(struct ospfd_conf *, struct iface *); int if_act_start(struct iface *); @@ -254,7 +254,7 @@ void lsa_cache_put(struct lsa_ref *, struct nbr *); /* neighbor.c */ void nbr_init(u_int32_t); struct nbr *nbr_new(u_int32_t, struct iface *, int); -int nbr_del(struct nbr *); +void nbr_del(struct nbr *); struct nbr *nbr_find_id(struct iface *, u_int32_t); struct nbr *nbr_find_peerid(u_int32_t); |