0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 18:21:54 +00:00

BGP: Static global linpools replaced by private linpools

This commit is contained in:
Maria Matejka 2022-01-10 09:31:27 +01:00
parent 8447b24e59
commit fccaeb0141
5 changed files with 13 additions and 36 deletions

View File

@ -42,6 +42,7 @@ typedef union list { /* In fact two overlayed nodes */
}; };
} list; } list;
#define STATIC_LIST_INIT(name) name = { .head = &name.tail_node, .tail = &name.head_node, .null = NULL }
#define NODE (node *) #define NODE (node *)
#define HEAD(list) ((void *)((list).head)) #define HEAD(list) ((void *)((list).head))

View File

@ -1847,13 +1847,11 @@ bgp_rt_notify(struct proto *P, struct channel *C, const net_addr *n, rte *new, c
if (new) if (new)
{ {
struct ea_list *attrs = bgp_update_attrs(p, c, new, new->attrs->eattrs, bgp_linpool2); struct ea_list *attrs = bgp_update_attrs(p, c, new, new->attrs->eattrs, C->rte_update_pool);
/* If attributes are invalid, we fail back to withdraw */ /* If attributes are invalid, we fail back to withdraw */
buck = attrs ? bgp_get_bucket(c, attrs) : bgp_get_withdraw_bucket(c); buck = attrs ? bgp_get_bucket(c, attrs) : bgp_get_withdraw_bucket(c);
path = new->src->global_id; path = new->src->global_id;
lp_flush(bgp_linpool2);
} }
else else
{ {
@ -2293,14 +2291,14 @@ bgp_rte_modify_stale(struct rt_export_request *req, const net_addr *n, struct rt
rte_import(&c->c.in_req, n, &e0, r->src); rte_import(&c->c.in_req, n, &e0, r->src);
else { else {
rta *a = e0.attrs = rta_do_cow(r->attrs, bgp_linpool); rta *a = e0.attrs = rta_do_cow(r->attrs, c->c.rte_update_pool);
bgp_set_attr_ptr(&(a->eattrs), bgp_linpool, BA_COMMUNITY, flags, bgp_set_attr_ptr(&(a->eattrs), c->c.rte_update_pool, BA_COMMUNITY, flags,
int_set_add(bgp_linpool, ad, BGP_COMM_LLGR_STALE)); int_set_add(c->c.rte_update_pool, ad, BGP_COMM_LLGR_STALE));
e0.pflags |= BGP_REF_STALE; e0.pflags |= BGP_REF_STALE;
rte_import(&c->c.in_req, n, &e0, r->src); rte_import(&c->c.in_req, n, &e0, r->src);
lp_flush(bgp_linpool); lp_flush(c->c.rte_update_pool);
} }
} while (count); } while (count);
} }

View File

