diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 18:36:56 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 18:36:56 +0000 |
commit | 91a2d3e0814baccd85b9405c7abed7eeb129a355 (patch) | |
tree | 723a6a0edaca508f16725f6a8f23394a74608e3f /usr.sbin/ldpd | |
parent | e20a03db287c83c833556d124aafc7811d7aac86 (diff) |
Don't create l2vpn targeted neighbors inside the config parser.
When removing a configured pseudowire, we remove the associated tnbr
in ldpe_l2vpn_pw_exit(). So, when a new pseudowire is configured, it
makes sense to create its tnbr in ldpe_l2vpn_pw_init() to keep things
consistent.
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/l2vpn.c | 15 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.h | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 13 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 17 |
5 files changed, 30 insertions, 26 deletions
diff --git a/usr.sbin/ldpd/l2vpn.c b/usr.sbin/ldpd/l2vpn.c index bc36ab1c7e1..b02befbae58 100644 --- a/usr.sbin/ldpd/l2vpn.c +++ b/usr.sbin/ldpd/l2vpn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2vpn.c,v 1.11 2016/05/23 18:33:56 renato Exp $ */ +/* $OpenBSD: l2vpn.c,v 1.12 2016/05/23 18:36:55 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -83,8 +83,9 @@ l2vpn_del(struct l2vpn *l2vpn) free(lif); } while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { + l2vpn_pw_exit(pw); LIST_REMOVE(pw, entry); - l2vpn_pw_del(pw); + free(pw); } free(l2vpn); @@ -167,13 +168,12 @@ l2vpn_pw_init(struct l2vpn_pw *pw) } void -l2vpn_pw_del(struct l2vpn_pw *pw) +l2vpn_pw_exit(struct l2vpn_pw *pw) { struct fec fec; l2vpn_pw_fec(pw, &fec); lde_kernel_remove(&fec, pw->lsr_id); - free(pw); } void @@ -472,8 +472,13 @@ ldpe_l2vpn_pw_init(struct l2vpn_pw *pw) struct tnbr *tnbr; tnbr = tnbr_find(leconf, pw->lsr_id); - if (!event_initialized(&tnbr->hello_timer)) + if (tnbr == NULL) { + tnbr = tnbr_new(leconf, pw->lsr_id); tnbr_update(tnbr); + LIST_INSERT_HEAD(&leconf->tnbr_list, tnbr, entry); + } + + tnbr->pw_count++; } void diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h index 4054635d2fa..02dd3faef38 100644 --- a/usr.sbin/ldpd/lde.h +++ b/usr.sbin/ldpd/lde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.h,v 1.32 2016/05/23 17:43:42 renato Exp $ */ +/* $OpenBSD: lde.h,v 1.33 2016/05/23 18:36:55 renato Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -170,8 +170,8 @@ struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *); struct l2vpn_if *l2vpn_if_find(struct l2vpn *, unsigned int); struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *); struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, unsigned int); -void l2vpn_pw_del(struct l2vpn_pw *); void l2vpn_pw_init(struct l2vpn_pw *); +void l2vpn_pw_exit(struct l2vpn_pw *); void l2vpn_pw_fec(struct l2vpn_pw *, struct fec *); void l2vpn_pw_reset(struct l2vpn_pw *); int l2vpn_pw_ok(struct l2vpn_pw *, struct fec_nh *); diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index b87dcf4f05c..5070735f691 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.39 2016/05/23 18:33:56 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.40 2016/05/23 18:36:55 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -904,20 +904,19 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) LIST_FOREACH_SAFE(pw, &l2vpn->pw_list, entry, ptmp) { /* find deleted pseudowires */ if ((xp = l2vpn_pw_find(xl, pw->ifindex)) == NULL) { - LIST_REMOVE(pw, entry); - switch (ldpd_process) { case PROC_LDE_ENGINE: - l2vpn_pw_del(pw); + l2vpn_pw_exit(pw); break; case PROC_LDP_ENGINE: ldpe_l2vpn_pw_exit(pw); - free(pw); break; case PROC_MAIN: - free(pw); break; } + + LIST_REMOVE(pw, entry); + free(pw); } } LIST_FOREACH_SAFE(xp, &xl->pw_list, entry, ptmp) { @@ -954,7 +953,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) switch (ldpd_process) { case PROC_LDE_ENGINE: - l2vpn_pw_del(pw); + l2vpn_pw_exit(pw); l2vpn_pw_init(xp); break; case PROC_LDP_ENGINE: diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 8db90f700be..dcd74df1663 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.52 2016/05/23 18:35:10 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.53 2016/05/23 18:36:55 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -73,6 +73,7 @@ pid_t ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2], int pipe_parent2lde[2]) { + struct l2vpn *l2vpn; struct passwd *pw; struct event ev_sigint, ev_sigterm; pid_t pid; @@ -169,6 +170,10 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[2], if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL) fatal(__func__); + /* create targeted neighbors for l2vpn pseudowires */ + LIST_FOREACH(l2vpn, &leconf->l2vpn_list, entry) + ldpe_l2vpn_init(l2vpn); + event_dispatch(); ldpe_shutdown(); diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index d5379b5cf9a..fbaa1e679b9 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.46 2016/05/23 18:31:12 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.47 2016/05/23 18:36:55 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -352,7 +352,6 @@ pwopts : PWID NUMBER { } | NEIGHBOR STRING { struct in_addr addr; - struct tnbr *t; if (inet_aton($2, &addr) == 0) { yyerror( @@ -361,16 +360,12 @@ pwopts : PWID NUMBER { YYERROR; } free($2); - - pw->lsr_id = addr; - - t = tnbr_find(conf, addr); - if (t == NULL) { - t = tnbr_new(conf, addr); - LIST_INSERT_HEAD(&conf->tnbr_list, t, entry); + if (bad_ip_addr(addr)) { + yyerror("invalid neighbor-id"); + YYERROR; } - t->pw_count++; + pw->lsr_id = addr; } | pw_defaults ; @@ -1202,7 +1197,7 @@ conf_get_tnbr(struct in_addr addr) struct tnbr *t; t = tnbr_find(conf, addr); - if (t && (t->flags & F_TNBR_CONFIGURED)) { + if (t) { yyerror("targeted neighbor %s already configured", inet_ntoa(addr)); return (NULL); |