From 9eca3e1a2e5a71c38ebd95ee01489d1eb62a063f Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 5 Nov 2024 17:35:20 +0100 Subject: [PATCH 1/2] Nest: Cleanup timeformat grammar --- conf/confbase.Y | 3 ++- nest/config.Y | 26 ++++++++++++++------------ sysdep/unix/config.Y | 1 - 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/conf/confbase.Y b/conf/confbase.Y index 1011a57c..5b00937f 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -96,7 +96,8 @@ CF_DECLS struct f_prefix px; struct proto_spec ps; struct channel_limit cl; - struct timeformat *tf; + struct timeformat tf; + struct timeformat *tfp; mpls_label_stack *mls; const struct adata *bs; struct aggr_item_node *ai; diff --git a/nest/config.Y b/nest/config.Y index 2b92ea52..f2a4f84b 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -153,6 +153,8 @@ CF_ENUM(T_ENUM_MPLS_POLICY, MPLS_POLICY_, NONE, STATIC, PREFIX, AGGREGATE, VRF) %type proto_patt proto_patt2 %type channel_start proto_channel %type limit_spec +%type timeformat_spec +%type timeformat_which %type r_args_for_val %type r_args_for %type channel_sym @@ -390,6 +392,10 @@ debug_default: conf: timeformat_base ; +timeformat_base: + TIMEFORMAT timeformat_which timeformat_spec ';' { *$2 = $3; } + ; + timeformat_which: ROUTE { $$ = &new_config->tf_route; } | PROTOCOL { $$ = &new_config->tf_proto; } @@ -398,18 +404,14 @@ timeformat_which: ; timeformat_spec: - timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; } - | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, (s64) $3 S_}; } - | timeformat_which ISO SHORT { *$1 = TM_ISO_SHORT_S; } - | timeformat_which ISO SHORT MS { *$1 = TM_ISO_SHORT_MS; } - | timeformat_which ISO SHORT US { *$1 = TM_ISO_SHORT_US; } - | timeformat_which ISO LONG { *$1 = TM_ISO_LONG_S; } - | timeformat_which ISO LONG MS { *$1 = TM_ISO_LONG_MS; } - | timeformat_which ISO LONG US { *$1 = TM_ISO_LONG_US; } - ; - -timeformat_base: - TIMEFORMAT timeformat_spec ';' + TEXT { $$ = (struct timeformat){$1, NULL, 0}; } + | TEXT expr TEXT { $$ = (struct timeformat){$1, $3, (s64) $2 S_}; } + | ISO SHORT { $$ = TM_ISO_SHORT_S; } + | ISO SHORT MS { $$ = TM_ISO_SHORT_MS; } + | ISO SHORT US { $$ = TM_ISO_SHORT_US; } + | ISO LONG { $$ = TM_ISO_LONG_S; } + | ISO LONG MS { $$ = TM_ISO_LONG_MS; } + | ISO LONG US { $$ = TM_ISO_LONG_US; } ; diff --git a/sysdep/unix/config.Y b/sysdep/unix/config.Y index 7607f34a..f4e70d19 100644 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@ -24,7 +24,6 @@ CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT, THREADS) %type log_mask log_mask_list log_cat cfg_timeout %type cfg_name -%type timeformat_which %type syslog_name CF_GRAMMAR From 82d57fb7adf02b297840ab710737df6043832ce2 Mon Sep 17 00:00:00 2001 From: Piotr Wydrych Date: Tue, 5 Nov 2024 18:53:22 +0100 Subject: [PATCH 2/2] CLI: Add timeformat command Adds ability to override time format of show commands for current CLI session so that it does not depend on configuration and may ease parsing when CLI is called from tools. Minor changes by committer. --- doc/bird.sgml | 7 +++++++ doc/reply_codes | 1 + nest/cli.c | 30 ++++++++++++++++++++++++++++++ nest/cli.h | 3 +++ nest/cmds.c | 7 ++++--- nest/config.Y | 10 ++++++++++ nest/proto.c | 2 +- nest/rt-show.c | 2 +- proto/bfd/bfd.c | 2 +- 9 files changed, 58 insertions(+), 6 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index 3faa9f3c..0d1e6f49 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1437,6 +1437,13 @@ This argument can be omitted if there exists only a single instance. pipe protocol, both directions are always reloaded together (