@ -124,11 +124,8 @@
#include "bgp.h" #include "bgp.h"
/* Global list of listening sockets */
struct linpool *bgp_linpool; /* Global temporary pool */ static list STATIC_LIST_INIT(bgp_sockets);
struct linpool *bgp_linpool2; /* Global temporary pool for bgp_rt_notify() */
static list bgp_sockets; /* Global list of listening sockets */
static void bgp_connect(struct bgp_proto *p); static void bgp_connect(struct bgp_proto *p);
static void bgp_active(struct bgp_proto *p); static void bgp_active(struct bgp_proto *p);
@ -167,10 +164,6 @@ bgp_open(struct bgp_proto *p)
(p->ipv4 ? IPA_NONE4 : IPA_NONE6); (p->ipv4 ? IPA_NONE4 : IPA_NONE6);
uint port = p->cf->local_port; uint port = p->cf->local_port;
/* FIXME: Add some global init? */
if (!bgp_linpool)
init_list(&bgp_sockets);
/* We assume that cf->iface is defined iff cf->local_ip is link-local */ /* We assume that cf->iface is defined iff cf->local_ip is link-local */
WALK_LIST(bs, bgp_sockets) WALK_LIST(bs, bgp_sockets)
@ -207,12 +200,6 @@ bgp_open(struct bgp_proto *p)
add_tail(&bgp_sockets, &bs->n); add_tail(&bgp_sockets, &bs->n);
if (!bgp_linpool)
{
bgp_linpool = lp_new_default(proto_pool);
bgp_linpool2 = lp_new_default(proto_pool);
}
return 0; return 0;
err: err:
@ -241,15 +228,6 @@ bgp_close(struct bgp_proto *p)
rfree(bs->sk); rfree(bs->sk);
rem_node(&bs->n); rem_node(&bs->n);
mb_free(bs); mb_free(bs);
if (!EMPTY_LIST(bgp_sockets))
return;
rfree(bgp_linpool);
bgp_linpool = NULL;
rfree(bgp_linpool2);
bgp_linpool2 = NULL;
} }
static inline int static inline int
@ -1602,6 +1580,8 @@ bgp_start(struct proto *P)
p->startup_timer = tm_new_init(p->p.pool, bgp_startup_timeout, p, 0, 0); p->startup_timer = tm_new_init(p->p.pool, bgp_startup_timeout, p, 0, 0);
p->gr_timer = tm_new_init(p->p.pool, bgp_graceful_restart_timeout, p, 0, 0); p->gr_timer = tm_new_init(p->p.pool, bgp_graceful_restart_timeout, p, 0, 0);
p->rx_lp = lp_new_default(p->p.pool);
p->local_id = proto_get_router_id(P->cf); p->local_id = proto_get_router_id(P->cf);
if (p->rr_client) if (p->rr_client)
p->rr_cluster_id = p->cf->rr_cluster_id ? p->cf->rr_cluster_id : p->local_id; p->rr_cluster_id = p->cf->rr_cluster_id ? p->cf->rr_cluster_id : p->local_id;

View File

@ -312,6 +312,7 @@ struct bgp_proto {
struct bgp_conn *conn; /* Connection we have established */ struct bgp_conn *conn; /* Connection we have established */
struct bgp_conn outgoing_conn; /* Outgoing connection we're working with */ struct bgp_conn outgoing_conn; /* Outgoing connection we're working with */
struct bgp_conn incoming_conn; /* Incoming connection we have neither accepted nor rejected yet */ struct bgp_conn incoming_conn; /* Incoming connection we have neither accepted nor rejected yet */
struct linpool *rx_lp; /* Linpool for parsing received updates */
struct object_lock *lock; /* Lock for neighbor connection */ struct object_lock *lock; /* Lock for neighbor connection */
struct neighbor *neigh; /* Neighbor entry corresponding to remote ip, NULL if multihop */ struct neighbor *neigh; /* Neighbor entry corresponding to remote ip, NULL if multihop */
struct bgp_socket *sock; /* Shared listening socket */ struct bgp_socket *sock; /* Shared listening socket */
@ -494,9 +495,6 @@ bgp_parse_error(struct bgp_parse_state *s, uint subcode)
longjmp(s->err_jmpbuf, 1); longjmp(s->err_jmpbuf, 1);
} }
extern struct linpool *bgp_linpool;
extern struct linpool *bgp_linpool2;
void bgp_start_timer(timer *t, uint value); void bgp_start_timer(timer *t, uint value);
void bgp_check_config(struct bgp_config *c); void bgp_check_config(struct bgp_config *c);

View File

@ -2295,7 +2295,7 @@ again: ;
struct bgp_write_state s = { struct bgp_write_state s = {
.proto = p, .proto = p,
.channel = c, .channel = c,
.pool = bgp_linpool, .pool = c->c.rte_update_pool,
.mp_reach = (c->afi != BGP_AF_IPV4) || c->ext_next_hop, .mp_reach = (c->afi != BGP_AF_IPV4) || c->ext_next_hop,
.as4_session = p->as4_session, .as4_session = p->as4_session,
.add_path = c->add_path_tx, .add_path = c->add_path_tx,
@ -2480,7 +2480,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, uint len)
/* Initialize parse state */ /* Initialize parse state */
struct bgp_parse_state s = { struct bgp_parse_state s = {
.proto = p, .proto = p,
.pool = bgp_linpool, .pool = p->rx_lp,
.as4_session = p->as4_session, .as4_session = p->as4_session,
}; };