mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-11 19:41:54 +00:00
MRT Table Dump: Bugfix creating filename from fmt
- At *BSD systems a command 'date +%f' returns only 'f' without percent - Small fixes for *BSD systems
This commit is contained in:
parent
0722998578
commit
2d2d8293b7
@ -170,8 +170,9 @@ mrt_peer_index_table_add_peer(struct mrt_peer_index_table *state, u32 peer_bgp_i
|
||||
struct mrt_buffer *msg = &state->msg;
|
||||
|
||||
u8 peer_type = MRT_PEER_TYPE_32BIT_ASN;
|
||||
if (sizeof(peer_ip_addr) > sizeof(ip4_addr))
|
||||
#ifdef IPV6
|
||||
peer_type |= MRT_PEER_TYPE_IPV6;
|
||||
#endif
|
||||
|
||||
mrt_buffer_put_var_autosize(msg, peer_type);
|
||||
mrt_buffer_put_var_autosize(msg, peer_bgp_id);
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include "nest/route.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#define MRT_HDR_LENGTH 12 /* MRT Timestamp + MRT Type + MRT Subtype + MRT Load Length */
|
||||
#define MRT_PEER_TYPE_32BIT_ASN 0b00000010 /* MRT Table Dump: Peer Index Table: Peer Type: Use 32bit ASN */
|
||||
#define MRT_PEER_TYPE_IPV6 0b00000001 /* MRT Table Dump: Peer Index Table: Peer Type: Use IPv6 IP Address */
|
||||
#define MRT_HDR_LENGTH 12 /* MRT Timestamp + MRT Type + MRT Subtype + MRT Load Length */
|
||||
#define MRT_PEER_TYPE_32BIT_ASN 2 /* MRT Table Dump: Peer Index Table: Peer Type: Use 32bit ASN */
|
||||
#define MRT_PEER_TYPE_IPV6 1 /* MRT Table Dump: Peer Index Table: Peer Type: Use IPv6 IP Address */
|
||||
|
||||
#ifdef PATH_MAX
|
||||
#define BIRD_PATH_MAX PATH_MAX
|
||||
|
@ -2858,7 +2858,7 @@ mrt_str_replace(const char *orig, const char *rep, const char *with)
|
||||
* ins points to the next occurrence of rep in orig
|
||||
* orig points to the remainder of orig after "end of rep"
|
||||
*/
|
||||
tmp = result = mb_alloc(&root_pool, strlen(orig) + (len_with - len_rep) * num_of_replacements + 1);
|
||||
tmp = result = mb_alloc(rt_table_pool, strlen(orig) + (len_with - len_rep) * num_of_replacements + 1);
|
||||
|
||||
if (!result)
|
||||
return NULL;
|
||||
@ -2890,17 +2890,17 @@ mrt_table_dump_get_realpath(const char *filename)
|
||||
void
|
||||
mrt_table_dump_init_file_descriptor(struct mrt_table_dump_ctx *state)
|
||||
{
|
||||
struct timeformat timestamp_fmt = {
|
||||
.fmt1 = mrt_table_dump_config_get_filename_fmt(state),
|
||||
};
|
||||
|
||||
char timestamp[TM_DATETIME_BUFFER_SIZE];
|
||||
tm_format_datetime(timestamp, ×tamp_fmt, now);
|
||||
char *tablename = state->config.table_cf->name;
|
||||
char *filename = mrt_str_replace(timestamp, "%f", tablename);
|
||||
char *filename_fmt = mrt_str_replace(mrt_table_dump_config_get_filename_fmt(state), "%f", tablename);
|
||||
|
||||
if (filename)
|
||||
if (filename_fmt)
|
||||
{
|
||||
struct timeformat timestamp_fmt = {
|
||||
.fmt1 = filename_fmt,
|
||||
};
|
||||
|
||||
char filename[TM_DATETIME_BUFFER_SIZE];
|
||||
tm_format_datetime(filename, ×tamp_fmt, now);
|
||||
state->rfile = tracked_fopen(rt_table_pool, filename, "a");
|
||||
|
||||
const char *filename_fullpath = mrt_table_dump_get_realpath(filename);
|
||||
@ -2923,14 +2923,14 @@ mrt_table_dump_init_file_descriptor(struct mrt_table_dump_ctx *state)
|
||||
cli_msg(13, "Dump of table %s is saving into file \"%s\"", tablename, state->file_path);
|
||||
}
|
||||
}
|
||||
mb_free(filename);
|
||||
mb_free(filename_fmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
log(L_ERR "Parsing MRT dump filename format \"%s\" for table %s failed", timestamp_fmt.fmt1, tablename);
|
||||
log(L_ERR "Parsing MRT dump filename filename_fmt \"%s\" for table %s failed", mrt_table_dump_config_get_filename_fmt(state), tablename);
|
||||
if (state->config.c.cli)
|
||||
{
|
||||
cli_msg(13, "Parsing filename format \"%s\" for table %s failed", timestamp_fmt.fmt1, tablename);
|
||||
cli_msg(13, "Parsing filename filename_fmt \"%s\" for table %s failed", mrt_table_dump_config_get_filename_fmt(state), tablename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user