summaryrefslogtreecommitdiff
path: root/proto/bgp
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-02 19:15:22 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-04 17:00:59 +0200
commit836e857b3098f8962c621a33f7ae5b532cf512f3 (patch)
tree96c62361fd7b2dd57cecdf9d9b9323f8aa95f021 /proto/bgp
parent571c4f69bfbcf437d848b332bb2f4995fea2347d (diff)
Sockets: Unified API for main and other loops
Now sk_open() requires an explicit IO loop to open the socket in. Also specific functions for socket RX pause / resume are added to allow for BGP corking. And last but not least, socket reloop is now synchronous to resolve weird cases of the target loop stopping before actually picking up the relooped socket. Now the caller must ensure that both loops are locked while relooping, and this way all sockets always have their respective loop.
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/bgp.c4
-rw-r--r--proto/bgp/packets.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 122b0c22..a9028353 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -263,7 +263,7 @@ bgp_listen_create(void *_ UNUSED)
sk->rx_hook = bgp_incoming_connection;
sk->err_hook = bgp_listen_sock_err;
- if (sk_open(sk) < 0)
+ if (sk_open(sk, &main_birdloop) < 0)
{
sk_log_error(sk, p->p.name);
log(L_ERR "%s: Cannot open listening socket", p->p.name);
@@ -1203,7 +1203,7 @@ bgp_connect(struct bgp_proto *p) /* Enter Connect state and start establishing c
bgp_setup_sk(conn, s);
bgp_conn_set_state(conn, BS_CONNECT);
- if (sk_open(s) < 0)
+ if (sk_open(s, p->p.loop) < 0)
goto err;
/* Set minimal receive TTL if needed */
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index 924d6828..c90798a0 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -3015,7 +3015,7 @@ bgp_kick_tx(void *vconn)
;
if (!max && !ev_active(conn->tx_ev))
- ev_schedule(conn->tx_ev);
+ proto_send_event(&conn->bgp->p, conn->tx_ev);
}
void
@@ -3023,13 +3023,14 @@ bgp_tx(sock *sk)
{
struct bgp_conn *conn = sk->data;
+ ASSERT_DIE(birdloop_inside(conn->bgp->p.loop));
DBG("BGP: TX hook\n");
uint max = 1024;
while (--max && (bgp_fire_tx(conn) > 0))
;
if (!max && !ev_active(conn->tx_ev))
- ev_schedule(conn->tx_ev);
+ proto_send_event(&conn->bgp->p, conn->tx_ev);
}