summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-06-03 15:20:11 -0400
committerDonald Sharp <sharpd@nvidia.com>2023-08-18 09:29:04 -0400
commit71d72c4998d6984e43411535eaa2a5b8c0e33d06 (patch)
tree7212c2d1e9c1a069bb2b5b9402b7bf7baacfd41f
parentc528b3b1531ef70c5fb823356b6a5f1a583395c0 (diff)
bgpd: READ and WRITE flags are a part of the connection
Move PEER_THREAD_WRITES_ON and PEER_THREAD_READS_ON to be a part of the `struct peer_connection` since this is a connection oriented bit of data. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--bgpd/bgp_fsm.c12
-rw-r--r--bgpd/bgp_io.c8
-rw-r--r--bgpd/bgp_network.c6
-rw-r--r--bgpd/bgp_vty.c6
-rw-r--r--bgpd/bgpd.c6
-rw-r--r--bgpd/bgpd.h11
6 files changed, 31 insertions, 18 deletions
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index e2068ef00e..20a5c4ce33 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -1657,8 +1657,10 @@ static void bgp_connect_check(struct event *thread)
struct peer *peer;
peer = EVENT_ARG(thread);
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_READS_ON));
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_READS_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_WRITES_ON));
assert(!peer->connection.t_read);
assert(!peer->connection.t_write);
@@ -1896,8 +1898,10 @@ enum bgp_fsm_state_progress bgp_start(struct peer *peer)
assert(!peer->connection.t_write);
assert(!peer->connection.t_read);
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_READS_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_WRITES_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_READS_ON));
status = bgp_connect(peer);
switch (status) {
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index fa5c677973..25180ee53e 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -59,7 +59,7 @@ void bgp_writes_on(struct peer_connection *connection)
event_add_write(fpt->master, bgp_process_writes, connection,
connection->fd, &connection->t_write);
- SET_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON);
+ SET_FLAG(connection->thread_flags, PEER_THREAD_WRITES_ON);
}
void bgp_writes_off(struct peer_connection *connection)
@@ -71,7 +71,7 @@ void bgp_writes_off(struct peer_connection *connection)
event_cancel_async(fpt->master, &connection->t_write, NULL);
EVENT_OFF(peer->t_generate_updgrp_packets);
- UNSET_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON);
+ UNSET_FLAG(peer->connection.thread_flags, PEER_THREAD_WRITES_ON);
}
void bgp_reads_on(struct peer_connection *connection)
@@ -92,7 +92,7 @@ void bgp_reads_on(struct peer_connection *connection)
event_add_read(fpt->master, bgp_process_reads, connection,
connection->fd, &connection->t_read);
- SET_FLAG(peer->thread_flags, PEER_THREAD_READS_ON);
+ SET_FLAG(connection->thread_flags, PEER_THREAD_READS_ON);
}
void bgp_reads_off(struct peer_connection *connection)
@@ -105,7 +105,7 @@ void bgp_reads_off(struct peer_connection *connection)
EVENT_OFF(peer->t_process_packet);
EVENT_OFF(peer->t_process_packet_error);
- UNSET_FLAG(peer->thread_flags, PEER_THREAD_READS_ON);
+ UNSET_FLAG(connection->thread_flags, PEER_THREAD_READS_ON);
}
/* Thread internal functions ----------------------------------------------- */
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index f83b9e8064..9a162b151e 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -697,8 +697,10 @@ static int bgp_update_source(struct peer *peer)
/* BGP try to connect to the peer. */
int bgp_connect(struct peer *peer)
{
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_READS_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_WRITES_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_READS_ON));
ifindex_t ifindex = 0;
if (peer->conf_if && BGP_PEER_SU_UNSPEC(peer)) {
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index c4f3ed9fae..5b224c4c56 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -15125,7 +15125,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
else
json_object_string_add(json_neigh, "readThread", "off");
- if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON))
+ if (CHECK_FLAG(p->connection.thread_flags,
+ PEER_THREAD_WRITES_ON))
json_object_string_add(json_neigh, "writeThread", "on");
else
json_object_string_add(json_neigh, "writeThread",
@@ -15157,7 +15158,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n",
p->connection.t_read ? "on" : "off",
- CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)
+ CHECK_FLAG(p->connection.thread_flags,
+ PEER_THREAD_WRITES_ON)
? "on"
: "off",
p->connection.fd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index cf6d316362..a1d9184829 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2567,8 +2567,10 @@ int peer_delete(struct peer *peer)
event_cancel_event_ready(bm->master, peer);
FOREACH_AFI_SAFI (afi, safi)
EVENT_OFF(peer->t_revalidate_all[afi][safi]);
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_WRITES_ON));
- assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_READS_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_WRITES_ON));
+ assert(!CHECK_FLAG(peer->connection.thread_flags,
+ PEER_THREAD_READS_ON));
assert(!CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON));
if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT))
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 24c6dd698b..dcee9caec8 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1134,6 +1134,11 @@ struct peer_connection {
struct event *t_read;
struct event *t_write;
+
+ /* Thread flags */
+ _Atomic uint32_t thread_flags;
+#define PEER_THREAD_WRITES_ON (1U << 0)
+#define PEER_THREAD_READS_ON (1U << 1)
};
extern void bgp_peer_connection_buffers_free(struct peer_connection *connection);
@@ -1558,10 +1563,8 @@ struct peer {
/* Thread flags. */
_Atomic uint32_t thread_flags;
-#define PEER_THREAD_WRITES_ON (1U << 0)
-#define PEER_THREAD_READS_ON (1U << 1)
-#define PEER_THREAD_KEEPALIVES_ON (1U << 2)
-#define PEER_THREAD_SUBGRP_ADV_DELAY (1U << 3)
+#define PEER_THREAD_KEEPALIVES_ON (1U << 0)
+#define PEER_THREAD_SUBGRP_ADV_DELAY (1U << 1)
/* workqueues */
struct work_queue *clear_node_queue;