diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 18:42:00 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 18:42:00 +0000 |
commit | 4bbbeedd28422326d4876132b79cdb39728fa694 (patch) | |
tree | 0ef17620c241aee107ad172046e0d76b09d5853c /usr.sbin | |
parent | 357bec510aebfba0e13d544b0a04ac7009abc178 (diff) |
Enable changing the router-id via config reload.
Now ldpd can start without a router-id, since it can be set later. Since
a router-id of 0.0.0.0 is invalid, interfaces and targeted-neighbors
will check for a valid router-id in order to be activated.
When the router-id is changed, all the neighborships are reset.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpd/adjacency.c | 13 | ||||
-rw-r--r-- | usr.sbin/ldpd/interface.c | 13 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 16 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 11 |
6 files changed, 49 insertions, 18 deletions
diff --git a/usr.sbin/ldpd/adjacency.c b/usr.sbin/ldpd/adjacency.c index 505acfb8d5d..3596315fd74 100644 --- a/usr.sbin/ldpd/adjacency.c +++ b/usr.sbin/ldpd/adjacency.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adjacency.c,v 1.16 2016/05/23 18:33:56 renato Exp $ */ +/* $OpenBSD: adjacency.c,v 1.17 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -213,15 +213,20 @@ tnbr_check(struct tnbr *tnbr) void tnbr_update(struct tnbr *tnbr) { - int socket_ok; + int socket_ok, rtr_id_ok; if (global.ldp_edisc_socket != -1) socket_ok = 1; else socket_ok = 0; + if (leconf->rtr_id.s_addr != INADDR_ANY) + rtr_id_ok = 1; + else + rtr_id_ok = 0; + if (tnbr->state == TNBR_STA_DOWN) { - if (!socket_ok) + if (!socket_ok || !rtr_id_ok) return; tnbr->state = TNBR_STA_ACTIVE; @@ -230,7 +235,7 @@ tnbr_update(struct tnbr *tnbr) evtimer_set(&tnbr->hello_timer, tnbr_hello_timer, tnbr); tnbr_start_hello_timer(tnbr); } else if (tnbr->state == TNBR_STA_ACTIVE) { - if (socket_ok) + if (socket_ok && rtr_id_ok) return; tnbr->state = TNBR_STA_DOWN; diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index 9d26b1b12dc..22a5ea17f84 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.39 2016/05/23 18:40:15 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.40 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -239,7 +239,7 @@ if_reset(struct iface *iface) int if_update(struct iface *iface) { - int link_ok, addr_ok = 0, socket_ok; + int link_ok, addr_ok = 0, socket_ok, rtr_id_ok; int ret; link_ok = (iface->flags & IFF_UP) && @@ -252,15 +252,20 @@ if_update(struct iface *iface) else socket_ok = 0; + if (leconf->rtr_id.s_addr != INADDR_ANY) + rtr_id_ok = 1; + else + rtr_id_ok = 0; + if (iface->state == IF_STA_DOWN) { - if (!link_ok || !addr_ok || !socket_ok) + if (!link_ok || !addr_ok || !socket_ok || !rtr_id_ok) return (0); iface->state = IF_STA_ACTIVE; ret = if_start(iface); } else { - if (link_ok && addr_ok && socket_ok) + if (link_ok && addr_ok && socket_ok && rtr_id_ok) return (0); iface->state = IF_STA_DOWN; diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 935257ad8d2..29d66ed65f3 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.41 2016/05/23 18:40:15 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.42 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -667,7 +667,19 @@ merge_global(struct ldpd_conf *conf, struct ldpd_conf *xconf) struct nbr_params *nbrp; int egress_label_changed = 0; - /* change of rtr_id needs a restart */ + /* change of router-id requires resetting all neighborships */ + if (conf->rtr_id.s_addr != xconf->rtr_id.s_addr) { + if (ldpd_process == PROC_LDP_ENGINE) { + ldpe_reset_nbrs(); + if (conf->rtr_id.s_addr == INADDR_ANY || + xconf->rtr_id.s_addr == INADDR_ANY) { + if_update_all(); + tnbr_update_all(); + } + } + conf->rtr_id = xconf->rtr_id; + } + if (conf->keepalive != xconf->keepalive) { conf->keepalive = xconf->keepalive; if (ldpd_process == PROC_LDP_ENGINE) diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 623632d828c..55ebe250fbc 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.54 2016/05/23 18:40:15 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.55 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -624,6 +624,15 @@ ldpe_close_sockets(void) } void +ldpe_reset_nbrs(void) +{ + struct nbr *nbr; + + RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) + session_shutdown(nbr, S_SHUTDOWN, 0, 0); +} + +void ldpe_remove_dynamic_tnbrs(void) { struct tnbr *tnbr, *safe; diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index ac8a04631ff..d56d2477ddb 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.49 2016/05/23 18:40:15 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.50 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -163,6 +163,7 @@ void ldpe_dispatch_lde(int, short, void *); void ldpe_dispatch_pfkey(int, short, void *); void ldpe_setup_sockets(int, int, int); void ldpe_close_sockets(void); +void ldpe_reset_nbrs(void); void ldpe_remove_dynamic_tnbrs(void); void ldpe_stop_init_backoff(void); void ldpe_iface_ctl(struct ctl_conn *, unsigned int); diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index fbaa1e679b9..cdfcb77c45d 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.47 2016/05/23 18:36:55 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.48 2016/05/23 18:41:59 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -1330,8 +1330,10 @@ get_rtr_id(void) localnet = htonl(INADDR_LOOPBACK & IN_CLASSA_NET); - if (getifaddrs(&ifap) == -1) - fatal("getifaddrs"); + if (getifaddrs(&ifap) == -1) { + log_warn("getifaddrs"); + return (0); + } for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (strncmp(ifa->ifa_name, "carp", 4) == 0) @@ -1346,9 +1348,6 @@ get_rtr_id(void) } freeifaddrs(ifap); - if (ip == 0) - fatal("router-id is 0.0.0.0"); - return (ip); } |