0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-15 13:31:54 +00:00

mrt compile fixup after rebase

This commit is contained in:
Maria Matejka 2024-08-28 16:33:58 +02:00
parent 0656ff59c2
commit fb2b3836ea
3 changed files with 22 additions and 18 deletions

View File

@ -145,7 +145,7 @@ bgp_dump_message(struct bgp_conn *conn, byte *pkt, uint len)
d.msg_len = len; d.msg_len = len;
d.add_path = bgp_estimate_add_path(conn->bgp, pkt, len); d.add_path = bgp_estimate_add_path(conn->bgp, pkt, len);
mrt_dump_bgp_message(&d); mrt_dump_bgp_message(&d, conn->bgp->p.pool);
} }
void void
@ -157,7 +157,7 @@ bgp_dump_state_change(struct bgp_conn *conn, uint old, uint new)
d.old_state = old; d.old_state = old;
d.new_state = new; d.new_state = new;
mrt_dump_bgp_state_change(&d); mrt_dump_bgp_state_change(&d, conn->bgp->p.pool);
} }
static byte * static byte *

View File

@ -83,6 +83,13 @@ mrt_buffer_init(buffer *b, pool *pool, size_t n)
b->end = b->start + n; b->end = b->start + n;
} }
static void
mrt_buffer_free(buffer *b)
{
mb_free(b->start);
b->start = b->pos = b->end = NULL;
}
static void static void
mrt_buffer_grow(buffer *b, size_t n) mrt_buffer_grow(buffer *b, size_t n)
{ {
@ -786,17 +793,12 @@ mrt_dump_cmd(struct mrt_dump_data *d)
*/ */
static buffer * static buffer *
mrt_bgp_buffer(void) mrt_bgp_buffer(pool *p)
{ {
/* Static buffer for BGP4MP dump, TODO: change to use MRT protocol */ /* Static buffer for BGP4MP dump, TODO: change to use MRT protocol */
static buffer b; static _Thread_local buffer b;
ASSERT(this_metaloop);
log("loop in mrt %x, pool %i (main loop is %x, pool %i)", this_metaloop, this_metaloop->pool, &main_birdloop, main_birdloop.pool);
ASSERT(this_metaloop->pool);
if (!b.start)
mrt_buffer_init(&b, this_metaloop->pool, 1024);
mrt_buffer_init(&b, p, 1024);
return &b; return &b;
} }
@ -830,7 +832,7 @@ mrt_bgp_header(buffer *b, struct mrt_bgp_data *d)
} }
void void
mrt_dump_bgp_message(struct mrt_bgp_data *d) mrt_dump_bgp_message(struct mrt_bgp_data *d, pool *p)
{ {
const u16 subtypes[] = { const u16 subtypes[] = {
MRT_BGP4MP_MESSAGE, MRT_BGP4MP_MESSAGE_AS4, MRT_BGP4MP_MESSAGE, MRT_BGP4MP_MESSAGE_AS4,
@ -839,15 +841,16 @@ mrt_dump_bgp_message(struct mrt_bgp_data *d)
MRT_BGP4MP_MESSAGE_LOCAL_ADDPATH, MRT_BGP4MP_MESSAGE_AS4_LOCAL_ADDPATH, MRT_BGP4MP_MESSAGE_LOCAL_ADDPATH, MRT_BGP4MP_MESSAGE_AS4_LOCAL_ADDPATH,
}; };
buffer *b = mrt_bgp_buffer(); buffer *b = mrt_bgp_buffer(p);
mrt_init_message(b, MRT_BGP4MP, subtypes[d->as4 + 4*d->add_path]); mrt_init_message(b, MRT_BGP4MP, subtypes[d->as4 + 4*d->add_path]);
mrt_bgp_header(b, d); mrt_bgp_header(b, d);
mrt_put_data(b, d->message, d->msg_len); mrt_put_data(b, d->message, d->msg_len);
mrt_dump_message(b, rf_fileno(OBSREF_GET(config)->mrtdump_file)); mrt_dump_message(b, rf_fileno(OBSREF_GET(config)->mrtdump_file));
mrt_buffer_free(b);
} }
void void
mrt_dump_bgp_state_change(struct mrt_bgp_data *d) mrt_dump_bgp_state_change(struct mrt_bgp_data *d, pool *p)
{ {
/* Convert state from our BS_* values to values used in MRTDump */ /* Convert state from our BS_* values to values used in MRTDump */
const u16 states[BS_MAX] = {1, 2, 3, 4, 5, 6, 1}; const u16 states[BS_MAX] = {1, 2, 3, 4, 5, 6, 1};
@ -858,12 +861,13 @@ mrt_dump_bgp_state_change(struct mrt_bgp_data *d)
/* Always use AS4 mode for STATE_CHANGE */ /* Always use AS4 mode for STATE_CHANGE */
d->as4 = 1; d->as4 = 1;
buffer *b = mrt_bgp_buffer(); buffer *b = mrt_bgp_buffer(p);
mrt_init_message(b, MRT_BGP4MP, MRT_BGP4MP_STATE_CHANGE_AS4); mrt_init_message(b, MRT_BGP4MP, MRT_BGP4MP_STATE_CHANGE_AS4);
mrt_bgp_header(b, d); mrt_bgp_header(b, d);
mrt_put_u16(b, states[d->old_state]); mrt_put_u16(b, states[d->old_state]);
mrt_put_u16(b, states[d->new_state]); mrt_put_u16(b, states[d->new_state]);
mrt_dump_message(b, rf_fileno(OBSREF_GET(config)->mrtdump_file)); mrt_dump_message(b, rf_fileno(OBSREF_GET(config)->mrtdump_file));
mrt_buffer_free(b);
} }

View File

@ -146,12 +146,12 @@ struct mrt_bgp_data {
#ifdef CONFIG_MRT #ifdef CONFIG_MRT
void mrt_dump_cmd(struct mrt_dump_data *d); void mrt_dump_cmd(struct mrt_dump_data *d);
void mrt_dump_bgp_message(struct mrt_bgp_data *d); void mrt_dump_bgp_message(struct mrt_bgp_data *d, pool *p);
void mrt_dump_bgp_state_change(struct mrt_bgp_data *d); void mrt_dump_bgp_state_change(struct mrt_bgp_data *d, pool *p);
void mrt_check_config(struct proto_config *C); void mrt_check_config(struct proto_config *C);
#else #else
static inline void mrt_dump_bgp_message(struct mrt_bgp_data *d UNUSED) { } static inline void mrt_dump_bgp_message(struct mrt_bgp_data *d UNUSED, pool *p UNUSED) { }
static inline void mrt_dump_bgp_state_change(struct mrt_bgp_data *d UNUSED) { } static inline void mrt_dump_bgp_state_change(struct mrt_bgp_data *d UNUSED, pool *p UNUSED) { }
#endif #endif
#endif /* _BIRD_MRT_H_ */ #endif /* _BIRD_MRT_H_ */