]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: READ and WRITE flags are a part of the connection
authorDonald Sharp <sharpd@nvidia.com>
Thu, 3 Jun 2021 19:20:11 +0000 (15:20 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 18 Aug 2023 13:29:04 +0000 (09:29 -0400)
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>
bgpd/bgp_fsm.c
bgpd/bgp_io.c
bgpd/bgp_network.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index e2068ef00e7ef8af95218133a34b851ebfee9276..20a5c4ce33572ee633b6728cce047583bc996c02 100644 (file)
@@ -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) {
index fa5c6779730c087d01cf343479ffcdf26ddc8973..25180ee53e23480c23eb6105c00ffce8e1808201 100644 (file)
@@ -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 ----------------------------------------------- */
index f83b9e8064fd486ca4fce912365ddf26111bcd05..9a162b151e2e50275952bb058fc9b53879db9560 100644 (file)
@@ -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)) {
index c4f3ed9fae5474e996d53e62bf8dd90f169225d0..5b224c4c56fbfb234b5523fcfb06d659fae5b242 100644 (file)
@@ -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);
index cf6d3163626f1b31f29062d9db846cf8b606a01b..a1d918482948508ac8557e8914c4f21b16ac6b5f 100644 (file)
@@ -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))
index 24c6dd698b794422b41e87541585f1ef583546e6..dcee9caec89929e237916de6c843d3d484ca1f4e 100644 (file)
@@ -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;