From: Pavel Tvrdik Date: Wed, 1 Jun 2016 14:33:40 +0000 (+0200) Subject: BGPsec: small refactoring of code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebb9ae8c6bae61003477d0c959d9db4dc2dc3483;p=thirdparty%2Fbird.git BGPsec: small refactoring of code 1) Move configuration global 'rpki dir' command to proto/rpki/config.Y 2) rpki_state_dir -> rpki_dir --- diff --git a/Makefile.in b/Makefile.in index 552e7a536..f20d0d7e5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,7 +108,7 @@ $(objdir)/sysdep/paths.h: Makefile echo >$@ "/* Generated by Makefile, don't edit manually! */" echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\"" echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\"" - echo >>$@ "#define PATH_RPKI_STATE_DIR \"@RPKI_STATE_DIR@\"" + echo >>$@ "#define PATH_RPKI_DIR \"@RPKI_DIR@\"" if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi # Finally include the computed dependencies diff --git a/conf/conf.c b/conf/conf.c index 9e9048589..bc4a827ff 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -104,7 +104,7 @@ config_alloc(byte *name) c->tf_route = c->tf_proto = (struct timeformat){"%T", "%F", 20*3600}; c->tf_base = c->tf_log = (struct timeformat){"%F %T", NULL, 0}; c->gr_wait = DEFAULT_GR_WAIT; - c->rpki_state_dir = PATH_RPKI_STATE_DIR; + c->rpki_dir = PATH_RPKI_DIR; return c; } diff --git a/conf/conf.h b/conf/conf.h index 421e2b458..224477895 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -31,7 +31,7 @@ struct config { ip_addr listen_bgp_addr; /* Listening BGP socket should use this address */ unsigned listen_bgp_port; /* Listening BGP socket should use this port (0 is default) */ u32 listen_bgp_flags; /* Listening BGP socket should use these flags */ - const char *rpki_state_dir; /* File path to save Router Keys for RPKI */ + const char *rpki_dir; /* File path to save Router Keys for RPKI */ unsigned proto_default_debug; /* Default protocol debug mask */ unsigned proto_default_mrtdump; /* Default protocol mrtdump mask */ struct timeformat tf_route; /* Time format for 'show route' */ diff --git a/configure.in b/configure.in index e2ef005d2..a748c5c1a 100644 --- a/configure.in +++ b/configure.in @@ -39,15 +39,15 @@ AC_SUBST(runtimedir) if test "$enable_debug" = yes ; then CONFIG_FILE="bird.conf" CONTROL_SOCKET="bird.ctl" - RPKI_STATE_DIR="rpki" + RPKI_DIR="rpki" else CONFIG_FILE="\$(sysconfdir)/bird.conf" CONTROL_SOCKET="$runtimedir/bird.ctl" - RPKI_STATE_DIR="\$(localstatedir)/rpki" + RPKI_DIR="\$(localstatedir)/rpki" fi AC_SUBST(CONFIG_FILE) AC_SUBST(CONTROL_SOCKET) -AC_SUBST(RPKI_STATE_DIR) +AC_SUBST(RPKI_DIR) AC_SEARCH_LIBS(clock_gettime, [c rt posix4], , AC_MSG_ERROR([[Function clock_gettime not available.]])) diff --git a/nest/config.Y b/nest/config.Y index 04c4415e3..7e34bb91f 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -457,11 +457,6 @@ password_item_params: | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); } ; -/* Overwrite RPKI State Dir for BGPSEC Router Keys */ - -CF_ADDTO(conf, rpki_state_dir) -rpki_state_dir: RPKI STATE DIR text ';' { new_config->rpki_state_dir = $4; } - /* Core commands */ CF_CLI_HELP(SHOW, ..., [[Show status information]]) diff --git a/proto/rpki/config.Y b/proto/rpki/config.Y index a0af7748e..6ac9ab47d 100644 --- a/proto/rpki/config.Y +++ b/proto/rpki/config.Y @@ -24,10 +24,17 @@ rpki_check_unused_hostname(void) CF_DECLS CF_KEYWORDS(RPKI, REMOTE, BIRD, PRIVATE, PUBLIC, KEY, SSH, ENCRYPTION, USER, - RETRY, REFRESH, EXPIRE, STATE, DIR) + RETRY, REFRESH, EXPIRE, DIR) CF_GRAMMAR +/* Overwrite RPKI directory for BGPSEC Router Keys */ + +CF_ADDTO(conf, rpki_dir) +rpki_dir: RPKI DIR text ';' { new_config->rpki_dir = $3; } + +/* RPKI Protocol */ + CF_ADDTO(proto, rpki_proto) rpki_proto_start: proto_start RPKI { diff --git a/proto/rpki/packets.c b/proto/rpki/packets.c index f6a5f77bc..f59eb8918 100644 --- a/proto/rpki/packets.c +++ b/proto/rpki/packets.c @@ -774,7 +774,7 @@ rpki_handle_router_key_pdu(struct rpki_cache *cache, const struct pdu_router_key { char file_name[4096]; /* PATH_MAX? */ char ski_hex[41]; - const char *state_dir = config->rpki_state_dir; + const char *state_dir = config->rpki_dir; int i; int fd = -1;