summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-06-08 23:30:08 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-06-08 23:30:08 +0000
commitcb55fe595fc7409d02f6f5535c1f50845f474136 (patch)
tree1248903e6a2caf511cd08ff10194cd03c339dbac
parent2205165babde0e7e7932792888f4a6cf6624e97e (diff)
Fix quick reconnect when the transport address is changed.
When the transport address is changed, we can't try to reconnect to the neighbors inside merge_af() because the ldpe process still didn't receive the new network sockets from the parent at this point. To resolve this, try to reconnect just after we receive these sockets.
-rw-r--r--usr.sbin/ldpd/ldpd.c19
-rw-r--r--usr.sbin/ldpd/ldpe.c21
2 files changed, 21 insertions, 19 deletions
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index 4c20b15479a..fa18779a515 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.50 2016/06/06 16:42:41 renato Exp $ */
+/* $OpenBSD: ldpd.c,v 1.51 2016/06/08 23:30:07 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -810,8 +810,6 @@ merge_global(struct ldpd_conf *conf, struct ldpd_conf *xconf)
static void
merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
{
- struct nbr *nbr;
- struct nbr_params *nbrp;
int egress_label_changed = 0;
if (af_conf->keepalive != xa->keepalive) {
@@ -854,21 +852,6 @@ merge_af(int af, struct ldpd_af_conf *af_conf, struct ldpd_af_conf *xa)
if (ldpd_process == PROC_MAIN)
imsg_compose_event(iev_ldpe, IMSG_CLOSE_SOCKETS, af,
0, -1, NULL, 0);
- if (ldpd_process == PROC_LDP_ENGINE) {
- RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) {
- if (nbr->af != af)
- continue;
-
- session_shutdown(nbr, S_SHUTDOWN, 0, 0);
- pfkey_remove(nbr);
- nbr->laddr = af_conf->trans_addr;
- nbrp = nbr_params_find(leconf, nbr->id);
- if (nbrp && pfkey_establish(nbr, nbrp) == -1)
- fatalx("pfkey setup failed");
- if (nbr_session_active_role(nbr))
- nbr_establish_connection(nbr);
- }
- }
}
}
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 0700a789919..8e33edf243d 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.62 2016/06/06 16:42:41 renato Exp $ */
+/* $OpenBSD: ldpe.c,v 1.63 2016/06/08 23:30:07 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -230,6 +230,8 @@ ldpe_dispatch_main(int fd, short event, void *bula)
static int disc_socket = -1;
static int edisc_socket = -1;
static int session_socket = -1;
+ struct nbr *nbr;
+ struct nbr_params *nbrp;
int n, shut = 0;
if (event & EV_READ) {
@@ -304,6 +306,12 @@ ldpe_dispatch_main(int fd, short event, void *bula)
case IMSG_CLOSE_SOCKETS:
af = imsg.hdr.peerid;
+ RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) {
+ if (nbr->af != af)
+ continue;
+ session_shutdown(nbr, S_SHUTDOWN, 0, 0);
+ pfkey_remove(nbr);
+ }
ldpe_close_sockets(af);
if_update_all(af);
tnbr_update_all(af);
@@ -349,6 +357,17 @@ ldpe_dispatch_main(int fd, short event, void *bula)
session_socket);
if_update_all(af);
tnbr_update_all(af);
+ RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) {
+ if (nbr->af != af)
+ continue;
+ nbr->laddr = (ldp_af_conf_get(leconf,
+ af))->trans_addr;
+ nbrp = nbr_params_find(leconf, nbr->id);
+ if (nbrp && pfkey_establish(nbr, nbrp) == -1)
+ fatalx("pfkey setup failed");
+ if (nbr_session_active_role(nbr))
+ nbr_establish_connection(nbr);
+ }
break;
case IMSG_RECONF_CONF:
if ((nconf = malloc(sizeof(struct ldpd_conf))) ==