BGP uses lp_save / lp_restore instead of linpool flushing
It is too cryptic to flush tmp_linpool in these cases and we don't want anybody in the future to break this code by adding an allocation somewhere which should persist over that flush. Saving and restoring linpool state is safer.
This commit is contained in:
parent
7e86ff2076
commit
d39ef961d1
1 changed files with 12 additions and 2 deletions
|
@ -2323,6 +2323,9 @@ bgp_create_update(struct bgp_channel *c, byte *buf)
|
||||||
|
|
||||||
again: ;
|
again: ;
|
||||||
|
|
||||||
|
struct lp_state tmpp;
|
||||||
|
lp_save(tmp_linpool, &tmpp);
|
||||||
|
|
||||||
/* Initialize write state */
|
/* Initialize write state */
|
||||||
struct bgp_write_state s = {
|
struct bgp_write_state s = {
|
||||||
.proto = p,
|
.proto = p,
|
||||||
|
@ -2353,6 +2356,7 @@ again: ;
|
||||||
if (EMPTY_LIST(buck->prefixes))
|
if (EMPTY_LIST(buck->prefixes))
|
||||||
{
|
{
|
||||||
bgp_free_bucket(c, buck);
|
bgp_free_bucket(c, buck);
|
||||||
|
lp_restore(tmp_linpool, &tmpp);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2366,7 +2370,10 @@ again: ;
|
||||||
bgp_defer_bucket(c, buck);
|
bgp_defer_bucket(c, buck);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
|
{
|
||||||
|
lp_restore(tmp_linpool, &tmpp);
|
||||||
goto again;
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -2377,7 +2384,7 @@ again: ;
|
||||||
done:
|
done:
|
||||||
BGP_TRACE_RL(&rl_snd_update, D_PACKETS, "Sending UPDATE");
|
BGP_TRACE_RL(&rl_snd_update, D_PACKETS, "Sending UPDATE");
|
||||||
p->stats.tx_updates++;
|
p->stats.tx_updates++;
|
||||||
lp_flush(s.pool);
|
lp_restore(tmp_linpool, &tmpp);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2506,6 +2513,9 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, uint len)
|
||||||
|
|
||||||
bgp_start_timer(conn->hold_timer, conn->hold_time);
|
bgp_start_timer(conn->hold_timer, conn->hold_time);
|
||||||
|
|
||||||
|
struct lp_state tmpp;
|
||||||
|
lp_save(tmp_linpool, &tmpp);
|
||||||
|
|
||||||
/* Initialize parse state */
|
/* Initialize parse state */
|
||||||
struct bgp_parse_state s = {
|
struct bgp_parse_state s = {
|
||||||
.proto = p,
|
.proto = p,
|
||||||
|
@ -2587,7 +2597,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, uint len)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
rta_free(s.cached_rta);
|
rta_free(s.cached_rta);
|
||||||
lp_flush(s.pool);
|
lp_restore(tmp_linpool, &tmpp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue