diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-03-23 22:26:35 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-03-23 22:26:35 +0000 |
commit | 09e412c5ea466048906589a8ee6631301516164f (patch) | |
tree | ef795ee7299cdcf04e5a8e6675aa296d3e1a0843 /usr.sbin | |
parent | 8548c5020c59d84a2d2cd9f6d7b02f69319ae4b5 (diff) |
Move the neighbor checking code from merge_config() to neighbor_consistent()
where it belongs. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/config.c | 22 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 23 |
2 files changed, 24 insertions, 21 deletions
diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index 9e7cabf33eb..01977f84a94 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.41 2005/03/15 14:40:08 henning Exp $ */ +/* $OpenBSD: config.c,v 1.42 2005/03/23 22:26:34 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -39,9 +39,7 @@ int merge_config(struct bgpd_config *xconf, struct bgpd_config *conf, struct peer *peer_l, struct listen_addrs *listen_addrs) { - struct peer *p; struct listen_addr *la; - int errs = 0; /* preserve cmd line opts */ conf->opts = xconf->opts; @@ -60,22 +58,6 @@ merge_config(struct bgpd_config *xconf, struct bgpd_config *conf, if ((conf->flags & BGPD_FLAG_REFLECTOR) && conf->clusterid == 0) conf->clusterid = conf->bgpid; - for (p = peer_l; p != NULL; p = p->next) { - p->conf.ebgp = (p->conf.remote_as != conf->as); - if (p->conf.announce_type == ANNOUNCE_UNDEF) - p->conf.announce_type = p->conf.ebgp == 0 ? - ANNOUNCE_ALL : ANNOUNCE_SELF; - if (p->conf.enforce_as == ENFORCE_AS_UNDEF) - p->conf.enforce_as = p->conf.ebgp == 0 ? - ENFORCE_AS_OFF : ENFORCE_AS_ON; - if (p->conf.reflector_client && p->conf.ebgp) { - log_peer_warnx(&p->conf, "configuration error: " - "EBGP neighbors are not allowed in route " - "reflector clusters"); - return (1); - } - } - if (xconf->listen_addrs != NULL) { while ((la = TAILQ_FIRST(xconf->listen_addrs)) != NULL) { TAILQ_REMOVE(xconf->listen_addrs, la, entry); @@ -88,7 +70,7 @@ merge_config(struct bgpd_config *xconf, struct bgpd_config *conf, xconf->listen_addrs = listen_addrs; - return (errs); + return (0); } u_int32_t diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 5fdff88575c..7865bf13601 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.153 2005/03/16 10:50:26 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.154 2005/03/23 22:26:34 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2117,6 +2117,27 @@ neighbor_consistent(struct peer *p) return (-1); } + if (!conf->as) { + yyerror("AS needs to be given before neighbor definitions"); + return (-1); + } + + /* set default values if they where undefined */ + p->conf.ebgp = (p->conf.remote_as != conf->as); + if (p->conf.announce_type == ANNOUNCE_UNDEF) + p->conf.announce_type = p->conf.ebgp == 0 ? + ANNOUNCE_ALL : ANNOUNCE_SELF; + if (p->conf.enforce_as == ENFORCE_AS_UNDEF) + p->conf.enforce_as = p->conf.ebgp == 0 ? + ENFORCE_AS_OFF : ENFORCE_AS_ON; + + /* EBGP neighbors are not allowed in route reflector clusters */ + if (p->conf.reflector_client && p->conf.ebgp) { + yyerror("EBGP neighbors are not allowed in route " + "reflector clusters"); + return (-1); + } + return (0); } |