summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/bgpd/bgpd.c20
-rw-r--r--usr.sbin/bgpd/bgpd.h5
-rw-r--r--usr.sbin/bgpd/config.c7
-rw-r--r--usr.sbin/bgpd/parse.y11
4 files changed, 21 insertions, 22 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 1108b71b164..9021f96a9a5 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.175 2015/02/09 11:37:31 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.176 2015/03/14 02:43:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -97,6 +97,8 @@ usage(void)
#define POLL_MAX 3
#define MAX_TIMEOUT 3600
+int cmd_opts;
+
int
main(int argc, char *argv[])
{
@@ -128,7 +130,7 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "cdD:f:nv")) != -1) {
switch (ch) {
case 'c':
- conf.opts |= BGPD_OPT_FORCE_DEMOTE;
+ cmd_opts |= BGPD_OPT_FORCE_DEMOTE;
break;
case 'd':
debug = 1;
@@ -142,12 +144,12 @@ main(int argc, char *argv[])
conffile = optarg;
break;
case 'n':
- conf.opts |= BGPD_OPT_NOACTION;
+ cmd_opts |= BGPD_OPT_NOACTION;
break;
case 'v':
- if (conf.opts & BGPD_OPT_VERBOSE)
- conf.opts |= BGPD_OPT_VERBOSE2;
- conf.opts |= BGPD_OPT_VERBOSE;
+ if (cmd_opts & BGPD_OPT_VERBOSE)
+ cmd_opts |= BGPD_OPT_VERBOSE2;
+ cmd_opts |= BGPD_OPT_VERBOSE;
log_verbose(1);
break;
default:
@@ -161,7 +163,7 @@ main(int argc, char *argv[])
if (argc > 0)
usage();
- if (conf.opts & BGPD_OPT_NOACTION) {
+ if (cmd_opts & BGPD_OPT_NOACTION) {
struct network_head net_l;
struct rdomain_head rdom_l;
struct filter_head rules_l;
@@ -170,7 +172,7 @@ main(int argc, char *argv[])
&rules_l, &rdom_l))
exit(1);
- if (conf.opts & BGPD_OPT_VERBOSE)
+ if (cmd_opts & BGPD_OPT_VERBOSE)
print_config(&conf, &ribnames, &net_l, peer_l, &rules_l,
&mrt_l, &rdom_l);
else
@@ -185,7 +187,7 @@ main(int argc, char *argv[])
errx(1, "unknown user %s", BGPD_USER);
log_init(debug);
- log_verbose(conf.opts & BGPD_OPT_VERBOSE);
+ log_verbose(cmd_opts & BGPD_OPT_VERBOSE);
if (!debug)
daemon(1, 0);
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 9f469cb798d..fb5ab850071 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.282 2014/11/03 16:55:59 bluhm Exp $ */
+/* $OpenBSD: bgpd.h,v 1.283 2015/03/14 02:43:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -199,7 +199,6 @@ struct bgpd_config {
struct listen_addrs *listen_addrs;
char *csock;
char *rcsock;
- int opts;
int flags;
int log;
u_int32_t bgpid;
@@ -212,6 +211,8 @@ struct bgpd_config {
u_int8_t fib_priority;
};
+extern int cmd_opts;
+
enum announce_type {
ANNOUNCE_UNDEF,
ANNOUNCE_SELF,
diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c
index 9859b04a470..25d55f371a5 100644
--- a/usr.sbin/bgpd/config.c
+++ b/usr.sbin/bgpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.59 2015/03/14 02:32:35 claudio Exp $ */
+/* $OpenBSD: config.c,v 1.60 2015/03/14 02:43:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -42,15 +42,12 @@ int
merge_config(struct bgpd_config *xconf, struct bgpd_config *conf,
struct peer *peer_l, struct listen_addrs *listen_addrs)
{
- struct listen_addr *nla, *ola, *next;
+ struct listen_addr *nla, *ola, *next;
/*
* merge the freshly parsed conf into the running xconf
*/
- /* preserve cmd line opts */
- conf->opts = xconf->opts;
-
if (!conf->as) {
log_warnx("configuration error: AS not given");
return (1);
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 8fb514a8802..ac954c8285e 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.276 2015/03/14 02:32:35 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.277 2015/03/14 02:43:02 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -306,7 +306,7 @@ yesno : STRING {
;
varset : STRING '=' string {
- if (conf->opts & BGPD_OPT_VERBOSE)
+ if (cmd_opts & BGPD_OPT_VERBOSE)
printf("%s = \"%s\"\n", $1, $3);
if (symset($1, $3, 0) == -1)
fatal("cannot store variable");
@@ -1302,7 +1302,7 @@ peeropts : REMOTEAS as4number {
}
free($2);
if (carp_demote_init(curpeer->conf.demote_group,
- conf->opts & BGPD_OPT_FORCE_DEMOTE) == -1) {
+ cmd_opts & BGPD_OPT_FORCE_DEMOTE) == -1) {
yyerror("error initializing group \"%s\"",
curpeer->conf.demote_group);
YYERROR;
@@ -1972,7 +1972,7 @@ filter_set_opt : LOCALPREF NUMBER {
if (($$ = calloc(1, sizeof(struct filter_set))) == NULL)
fatal(NULL);
$$->type = ACTION_PFTABLE;
- if (!(conf->opts & BGPD_OPT_NOACTION) &&
+ if (!(cmd_opts & BGPD_OPT_NOACTION) &&
pftable_exists($2) != 0) {
yyerror("pftable name does not exist");
free($2);
@@ -2582,7 +2582,6 @@ parse_config(char *filename, struct bgpd_config *xconf,
if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL)
fatal(NULL);
- conf->opts = xconf->opts;
conf->csock = strdup(SOCKET_NAME);
if ((file = pushfile(filename, 1)) == NULL) {
@@ -2631,7 +2630,7 @@ parse_config(char *filename, struct bgpd_config *xconf,
/* Free macros and check which have not been used. */
for (sym = TAILQ_FIRST(&symhead); sym != NULL; sym = next) {
next = TAILQ_NEXT(sym, entry);
- if ((conf->opts & BGPD_OPT_VERBOSE2) && !sym->used)
+ if ((cmd_opts & BGPD_OPT_VERBOSE2) && !sym->used)
fprintf(stderr, "warning: macro \"%s\" not "
"used\n", sym->nam);
if (!sym->persist) {