summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2019-03-15 09:54:55 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2019-03-15 09:54:55 +0000
commit88a70d09581d498eab51f838824a9e6885245903 (patch)
tree68be4a0a7502458d796661822e8295259f6b3eff
parentace2a0ead8129749e6be405252844ba3fcaf56b3 (diff)
Set all default values in init_config in parse.y and remove the special
ones in session.c. Adjust printconfig a bit to only show non default values and move mrt_mergeconfig into merge_conifg where it kind of belongs. OK benno@
-rw-r--r--usr.sbin/bgpd/config.c6
-rw-r--r--usr.sbin/bgpd/parse.y5
-rw-r--r--usr.sbin/bgpd/printconf.c16
-rw-r--r--usr.sbin/bgpd/session.c13
4 files changed, 17 insertions, 23 deletions
diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c
index ca2ec1b850e..e3a9a93fe61 100644
--- a/usr.sbin/bgpd/config.c
+++ b/usr.sbin/bgpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.85 2019/03/07 07:42:36 claudio Exp $ */
+/* $OpenBSD: config.c,v 1.86 2019/03/15 09:54:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -200,7 +200,6 @@ merge_config(struct bgpd_config *xconf, struct bgpd_config *conf,
if ((conf->flags & BGPD_FLAG_REFLECTOR) && conf->clusterid == 0)
conf->clusterid = conf->bgpid;
-
/* adjust FIB priority if changed */
/* if xconf is uninitialized we get RTP_NONE */
if (xconf->fib_priority != conf->fib_priority) {
@@ -226,6 +225,9 @@ merge_config(struct bgpd_config *xconf, struct bgpd_config *conf,
xconf->filters = conf->filters;
conf->filters = NULL;
+ /* merge mrt config */
+ mrt_mergeconfig(xconf->mrt, conf->mrt);
+
/* switch the roa, first remove the old one */
free_prefixtree(&xconf->roa);
/* then move the RB tree root */
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index e6207b6ad13..a0bca769d66 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.383 2019/03/09 10:05:58 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.384 2019/03/15 09:54:54 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -3249,6 +3249,8 @@ init_config(struct bgpd_config *c)
u_int rdomid;
c->min_holdtime = MIN_HOLDTIME;
+ c->holdtime = INTERVAL_HOLD;
+ c->connectretry = INTERVAL_CONNECTRETRY;
c->bgpid = get_bgpid();
c->fib_priority = RTP_BGP;
c->default_tableid = getrtable();
@@ -3362,7 +3364,6 @@ errors:
optimize_filters(conf->filters);
- mrt_mergeconfig(xconf->mrt, conf->mrt);
merge_config(xconf, conf, peer_l);
*xpeers = peer_l;
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index 80f733a5f2a..51019f1ecea 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.132 2019/02/26 10:49:15 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.133 2019/03/15 09:54:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -378,11 +378,11 @@ print_mainconf(struct bgpd_config *conf)
printf("socket \"%s\"\n", conf->csock);
if (conf->rcsock)
printf("socket \"%s\" restricted\n", conf->rcsock);
- if (conf->holdtime)
+ if (conf->holdtime != INTERVAL_HOLD)
printf("holdtime %u\n", conf->holdtime);
- if (conf->min_holdtime)
+ if (conf->min_holdtime != MIN_HOLDTIME)
printf("holdtime min %u\n", conf->min_holdtime);
- if (conf->connectretry)
+ if (conf->connectretry != INTERVAL_CONNECTRETRY)
printf("connect-retry %u\n", conf->connectretry);
if (conf->flags & BGPD_FLAG_NO_EVALUATE)
@@ -405,8 +405,9 @@ print_mainconf(struct bgpd_config *conf)
printf("nexthop qualify via bgp\n");
if (conf->flags & BGPD_FLAG_NEXTHOP_DEFAULT)
printf("nexthop qualify via default\n");
- printf("fib-priority %hhu", conf->fib_priority);
- printf("\n\n");
+ if (conf->fib_priority != RTP_BGP)
+ printf("fib-priority %hhu\n", conf->fib_priority);
+ printf("\n");
}
void
@@ -732,7 +733,8 @@ print_announce(struct peer_config *p, const char *c)
printf("%s\tannounce %s\n", c, aid2str(aid));
}
-void print_as(struct filter_rule *r)
+void
+print_as(struct filter_rule *r)
{
if (r->match.as.flags & AS_FLAG_AS_SET_NAME) {
printf("as-set \"%s\" ", r->match.as.name);
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 3b2453f1bd1..a4e242450fa 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.375 2019/03/07 07:42:36 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.376 2019/03/15 09:54:54 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -57,7 +57,6 @@
void session_sighdlr(int);
int setup_listeners(u_int *);
-void init_conf(struct bgpd_config *);
void init_peer(struct peer *);
void start_timer_holdtime(struct peer *);
void start_timer_keepalive(struct peer *);
@@ -585,15 +584,6 @@ session_main(int debug, int verbose)
}
void
-init_conf(struct bgpd_config *c)
-{
- if (!c->holdtime)
- c->holdtime = INTERVAL_HOLD;
- if (!c->connectretry)
- c->connectretry = INTERVAL_CONNECTRETRY;
-}
-
-void
init_peer(struct peer *p)
{
TAILQ_INIT(&p->timers);
@@ -2619,7 +2609,6 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
npeers = NULL;
copy_config(nconf, imsg.data);
- init_conf(nconf);
pending_reconf = 1;
break;
case IMSG_RECONF_PEER: