diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-06-18 17:31:33 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-06-18 17:31:33 +0000 |
commit | a9f28d78e1e7c95f663dd4bf3fea651eecb48098 (patch) | |
tree | ad6863b73262d751feccd1376198cdede5b8889f | |
parent | 9bd1599b3b41e7a556919282bec4e8dd2ff56b51 (diff) |
Fix removal of dual-stack neighbors.
-rw-r--r-- | usr.sbin/ldpd/adjacency.c | 42 | ||||
-rw-r--r-- | usr.sbin/ldpd/hello.c | 8 | ||||
-rw-r--r-- | usr.sbin/ldpd/interface.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/packet.c | 7 |
6 files changed, 35 insertions, 34 deletions
diff --git a/usr.sbin/ldpd/adjacency.c b/usr.sbin/ldpd/adjacency.c index 8af0d0e564f..a40027225ea 100644 --- a/usr.sbin/ldpd/adjacency.c +++ b/usr.sbin/ldpd/adjacency.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adjacency.c,v 1.25 2016/06/18 17:11:37 renato Exp $ */ +/* $OpenBSD: adjacency.c,v 1.26 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2015 Renato Westphal <renato@openbsd.org> @@ -28,6 +28,7 @@ #include "ldpe.h" #include "log.h" +static void adj_del_single(struct adj *); static void adj_itimer(int, short, void *); static void tnbr_del(struct tnbr *); static void tnbr_hello_timer(int, short, void *); @@ -67,14 +68,11 @@ adj_new(struct in_addr lsr_id, struct hello_source *source, return (adj); } -void -adj_del(struct adj *adj, int send_notif, uint32_t notif_status) +static void +adj_del_single(struct adj *adj) { - struct nbr *nbr = adj->nbr; - struct adj *atmp; - - log_debug("%s: lsr-id %s, %s", __func__, inet_ntoa(adj->lsr_id), - log_hello_src(&adj->source)); + log_debug("%s: lsr-id %s, %s (%s)", __func__, inet_ntoa(adj->lsr_id), + log_hello_src(&adj->source), af_name(adj_get_af(adj))); adj_stop_itimer(adj); @@ -91,22 +89,26 @@ adj_del(struct adj *adj, int send_notif, uint32_t notif_status) } free(adj); +} - /* last adjacency deleted */ - if (nbr && LIST_EMPTY(&nbr->adj_list)) { - if (send_notif) - session_shutdown(nbr, notif_status, 0, 0); - nbr_del(nbr); - nbr = NULL; - } +void +adj_del(struct adj *adj, uint32_t notif_status) +{ + struct nbr *nbr = adj->nbr; + struct adj *atmp; + + adj_del_single(adj); /* - * If the neighbor still exists but none of its remaining adjacencies - * are from the preferred address-family, then delete it. + * If the neighbor still exists but none of its remaining + * adjacencies (if any) are from the preferred address-family, + * then delete it. */ if (nbr && nbr_adj_count(nbr, nbr->af) == 0) { LIST_FOREACH_SAFE(adj, &nbr->adj_list, nbr_entry, atmp) - adj_del(adj, 0, 0); + adj_del_single(adj); + session_shutdown(nbr, notif_status, 0, 0); + nbr_del(nbr); } } @@ -169,7 +171,7 @@ adj_itimer(int fd, short event, void *arg) adj->source.target->adj = NULL; } - adj_del(adj, 1, S_HOLDTIME_EXP); + adj_del(adj, S_HOLDTIME_EXP); } void @@ -215,7 +217,7 @@ tnbr_del(struct tnbr *tnbr) { tnbr_stop_hello_timer(tnbr); if (tnbr->adj) - adj_del(tnbr->adj, 1, S_SHUTDOWN); + adj_del(tnbr->adj, S_SHUTDOWN); LIST_REMOVE(tnbr, entry); free(tnbr); } diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c index 42278036f89..192bdf908b8 100644 --- a/usr.sbin/ldpd/hello.c +++ b/usr.sbin/ldpd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.49 2016/06/13 23:01:37 renato Exp $ */ +/* $OpenBSD: hello.c,v 1.50 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -286,7 +286,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af, session_shutdown(nbr, S_TRANS_MISMTCH, lm->msgid, lm->type); if (adj) - adj_del(adj, 0, 0); + adj_del(adj, S_SHUTDOWN); return; } @@ -324,7 +324,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af, log_warnx("%s: lsr-id %s: hello packet advertising a different " "transport address", __func__, inet_ntoa(lsr_id)); if (adj) - adj_del(adj, 0, 0); + adj_del(adj, S_SHUTDOWN); return; } if (nbr == NULL) { @@ -334,7 +334,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af, "used by lsr-id %s", __func__, log_addr(af, &trans_addr), inet_ntoa(nbrt->id)); if (adj) - adj_del(adj, 0, 0); + adj_del(adj, S_SHUTDOWN); return; } } diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index c455279ed14..98c846bb31d 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.45 2016/06/09 17:26:32 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.46 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -278,7 +278,7 @@ if_reset(struct iface *iface, int af) if_stop_hello_timer(ia); while ((adj = LIST_FIRST(&ia->adj_list)) != NULL) - adj_del(adj, 1, S_SHUTDOWN); + adj_del(adj, S_SHUTDOWN); /* try to cleanup */ switch (af) { diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 51fe0b9b864..f110b9d7c0f 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.66 2016/06/13 23:01:37 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.67 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -179,7 +179,7 @@ ldpe_shutdown(void) free(if_addr); } while ((adj = LIST_FIRST(&global.adj_list)) != NULL) - adj_del(adj, 1, S_SHUTDOWN); + adj_del(adj, S_SHUTDOWN); /* clean up */ msgbuf_write(&iev_lde->ibuf.w); diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index dfdb19f3a99..9c52a3e860a 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.61 2016/06/13 23:01:37 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.62 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -206,7 +206,7 @@ in_addr_t if_get_ipv4_addr(struct iface *); /* adjacency.c */ struct adj *adj_new(struct in_addr, struct hello_source *, union ldpd_addr *); -void adj_del(struct adj *, int, uint32_t); +void adj_del(struct adj *, uint32_t); struct adj *adj_find(struct hello_source *); int adj_get_af(struct adj *adj); void adj_start_itimer(struct adj *); diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c index a804a7f7c24..a211994a9a2 100644 --- a/usr.sbin/ldpd/packet.c +++ b/usr.sbin/ldpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.63 2016/06/13 20:19:40 renato Exp $ */ +/* $OpenBSD: packet.c,v 1.64 2016/06/18 17:31:32 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -629,9 +629,6 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msgid, send_notification_nbr(nbr, status, msgid, type); - /* try to flush write buffer, if it fails tough shit */ - msgbuf_write(&nbr->tcp->wbuf.wbuf); - nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); break; default: @@ -707,6 +704,8 @@ tcp_new(int fd, struct nbr *nbr) static void tcp_close(struct tcp_conn *tcp) { + /* try to flush write buffer */ + msgbuf_write(&tcp->wbuf.wbuf); evbuf_clear(&tcp->wbuf); if (tcp->nbr) { |