summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-24 16:10:59 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-25 09:52:28 +0200
commitce7495b49a5192b1cba17fd88cdb2495a40824e2 (patch)
tree005901ea2c816483fd1e195a066b0685f8c4d7b9 /proto
parent19e79eb8adddb6194248974443b9a906f66984ce (diff)
Refactoring of domains connected to pools
Diffstat (limited to 'proto')
-rw-r--r--proto/bfd/bfd.c4
-rw-r--r--proto/bgp/bgp.c17
2 files changed, 16 insertions, 5 deletions
diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c
index f7d8f8d9..e373e4dd 100644
--- a/proto/bfd/bfd.c
+++ b/proto/bfd/bfd.c
@@ -1232,7 +1232,9 @@ bfd_build(void)
{
proto_build(&proto_bfd);
- bfd_global.lock = DOMAIN_NEW(rtable, "BFD Global");
+ bfd_global.lock = DOMAIN_NEW(rtable);
+ DOMAIN_SETUP(rtable, bfd_global.lock, "BFD Global", NULL);
+
init_list(&bfd_global.wait_list);
init_list(&bfd_global.pickup_list);
init_list(&bfd_global.proto_list);
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index e60884ba..f4d80e8d 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -132,7 +132,8 @@ static list STATIC_LIST_INIT(bgp_sockets); /* Global list of listening sockets
static list STATIC_LIST_INIT(bgp_listen_pending); /* Global list of listening socket open requests */
static event bgp_listen_event = { .hook = bgp_listen_create };
-DOMAIN(rtable) bgp_listen_domain;
+static DOMAIN(rtable) bgp_listen_domain;
+static pool *bgp_listen_pool;
static void bgp_connect(struct bgp_proto *p);
static void bgp_active(struct bgp_proto *p);
@@ -276,7 +277,7 @@ bgp_listen_create(void *_ UNUSED)
{
/* Allocating new socket from global protocol pool.
* We can do this in main_birdloop. */
- sock *sk = sk_new(proto_pool);
+ sock *sk = sk_new(bgp_listen_pool);
sk->type = SK_TCP_PASSIVE;
sk->ttl = 255;
sk->saddr = req->addr;
@@ -301,7 +302,7 @@ bgp_listen_create(void *_ UNUSED)
continue;
}
- bs = mb_allocz(proto_pool, sizeof(struct bgp_socket));
+ bs = mb_allocz(bgp_listen_pool, sizeof(struct bgp_socket));
bs->sk = sk;
sk->data = bs;
@@ -1337,7 +1338,9 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED)
{
log(L_WARN "BGP: Unexpected connect from unknown address %I%J (port %d)",
sk->daddr, ipa_is_link_local(sk->daddr) ? sk->iface : NULL, sk->dport);
+ LOCK_DOMAIN(rtable, bgp_listen_domain);
sk_close(sk);
+ UNLOCK_DOMAIN(rtable, bgp_listen_domain);
return 0;
}
@@ -1365,6 +1368,8 @@ bgp_incoming_connection(sock *sk, uint dummy UNUSED)
bgp_close_conn(&p->incoming_conn);
}
+ LOCK_DOMAIN(rtable, bgp_listen_domain);
+
BGP_TRACE(D_EVENTS, "Incoming connection from %I%J (port %d) %s",
sk->daddr, ipa_is_link_local(sk->daddr) ? sk->iface : NULL,
sk->dport, acc ? "accepted" : "rejected");
@@ -1414,6 +1419,7 @@ err:
sk_close(sk);
leave:
+ UNLOCK_DOMAIN(rtable, bgp_listen_domain);
birdloop_leave(p->p.loop);
return 0;
}
@@ -2843,5 +2849,8 @@ void bgp_build(void)
{
proto_build(&proto_bgp);
bgp_register_attrs();
- bgp_listen_domain = DOMAIN_NEW(rtable, "BGP Listen Sockets");
+ bgp_listen_domain = DOMAIN_NEW(rtable);
+ LOCK_DOMAIN(rtable, bgp_listen_domain);
+ bgp_listen_pool = rp_new(proto_pool, bgp_listen_domain.rtable, "BGP Listen Sockets");
+ UNLOCK_DOMAIN(rtable, bgp_listen_domain);
}