This diff is cleaning up a few minor things. It removes the init_conf()
function in session.c and moves it to init_config() where all defaults
should be set. Because of this printconf is a bit changed to only print
values which diverge from the default. Finally move mrt_mergeconfig into
merge_config.

OK?
-- 
:wq Claudio

Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/config.c,v
retrieving revision 1.85
diff -u -p -r1.85 config.c
--- config.c    7 Mar 2019 07:42:36 -0000       1.85
+++ config.c    11 Mar 2019 08:01:05 -0000
@@ -200,7 +200,6 @@ merge_config(struct bgpd_config *xconf, 
        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) {
@@ -225,6 +224,9 @@ merge_config(struct bgpd_config *xconf, 
        filterlist_free(xconf->filters);
        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);
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.383
diff -u -p -r1.383 parse.y
--- parse.y     9 Mar 2019 10:05:58 -0000       1.383
+++ parse.y     11 Mar 2019 08:01:47 -0000
@@ -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;
 
Index: printconf.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
retrieving revision 1.132
diff -u -p -r1.132 printconf.c
--- printconf.c 26 Feb 2019 10:49:15 -0000      1.132
+++ printconf.c 11 Mar 2019 08:05:12 -0000
@@ -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, co
                        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);
Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
retrieving revision 1.375
diff -u -p -r1.375 session.c
--- session.c   7 Mar 2019 07:42:36 -0000       1.375
+++ session.c   11 Mar 2019 08:01:05 -0000
@@ -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 *ib
                        npeers = NULL;
 
                        copy_config(nconf, imsg.data); 
-                       init_conf(nconf);
                        pending_reconf = 1;
                        break;
                case IMSG_RECONF_PEER:

Reply via email to