forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0087-zebra-move-peer-conn-error-list-to-connection-struct.patch
210 lines (176 loc) · 7.11 KB
/
0087-zebra-move-peer-conn-error-list-to-connection-struct.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
From e9eee90c3f68dc83a92f519841732c951948875b Mon Sep 17 00:00:00 2001
From: Mark Stapp <mjs@cisco.com>
Date: Thu, 7 Nov 2024 10:55:19 -0500
Subject: [PATCH 4/4] zebra: move peer conn error list to connection struct
Move the peer connection error list to the peer_connection
struct; that seems to line up better with the way that struct
works.
Signed-off-by: Mark Stapp <mjs@cisco.com>
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index 4d5e1d9c5..31aba90d2 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -251,7 +251,7 @@ static void bgp_process_reads(struct event *thread)
/* Handle the error in the main pthread, include the
* specific state change from 'bgp_read'.
*/
- bgp_enqueue_conn_err_peer(peer->bgp, connection->peer, code);
+ bgp_enqueue_conn_err(peer->bgp, connection, code);
goto done;
}
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index e3f103724..7d5e2b5c6 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -87,7 +87,7 @@ DEFINE_QOBJ_TYPE(peer);
DEFINE_HOOK(bgp_inst_delete, (struct bgp *bgp), (bgp));
/* Peers with connection error/failure, per bgp instance */
-DECLARE_DLIST(bgp_peer_conn_errlist, struct peer, conn_err_link);
+DECLARE_DLIST(bgp_peer_conn_errlist, struct peer_connection, conn_err_link);
/* List of info about peers that are being cleared from BGP RIBs in a batch */
DECLARE_DLIST(bgp_clearing_info, struct bgp_clearing_info, link);
@@ -2722,9 +2722,9 @@ int peer_delete(struct peer *peer)
/* Ensure the peer is removed from the connection error list */
frr_with_mutex (&bgp->peer_errs_mtx) {
- if (bgp_peer_conn_errlist_anywhere(peer))
+ if (bgp_peer_conn_errlist_anywhere(peer->connection))
bgp_peer_conn_errlist_del(&bgp->peer_conn_errlist,
- peer);
+ peer->connection);
}
if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT))
@@ -3924,6 +3924,8 @@ int bgp_delete(struct bgp *bgp)
struct bgp_table *dest_table = NULL;
struct graceful_restart_info *gr_info;
uint32_t cnt_before, cnt_after;
+ struct bgp_clearing_info *cinfo;
+ struct peer_connection *connection;
assert(bgp);
@@ -4044,9 +4046,9 @@ int bgp_delete(struct bgp *bgp)
*/
frr_with_mutex (&bgp->peer_errs_mtx) {
do {
- peer = bgp_peer_conn_errlist_pop(
+ connection = bgp_peer_conn_errlist_pop(
&bgp->peer_conn_errlist);
- } while (peer != NULL);
+ } while (connection != NULL);
}
/* Free peers and peer-groups. */
@@ -8998,7 +9000,7 @@ static void bgp_process_conn_error(struct event *event)
bgp = EVENT_ARG(event);
frr_with_mutex (&bgp->peer_errs_mtx) {
- peer = bgp_peer_conn_errlist_pop(&bgp->peer_conn_errlist);
+ connection = bgp_peer_conn_errlist_pop(&bgp->peer_conn_errlist);
list_count =
bgp_peer_conn_errlist_count(&bgp->peer_conn_errlist);
@@ -9011,12 +9013,12 @@ static void bgp_process_conn_error(struct event *event)
bgp_clearing_batch_begin(bgp);
/* Dequeue peers from the error list */
- while (peer != NULL) {
- connection = peer->connection;
+ while (connection != NULL) {
+ peer = connection->peer;
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s [Event] BGP error %d on fd %d",
- peer->host, peer->connection_errcode,
+ peer->host, connection->connection_errcode,
connection->fd);
/* Closed connection or error on the socket */
@@ -9035,13 +9037,13 @@ static void bgp_process_conn_error(struct event *event)
bgp_keepalives_off(peer->connection);
/* Drive into state-machine changes */
- bgp_event_update(connection, peer->connection_errcode);
+ bgp_event_update(connection, connection->connection_errcode);
counter++;
if (counter >= BGP_CONN_ERROR_DEQUEUE_MAX)
break;
- peer = bgp_dequeue_conn_err_peer(bgp, &more_p);
+ connection = bgp_dequeue_conn_err(bgp, &more_p);
}
/* Reschedule event if necessary */
@@ -9058,18 +9060,19 @@ static void bgp_process_conn_error(struct event *event)
}
/*
- * Enqueue a peer with a connection error to be handled in the main pthread;
+ * Enqueue a connection with an error to be handled in the main pthread;
* this is called from the io pthread.
*/
-int bgp_enqueue_conn_err_peer(struct bgp *bgp, struct peer *peer, int errcode)
+int bgp_enqueue_conn_err(struct bgp *bgp, struct peer_connection *connection,
+ int errcode)
{
frr_with_mutex (&bgp->peer_errs_mtx) {
- peer->connection_errcode = errcode;
+ connection->connection_errcode = errcode;
/* Careful not to double-enqueue */
- if (!bgp_peer_conn_errlist_anywhere(peer)) {
+ if (!bgp_peer_conn_errlist_anywhere(connection)) {
bgp_peer_conn_errlist_add_tail(&bgp->peer_conn_errlist,
- peer);
+ connection);
}
}
/* Ensure an event is scheduled */
@@ -9079,16 +9082,16 @@ int bgp_enqueue_conn_err_peer(struct bgp *bgp, struct peer *peer, int errcode)
}
/*
- * Dequeue a peer that encountered a connection error; signal whether there
+ * Dequeue a connection that encountered a connection error; signal whether there
* are more queued peers.
*/
-struct peer *bgp_dequeue_conn_err_peer(struct bgp *bgp, bool *more_p)
+struct peer_connection *bgp_dequeue_conn_err(struct bgp *bgp, bool *more_p)
{
- struct peer *peer = NULL;
+ struct peer_connection *connection = NULL;
bool more = false;
frr_with_mutex (&bgp->peer_errs_mtx) {
- peer = bgp_peer_conn_errlist_pop(&bgp->peer_conn_errlist);
+ connection = bgp_peer_conn_errlist_pop(&bgp->peer_conn_errlist);
if (bgp_peer_conn_errlist_const_first(
&bgp->peer_conn_errlist) != NULL)
@@ -9098,7 +9101,7 @@ struct peer *bgp_dequeue_conn_err_peer(struct bgp *bgp, bool *more_p)
if (more_p)
*more_p = more;
- return peer;
+ return connection;
}
/*
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ff3f1b9f1..b53ece40d 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1254,6 +1254,11 @@ struct peer_connection {
struct event *t_process_packet;
struct event *t_stop_with_notify;
+ /* Linkage for list connections with errors, from IO pthread */
+ struct bgp_peer_conn_errlist_item conn_err_link;
+
+ /* Connection error code */
+ uint16_t connection_errcode;
union sockunion su;
#define BGP_CONNECTION_SU_UNSPEC(connection) \
@@ -1921,12 +1926,6 @@ struct peer {
/* Add-Path Best selected paths number to advertise */
uint8_t addpath_best_selected[AFI_MAX][SAFI_MAX];
- /* Linkage for list of peers with connection errors from IO pthread */
- struct bgp_peer_conn_errlist_item conn_err_link;
-
- /* Connection error code */
- uint16_t connection_errcode;
-
/* Linkage for hash of clearing peers being cleared in a batch */
struct bgp_clearing_hash_item clear_hash_link;
@@ -2565,8 +2564,9 @@ int bgp_global_gr_init(struct bgp *bgp);
int bgp_peer_gr_init(struct peer *peer);
/* APIs for the per-bgp peer connection error list */
-int bgp_enqueue_conn_err_peer(struct bgp *bgp, struct peer *peer, int errcode);
-struct peer *bgp_dequeue_conn_err_peer(struct bgp *bgp, bool *more_p);
+int bgp_enqueue_conn_err(struct bgp *bgp, struct peer_connection *connection,
+ int errcode);
+struct peer_connection *bgp_dequeue_conn_err(struct bgp *bgp, bool *more_p);
void bgp_conn_err_reschedule(struct bgp *bgp);
#define BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(_bgp, _peer_list) \
--
2.43.2