diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 16:18:52 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 16:18:52 +0000 |
commit | 9b77d13163cce652826e4446edc864a88be2e9e1 (patch) | |
tree | 6dd77b8e38c3f857b59a6df95c67a07af9198c74 | |
parent | ee37d06fb0be0723e1adb722bcd73a0cf713dca1 (diff) |
Make neighbor parameters per lsr-id not per transport-address.
With the advent of IPv6 support, a single neighbor can have two different
transport-addresses: one for ipv4 and one for ipv6. In order to define
neighbor-specific parameters in an indistinguishable way, define them
by lsr-id. This way we can switch between LDPov4 and LDPov6 and keep
the same configuration.
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 12 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.conf.5 | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldpd/packet.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/printconf.c | 4 |
6 files changed, 26 insertions, 25 deletions
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 1cf82c446a1..81a88673232 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.34 2016/05/23 16:14:36 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.35 2016/05/23 16:18:51 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -707,9 +707,9 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf) LIST_FOREACH_SAFE(nbrp, &conf->nbrp_list, entry, ntmp) { /* find deleted nbrps */ - if ((xn = nbr_params_find(xconf, nbrp->addr)) == NULL) { + if ((xn = nbr_params_find(xconf, nbrp->lsr_id)) == NULL) { if (ldpd_process == PROC_LDP_ENGINE) { - nbr = nbr_find_ldpid(nbrp->addr.s_addr); + nbr = nbr_find_ldpid(nbrp->lsr_id.s_addr); if (nbr) { if (nbr->state == NBR_STA_OPER) session_shutdown(nbr, @@ -723,12 +723,12 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf) } LIST_FOREACH_SAFE(xn, &xconf->nbrp_list, entry, ntmp) { /* find new nbrps */ - if ((nbrp = nbr_params_find(conf, xn->addr)) == NULL) { + if ((nbrp = nbr_params_find(conf, xn->lsr_id)) == NULL) { LIST_REMOVE(xn, entry); LIST_INSERT_HEAD(&conf->nbrp_list, xn, entry); if (ldpd_process == PROC_LDP_ENGINE) { - nbr = nbr_find_ldpid(xn->addr.s_addr); + nbr = nbr_find_ldpid(xn->lsr_id.s_addr); if (nbr) { if (nbr->state == NBR_STA_OPER) session_shutdown(nbr, @@ -749,7 +749,7 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf) nbrp->auth.md5key_len = xn->auth.md5key_len; if (ldpd_process == PROC_LDP_ENGINE) { - nbr = nbr_find_ldpid(nbrp->addr.s_addr); + nbr = nbr_find_ldpid(nbrp->lsr_id.s_addr); if (nbr && (nbr->auth.method != nbrp->auth.method || strcmp(nbr->auth.md5key, nbrp->auth.md5key) != 0)) { diff --git a/usr.sbin/ldpd/ldpd.conf.5 b/usr.sbin/ldpd/ldpd.conf.5 index 59e2bf2f3a0..6011d4b4312 100644 --- a/usr.sbin/ldpd/ldpd.conf.5 +++ b/usr.sbin/ldpd/ldpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ldpd.conf.5,v 1.23 2016/05/23 15:53:40 renato Exp $ +.\" $OpenBSD: ldpd.conf.5,v 1.24 2016/05/23 16:18:51 renato Exp $ .\" .\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> .\" Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -177,6 +177,7 @@ Note, however, that .Xr ldpd 8 uses the hello discovery mechanism to discover its neighbors. Without an underlying adjacency these commands have no effect. +A neighbor is identified by its LSR-ID, not by its remote address. .Bd -literal -offset indent neighbor A.B.C.D { } diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index 8b3f1824581..5e8bba48f91 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.60 2016/05/23 16:16:44 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.61 2016/05/23 16:18:51 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -256,7 +256,7 @@ nbr_new(struct in_addr id, struct in_addr addr) /* init pfkey - remove old if any, load new ones */ pfkey_remove(nbr); - nbrp = nbr_params_find(leconf, nbr->raddr); + nbrp = nbr_params_find(leconf, nbr->id); if (nbrp && pfkey_establish(nbr, nbrp) == -1) fatalx("pfkey setup failed"); @@ -508,7 +508,7 @@ nbr_establish_connection(struct nbr *nbr) return (-1); } - nbrp = nbr_params_find(leconf, nbr->raddr); + nbrp = nbr_params_find(leconf, nbr->id); if (nbrp && nbrp->auth.method == AUTH_MD5SIG) { if (sysdep.no_pfkey || sysdep.no_md5sig) { log_warnx("md5sig configured but not available"); @@ -587,37 +587,37 @@ nbr_send_labelmappings(struct nbr *nbr) } struct nbr_params * -nbr_params_new(struct in_addr addr) +nbr_params_new(struct in_addr lsr_id) { struct nbr_params *nbrp; if ((nbrp = calloc(1, sizeof(*nbrp))) == NULL) fatal(__func__); - nbrp->addr.s_addr = addr.s_addr; + nbrp->lsr_id = lsr_id; nbrp->auth.method = AUTH_NONE; return (nbrp); } struct nbr_params * -nbr_params_find(struct ldpd_conf *xconf, struct in_addr addr) +nbr_params_find(struct ldpd_conf *xconf, struct in_addr lsr_id) { struct nbr_params *nbrp; LIST_FOREACH(nbrp, &xconf->nbrp_list, entry) - if (nbrp->addr.s_addr == addr.s_addr) + if (nbrp->lsr_id.s_addr == lsr_id.s_addr) return (nbrp); return (NULL); } uint16_t -nbr_get_keepalive(struct in_addr addr) +nbr_get_keepalive(struct in_addr lsr_id) { struct nbr_params *nbrp; - nbrp = nbr_params_find(leconf, addr); + nbrp = nbr_params_find(leconf, lsr_id); if (nbrp && (nbrp->flags & F_NBRP_KEEPALIVE)) return (nbrp->keepalive); diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c index e020665d837..8c1c04d1ea0 100644 --- a/usr.sbin/ldpd/packet.c +++ b/usr.sbin/ldpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.50 2016/05/23 16:16:44 renato Exp $ */ +/* $OpenBSD: packet.c,v 1.51 2016/05/23 16:18:51 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -318,7 +318,7 @@ session_accept_nbr(struct nbr *nbr, int fd) int opt; socklen_t len; - nbrp = nbr_params_find(leconf, nbr->raddr); + nbrp = nbr_params_find(leconf, nbr->id); if (nbrp && nbrp->auth.method == AUTH_MD5SIG) { if (sysdep.no_pfkey || sysdep.no_md5sig) { log_warnx("md5sig configured but not available"); diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index e089918eb9d..f0334df81eb 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.38 2016/05/23 16:14:36 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.39 2016/05/23 16:18:51 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -1217,19 +1217,19 @@ conf_get_tnbr(struct in_addr addr) } struct nbr_params * -conf_get_nbrp(struct in_addr addr) +conf_get_nbrp(struct in_addr lsr_id) { struct nbr_params *n; LIST_FOREACH(n, &conf->nbrp_list, entry) { - if (n->addr.s_addr == addr.s_addr) { + if (n->lsr_id.s_addr == lsr_id.s_addr) { yyerror("neighbor %s already configured", - inet_ntoa(addr)); + inet_ntoa(lsr_id)); return (NULL); } } - n = nbr_params_new(addr); + n = nbr_params_new(lsr_id); return (n); } diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c index c27b62eb262..51c420168a9 100644 --- a/usr.sbin/ldpd/printconf.c +++ b/usr.sbin/ldpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.15 2016/05/23 16:14:37 renato Exp $ */ +/* $OpenBSD: printconf.c,v 1.16 2016/05/23 16:18:51 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -75,7 +75,7 @@ print_tnbr(struct tnbr *tnbr) void print_nbrp(struct nbr_params *nbrp) { - printf("\nneighbor %s {\n", inet_ntoa(nbrp->addr)); + printf("\nneighbor %s {\n", inet_ntoa(nbrp->lsr_id)); if (nbrp->flags & F_NBRP_KEEPALIVE) printf("\tkeepalive %u\n", nbrp->keepalive); if (nbrp->auth.method == AUTH_MD5SIG) |