/src/frr/bgpd/bgp_debug.c
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | /* BGP-4, BGP-4+ packet debug routine |
3 | | * Copyright (C) 1996, 97, 99 Kunihiro Ishiguro |
4 | | */ |
5 | | |
6 | | #include <zebra.h> |
7 | | |
8 | | #include "lib/bfd.h" |
9 | | #include "lib/printfrr.h" |
10 | | #include "prefix.h" |
11 | | #include "linklist.h" |
12 | | #include "stream.h" |
13 | | #include "command.h" |
14 | | #include "log.h" |
15 | | #include "sockunion.h" |
16 | | #include "memory.h" |
17 | | #include "queue.h" |
18 | | #include "filter.h" |
19 | | |
20 | | #include "bgpd/bgpd.h" |
21 | | #include "bgpd/bgp_aspath.h" |
22 | | #include "bgpd/bgp_route.h" |
23 | | #include "bgpd/bgp_attr.h" |
24 | | #include "bgpd/bgp_debug.h" |
25 | | #include "bgpd/bgp_community.h" |
26 | | #include "bgpd/bgp_lcommunity.h" |
27 | | #include "bgpd/bgp_updgrp.h" |
28 | | #include "bgpd/bgp_mplsvpn.h" |
29 | | #include "bgpd/bgp_ecommunity.h" |
30 | | #include "bgpd/bgp_label.h" |
31 | | #include "bgpd/bgp_evpn.h" |
32 | | #include "bgpd/bgp_evpn_private.h" |
33 | | #include "bgpd/bgp_evpn_vty.h" |
34 | | #include "bgpd/bgp_vty.h" |
35 | | #include "bgpd/bgp_flowspec.h" |
36 | | #include "bgpd/bgp_packet.h" |
37 | | |
38 | | #include "bgpd/bgp_debug_clippy.c" |
39 | | |
40 | | unsigned long conf_bgp_debug_as4; |
41 | | unsigned long conf_bgp_debug_neighbor_events; |
42 | | unsigned long conf_bgp_debug_events; |
43 | | unsigned long conf_bgp_debug_packet; |
44 | | unsigned long conf_bgp_debug_filter; |
45 | | unsigned long conf_bgp_debug_keepalive; |
46 | | unsigned long conf_bgp_debug_update; |
47 | | unsigned long conf_bgp_debug_bestpath; |
48 | | unsigned long conf_bgp_debug_zebra; |
49 | | unsigned long conf_bgp_debug_allow_martians; |
50 | | unsigned long conf_bgp_debug_nht; |
51 | | unsigned long conf_bgp_debug_update_groups; |
52 | | unsigned long conf_bgp_debug_vpn; |
53 | | unsigned long conf_bgp_debug_flowspec; |
54 | | unsigned long conf_bgp_debug_labelpool; |
55 | | unsigned long conf_bgp_debug_pbr; |
56 | | unsigned long conf_bgp_debug_graceful_restart; |
57 | | unsigned long conf_bgp_debug_evpn_mh; |
58 | | unsigned long conf_bgp_debug_bfd; |
59 | | unsigned long conf_bgp_debug_cond_adv; |
60 | | |
61 | | unsigned long term_bgp_debug_as4; |
62 | | unsigned long term_bgp_debug_neighbor_events; |
63 | | unsigned long term_bgp_debug_events; |
64 | | unsigned long term_bgp_debug_packet; |
65 | | unsigned long term_bgp_debug_filter; |
66 | | unsigned long term_bgp_debug_keepalive; |
67 | | unsigned long term_bgp_debug_update; |
68 | | unsigned long term_bgp_debug_bestpath; |
69 | | unsigned long term_bgp_debug_zebra; |
70 | | unsigned long term_bgp_debug_allow_martians; |
71 | | unsigned long term_bgp_debug_nht; |
72 | | unsigned long term_bgp_debug_update_groups; |
73 | | unsigned long term_bgp_debug_vpn; |
74 | | unsigned long term_bgp_debug_flowspec; |
75 | | unsigned long term_bgp_debug_labelpool; |
76 | | unsigned long term_bgp_debug_pbr; |
77 | | unsigned long term_bgp_debug_graceful_restart; |
78 | | unsigned long term_bgp_debug_evpn_mh; |
79 | | unsigned long term_bgp_debug_bfd; |
80 | | unsigned long term_bgp_debug_cond_adv; |
81 | | |
82 | | struct list *bgp_debug_neighbor_events_peers = NULL; |
83 | | struct list *bgp_debug_keepalive_peers = NULL; |
84 | | struct list *bgp_debug_update_out_peers = NULL; |
85 | | struct list *bgp_debug_update_in_peers = NULL; |
86 | | struct list *bgp_debug_update_prefixes = NULL; |
87 | | struct list *bgp_debug_bestpath_prefixes = NULL; |
88 | | struct list *bgp_debug_zebra_prefixes = NULL; |
89 | | |
90 | | /* messages for BGP-4 status */ |
91 | | const struct message bgp_status_msg[] = {{Idle, "Idle"}, |
92 | | {Connect, "Connect"}, |
93 | | {Active, "Active"}, |
94 | | {OpenSent, "OpenSent"}, |
95 | | {OpenConfirm, "OpenConfirm"}, |
96 | | {Established, "Established"}, |
97 | | {Clearing, "Clearing"}, |
98 | | {Deleted, "Deleted"}, |
99 | | {0}}; |
100 | | |
101 | | /* BGP message type string. */ |
102 | | const char *const bgp_type_str[] = {NULL, "OPEN", "UPDATE", |
103 | | "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH", |
104 | | "CAPABILITY"}; |
105 | | |
106 | | /* message for BGP-4 Notify */ |
107 | | static const struct message bgp_notify_msg[] = { |
108 | | {BGP_NOTIFY_HEADER_ERR, "Message Header Error"}, |
109 | | {BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"}, |
110 | | {BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"}, |
111 | | {BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"}, |
112 | | {BGP_NOTIFY_FSM_ERR, "Neighbor Events Error"}, |
113 | | {BGP_NOTIFY_CEASE, "Cease"}, |
114 | | {BGP_NOTIFY_ROUTE_REFRESH_ERR, "ROUTE-REFRESH Message Error"}, |
115 | | {0}}; |
116 | | |
117 | | static const struct message bgp_notify_head_msg[] = { |
118 | | {BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"}, |
119 | | {BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"}, |
120 | | {BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}, |
121 | | {0}}; |
122 | | |
123 | | static const struct message bgp_notify_open_msg[] = { |
124 | | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
125 | | {BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number"}, |
126 | | {BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"}, |
127 | | {BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"}, |
128 | | {BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"}, |
129 | | {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, |
130 | | {BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"}, |
131 | | {BGP_NOTIFY_OPEN_ROLE_MISMATCH, "/Role Mismatch"}, |
132 | | {0}}; |
133 | | |
134 | | static const struct message bgp_notify_update_msg[] = { |
135 | | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
136 | | {BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"}, |
137 | | {BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"}, |
138 | | {BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"}, |
139 | | {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"}, |
140 | | {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"}, |
141 | | {BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"}, |
142 | | {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"}, |
143 | | {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"}, |
144 | | {BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"}, |
145 | | {BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"}, |
146 | | {0}}; |
147 | | |
148 | | static const struct message bgp_notify_cease_msg[] = { |
149 | | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
150 | | {BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"}, |
151 | | {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administrative Shutdown"}, |
152 | | {BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer De-configured"}, |
153 | | {BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administrative Reset"}, |
154 | | {BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"}, |
155 | | {BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"}, |
156 | | {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, |
157 | | "/Connection Collision Resolution"}, |
158 | | {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resources"}, |
159 | | {BGP_NOTIFY_CEASE_HARD_RESET, "/Hard Reset"}, |
160 | | {BGP_NOTIFY_CEASE_BFD_DOWN, "/BFD Down"}, |
161 | | {0}}; |
162 | | |
163 | | static const struct message bgp_notify_route_refresh_msg[] = { |
164 | | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
165 | | {BGP_NOTIFY_ROUTE_REFRESH_INVALID_MSG_LEN, "/Invalid Message Length"}, |
166 | | {0}}; |
167 | | |
168 | | static const struct message bgp_notify_fsm_msg[] = { |
169 | | {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
170 | | {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT, |
171 | | "/Receive Unexpected Message in OpenSent State"}, |
172 | | {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM, |
173 | | "/Receive Unexpected Message in OpenConfirm State"}, |
174 | | {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED, |
175 | | "/Receive Unexpected Message in Established State"}, |
176 | | {0}}; |
177 | | |
178 | | /* Origin strings. */ |
179 | | const char *const bgp_origin_str[] = {"i", "e", "?"}; |
180 | | const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; |
181 | | |
182 | | static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, |
183 | | struct prefix *p); |
184 | | /* Given a string return a pointer the corresponding peer structure */ |
185 | | static struct peer *bgp_find_peer(struct vty *vty, const char *peer_str) |
186 | 0 | { |
187 | 0 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
188 | 0 | int ret; |
189 | 0 | union sockunion su; |
190 | 0 | struct peer *peer; |
191 | |
|
192 | 0 | if (!bgp) { |
193 | 0 | return NULL; |
194 | 0 | } |
195 | 0 | ret = str2sockunion(peer_str, &su); |
196 | | |
197 | | /* 'swpX' string */ |
198 | 0 | if (ret < 0) { |
199 | 0 | peer = peer_lookup_by_conf_if(bgp, peer_str); |
200 | |
|
201 | 0 | if (!peer) |
202 | 0 | peer = peer_lookup_by_hostname(bgp, peer_str); |
203 | |
|
204 | 0 | return peer; |
205 | 0 | } else |
206 | 0 | return peer_lookup(bgp, &su); |
207 | 0 | } |
208 | | |
209 | | static void bgp_debug_list_free(struct list *list) |
210 | 0 | { |
211 | 0 | struct bgp_debug_filter *filter; |
212 | 0 | struct listnode *node, *nnode; |
213 | |
|
214 | 0 | if (list) |
215 | 0 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { |
216 | 0 | listnode_delete(list, filter); |
217 | 0 | prefix_free(&filter->p); |
218 | 0 | XFREE(MTYPE_BGP_DEBUG_STR, filter->host); |
219 | 0 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); |
220 | 0 | } |
221 | 0 | } |
222 | | |
223 | | /* |
224 | | * Print the desc along with a list of peers/prefixes this debug is |
225 | | * enabled for |
226 | | */ |
227 | | static void bgp_debug_list_print(struct vty *vty, const char *desc, |
228 | | struct list *list) |
229 | 0 | { |
230 | 0 | struct bgp_debug_filter *filter; |
231 | 0 | struct listnode *node, *nnode; |
232 | |
|
233 | 0 | vty_out(vty, "%s", desc); |
234 | |
|
235 | 0 | if (list && !list_isempty(list)) { |
236 | 0 | vty_out(vty, " for"); |
237 | 0 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { |
238 | 0 | if (filter->host) |
239 | 0 | vty_out(vty, " %s", filter->host); |
240 | |
|
241 | 0 | if (filter->p && filter->p->family == AF_EVPN) |
242 | 0 | bgp_debug_print_evpn_prefix(vty, "", filter->p); |
243 | 0 | else if (filter->p) |
244 | 0 | vty_out(vty, " %pFX", filter->p); |
245 | 0 | } |
246 | 0 | } |
247 | |
|
248 | 0 | vty_out(vty, "\n"); |
249 | 0 | } |
250 | | |
251 | | /* |
252 | | * Print the command to enable the debug for each peer/prefix this debug is |
253 | | * enabled for |
254 | | */ |
255 | | static int bgp_debug_list_conf_print(struct vty *vty, const char *desc, |
256 | | struct list *list) |
257 | 0 | { |
258 | 0 | struct bgp_debug_filter *filter; |
259 | 0 | struct listnode *node, *nnode; |
260 | 0 | int write = 0; |
261 | |
|
262 | 0 | if (list && !list_isempty(list)) { |
263 | 0 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { |
264 | 0 | if (filter->host) { |
265 | 0 | vty_out(vty, "%s %s\n", desc, filter->host); |
266 | 0 | write++; |
267 | 0 | } |
268 | |
|
269 | 0 | if (filter->p && filter->p->family == AF_EVPN) { |
270 | 0 | bgp_debug_print_evpn_prefix(vty, desc, |
271 | 0 | filter->p); |
272 | 0 | write++; |
273 | 0 | } else if (filter->p) { |
274 | 0 | vty_out(vty, "%s %pFX\n", desc, filter->p); |
275 | 0 | write++; |
276 | 0 | } |
277 | 0 | } |
278 | 0 | } |
279 | |
|
280 | 0 | if (!write) { |
281 | 0 | vty_out(vty, "%s\n", desc); |
282 | 0 | write++; |
283 | 0 | } |
284 | |
|
285 | 0 | return write; |
286 | 0 | } |
287 | | |
288 | | static void bgp_debug_list_add_entry(struct list *list, const char *host, |
289 | | const struct prefix *p) |
290 | 0 | { |
291 | 0 | struct bgp_debug_filter *filter; |
292 | |
|
293 | 0 | filter = XCALLOC(MTYPE_BGP_DEBUG_FILTER, |
294 | 0 | sizeof(struct bgp_debug_filter)); |
295 | |
|
296 | 0 | if (host) { |
297 | 0 | filter->host = XSTRDUP(MTYPE_BGP_DEBUG_STR, host); |
298 | 0 | filter->p = NULL; |
299 | 0 | } else if (p) { |
300 | 0 | filter->host = NULL; |
301 | 0 | filter->p = prefix_new(); |
302 | 0 | prefix_copy(filter->p, p); |
303 | 0 | } |
304 | |
|
305 | 0 | listnode_add(list, filter); |
306 | 0 | } |
307 | | |
308 | | static bool bgp_debug_list_remove_entry(struct list *list, const char *host, |
309 | | const struct prefix *p) |
310 | 0 | { |
311 | 0 | struct bgp_debug_filter *filter; |
312 | 0 | struct listnode *node, *nnode; |
313 | |
|
314 | 0 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { |
315 | 0 | if (host && strcmp(filter->host, host) == 0) { |
316 | 0 | listnode_delete(list, filter); |
317 | 0 | XFREE(MTYPE_BGP_DEBUG_STR, filter->host); |
318 | 0 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); |
319 | 0 | return true; |
320 | 0 | } else if (p && filter->p->prefixlen == p->prefixlen |
321 | 0 | && prefix_match(filter->p, p)) { |
322 | 0 | listnode_delete(list, filter); |
323 | 0 | prefix_free(&filter->p); |
324 | 0 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); |
325 | 0 | return true; |
326 | 0 | } |
327 | 0 | } |
328 | | |
329 | 0 | return false; |
330 | 0 | } |
331 | | |
332 | | static bool bgp_debug_list_has_entry(struct list *list, const char *host, |
333 | | const struct prefix *p) |
334 | 0 | { |
335 | 0 | struct bgp_debug_filter *filter; |
336 | 0 | struct listnode *node, *nnode; |
337 | |
|
338 | 0 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { |
339 | 0 | if (host) { |
340 | 0 | if (strcmp(filter->host, host) == 0) { |
341 | 0 | return true; |
342 | 0 | } |
343 | 0 | } else if (p) { |
344 | 0 | if (filter->p->prefixlen == p->prefixlen |
345 | 0 | && prefix_match(filter->p, p)) { |
346 | 0 | return true; |
347 | 0 | } |
348 | 0 | } |
349 | 0 | } |
350 | | |
351 | 0 | return false; |
352 | 0 | } |
353 | | |
354 | | bool bgp_debug_peer_updout_enabled(char *host) |
355 | 0 | { |
356 | 0 | return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, |
357 | 0 | NULL)); |
358 | 0 | } |
359 | | |
360 | | /* Dump attribute. */ |
361 | | bool bgp_dump_attr(struct attr *attr, char *buf, size_t size) |
362 | 121 | { |
363 | 121 | if (!attr) |
364 | 0 | return false; |
365 | | |
366 | 121 | buf[0] = '\0'; |
367 | | |
368 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) |
369 | 17 | snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop); |
370 | | |
371 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN))) |
372 | 4 | snprintf(buf + strlen(buf), size - strlen(buf), ", origin %s", |
373 | 4 | bgp_origin_str[attr->origin]); |
374 | | |
375 | | /* Add MP case. */ |
376 | 121 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL |
377 | 119 | || attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
378 | 2 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
379 | 2 | ", mp_nexthop %pI6", &attr->mp_nexthop_global); |
380 | | |
381 | 121 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) |
382 | 0 | snprintfrr(buf + strlen(buf), size - strlen(buf), "(%pI6)", |
383 | 0 | &attr->mp_nexthop_local); |
384 | | |
385 | 121 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) |
386 | 12 | snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop); |
387 | | |
388 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) |
389 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), |
390 | 0 | ", localpref %u", attr->local_pref); |
391 | | |
392 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP))) |
393 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), |
394 | 0 | ", aigp-metric %" PRIu64, |
395 | 0 | (unsigned long long)bgp_attr_get_aigp_metric(attr)); |
396 | | |
397 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) |
398 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), ", metric %u", |
399 | 0 | attr->med); |
400 | | |
401 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) |
402 | 9 | snprintf(buf + strlen(buf), size - strlen(buf), |
403 | 9 | ", community %s", |
404 | 9 | community_str(bgp_attr_get_community(attr), false, |
405 | 9 | true)); |
406 | | |
407 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) |
408 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), |
409 | 0 | ", large-community %s", |
410 | 0 | lcommunity_str(bgp_attr_get_lcommunity(attr), false, |
411 | 0 | true)); |
412 | | |
413 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) |
414 | 25 | snprintf(buf + strlen(buf), size - strlen(buf), |
415 | 25 | ", extcommunity %s", |
416 | 25 | ecommunity_str(bgp_attr_get_ecommunity(attr))); |
417 | | |
418 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))) |
419 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), |
420 | 0 | ", atomic-aggregate"); |
421 | | |
422 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) |
423 | 0 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
424 | 0 | ", aggregated by %u %pI4", attr->aggregator_as, |
425 | 0 | &attr->aggregator_addr); |
426 | | |
427 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) |
428 | 3 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
429 | 3 | ", originator %pI4", &attr->originator_id); |
430 | | |
431 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { |
432 | 14 | struct cluster_list *cluster; |
433 | 14 | int i; |
434 | | |
435 | 14 | snprintf(buf + strlen(buf), size - strlen(buf), |
436 | 14 | ", clusterlist"); |
437 | | |
438 | 14 | cluster = bgp_attr_get_cluster(attr); |
439 | 1.73k | for (i = 0; i < cluster->length / 4; i++) |
440 | 1.72k | snprintfrr(buf + strlen(buf), size - strlen(buf), |
441 | 1.72k | " %pI4", &cluster->list[i]); |
442 | 14 | } |
443 | | |
444 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) |
445 | 0 | snprintf(buf + strlen(buf), size - strlen(buf), |
446 | 0 | ", pmsi tnltype %u", bgp_attr_get_pmsi_tnl_type(attr)); |
447 | | |
448 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH))) |
449 | 6 | snprintf(buf + strlen(buf), size - strlen(buf), ", path %s", |
450 | 6 | aspath_print(attr->aspath)); |
451 | | |
452 | 121 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID))) { |
453 | 16 | if (attr->label_index != BGP_INVALID_LABEL_INDEX) |
454 | 1 | snprintf(buf + strlen(buf), size - strlen(buf), |
455 | 1 | ", label-index %u", attr->label_index); |
456 | 16 | } |
457 | | |
458 | 121 | if (strlen(buf) > 1) |
459 | 74 | return true; |
460 | 47 | else |
461 | 47 | return false; |
462 | 121 | } |
463 | | |
464 | | const char *bgp_notify_code_str(char code) |
465 | 0 | { |
466 | 0 | return lookup_msg(bgp_notify_msg, code, "Unrecognized Error Code"); |
467 | 0 | } |
468 | | |
469 | | const char *bgp_notify_subcode_str(char code, char subcode) |
470 | 0 | { |
471 | |
|
472 | 0 | switch (code) { |
473 | 0 | case BGP_NOTIFY_HEADER_ERR: |
474 | 0 | return lookup_msg(bgp_notify_head_msg, subcode, |
475 | 0 | "Unrecognized Error Subcode"); |
476 | 0 | case BGP_NOTIFY_OPEN_ERR: |
477 | 0 | return lookup_msg(bgp_notify_open_msg, subcode, |
478 | 0 | "Unrecognized Error Subcode"); |
479 | 0 | case BGP_NOTIFY_UPDATE_ERR: |
480 | 0 | return lookup_msg(bgp_notify_update_msg, subcode, |
481 | 0 | "Unrecognized Error Subcode"); |
482 | 0 | case BGP_NOTIFY_HOLD_ERR: |
483 | 0 | break; |
484 | 0 | case BGP_NOTIFY_FSM_ERR: |
485 | 0 | return lookup_msg(bgp_notify_fsm_msg, subcode, |
486 | 0 | "Unrecognized Error Subcode"); |
487 | 0 | case BGP_NOTIFY_CEASE: |
488 | 0 | return lookup_msg(bgp_notify_cease_msg, subcode, |
489 | 0 | "Unrecognized Error Subcode"); |
490 | 0 | case BGP_NOTIFY_ROUTE_REFRESH_ERR: |
491 | 0 | return lookup_msg(bgp_notify_route_refresh_msg, subcode, |
492 | 0 | "Unrecognized Error Subcode"); |
493 | 0 | } |
494 | 0 | return ""; |
495 | 0 | } |
496 | | |
497 | | /* extract notify admin reason if correctly present */ |
498 | | const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data, |
499 | | size_t datalen) |
500 | 0 | { |
501 | 0 | if (!data || datalen < 1) |
502 | 0 | return NULL; |
503 | | |
504 | 0 | uint8_t len = data[0]; |
505 | 0 | if (!len || len > datalen - 1) |
506 | 0 | return NULL; |
507 | | |
508 | 0 | return zlog_sanitize(buf, bufsz, data + 1, len); |
509 | 0 | } |
510 | | |
511 | | /* dump notify packet */ |
512 | | void bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, |
513 | | const char *direct, bool hard_reset) |
514 | 456 | { |
515 | 456 | const char *subcode_str; |
516 | 456 | const char *code_str; |
517 | 456 | const char *msg_str = NULL; |
518 | 456 | char msg_buf[1024]; |
519 | | |
520 | 456 | if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS) |
521 | 456 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) { |
522 | 0 | code_str = bgp_notify_code_str(bgp_notify->code); |
523 | 0 | subcode_str = bgp_notify_subcode_str(bgp_notify->code, |
524 | 0 | bgp_notify->subcode); |
525 | |
|
526 | 0 | if (bgp_notify->code == BGP_NOTIFY_CEASE |
527 | 0 | && (bgp_notify->subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN |
528 | 0 | || bgp_notify->subcode |
529 | 0 | == BGP_NOTIFY_CEASE_ADMIN_RESET)) { |
530 | 0 | msg_str = bgp_notify_admin_message( |
531 | 0 | msg_buf, sizeof(msg_buf), bgp_notify->raw_data, |
532 | 0 | bgp_notify->length); |
533 | 0 | } |
534 | |
|
535 | 0 | if (msg_str) { |
536 | 0 | zlog_info( |
537 | 0 | "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) \"%s\"", |
538 | 0 | hard_reset ? "(Hard Reset)" : "", |
539 | 0 | strcmp(direct, "received") == 0 |
540 | 0 | ? "received from" |
541 | 0 | : "sent to", |
542 | 0 | peer->host, bgp_notify->code, |
543 | 0 | bgp_notify->subcode, code_str, subcode_str, |
544 | 0 | msg_str); |
545 | 0 | } else { |
546 | 0 | msg_str = bgp_notify->data ? bgp_notify->data : ""; |
547 | 0 | zlog_info( |
548 | 0 | "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) %d bytes %s", |
549 | 0 | hard_reset ? "(Hard Reset)" : "", |
550 | 0 | strcmp(direct, "received") == 0 |
551 | 0 | ? "received from" |
552 | 0 | : "sent to", |
553 | 0 | peer->host, bgp_notify->code, |
554 | 0 | bgp_notify->subcode, code_str, subcode_str, |
555 | 0 | bgp_notify->length, msg_str); |
556 | 0 | } |
557 | 0 | } |
558 | 456 | } |
559 | | |
560 | | static void bgp_debug_clear_updgrp_update_dbg(struct bgp *bgp) |
561 | 0 | { |
562 | 0 | if (!bgp) |
563 | 0 | bgp = bgp_get_default(); |
564 | 0 | update_group_walk(bgp, update_group_clear_update_dbg, NULL); |
565 | 0 | } |
566 | | |
567 | | static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, |
568 | | struct prefix *p) |
569 | 0 | { |
570 | 0 | char evpn_desc[PREFIX2STR_BUFFER + INET_ADDRSTRLEN]; |
571 | 0 | char buf[PREFIX2STR_BUFFER]; |
572 | 0 | char buf2[ETHER_ADDR_STRLEN]; |
573 | |
|
574 | 0 | if (p->u.prefix_evpn.route_type == BGP_EVPN_MAC_IP_ROUTE) { |
575 | 0 | if (is_evpn_prefix_ipaddr_none((struct prefix_evpn *)p)) { |
576 | 0 | snprintf( |
577 | 0 | evpn_desc, sizeof(evpn_desc), |
578 | 0 | "l2vpn evpn type macip mac %s", |
579 | 0 | prefix_mac2str(&p->u.prefix_evpn.macip_addr.mac, |
580 | 0 | buf2, sizeof(buf2))); |
581 | 0 | } else { |
582 | 0 | uint8_t family = is_evpn_prefix_ipaddr_v4( |
583 | 0 | (struct prefix_evpn *)p) ? |
584 | 0 | AF_INET : AF_INET6; |
585 | 0 | snprintf( |
586 | 0 | evpn_desc, sizeof(evpn_desc), |
587 | 0 | "l2vpn evpn type macip mac %s ip %s", |
588 | 0 | prefix_mac2str(&p->u.prefix_evpn.macip_addr.mac, |
589 | 0 | buf2, sizeof(buf2)), |
590 | 0 | inet_ntop( |
591 | 0 | family, |
592 | 0 | &p->u.prefix_evpn.macip_addr.ip.ip.addr, |
593 | 0 | buf, PREFIX2STR_BUFFER)); |
594 | 0 | } |
595 | 0 | } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IMET_ROUTE) { |
596 | 0 | snprintfrr(evpn_desc, sizeof(evpn_desc), |
597 | 0 | "l2vpn evpn type multicast ip %pI4", |
598 | 0 | &p->u.prefix_evpn.imet_addr.ip.ipaddr_v4); |
599 | 0 | } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IP_PREFIX_ROUTE) { |
600 | 0 | uint8_t family = is_evpn_prefix_ipaddr_v4( |
601 | 0 | (struct prefix_evpn *)p) ? AF_INET |
602 | 0 | : AF_INET6; |
603 | 0 | snprintf(evpn_desc, sizeof(evpn_desc), |
604 | 0 | "l2vpn evpn type prefix ip %s/%d", |
605 | 0 | inet_ntop(family, |
606 | 0 | &p->u.prefix_evpn.prefix_addr.ip.ip.addr, |
607 | 0 | buf, PREFIX2STR_BUFFER), |
608 | 0 | p->u.prefix_evpn.prefix_addr.ip_prefix_length); |
609 | 0 | } |
610 | |
|
611 | 0 | vty_out(vty, "%s %s\n", desc, evpn_desc); |
612 | 0 | } |
613 | | |
614 | | static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv, |
615 | | int argc, struct prefix *argv_p) |
616 | 0 | { |
617 | 0 | struct ethaddr mac = {}; |
618 | 0 | struct ipaddr ip = {}; |
619 | 0 | int evpn_type = 0; |
620 | 0 | int mac_idx = 0; |
621 | 0 | int ip_idx = 0; |
622 | |
|
623 | 0 | if (bgp_evpn_cli_parse_type(&evpn_type, argv, argc) < 0) |
624 | 0 | return CMD_WARNING; |
625 | | |
626 | 0 | if (evpn_type == BGP_EVPN_MAC_IP_ROUTE) { |
627 | 0 | memset(&ip, 0, sizeof(ip)); |
628 | |
|
629 | 0 | if (argv_find(argv, argc, "mac", &mac_idx)) |
630 | 0 | if (!prefix_str2mac(argv[mac_idx + 1]->arg, &mac)) { |
631 | 0 | vty_out(vty, "%% Malformed MAC address\n"); |
632 | 0 | return CMD_WARNING; |
633 | 0 | } |
634 | | |
635 | 0 | if (argv_find(argv, argc, "ip", &ip_idx)) |
636 | 0 | if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { |
637 | 0 | vty_out(vty, "%% Malformed IP address\n"); |
638 | 0 | return CMD_WARNING; |
639 | 0 | } |
640 | | |
641 | 0 | build_evpn_type2_prefix((struct prefix_evpn *)argv_p, |
642 | 0 | &mac, &ip); |
643 | 0 | } else if (evpn_type == BGP_EVPN_IMET_ROUTE) { |
644 | 0 | memset(&ip, 0, sizeof(ip)); |
645 | |
|
646 | 0 | if (argv_find(argv, argc, "ip", &ip_idx)) |
647 | 0 | if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { |
648 | 0 | vty_out(vty, "%% Malformed IP address\n"); |
649 | 0 | return CMD_WARNING; |
650 | 0 | } |
651 | | |
652 | 0 | build_evpn_type3_prefix((struct prefix_evpn *)argv_p, |
653 | 0 | ip.ipaddr_v4); |
654 | 0 | } else if (evpn_type == BGP_EVPN_IP_PREFIX_ROUTE) { |
655 | 0 | struct prefix ip_prefix; |
656 | |
|
657 | 0 | memset(&ip_prefix, 0, sizeof(ip_prefix)); |
658 | 0 | if (argv_find(argv, argc, "ip", &ip_idx)) { |
659 | 0 | (void)str2prefix(argv[ip_idx + 1]->arg, &ip_prefix); |
660 | 0 | apply_mask(&ip_prefix); |
661 | 0 | } |
662 | 0 | build_type5_prefix_from_ip_prefix( |
663 | 0 | (struct prefix_evpn *)argv_p, |
664 | 0 | &ip_prefix); |
665 | 0 | } |
666 | | |
667 | 0 | return CMD_SUCCESS; |
668 | 0 | } |
669 | | |
670 | | /* Debug option setting interface. */ |
671 | | unsigned long bgp_debug_option = 0; |
672 | | |
673 | | int debug(unsigned int option) |
674 | 0 | { |
675 | 0 | return bgp_debug_option & option; |
676 | 0 | } |
677 | | |
678 | | DEFUN (debug_bgp_as4, |
679 | | debug_bgp_as4_cmd, |
680 | | "debug bgp as4", |
681 | | DEBUG_STR |
682 | | BGP_STR |
683 | | "BGP AS4 actions\n") |
684 | 0 | { |
685 | 0 | if (vty->node == CONFIG_NODE) |
686 | 0 | DEBUG_ON(as4, AS4); |
687 | 0 | else { |
688 | 0 | TERM_DEBUG_ON(as4, AS4); |
689 | 0 | vty_out(vty, "BGP as4 debugging is on\n"); |
690 | 0 | } |
691 | 0 | return CMD_SUCCESS; |
692 | 0 | } |
693 | | |
694 | | DEFUN (no_debug_bgp_as4, |
695 | | no_debug_bgp_as4_cmd, |
696 | | "no debug bgp as4", |
697 | | NO_STR |
698 | | DEBUG_STR |
699 | | BGP_STR |
700 | | "BGP AS4 actions\n") |
701 | 0 | { |
702 | 0 | if (vty->node == CONFIG_NODE) |
703 | 0 | DEBUG_OFF(as4, AS4); |
704 | 0 | else { |
705 | 0 | TERM_DEBUG_OFF(as4, AS4); |
706 | 0 | vty_out(vty, "BGP as4 debugging is off\n"); |
707 | 0 | } |
708 | 0 | return CMD_SUCCESS; |
709 | 0 | } |
710 | | |
711 | | DEFUN (debug_bgp_as4_segment, |
712 | | debug_bgp_as4_segment_cmd, |
713 | | "debug bgp as4 segment", |
714 | | DEBUG_STR |
715 | | BGP_STR |
716 | | "BGP AS4 actions\n" |
717 | | "BGP AS4 aspath segment handling\n") |
718 | 0 | { |
719 | 0 | if (vty->node == CONFIG_NODE) |
720 | 0 | DEBUG_ON(as4, AS4_SEGMENT); |
721 | 0 | else { |
722 | 0 | TERM_DEBUG_ON(as4, AS4_SEGMENT); |
723 | 0 | vty_out(vty, "BGP as4 segment debugging is on\n"); |
724 | 0 | } |
725 | 0 | return CMD_SUCCESS; |
726 | 0 | } |
727 | | |
728 | | DEFUN (no_debug_bgp_as4_segment, |
729 | | no_debug_bgp_as4_segment_cmd, |
730 | | "no debug bgp as4 segment", |
731 | | NO_STR |
732 | | DEBUG_STR |
733 | | BGP_STR |
734 | | "BGP AS4 actions\n" |
735 | | "BGP AS4 aspath segment handling\n") |
736 | 0 | { |
737 | 0 | if (vty->node == CONFIG_NODE) |
738 | 0 | DEBUG_OFF(as4, AS4_SEGMENT); |
739 | 0 | else { |
740 | 0 | TERM_DEBUG_OFF(as4, AS4_SEGMENT); |
741 | 0 | vty_out(vty, "BGP as4 segment debugging is off\n"); |
742 | 0 | } |
743 | 0 | return CMD_SUCCESS; |
744 | 0 | } |
745 | | |
746 | | /* debug bgp neighbor_events */ |
747 | | DEFUN (debug_bgp_neighbor_events, |
748 | | debug_bgp_neighbor_events_cmd, |
749 | | "debug bgp neighbor-events", |
750 | | DEBUG_STR |
751 | | BGP_STR |
752 | | "BGP Neighbor Events\n") |
753 | 0 | { |
754 | 0 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
755 | |
|
756 | 0 | if (vty->node == CONFIG_NODE) |
757 | 0 | DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); |
758 | 0 | else { |
759 | 0 | TERM_DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); |
760 | 0 | vty_out(vty, "BGP neighbor-events debugging is on\n"); |
761 | 0 | } |
762 | 0 | return CMD_SUCCESS; |
763 | 0 | } |
764 | | |
765 | | DEFUN (debug_bgp_neighbor_events_peer, |
766 | | debug_bgp_neighbor_events_peer_cmd, |
767 | | "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", |
768 | | DEBUG_STR |
769 | | BGP_STR |
770 | | "BGP Neighbor Events\n" |
771 | | "BGP neighbor IP address to debug\n" |
772 | | "BGP IPv6 neighbor to debug\n" |
773 | | "BGP neighbor on interface to debug\n") |
774 | 0 | { |
775 | 0 | int idx_peer = 3; |
776 | 0 | const char *host = argv[idx_peer]->arg; |
777 | |
|
778 | 0 | if (!bgp_debug_neighbor_events_peers) |
779 | 0 | bgp_debug_neighbor_events_peers = list_new(); |
780 | |
|
781 | 0 | if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers, host, |
782 | 0 | NULL)) { |
783 | 0 | vty_out(vty, |
784 | 0 | "BGP neighbor-events debugging is already enabled for %s\n", |
785 | 0 | host); |
786 | 0 | return CMD_SUCCESS; |
787 | 0 | } |
788 | | |
789 | 0 | bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers, host, NULL); |
790 | |
|
791 | 0 | if (vty->node == CONFIG_NODE) |
792 | 0 | DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); |
793 | 0 | else { |
794 | 0 | TERM_DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); |
795 | 0 | vty_out(vty, "BGP neighbor-events debugging is on for %s\n", |
796 | 0 | host); |
797 | 0 | } |
798 | 0 | return CMD_SUCCESS; |
799 | 0 | } |
800 | | |
801 | | DEFUN (no_debug_bgp_neighbor_events, |
802 | | no_debug_bgp_neighbor_events_cmd, |
803 | | "no debug bgp neighbor-events", |
804 | | NO_STR |
805 | | DEBUG_STR |
806 | | BGP_STR |
807 | | "Neighbor Events\n") |
808 | 0 | { |
809 | 0 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
810 | |
|
811 | 0 | if (vty->node == CONFIG_NODE) |
812 | 0 | DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); |
813 | 0 | else { |
814 | 0 | TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); |
815 | 0 | vty_out(vty, "BGP neighbor-events debugging is off\n"); |
816 | 0 | } |
817 | 0 | return CMD_SUCCESS; |
818 | 0 | } |
819 | | |
820 | | DEFUN (no_debug_bgp_neighbor_events_peer, |
821 | | no_debug_bgp_neighbor_events_peer_cmd, |
822 | | "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", |
823 | | NO_STR |
824 | | DEBUG_STR |
825 | | BGP_STR |
826 | | "Neighbor Events\n" |
827 | | "BGP neighbor IP address to debug\n" |
828 | | "BGP IPv6 neighbor to debug\n" |
829 | | "BGP neighbor on interface to debug\n") |
830 | 0 | { |
831 | 0 | int idx_peer = 4; |
832 | 0 | int found_peer = 0; |
833 | 0 | const char *host = argv[idx_peer]->arg; |
834 | |
|
835 | 0 | if (bgp_debug_neighbor_events_peers |
836 | 0 | && !list_isempty(bgp_debug_neighbor_events_peers)) { |
837 | 0 | found_peer = bgp_debug_list_remove_entry( |
838 | 0 | bgp_debug_neighbor_events_peers, host, NULL); |
839 | |
|
840 | 0 | if (list_isempty(bgp_debug_neighbor_events_peers)) { |
841 | 0 | if (vty->node == CONFIG_NODE) |
842 | 0 | DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); |
843 | 0 | else |
844 | 0 | TERM_DEBUG_OFF(neighbor_events, |
845 | 0 | NEIGHBOR_EVENTS); |
846 | 0 | } |
847 | 0 | } |
848 | |
|
849 | 0 | if (found_peer) |
850 | 0 | vty_out(vty, "BGP neighbor-events debugging is off for %s\n", |
851 | 0 | host); |
852 | 0 | else |
853 | 0 | vty_out(vty, |
854 | 0 | "BGP neighbor-events debugging was not enabled for %s\n", |
855 | 0 | host); |
856 | |
|
857 | 0 | return CMD_SUCCESS; |
858 | 0 | } |
859 | | |
860 | | /* debug bgp nht */ |
861 | | DEFUN (debug_bgp_nht, |
862 | | debug_bgp_nht_cmd, |
863 | | "debug bgp nht", |
864 | | DEBUG_STR |
865 | | BGP_STR |
866 | | "BGP nexthop tracking events\n") |
867 | 0 | { |
868 | 0 | if (vty->node == CONFIG_NODE) |
869 | 0 | DEBUG_ON(nht, NHT); |
870 | 0 | else { |
871 | 0 | TERM_DEBUG_ON(nht, NHT); |
872 | 0 | vty_out(vty, "BGP nexthop tracking debugging is on\n"); |
873 | 0 | } |
874 | 0 | return CMD_SUCCESS; |
875 | 0 | } |
876 | | |
877 | | DEFUN (no_debug_bgp_nht, |
878 | | no_debug_bgp_nht_cmd, |
879 | | "no debug bgp nht", |
880 | | NO_STR |
881 | | DEBUG_STR |
882 | | BGP_STR |
883 | | "BGP nexthop tracking events\n") |
884 | 0 | { |
885 | 0 | if (vty->node == CONFIG_NODE) |
886 | 0 | DEBUG_OFF(nht, NHT); |
887 | 0 | else { |
888 | 0 | TERM_DEBUG_OFF(nht, NHT); |
889 | 0 | vty_out(vty, "BGP nexthop tracking debugging is off\n"); |
890 | 0 | } |
891 | 0 | return CMD_SUCCESS; |
892 | 0 | } |
893 | | |
894 | | /* debug bgp keepalives */ |
895 | | DEFUN (debug_bgp_keepalive, |
896 | | debug_bgp_keepalive_cmd, |
897 | | "debug bgp keepalives", |
898 | | DEBUG_STR |
899 | | BGP_STR |
900 | | "BGP keepalives\n") |
901 | 0 | { |
902 | 0 | bgp_debug_list_free(bgp_debug_keepalive_peers); |
903 | |
|
904 | 0 | if (vty->node == CONFIG_NODE) |
905 | 0 | DEBUG_ON(keepalive, KEEPALIVE); |
906 | 0 | else { |
907 | 0 | TERM_DEBUG_ON(keepalive, KEEPALIVE); |
908 | 0 | vty_out(vty, "BGP keepalives debugging is on\n"); |
909 | 0 | } |
910 | 0 | return CMD_SUCCESS; |
911 | 0 | } |
912 | | |
913 | | DEFUN (debug_bgp_keepalive_peer, |
914 | | debug_bgp_keepalive_peer_cmd, |
915 | | "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", |
916 | | DEBUG_STR |
917 | | BGP_STR |
918 | | "BGP keepalives\n" |
919 | | "BGP IPv4 neighbor to debug\n" |
920 | | "BGP IPv6 neighbor to debug\n" |
921 | | "BGP neighbor on interface to debug\n") |
922 | 0 | { |
923 | 0 | int idx_peer = 3; |
924 | 0 | const char *host = argv[idx_peer]->arg; |
925 | |
|
926 | 0 | if (!bgp_debug_keepalive_peers) |
927 | 0 | bgp_debug_keepalive_peers = list_new(); |
928 | |
|
929 | 0 | if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, host, NULL)) { |
930 | 0 | vty_out(vty, |
931 | 0 | "BGP keepalive debugging is already enabled for %s\n", |
932 | 0 | host); |
933 | 0 | return CMD_SUCCESS; |
934 | 0 | } |
935 | | |
936 | 0 | bgp_debug_list_add_entry(bgp_debug_keepalive_peers, host, NULL); |
937 | |
|
938 | 0 | if (vty->node == CONFIG_NODE) |
939 | 0 | DEBUG_ON(keepalive, KEEPALIVE); |
940 | 0 | else { |
941 | 0 | TERM_DEBUG_ON(keepalive, KEEPALIVE); |
942 | 0 | vty_out(vty, "BGP keepalives debugging is on for %s\n", host); |
943 | 0 | } |
944 | 0 | return CMD_SUCCESS; |
945 | 0 | } |
946 | | |
947 | | DEFUN (no_debug_bgp_keepalive, |
948 | | no_debug_bgp_keepalive_cmd, |
949 | | "no debug bgp keepalives", |
950 | | NO_STR |
951 | | DEBUG_STR |
952 | | BGP_STR |
953 | | "BGP keepalives\n") |
954 | 0 | { |
955 | 0 | bgp_debug_list_free(bgp_debug_keepalive_peers); |
956 | |
|
957 | 0 | if (vty->node == CONFIG_NODE) |
958 | 0 | DEBUG_OFF(keepalive, KEEPALIVE); |
959 | 0 | else { |
960 | 0 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); |
961 | 0 | vty_out(vty, "BGP keepalives debugging is off\n"); |
962 | 0 | } |
963 | 0 | return CMD_SUCCESS; |
964 | 0 | } |
965 | | |
966 | | DEFUN (no_debug_bgp_keepalive_peer, |
967 | | no_debug_bgp_keepalive_peer_cmd, |
968 | | "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", |
969 | | NO_STR |
970 | | DEBUG_STR |
971 | | BGP_STR |
972 | | "BGP keepalives\n" |
973 | | "BGP neighbor IP address to debug\n" |
974 | | "BGP IPv6 neighbor to debug\n" |
975 | | "BGP neighbor on interface to debug\n") |
976 | 0 | { |
977 | 0 | int idx_peer = 4; |
978 | 0 | int found_peer = 0; |
979 | 0 | const char *host = argv[idx_peer]->arg; |
980 | |
|
981 | 0 | if (bgp_debug_keepalive_peers |
982 | 0 | && !list_isempty(bgp_debug_keepalive_peers)) { |
983 | 0 | found_peer = bgp_debug_list_remove_entry( |
984 | 0 | bgp_debug_keepalive_peers, host, NULL); |
985 | |
|
986 | 0 | if (list_isempty(bgp_debug_keepalive_peers)) { |
987 | 0 | if (vty->node == CONFIG_NODE) |
988 | 0 | DEBUG_OFF(keepalive, KEEPALIVE); |
989 | 0 | else |
990 | 0 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); |
991 | 0 | } |
992 | 0 | } |
993 | |
|
994 | 0 | if (found_peer) |
995 | 0 | vty_out(vty, "BGP keepalives debugging is off for %s\n", host); |
996 | 0 | else |
997 | 0 | vty_out(vty, |
998 | 0 | "BGP keepalives debugging was not enabled for %s\n", |
999 | 0 | host); |
1000 | |
|
1001 | 0 | return CMD_SUCCESS; |
1002 | 0 | } |
1003 | | |
1004 | | /* debug bgp bestpath */ |
1005 | | DEFPY (debug_bgp_bestpath_prefix, |
1006 | | debug_bgp_bestpath_prefix_cmd, |
1007 | | "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>$prefix", |
1008 | | DEBUG_STR |
1009 | | BGP_STR |
1010 | | "BGP bestpath\n" |
1011 | | "IPv4 prefix\n" |
1012 | | "IPv6 prefix\n") |
1013 | 0 | { |
1014 | 0 | if (!bgp_debug_bestpath_prefixes) |
1015 | 0 | bgp_debug_bestpath_prefixes = list_new(); |
1016 | |
|
1017 | 0 | if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, |
1018 | 0 | prefix)) { |
1019 | 0 | vty_out(vty, |
1020 | 0 | "BGP bestpath debugging is already enabled for %s\n", |
1021 | 0 | prefix_str); |
1022 | 0 | return CMD_SUCCESS; |
1023 | 0 | } |
1024 | | |
1025 | 0 | bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, prefix); |
1026 | |
|
1027 | 0 | if (vty->node == CONFIG_NODE) { |
1028 | 0 | DEBUG_ON(bestpath, BESTPATH); |
1029 | 0 | } else { |
1030 | 0 | TERM_DEBUG_ON(bestpath, BESTPATH); |
1031 | 0 | vty_out(vty, "BGP bestpath debugging is on for %s\n", |
1032 | 0 | prefix_str); |
1033 | 0 | } |
1034 | |
|
1035 | 0 | return CMD_SUCCESS; |
1036 | 0 | } |
1037 | | |
1038 | | DEFPY (no_debug_bgp_bestpath_prefix, |
1039 | | no_debug_bgp_bestpath_prefix_cmd, |
1040 | | "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>$prefix", |
1041 | | NO_STR |
1042 | | DEBUG_STR |
1043 | | BGP_STR |
1044 | | "BGP bestpath\n" |
1045 | | "IPv4 prefix\n" |
1046 | | "IPv6 prefix\n") |
1047 | 0 | { |
1048 | 0 | bool found_prefix = false; |
1049 | |
|
1050 | 0 | if (bgp_debug_bestpath_prefixes |
1051 | 0 | && !list_isempty(bgp_debug_bestpath_prefixes)) { |
1052 | 0 | found_prefix = bgp_debug_list_remove_entry( |
1053 | 0 | bgp_debug_bestpath_prefixes, NULL, prefix); |
1054 | |
|
1055 | 0 | if (list_isempty(bgp_debug_bestpath_prefixes)) { |
1056 | 0 | if (vty->node == CONFIG_NODE) { |
1057 | 0 | DEBUG_OFF(bestpath, BESTPATH); |
1058 | 0 | } else { |
1059 | 0 | TERM_DEBUG_OFF(bestpath, BESTPATH); |
1060 | 0 | vty_out(vty, |
1061 | 0 | "BGP bestpath debugging (per prefix) is off\n"); |
1062 | 0 | } |
1063 | 0 | } |
1064 | 0 | } |
1065 | |
|
1066 | 0 | if (found_prefix) |
1067 | 0 | vty_out(vty, "BGP bestpath debugging is off for %s\n", |
1068 | 0 | prefix_str); |
1069 | 0 | else |
1070 | 0 | vty_out(vty, "BGP bestpath debugging was not enabled for %s\n", |
1071 | 0 | prefix_str); |
1072 | |
|
1073 | 0 | return CMD_SUCCESS; |
1074 | 0 | } |
1075 | | |
1076 | | DEFUN (no_debug_bgp_bestpath, |
1077 | | no_debug_bgp_bestpath_cmd, |
1078 | | "no debug bgp bestpath", |
1079 | | NO_STR |
1080 | | DEBUG_STR |
1081 | | BGP_STR |
1082 | | "BGP bestpath\n") |
1083 | 0 | { |
1084 | 0 | bgp_debug_list_free(bgp_debug_bestpath_prefixes); |
1085 | |
|
1086 | 0 | if (vty->node == CONFIG_NODE) |
1087 | 0 | DEBUG_OFF(bestpath, BESTPATH); |
1088 | 0 | else { |
1089 | 0 | TERM_DEBUG_OFF(bestpath, BESTPATH); |
1090 | 0 | vty_out(vty, "BGP bestpath debugging is off\n"); |
1091 | 0 | } |
1092 | 0 | return CMD_SUCCESS; |
1093 | 0 | } |
1094 | | |
1095 | | /* debug bgp updates */ |
1096 | | DEFUN (debug_bgp_update, |
1097 | | debug_bgp_update_cmd, |
1098 | | "debug bgp updates", |
1099 | | DEBUG_STR |
1100 | | BGP_STR |
1101 | | "BGP updates\n") |
1102 | 0 | { |
1103 | 0 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1104 | 0 | bgp_debug_list_free(bgp_debug_update_out_peers); |
1105 | 0 | bgp_debug_list_free(bgp_debug_update_prefixes); |
1106 | |
|
1107 | 0 | if (vty->node == CONFIG_NODE) { |
1108 | 0 | DEBUG_ON(update, UPDATE_IN); |
1109 | 0 | DEBUG_ON(update, UPDATE_OUT); |
1110 | 0 | } else { |
1111 | 0 | TERM_DEBUG_ON(update, UPDATE_IN); |
1112 | 0 | TERM_DEBUG_ON(update, UPDATE_OUT); |
1113 | 0 | vty_out(vty, "BGP updates debugging is on\n"); |
1114 | 0 | } |
1115 | 0 | return CMD_SUCCESS; |
1116 | 0 | } |
1117 | | |
1118 | | DEFUN (debug_bgp_update_direct, |
1119 | | debug_bgp_update_direct_cmd, |
1120 | | "debug bgp updates <in|out>", |
1121 | | DEBUG_STR |
1122 | | BGP_STR |
1123 | | "BGP updates\n" |
1124 | | "Inbound updates\n" |
1125 | | "Outbound updates\n") |
1126 | 0 | { |
1127 | 0 | int idx_in_out = 3; |
1128 | |
|
1129 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) |
1130 | 0 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1131 | 0 | else |
1132 | 0 | bgp_debug_list_free(bgp_debug_update_out_peers); |
1133 | |
|
1134 | 0 | if (vty->node == CONFIG_NODE) { |
1135 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) |
1136 | 0 | DEBUG_ON(update, UPDATE_IN); |
1137 | 0 | else |
1138 | 0 | DEBUG_ON(update, UPDATE_OUT); |
1139 | 0 | } else { |
1140 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) { |
1141 | 0 | TERM_DEBUG_ON(update, UPDATE_IN); |
1142 | 0 | vty_out(vty, "BGP updates debugging is on (inbound)\n"); |
1143 | 0 | } else { |
1144 | 0 | TERM_DEBUG_ON(update, UPDATE_OUT); |
1145 | 0 | vty_out(vty, |
1146 | 0 | "BGP updates debugging is on (outbound)\n"); |
1147 | 0 | } |
1148 | 0 | } |
1149 | 0 | return CMD_SUCCESS; |
1150 | 0 | } |
1151 | | |
1152 | | DEFUN (debug_bgp_update_direct_peer, |
1153 | | debug_bgp_update_direct_peer_cmd, |
1154 | | "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", |
1155 | | DEBUG_STR |
1156 | | BGP_STR |
1157 | | "BGP updates\n" |
1158 | | "Inbound updates\n" |
1159 | | "Outbound updates\n" |
1160 | | "BGP neighbor IP address to debug\n" |
1161 | | "BGP IPv6 neighbor to debug\n" |
1162 | | "BGP neighbor on interface to debug\n") |
1163 | 0 | { |
1164 | 0 | int idx_in_out = 3; |
1165 | 0 | int idx_peer = 4; |
1166 | 0 | const char *host = argv[idx_peer]->arg; |
1167 | 0 | int inbound; |
1168 | |
|
1169 | 0 | if (!bgp_debug_update_in_peers) |
1170 | 0 | bgp_debug_update_in_peers = list_new(); |
1171 | |
|
1172 | 0 | if (!bgp_debug_update_out_peers) |
1173 | 0 | bgp_debug_update_out_peers = list_new(); |
1174 | |
|
1175 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) |
1176 | 0 | inbound = 1; |
1177 | 0 | else |
1178 | 0 | inbound = 0; |
1179 | |
|
1180 | 0 | if (inbound) { |
1181 | 0 | if (bgp_debug_list_has_entry(bgp_debug_update_in_peers, host, |
1182 | 0 | NULL)) { |
1183 | 0 | vty_out(vty, |
1184 | 0 | "BGP inbound update debugging is already enabled for %s\n", |
1185 | 0 | host); |
1186 | 0 | return CMD_SUCCESS; |
1187 | 0 | } |
1188 | 0 | } |
1189 | | |
1190 | 0 | else { |
1191 | 0 | if (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, |
1192 | 0 | NULL)) { |
1193 | 0 | vty_out(vty, |
1194 | 0 | "BGP outbound update debugging is already enabled for %s\n", |
1195 | 0 | host); |
1196 | 0 | return CMD_SUCCESS; |
1197 | 0 | } |
1198 | 0 | } |
1199 | | |
1200 | 0 | if (inbound) |
1201 | 0 | bgp_debug_list_add_entry(bgp_debug_update_in_peers, host, NULL); |
1202 | 0 | else { |
1203 | 0 | struct peer *peer; |
1204 | 0 | struct peer_af *paf; |
1205 | 0 | int afidx; |
1206 | |
|
1207 | 0 | bgp_debug_list_add_entry(bgp_debug_update_out_peers, host, |
1208 | 0 | NULL); |
1209 | 0 | peer = bgp_find_peer(vty, host); |
1210 | |
|
1211 | 0 | if (peer) { |
1212 | 0 | for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; |
1213 | 0 | afidx++) { |
1214 | 0 | paf = peer->peer_af_array[afidx]; |
1215 | 0 | if (paf != NULL) { |
1216 | 0 | if (PAF_SUBGRP(paf)) { |
1217 | 0 | UPDGRP_PEER_DBG_EN( |
1218 | 0 | PAF_SUBGRP(paf) |
1219 | 0 | ->update_group); |
1220 | 0 | } |
1221 | 0 | } |
1222 | 0 | } |
1223 | 0 | } |
1224 | 0 | } |
1225 | |
|
1226 | 0 | if (vty->node == CONFIG_NODE) { |
1227 | 0 | if (inbound) |
1228 | 0 | DEBUG_ON(update, UPDATE_IN); |
1229 | 0 | else |
1230 | 0 | DEBUG_ON(update, UPDATE_OUT); |
1231 | 0 | } else { |
1232 | 0 | if (inbound) { |
1233 | 0 | TERM_DEBUG_ON(update, UPDATE_IN); |
1234 | 0 | vty_out(vty, |
1235 | 0 | "BGP updates debugging is on (inbound) for %s\n", |
1236 | 0 | argv[idx_peer]->arg); |
1237 | 0 | } else { |
1238 | 0 | TERM_DEBUG_ON(update, UPDATE_OUT); |
1239 | 0 | vty_out(vty, |
1240 | 0 | "BGP updates debugging is on (outbound) for %s\n", |
1241 | 0 | argv[idx_peer]->arg); |
1242 | 0 | } |
1243 | 0 | } |
1244 | 0 | return CMD_SUCCESS; |
1245 | 0 | } |
1246 | | |
1247 | | DEFUN (no_debug_bgp_update_direct, |
1248 | | no_debug_bgp_update_direct_cmd, |
1249 | | "no debug bgp updates <in|out>", |
1250 | | NO_STR |
1251 | | DEBUG_STR |
1252 | | BGP_STR |
1253 | | "BGP updates\n" |
1254 | | "Inbound updates\n" |
1255 | | "Outbound updates\n") |
1256 | 0 | { |
1257 | 0 | int idx_in_out = 4; |
1258 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) { |
1259 | 0 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1260 | |
|
1261 | 0 | if (vty->node == CONFIG_NODE) { |
1262 | 0 | DEBUG_OFF(update, UPDATE_IN); |
1263 | 0 | } else { |
1264 | 0 | TERM_DEBUG_OFF(update, UPDATE_IN); |
1265 | 0 | vty_out(vty, |
1266 | 0 | "BGP updates debugging is off (inbound)\n"); |
1267 | 0 | } |
1268 | 0 | } else { |
1269 | 0 | bgp_debug_list_free(bgp_debug_update_out_peers); |
1270 | |
|
1271 | 0 | if (vty->node == CONFIG_NODE) { |
1272 | 0 | DEBUG_OFF(update, UPDATE_OUT); |
1273 | 0 | } else { |
1274 | 0 | TERM_DEBUG_OFF(update, UPDATE_OUT); |
1275 | 0 | vty_out(vty, |
1276 | 0 | "BGP updates debugging is off (outbound)\n"); |
1277 | 0 | } |
1278 | 0 | } |
1279 | |
|
1280 | 0 | return CMD_SUCCESS; |
1281 | 0 | } |
1282 | | |
1283 | | DEFUN (no_debug_bgp_update_direct_peer, |
1284 | | no_debug_bgp_update_direct_peer_cmd, |
1285 | | "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", |
1286 | | NO_STR |
1287 | | DEBUG_STR |
1288 | | BGP_STR |
1289 | | "BGP updates\n" |
1290 | | "Inbound updates\n" |
1291 | | "Outbound updates\n" |
1292 | | "BGP neighbor IP address to debug\n" |
1293 | | "BGP IPv6 neighbor to debug\n" |
1294 | | "BGP neighbor on interface to debug\n") |
1295 | 0 | { |
1296 | 0 | int idx_in_out = 4; |
1297 | 0 | int idx_peer = 5; |
1298 | 0 | int inbound; |
1299 | 0 | int found_peer = 0; |
1300 | 0 | const char *host = argv[idx_peer]->arg; |
1301 | |
|
1302 | 0 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) |
1303 | 0 | inbound = 1; |
1304 | 0 | else |
1305 | 0 | inbound = 0; |
1306 | |
|
1307 | 0 | if (inbound && bgp_debug_update_in_peers |
1308 | 0 | && !list_isempty(bgp_debug_update_in_peers)) { |
1309 | 0 | found_peer = bgp_debug_list_remove_entry( |
1310 | 0 | bgp_debug_update_in_peers, host, NULL); |
1311 | |
|
1312 | 0 | if (list_isempty(bgp_debug_update_in_peers)) { |
1313 | 0 | if (vty->node == CONFIG_NODE) |
1314 | 0 | DEBUG_OFF(update, UPDATE_IN); |
1315 | 0 | else { |
1316 | 0 | TERM_DEBUG_OFF(update, UPDATE_IN); |
1317 | 0 | vty_out(vty, |
1318 | 0 | "BGP updates debugging (inbound) is off\n"); |
1319 | 0 | } |
1320 | 0 | } |
1321 | 0 | } |
1322 | |
|
1323 | 0 | if (!inbound && bgp_debug_update_out_peers |
1324 | 0 | && !list_isempty(bgp_debug_update_out_peers)) { |
1325 | 0 | found_peer = bgp_debug_list_remove_entry( |
1326 | 0 | bgp_debug_update_out_peers, host, NULL); |
1327 | |
|
1328 | 0 | if (list_isempty(bgp_debug_update_out_peers)) { |
1329 | 0 | if (vty->node == CONFIG_NODE) |
1330 | 0 | DEBUG_OFF(update, UPDATE_OUT); |
1331 | 0 | else { |
1332 | 0 | TERM_DEBUG_OFF(update, UPDATE_OUT); |
1333 | 0 | vty_out(vty, |
1334 | 0 | "BGP updates debugging (outbound) is off\n"); |
1335 | 0 | } |
1336 | 0 | } |
1337 | |
|
1338 | 0 | struct peer *peer; |
1339 | 0 | struct peer_af *paf; |
1340 | 0 | int afidx; |
1341 | 0 | peer = bgp_find_peer(vty, host); |
1342 | |
|
1343 | 0 | if (peer) { |
1344 | 0 | for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; |
1345 | 0 | afidx++) { |
1346 | 0 | paf = peer->peer_af_array[afidx]; |
1347 | 0 | if (paf != NULL) { |
1348 | 0 | if (PAF_SUBGRP(paf)) { |
1349 | 0 | UPDGRP_PEER_DBG_DIS( |
1350 | 0 | PAF_SUBGRP(paf) |
1351 | 0 | ->update_group); |
1352 | 0 | } |
1353 | 0 | } |
1354 | 0 | } |
1355 | 0 | } |
1356 | 0 | } |
1357 | |
|
1358 | 0 | if (found_peer) |
1359 | 0 | if (inbound) |
1360 | 0 | vty_out(vty, |
1361 | 0 | "BGP updates debugging (inbound) is off for %s\n", |
1362 | 0 | host); |
1363 | 0 | else |
1364 | 0 | vty_out(vty, |
1365 | 0 | "BGP updates debugging (outbound) is off for %s\n", |
1366 | 0 | host); |
1367 | 0 | else if (inbound) |
1368 | 0 | vty_out(vty, |
1369 | 0 | "BGP updates debugging (inbound) was not enabled for %s\n", |
1370 | 0 | host); |
1371 | 0 | else |
1372 | 0 | vty_out(vty, |
1373 | 0 | "BGP updates debugging (outbound) was not enabled for %s\n", |
1374 | 0 | host); |
1375 | |
|
1376 | 0 | return CMD_SUCCESS; |
1377 | 0 | } |
1378 | | |
1379 | | DEFPY (debug_bgp_update_prefix_afi_safi, |
1380 | | debug_bgp_update_prefix_afi_safi_cmd, |
1381 | | "debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>", |
1382 | | DEBUG_STR |
1383 | | BGP_STR |
1384 | | "BGP updates\n" |
1385 | | "Specify a prefix to debug\n" |
1386 | | L2VPN_HELP_STR |
1387 | | EVPN_HELP_STR |
1388 | | EVPN_TYPE_HELP_STR |
1389 | | EVPN_TYPE_2_HELP_STR |
1390 | | EVPN_TYPE_2_HELP_STR |
1391 | | MAC_STR MAC_STR MAC_STR |
1392 | | IP_STR |
1393 | | "IPv4 address\n" |
1394 | | "IPv6 address\n" |
1395 | | EVPN_TYPE_3_HELP_STR |
1396 | | EVPN_TYPE_3_HELP_STR |
1397 | | IP_STR |
1398 | | "IPv4 address\n" |
1399 | | "IPv6 address\n" |
1400 | | EVPN_TYPE_5_HELP_STR |
1401 | | EVPN_TYPE_5_HELP_STR |
1402 | | IP_STR |
1403 | | "IPv4 prefix\n" |
1404 | | "IPv6 prefix\n") |
1405 | 0 | { |
1406 | 0 | struct prefix argv_p; |
1407 | 0 | int ret = CMD_SUCCESS; |
1408 | |
|
1409 | 0 | ret = bgp_debug_parse_evpn_prefix(vty, argv, argc, &argv_p); |
1410 | 0 | if (ret != CMD_SUCCESS) |
1411 | 0 | return ret; |
1412 | | |
1413 | 0 | if (!bgp_debug_update_prefixes) |
1414 | 0 | bgp_debug_update_prefixes = list_new(); |
1415 | |
|
1416 | 0 | if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, |
1417 | 0 | &argv_p)) { |
1418 | 0 | vty_out(vty, |
1419 | 0 | "BGP updates debugging is already enabled for %pFX\n", |
1420 | 0 | &argv_p); |
1421 | 0 | return CMD_SUCCESS; |
1422 | 0 | } |
1423 | | |
1424 | 0 | bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, &argv_p); |
1425 | |
|
1426 | 0 | if (vty->node == CONFIG_NODE) { |
1427 | 0 | DEBUG_ON(update, UPDATE_PREFIX); |
1428 | 0 | } else { |
1429 | 0 | TERM_DEBUG_ON(update, UPDATE_PREFIX); |
1430 | 0 | vty_out(vty, "BGP updates debugging is on for %pFX\n", &argv_p); |
1431 | 0 | } |
1432 | |
|
1433 | 0 | return CMD_SUCCESS; |
1434 | 0 | } |
1435 | | |
1436 | | DEFPY (no_debug_bgp_update_prefix_afi_safi, |
1437 | | no_debug_bgp_update_prefix_afi_safi_cmd, |
1438 | | "no debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>", |
1439 | | NO_STR |
1440 | | DEBUG_STR |
1441 | | BGP_STR |
1442 | | "BGP updates\n" |
1443 | | "Specify a prefix to debug\n" |
1444 | | L2VPN_HELP_STR |
1445 | | EVPN_HELP_STR |
1446 | | EVPN_TYPE_HELP_STR |
1447 | | EVPN_TYPE_2_HELP_STR |
1448 | | EVPN_TYPE_2_HELP_STR |
1449 | | MAC_STR MAC_STR MAC_STR |
1450 | | IP_STR |
1451 | | "IPv4 address\n" |
1452 | | "IPv6 address\n" |
1453 | | EVPN_TYPE_3_HELP_STR |
1454 | | EVPN_TYPE_3_HELP_STR |
1455 | | IP_STR |
1456 | | "IPv4 address\n" |
1457 | | "IPv6 address\n" |
1458 | | EVPN_TYPE_5_HELP_STR |
1459 | | EVPN_TYPE_5_HELP_STR |
1460 | | IP_STR |
1461 | | "IPv4 prefix\n" |
1462 | | "IPv6 prefix\n") |
1463 | 0 | { |
1464 | 0 | struct prefix argv_p; |
1465 | 0 | bool found_prefix = false; |
1466 | 0 | int ret = CMD_SUCCESS; |
1467 | |
|
1468 | 0 | ret = bgp_debug_parse_evpn_prefix(vty, argv, argc, &argv_p); |
1469 | 0 | if (ret != CMD_SUCCESS) |
1470 | 0 | return ret; |
1471 | | |
1472 | 0 | if (bgp_debug_update_prefixes |
1473 | 0 | && !list_isempty(bgp_debug_update_prefixes)) { |
1474 | 0 | found_prefix = bgp_debug_list_remove_entry( |
1475 | 0 | bgp_debug_update_prefixes, NULL, &argv_p); |
1476 | |
|
1477 | 0 | if (list_isempty(bgp_debug_update_prefixes)) { |
1478 | 0 | if (vty->node == CONFIG_NODE) { |
1479 | 0 | DEBUG_OFF(update, UPDATE_PREFIX); |
1480 | 0 | } else { |
1481 | 0 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); |
1482 | 0 | vty_out(vty, |
1483 | 0 | "BGP updates debugging (per prefix) is off\n"); |
1484 | 0 | } |
1485 | 0 | } |
1486 | 0 | } |
1487 | |
|
1488 | 0 | if (found_prefix) |
1489 | 0 | vty_out(vty, "BGP updates debugging is off for %pFX\n", |
1490 | 0 | &argv_p); |
1491 | 0 | else |
1492 | 0 | vty_out(vty, "BGP updates debugging was not enabled for %pFX\n", |
1493 | 0 | &argv_p); |
1494 | |
|
1495 | 0 | return ret; |
1496 | 0 | } |
1497 | | |
1498 | | |
1499 | | DEFPY (debug_bgp_update_prefix, |
1500 | | debug_bgp_update_prefix_cmd, |
1501 | | "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>$prefix", |
1502 | | DEBUG_STR |
1503 | | BGP_STR |
1504 | | "BGP updates\n" |
1505 | | "Specify a prefix to debug\n" |
1506 | | "IPv4 prefix\n" |
1507 | | "IPv6 prefix\n") |
1508 | 0 | { |
1509 | 0 | if (!bgp_debug_update_prefixes) |
1510 | 0 | bgp_debug_update_prefixes = list_new(); |
1511 | |
|
1512 | 0 | if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, prefix)) { |
1513 | 0 | vty_out(vty, |
1514 | 0 | "BGP updates debugging is already enabled for %s\n", |
1515 | 0 | prefix_str); |
1516 | 0 | return CMD_SUCCESS; |
1517 | 0 | } |
1518 | | |
1519 | 0 | bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, prefix); |
1520 | |
|
1521 | 0 | if (vty->node == CONFIG_NODE) { |
1522 | 0 | DEBUG_ON(update, UPDATE_PREFIX); |
1523 | 0 | } else { |
1524 | 0 | TERM_DEBUG_ON(update, UPDATE_PREFIX); |
1525 | 0 | vty_out(vty, "BGP updates debugging is on for %s\n", |
1526 | 0 | prefix_str); |
1527 | 0 | } |
1528 | |
|
1529 | 0 | return CMD_SUCCESS; |
1530 | 0 | } |
1531 | | |
1532 | | DEFPY (no_debug_bgp_update_prefix, |
1533 | | no_debug_bgp_update_prefix_cmd, |
1534 | | "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>$prefix", |
1535 | | NO_STR |
1536 | | DEBUG_STR |
1537 | | BGP_STR |
1538 | | "BGP updates\n" |
1539 | | "Specify a prefix to debug\n" |
1540 | | "IPv4 prefix\n" |
1541 | | "IPv6 prefix\n") |
1542 | 0 | { |
1543 | 0 | bool found_prefix = false; |
1544 | |
|
1545 | 0 | if (bgp_debug_update_prefixes |
1546 | 0 | && !list_isempty(bgp_debug_update_prefixes)) { |
1547 | 0 | found_prefix = bgp_debug_list_remove_entry( |
1548 | 0 | bgp_debug_update_prefixes, NULL, prefix); |
1549 | |
|
1550 | 0 | if (list_isempty(bgp_debug_update_prefixes)) { |
1551 | 0 | if (vty->node == CONFIG_NODE) { |
1552 | 0 | DEBUG_OFF(update, UPDATE_PREFIX); |
1553 | 0 | } else { |
1554 | 0 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); |
1555 | 0 | vty_out(vty, |
1556 | 0 | "BGP updates debugging (per prefix) is off\n"); |
1557 | 0 | } |
1558 | 0 | } |
1559 | 0 | } |
1560 | |
|
1561 | 0 | if (found_prefix) |
1562 | 0 | vty_out(vty, "BGP updates debugging is off for %s\n", |
1563 | 0 | prefix_str); |
1564 | 0 | else |
1565 | 0 | vty_out(vty, "BGP updates debugging was not enabled for %s\n", |
1566 | 0 | prefix_str); |
1567 | |
|
1568 | 0 | return CMD_SUCCESS; |
1569 | 0 | } |
1570 | | |
1571 | | DEFUN (no_debug_bgp_update, |
1572 | | no_debug_bgp_update_cmd, |
1573 | | "no debug bgp updates", |
1574 | | NO_STR |
1575 | | DEBUG_STR |
1576 | | BGP_STR |
1577 | | "BGP updates\n") |
1578 | 0 | { |
1579 | 0 | struct listnode *ln; |
1580 | 0 | struct bgp *bgp; |
1581 | |
|
1582 | 0 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1583 | 0 | bgp_debug_list_free(bgp_debug_update_out_peers); |
1584 | 0 | bgp_debug_list_free(bgp_debug_update_prefixes); |
1585 | |
|
1586 | 0 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, ln, bgp)) |
1587 | 0 | bgp_debug_clear_updgrp_update_dbg(bgp); |
1588 | |
|
1589 | 0 | if (vty->node == CONFIG_NODE) { |
1590 | 0 | DEBUG_OFF(update, UPDATE_IN); |
1591 | 0 | DEBUG_OFF(update, UPDATE_OUT); |
1592 | 0 | DEBUG_OFF(update, UPDATE_PREFIX); |
1593 | 0 | } else { |
1594 | 0 | TERM_DEBUG_OFF(update, UPDATE_IN); |
1595 | 0 | TERM_DEBUG_OFF(update, UPDATE_OUT); |
1596 | 0 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); |
1597 | 0 | vty_out(vty, "BGP updates debugging is off\n"); |
1598 | 0 | } |
1599 | 0 | return CMD_SUCCESS; |
1600 | 0 | } |
1601 | | |
1602 | | /* debug bgp zebra */ |
1603 | | DEFUN (debug_bgp_zebra, |
1604 | | debug_bgp_zebra_cmd, |
1605 | | "debug bgp zebra", |
1606 | | DEBUG_STR |
1607 | | BGP_STR |
1608 | | "BGP Zebra messages\n") |
1609 | 0 | { |
1610 | 0 | if (vty->node == CONFIG_NODE) |
1611 | 0 | DEBUG_ON(zebra, ZEBRA); |
1612 | 0 | else { |
1613 | 0 | TERM_DEBUG_ON(zebra, ZEBRA); |
1614 | 0 | vty_out(vty, "BGP zebra debugging is on\n"); |
1615 | 0 | } |
1616 | 0 | return CMD_SUCCESS; |
1617 | 0 | } |
1618 | | |
1619 | | DEFUN (debug_bgp_graceful_restart, |
1620 | | debug_bgp_graceful_restart_cmd, |
1621 | | "debug bgp graceful-restart", |
1622 | | DEBUG_STR |
1623 | | BGP_STR |
1624 | | GR_DEBUG) |
1625 | 0 | { |
1626 | 0 | if (vty->node == CONFIG_NODE) { |
1627 | 0 | DEBUG_ON(graceful_restart, GRACEFUL_RESTART); |
1628 | 0 | } else { |
1629 | 0 | TERM_DEBUG_ON(graceful_restart, GRACEFUL_RESTART); |
1630 | 0 | vty_out(vty, "BGP Graceful Restart debugging is on\n"); |
1631 | 0 | } |
1632 | 0 | return CMD_SUCCESS; |
1633 | 0 | } |
1634 | | |
1635 | | |
1636 | | DEFPY (debug_bgp_zebra_prefix, |
1637 | | debug_bgp_zebra_prefix_cmd, |
1638 | | "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>$prefix", |
1639 | | DEBUG_STR |
1640 | | BGP_STR |
1641 | | "BGP Zebra messages\n" |
1642 | | "Specify a prefix to debug\n" |
1643 | | "IPv4 prefix\n" |
1644 | | "IPv6 prefix\n") |
1645 | 0 | { |
1646 | 0 | if (!bgp_debug_zebra_prefixes) |
1647 | 0 | bgp_debug_zebra_prefixes = list_new(); |
1648 | |
|
1649 | 0 | if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, prefix)) { |
1650 | 0 | vty_out(vty, "BGP zebra debugging is already enabled for %s\n", |
1651 | 0 | prefix_str); |
1652 | 0 | return CMD_SUCCESS; |
1653 | 0 | } |
1654 | | |
1655 | 0 | bgp_debug_list_add_entry(bgp_debug_zebra_prefixes, NULL, prefix); |
1656 | |
|
1657 | 0 | if (vty->node == CONFIG_NODE) |
1658 | 0 | DEBUG_ON(zebra, ZEBRA); |
1659 | 0 | else { |
1660 | 0 | TERM_DEBUG_ON(zebra, ZEBRA); |
1661 | 0 | vty_out(vty, "BGP zebra debugging is on for %s\n", prefix_str); |
1662 | 0 | } |
1663 | |
|
1664 | 0 | return CMD_SUCCESS; |
1665 | 0 | } |
1666 | | |
1667 | | DEFUN (no_debug_bgp_zebra, |
1668 | | no_debug_bgp_zebra_cmd, |
1669 | | "no debug bgp zebra", |
1670 | | NO_STR |
1671 | | DEBUG_STR |
1672 | | BGP_STR |
1673 | | "BGP Zebra messages\n") |
1674 | 0 | { |
1675 | 0 | bgp_debug_list_free(bgp_debug_zebra_prefixes); |
1676 | |
|
1677 | 0 | if (vty->node == CONFIG_NODE) |
1678 | 0 | DEBUG_OFF(zebra, ZEBRA); |
1679 | 0 | else { |
1680 | 0 | TERM_DEBUG_OFF(zebra, ZEBRA); |
1681 | 0 | vty_out(vty, "BGP zebra debugging is off\n"); |
1682 | 0 | } |
1683 | 0 | return CMD_SUCCESS; |
1684 | 0 | } |
1685 | | |
1686 | | DEFUN (no_debug_bgp_graceful_restart, |
1687 | | no_debug_bgp_graceful_restart_cmd, |
1688 | | "no debug bgp graceful-restart", |
1689 | | DEBUG_STR |
1690 | | BGP_STR |
1691 | | GR_DEBUG |
1692 | | NO_STR) |
1693 | 0 | { |
1694 | 0 | if (vty->node == CONFIG_NODE) { |
1695 | 0 | DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); |
1696 | 0 | } else { |
1697 | 0 | TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); |
1698 | 0 | vty_out(vty, "BGP Graceful Restart debugging is off\n"); |
1699 | 0 | } |
1700 | 0 | return CMD_SUCCESS; |
1701 | 0 | } |
1702 | | |
1703 | | DEFPY (no_debug_bgp_zebra_prefix, |
1704 | | no_debug_bgp_zebra_prefix_cmd, |
1705 | | "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>$prefix", |
1706 | | NO_STR |
1707 | | DEBUG_STR |
1708 | | BGP_STR |
1709 | | "BGP Zebra messages\n" |
1710 | | "Specify a prefix to debug\n" |
1711 | | "IPv4 prefix\n" |
1712 | | "IPv6 prefix\n") |
1713 | 0 | { |
1714 | 0 | bool found_prefix = false; |
1715 | |
|
1716 | 0 | if (bgp_debug_zebra_prefixes |
1717 | 0 | && !list_isempty(bgp_debug_zebra_prefixes)) { |
1718 | 0 | found_prefix = bgp_debug_list_remove_entry( |
1719 | 0 | bgp_debug_zebra_prefixes, NULL, prefix); |
1720 | |
|
1721 | 0 | if (list_isempty(bgp_debug_zebra_prefixes)) { |
1722 | 0 | if (vty->node == CONFIG_NODE) |
1723 | 0 | DEBUG_OFF(zebra, ZEBRA); |
1724 | 0 | else { |
1725 | 0 | TERM_DEBUG_OFF(zebra, ZEBRA); |
1726 | 0 | vty_out(vty, "BGP zebra debugging is off\n"); |
1727 | 0 | } |
1728 | 0 | } |
1729 | 0 | } |
1730 | |
|
1731 | 0 | if (found_prefix) |
1732 | 0 | vty_out(vty, "BGP zebra debugging is off for %s\n", prefix_str); |
1733 | 0 | else |
1734 | 0 | vty_out(vty, "BGP zebra debugging was not enabled for %s\n", |
1735 | 0 | prefix_str); |
1736 | |
|
1737 | 0 | return CMD_SUCCESS; |
1738 | 0 | } |
1739 | | |
1740 | | /* debug bgp update-groups */ |
1741 | | DEFUN (debug_bgp_update_groups, |
1742 | | debug_bgp_update_groups_cmd, |
1743 | | "debug bgp update-groups", |
1744 | | DEBUG_STR |
1745 | | BGP_STR |
1746 | | "BGP update-groups\n") |
1747 | 0 | { |
1748 | 0 | if (vty->node == CONFIG_NODE) |
1749 | 0 | DEBUG_ON(update_groups, UPDATE_GROUPS); |
1750 | 0 | else { |
1751 | 0 | TERM_DEBUG_ON(update_groups, UPDATE_GROUPS); |
1752 | 0 | vty_out(vty, "BGP update-groups debugging is on\n"); |
1753 | 0 | } |
1754 | 0 | return CMD_SUCCESS; |
1755 | 0 | } |
1756 | | |
1757 | | DEFUN (no_debug_bgp_update_groups, |
1758 | | no_debug_bgp_update_groups_cmd, |
1759 | | "no debug bgp update-groups", |
1760 | | NO_STR |
1761 | | DEBUG_STR |
1762 | | BGP_STR |
1763 | | "BGP update-groups\n") |
1764 | 0 | { |
1765 | 0 | if (vty->node == CONFIG_NODE) |
1766 | 0 | DEBUG_OFF(update_groups, UPDATE_GROUPS); |
1767 | 0 | else { |
1768 | 0 | TERM_DEBUG_OFF(update_groups, UPDATE_GROUPS); |
1769 | 0 | vty_out(vty, "BGP update-groups debugging is off\n"); |
1770 | 0 | } |
1771 | 0 | return CMD_SUCCESS; |
1772 | 0 | } |
1773 | | |
1774 | | DEFUN (debug_bgp_vpn, |
1775 | | debug_bgp_vpn_cmd, |
1776 | | "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>", |
1777 | | DEBUG_STR |
1778 | | BGP_STR |
1779 | | "VPN routes\n" |
1780 | | "leaked from vrf to vpn\n" |
1781 | | "leaked to vrf from vpn\n" |
1782 | | "route-map updates\n" |
1783 | | "labels\n") |
1784 | 0 | { |
1785 | 0 | int idx = 3; |
1786 | |
|
1787 | 0 | if (argv_find(argv, argc, "leak-from-vrf", &idx)) { |
1788 | 0 | if (vty->node == CONFIG_NODE) |
1789 | 0 | DEBUG_ON(vpn, VPN_LEAK_FROM_VRF); |
1790 | 0 | else |
1791 | 0 | TERM_DEBUG_ON(vpn, VPN_LEAK_FROM_VRF); |
1792 | 0 | } else if (argv_find(argv, argc, "leak-to-vrf", &idx)) { |
1793 | 0 | if (vty->node == CONFIG_NODE) |
1794 | 0 | DEBUG_ON(vpn, VPN_LEAK_TO_VRF); |
1795 | 0 | else |
1796 | 0 | TERM_DEBUG_ON(vpn, VPN_LEAK_TO_VRF); |
1797 | 0 | } else if (argv_find(argv, argc, "rmap-event", &idx)) { |
1798 | 0 | if (vty->node == CONFIG_NODE) |
1799 | 0 | DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT); |
1800 | 0 | else |
1801 | 0 | TERM_DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT); |
1802 | 0 | } else if (argv_find(argv, argc, "label", &idx)) { |
1803 | 0 | if (vty->node == CONFIG_NODE) |
1804 | 0 | DEBUG_ON(vpn, VPN_LEAK_LABEL); |
1805 | 0 | else |
1806 | 0 | TERM_DEBUG_ON(vpn, VPN_LEAK_LABEL); |
1807 | 0 | } else { |
1808 | 0 | vty_out(vty, "%% unknown debug bgp vpn keyword\n"); |
1809 | 0 | return CMD_WARNING_CONFIG_FAILED; |
1810 | 0 | } |
1811 | | |
1812 | 0 | if (vty->node != CONFIG_NODE) |
1813 | 0 | vty_out(vty, "enabled debug bgp vpn %s\n", argv[idx]->text); |
1814 | |
|
1815 | 0 | return CMD_SUCCESS; |
1816 | 0 | } |
1817 | | |
1818 | | DEFUN (no_debug_bgp_vpn, |
1819 | | no_debug_bgp_vpn_cmd, |
1820 | | "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>", |
1821 | | NO_STR |
1822 | | DEBUG_STR |
1823 | | BGP_STR |
1824 | | "VPN routes\n" |
1825 | | "leaked from vrf to vpn\n" |
1826 | | "leaked to vrf from vpn\n" |
1827 | | "route-map updates\n" |
1828 | | "labels\n") |
1829 | 0 | { |
1830 | 0 | int idx = 4; |
1831 | |
|
1832 | 0 | if (argv_find(argv, argc, "leak-from-vrf", &idx)) { |
1833 | 0 | if (vty->node == CONFIG_NODE) |
1834 | 0 | DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); |
1835 | 0 | else |
1836 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); |
1837 | |
|
1838 | 0 | } else if (argv_find(argv, argc, "leak-to-vrf", &idx)) { |
1839 | 0 | if (vty->node == CONFIG_NODE) |
1840 | 0 | DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); |
1841 | 0 | else |
1842 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); |
1843 | 0 | } else if (argv_find(argv, argc, "rmap-event", &idx)) { |
1844 | 0 | if (vty->node == CONFIG_NODE) |
1845 | 0 | DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); |
1846 | 0 | else |
1847 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); |
1848 | 0 | } else if (argv_find(argv, argc, "label", &idx)) { |
1849 | 0 | if (vty->node == CONFIG_NODE) |
1850 | 0 | DEBUG_OFF(vpn, VPN_LEAK_LABEL); |
1851 | 0 | else |
1852 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL); |
1853 | 0 | } else { |
1854 | 0 | vty_out(vty, "%% unknown debug bgp vpn keyword\n"); |
1855 | 0 | return CMD_WARNING_CONFIG_FAILED; |
1856 | 0 | } |
1857 | | |
1858 | 0 | if (vty->node != CONFIG_NODE) |
1859 | 0 | vty_out(vty, "disabled debug bgp vpn %s\n", argv[idx]->text); |
1860 | 0 | return CMD_SUCCESS; |
1861 | 0 | } |
1862 | | |
1863 | | /* debug bgp pbr */ |
1864 | | DEFUN (debug_bgp_pbr, |
1865 | | debug_bgp_pbr_cmd, |
1866 | | "debug bgp pbr [error]", |
1867 | | DEBUG_STR |
1868 | | BGP_STR |
1869 | | "BGP policy based routing\n" |
1870 | | "BGP PBR error\n") |
1871 | 0 | { |
1872 | 0 | int idx = 3; |
1873 | |
|
1874 | 0 | if (argv_find(argv, argc, "error", &idx)) { |
1875 | 0 | if (vty->node == CONFIG_NODE) |
1876 | 0 | DEBUG_ON(pbr, PBR_ERROR); |
1877 | 0 | else { |
1878 | 0 | TERM_DEBUG_ON(pbr, PBR_ERROR); |
1879 | 0 | vty_out(vty, "BGP policy based routing error is on\n"); |
1880 | 0 | } |
1881 | 0 | return CMD_SUCCESS; |
1882 | 0 | } |
1883 | 0 | if (vty->node == CONFIG_NODE) |
1884 | 0 | DEBUG_ON(pbr, PBR); |
1885 | 0 | else { |
1886 | 0 | TERM_DEBUG_ON(pbr, PBR); |
1887 | 0 | vty_out(vty, "BGP policy based routing is on\n"); |
1888 | 0 | } |
1889 | 0 | return CMD_SUCCESS; |
1890 | 0 | } |
1891 | | |
1892 | | DEFUN (no_debug_bgp_pbr, |
1893 | | no_debug_bgp_pbr_cmd, |
1894 | | "no debug bgp pbr [error]", |
1895 | | NO_STR |
1896 | | DEBUG_STR |
1897 | | BGP_STR |
1898 | | "BGP policy based routing\n" |
1899 | | "BGP PBR Error\n") |
1900 | 0 | { |
1901 | 0 | int idx = 3; |
1902 | |
|
1903 | 0 | if (argv_find(argv, argc, "error", &idx)) { |
1904 | 0 | if (vty->node == CONFIG_NODE) |
1905 | 0 | DEBUG_OFF(pbr, PBR_ERROR); |
1906 | 0 | else { |
1907 | 0 | TERM_DEBUG_OFF(pbr, PBR_ERROR); |
1908 | 0 | vty_out(vty, "BGP policy based routing error is off\n"); |
1909 | 0 | } |
1910 | 0 | return CMD_SUCCESS; |
1911 | 0 | } |
1912 | 0 | if (vty->node == CONFIG_NODE) |
1913 | 0 | DEBUG_OFF(pbr, PBR); |
1914 | 0 | else { |
1915 | 0 | TERM_DEBUG_OFF(pbr, PBR); |
1916 | 0 | vty_out(vty, "BGP policy based routing is off\n"); |
1917 | 0 | } |
1918 | 0 | return CMD_SUCCESS; |
1919 | 0 | } |
1920 | | |
1921 | | DEFPY (debug_bgp_evpn_mh, |
1922 | | debug_bgp_evpn_mh_cmd, |
1923 | | "[no$no] debug bgp evpn mh <es$es|route$rt>", |
1924 | | NO_STR |
1925 | | DEBUG_STR |
1926 | | BGP_STR |
1927 | | "EVPN\n" |
1928 | | "Multihoming\n" |
1929 | | "Ethernet Segment debugging\n" |
1930 | | "Route debugging\n") |
1931 | 0 | { |
1932 | 0 | if (es) { |
1933 | 0 | if (vty->node == CONFIG_NODE) { |
1934 | 0 | if (no) |
1935 | 0 | DEBUG_OFF(evpn_mh, EVPN_MH_ES); |
1936 | 0 | else |
1937 | 0 | DEBUG_ON(evpn_mh, EVPN_MH_ES); |
1938 | 0 | } else { |
1939 | 0 | if (no) { |
1940 | 0 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES); |
1941 | 0 | vty_out(vty, |
1942 | 0 | "BGP EVPN-MH ES debugging is off\n"); |
1943 | 0 | } else { |
1944 | 0 | TERM_DEBUG_ON(evpn_mh, EVPN_MH_ES); |
1945 | 0 | vty_out(vty, |
1946 | 0 | "BGP EVPN-MH ES debugging is on\n"); |
1947 | 0 | } |
1948 | 0 | } |
1949 | 0 | } |
1950 | 0 | if (rt) { |
1951 | 0 | if (vty->node == CONFIG_NODE) { |
1952 | 0 | if (no) |
1953 | 0 | DEBUG_OFF(evpn_mh, EVPN_MH_RT); |
1954 | 0 | else |
1955 | 0 | DEBUG_ON(evpn_mh, EVPN_MH_RT); |
1956 | 0 | } else { |
1957 | 0 | if (no) { |
1958 | 0 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT); |
1959 | 0 | vty_out(vty, |
1960 | 0 | "BGP EVPN-MH route debugging is off\n"); |
1961 | 0 | } else { |
1962 | 0 | TERM_DEBUG_ON(evpn_mh, EVPN_MH_RT); |
1963 | 0 | vty_out(vty, |
1964 | 0 | "BGP EVPN-MH route debugging is on\n"); |
1965 | 0 | } |
1966 | 0 | } |
1967 | 0 | } |
1968 | |
|
1969 | 0 | return CMD_SUCCESS; |
1970 | 0 | } |
1971 | | |
1972 | | DEFUN (debug_bgp_labelpool, |
1973 | | debug_bgp_labelpool_cmd, |
1974 | | "debug bgp labelpool", |
1975 | | DEBUG_STR |
1976 | | BGP_STR |
1977 | | "label pool\n") |
1978 | 0 | { |
1979 | 0 | if (vty->node == CONFIG_NODE) |
1980 | 0 | DEBUG_ON(labelpool, LABELPOOL); |
1981 | 0 | else |
1982 | 0 | TERM_DEBUG_ON(labelpool, LABELPOOL); |
1983 | |
|
1984 | 0 | if (vty->node != CONFIG_NODE) |
1985 | 0 | vty_out(vty, "enabled debug bgp labelpool\n"); |
1986 | |
|
1987 | 0 | return CMD_SUCCESS; |
1988 | 0 | } |
1989 | | |
1990 | | DEFUN (no_debug_bgp_labelpool, |
1991 | | no_debug_bgp_labelpool_cmd, |
1992 | | "no debug bgp labelpool", |
1993 | | NO_STR |
1994 | | DEBUG_STR |
1995 | | BGP_STR |
1996 | | "label pool\n") |
1997 | 0 | { |
1998 | 0 | if (vty->node == CONFIG_NODE) |
1999 | 0 | DEBUG_OFF(labelpool, LABELPOOL); |
2000 | 0 | else |
2001 | 0 | TERM_DEBUG_OFF(labelpool, LABELPOOL); |
2002 | | |
2003 | |
|
2004 | 0 | if (vty->node != CONFIG_NODE) |
2005 | 0 | vty_out(vty, "disabled debug bgp labelpool\n"); |
2006 | |
|
2007 | 0 | return CMD_SUCCESS; |
2008 | 0 | } |
2009 | | |
2010 | | DEFPY(debug_bgp_bfd, debug_bgp_bfd_cmd, |
2011 | | "[no] debug bgp bfd", |
2012 | | NO_STR |
2013 | | DEBUG_STR |
2014 | | BGP_STR |
2015 | | "Bidirection Forwarding Detection\n") |
2016 | 0 | { |
2017 | 0 | if (vty->node == CONFIG_NODE) { |
2018 | 0 | if (no) { |
2019 | 0 | DEBUG_OFF(bfd, BFD_LIB); |
2020 | 0 | bfd_protocol_integration_set_debug(false); |
2021 | 0 | } else { |
2022 | 0 | DEBUG_ON(bfd, BFD_LIB); |
2023 | 0 | bfd_protocol_integration_set_debug(true); |
2024 | 0 | } |
2025 | 0 | } else { |
2026 | 0 | if (no) { |
2027 | 0 | TERM_DEBUG_OFF(bfd, BFD_LIB); |
2028 | 0 | bfd_protocol_integration_set_debug(false); |
2029 | 0 | } else { |
2030 | 0 | TERM_DEBUG_ON(bfd, BFD_LIB); |
2031 | 0 | bfd_protocol_integration_set_debug(true); |
2032 | 0 | } |
2033 | 0 | } |
2034 | |
|
2035 | 0 | return CMD_SUCCESS; |
2036 | 0 | } |
2037 | | |
2038 | | DEFPY (debug_bgp_cond_adv, |
2039 | | debug_bgp_cond_adv_cmd, |
2040 | | "[no$no] debug bgp conditional-advertisement", |
2041 | | NO_STR |
2042 | | DEBUG_STR |
2043 | | BGP_STR |
2044 | | "BGP conditional advertisement\n") |
2045 | 0 | { |
2046 | 0 | if (vty->node == CONFIG_NODE) { |
2047 | 0 | if (no) |
2048 | 0 | DEBUG_OFF(cond_adv, COND_ADV); |
2049 | 0 | else |
2050 | 0 | DEBUG_ON(cond_adv, COND_ADV); |
2051 | 0 | } else { |
2052 | 0 | if (no) { |
2053 | 0 | TERM_DEBUG_OFF(cond_adv, COND_ADV); |
2054 | 0 | vty_out(vty, |
2055 | 0 | "BGP conditional advertisement debugging is off\n"); |
2056 | 0 | } else { |
2057 | 0 | TERM_DEBUG_ON(cond_adv, COND_ADV); |
2058 | 0 | vty_out(vty, |
2059 | 0 | "BGP conditional advertisement debugging is on\n"); |
2060 | 0 | } |
2061 | 0 | } |
2062 | 0 | return CMD_SUCCESS; |
2063 | 0 | } |
2064 | | |
2065 | | DEFUN (no_debug_bgp, |
2066 | | no_debug_bgp_cmd, |
2067 | | "no debug bgp", |
2068 | | NO_STR |
2069 | | DEBUG_STR |
2070 | | BGP_STR) |
2071 | 0 | { |
2072 | 0 | struct bgp *bgp; |
2073 | 0 | struct listnode *ln; |
2074 | |
|
2075 | 0 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
2076 | 0 | bgp_debug_list_free(bgp_debug_keepalive_peers); |
2077 | 0 | bgp_debug_list_free(bgp_debug_update_in_peers); |
2078 | 0 | bgp_debug_list_free(bgp_debug_update_out_peers); |
2079 | 0 | bgp_debug_list_free(bgp_debug_update_prefixes); |
2080 | 0 | bgp_debug_list_free(bgp_debug_bestpath_prefixes); |
2081 | 0 | bgp_debug_list_free(bgp_debug_zebra_prefixes); |
2082 | |
|
2083 | 0 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, ln, bgp)) |
2084 | 0 | bgp_debug_clear_updgrp_update_dbg(bgp); |
2085 | |
|
2086 | 0 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); |
2087 | 0 | TERM_DEBUG_OFF(update, UPDATE_IN); |
2088 | 0 | TERM_DEBUG_OFF(update, UPDATE_OUT); |
2089 | 0 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); |
2090 | 0 | TERM_DEBUG_OFF(bestpath, BESTPATH); |
2091 | 0 | TERM_DEBUG_OFF(as4, AS4); |
2092 | 0 | TERM_DEBUG_OFF(as4, AS4_SEGMENT); |
2093 | 0 | TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); |
2094 | 0 | TERM_DEBUG_OFF(zebra, ZEBRA); |
2095 | 0 | TERM_DEBUG_OFF(allow_martians, ALLOW_MARTIANS); |
2096 | 0 | TERM_DEBUG_OFF(nht, NHT); |
2097 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); |
2098 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); |
2099 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); |
2100 | 0 | TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL); |
2101 | 0 | TERM_DEBUG_OFF(flowspec, FLOWSPEC); |
2102 | 0 | TERM_DEBUG_OFF(labelpool, LABELPOOL); |
2103 | 0 | TERM_DEBUG_OFF(pbr, PBR); |
2104 | 0 | TERM_DEBUG_OFF(pbr, PBR_ERROR); |
2105 | 0 | TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); |
2106 | 0 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES); |
2107 | 0 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT); |
2108 | 0 | TERM_DEBUG_OFF(bfd, BFD_LIB); |
2109 | 0 | TERM_DEBUG_OFF(cond_adv, COND_ADV); |
2110 | |
|
2111 | 0 | vty_out(vty, "All possible debugging has been turned off\n"); |
2112 | |
|
2113 | 0 | return CMD_SUCCESS; |
2114 | 0 | } |
2115 | | |
2116 | | DEFUN_NOSH (show_debugging_bgp, |
2117 | | show_debugging_bgp_cmd, |
2118 | | "show debugging [bgp]", |
2119 | | SHOW_STR |
2120 | | DEBUG_STR |
2121 | | BGP_STR) |
2122 | 0 | { |
2123 | 0 | vty_out(vty, "BGP debugging status:\n"); |
2124 | |
|
2125 | 0 | if (BGP_DEBUG(as4, AS4)) |
2126 | 0 | vty_out(vty, " BGP as4 debugging is on\n"); |
2127 | |
|
2128 | 0 | if (BGP_DEBUG(as4, AS4_SEGMENT)) |
2129 | 0 | vty_out(vty, " BGP as4 aspath segment debugging is on\n"); |
2130 | |
|
2131 | 0 | if (BGP_DEBUG(bestpath, BESTPATH)) |
2132 | 0 | bgp_debug_list_print(vty, " BGP bestpath debugging is on", |
2133 | 0 | bgp_debug_bestpath_prefixes); |
2134 | |
|
2135 | 0 | if (BGP_DEBUG(keepalive, KEEPALIVE)) |
2136 | 0 | bgp_debug_list_print(vty, " BGP keepalives debugging is on", |
2137 | 0 | bgp_debug_keepalive_peers); |
2138 | |
|
2139 | 0 | if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS)) |
2140 | 0 | bgp_debug_list_print(vty, |
2141 | 0 | " BGP neighbor-events debugging is on", |
2142 | 0 | bgp_debug_neighbor_events_peers); |
2143 | |
|
2144 | 0 | if (BGP_DEBUG(nht, NHT)) |
2145 | 0 | vty_out(vty, " BGP next-hop tracking debugging is on\n"); |
2146 | |
|
2147 | 0 | if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) |
2148 | 0 | vty_out(vty, " BGP update-groups debugging is on\n"); |
2149 | |
|
2150 | 0 | if (BGP_DEBUG(update, UPDATE_PREFIX)) |
2151 | 0 | bgp_debug_list_print(vty, " BGP updates debugging is on", |
2152 | 0 | bgp_debug_update_prefixes); |
2153 | |
|
2154 | 0 | if (BGP_DEBUG(update, UPDATE_IN)) |
2155 | 0 | bgp_debug_list_print(vty, |
2156 | 0 | " BGP updates debugging is on (inbound)", |
2157 | 0 | bgp_debug_update_in_peers); |
2158 | |
|
2159 | 0 | if (BGP_DEBUG(update, UPDATE_OUT)) |
2160 | 0 | bgp_debug_list_print(vty, |
2161 | 0 | " BGP updates debugging is on (outbound)", |
2162 | 0 | bgp_debug_update_out_peers); |
2163 | |
|
2164 | 0 | if (BGP_DEBUG(zebra, ZEBRA)) |
2165 | 0 | bgp_debug_list_print(vty, " BGP zebra debugging is on", |
2166 | 0 | bgp_debug_zebra_prefixes); |
2167 | |
|
2168 | 0 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2169 | 0 | vty_out(vty, " BGP graceful-restart debugging is on\n"); |
2170 | |
|
2171 | 0 | if (BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) |
2172 | 0 | vty_out(vty, " BGP allow martian next hop debugging is on\n"); |
2173 | |
|
2174 | 0 | if (BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)) |
2175 | 0 | vty_out(vty, |
2176 | 0 | " BGP route leak from vrf to vpn debugging is on\n"); |
2177 | 0 | if (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF)) |
2178 | 0 | vty_out(vty, |
2179 | 0 | " BGP route leak to vrf from vpn debugging is on\n"); |
2180 | 0 | if (BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT)) |
2181 | 0 | vty_out(vty, " BGP vpn route-map event debugging is on\n"); |
2182 | 0 | if (BGP_DEBUG(vpn, VPN_LEAK_LABEL)) |
2183 | 0 | vty_out(vty, " BGP vpn label event debugging is on\n"); |
2184 | 0 | if (BGP_DEBUG(flowspec, FLOWSPEC)) |
2185 | 0 | vty_out(vty, " BGP flowspec debugging is on\n"); |
2186 | 0 | if (BGP_DEBUG(labelpool, LABELPOOL)) |
2187 | 0 | vty_out(vty, " BGP labelpool debugging is on\n"); |
2188 | |
|
2189 | 0 | if (BGP_DEBUG(pbr, PBR)) |
2190 | 0 | vty_out(vty, " BGP policy based routing debugging is on\n"); |
2191 | 0 | if (BGP_DEBUG(pbr, PBR_ERROR)) |
2192 | 0 | vty_out(vty, " BGP policy based routing error debugging is on\n"); |
2193 | |
|
2194 | 0 | if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) |
2195 | 0 | vty_out(vty, " BGP EVPN-MH ES debugging is on\n"); |
2196 | 0 | if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) |
2197 | 0 | vty_out(vty, " BGP EVPN-MH route debugging is on\n"); |
2198 | |
|
2199 | 0 | if (BGP_DEBUG(bfd, BFD_LIB)) |
2200 | 0 | vty_out(vty, " BGP BFD library debugging is on\n"); |
2201 | |
|
2202 | 0 | if (BGP_DEBUG(cond_adv, COND_ADV)) |
2203 | 0 | vty_out(vty, |
2204 | 0 | " BGP conditional advertisement debugging is on\n"); |
2205 | |
|
2206 | 0 | cmd_show_lib_debugs(vty); |
2207 | |
|
2208 | 0 | return CMD_SUCCESS; |
2209 | 0 | } |
2210 | | |
2211 | | static int bgp_config_write_debug(struct vty *vty) |
2212 | 0 | { |
2213 | 0 | int write = 0; |
2214 | |
|
2215 | 0 | if (CONF_BGP_DEBUG(as4, AS4)) { |
2216 | 0 | vty_out(vty, "debug bgp as4\n"); |
2217 | 0 | write++; |
2218 | 0 | } |
2219 | |
|
2220 | 0 | if (CONF_BGP_DEBUG(as4, AS4_SEGMENT)) { |
2221 | 0 | vty_out(vty, "debug bgp as4 segment\n"); |
2222 | 0 | write++; |
2223 | 0 | } |
2224 | |
|
2225 | 0 | if (CONF_BGP_DEBUG(bestpath, BESTPATH)) { |
2226 | 0 | write += bgp_debug_list_conf_print(vty, "debug bgp bestpath", |
2227 | 0 | bgp_debug_bestpath_prefixes); |
2228 | 0 | } |
2229 | |
|
2230 | 0 | if (CONF_BGP_DEBUG(keepalive, KEEPALIVE)) { |
2231 | 0 | write += bgp_debug_list_conf_print(vty, "debug bgp keepalives", |
2232 | 0 | bgp_debug_keepalive_peers); |
2233 | 0 | } |
2234 | |
|
2235 | 0 | if (CONF_BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS)) { |
2236 | 0 | write += bgp_debug_list_conf_print( |
2237 | 0 | vty, "debug bgp neighbor-events", |
2238 | 0 | bgp_debug_neighbor_events_peers); |
2239 | 0 | } |
2240 | |
|
2241 | 0 | if (CONF_BGP_DEBUG(nht, NHT)) { |
2242 | 0 | vty_out(vty, "debug bgp nht\n"); |
2243 | 0 | write++; |
2244 | 0 | } |
2245 | |
|
2246 | 0 | if (CONF_BGP_DEBUG(update_groups, UPDATE_GROUPS)) { |
2247 | 0 | vty_out(vty, "debug bgp update-groups\n"); |
2248 | 0 | write++; |
2249 | 0 | } |
2250 | |
|
2251 | 0 | if (CONF_BGP_DEBUG(update, UPDATE_PREFIX)) { |
2252 | 0 | write += bgp_debug_list_conf_print(vty, |
2253 | 0 | "debug bgp updates prefix", |
2254 | 0 | bgp_debug_update_prefixes); |
2255 | 0 | } |
2256 | |
|
2257 | 0 | if (CONF_BGP_DEBUG(update, UPDATE_IN)) { |
2258 | 0 | write += bgp_debug_list_conf_print(vty, "debug bgp updates in", |
2259 | 0 | bgp_debug_update_in_peers); |
2260 | 0 | } |
2261 | |
|
2262 | 0 | if (CONF_BGP_DEBUG(update, UPDATE_OUT)) { |
2263 | 0 | write += bgp_debug_list_conf_print(vty, "debug bgp updates out", |
2264 | 0 | bgp_debug_update_out_peers); |
2265 | 0 | } |
2266 | |
|
2267 | 0 | if (CONF_BGP_DEBUG(zebra, ZEBRA)) { |
2268 | 0 | if (!bgp_debug_zebra_prefixes |
2269 | 0 | || list_isempty(bgp_debug_zebra_prefixes)) { |
2270 | 0 | vty_out(vty, "debug bgp zebra\n"); |
2271 | 0 | write++; |
2272 | 0 | } else { |
2273 | 0 | write += bgp_debug_list_conf_print( |
2274 | 0 | vty, "debug bgp zebra prefix", |
2275 | 0 | bgp_debug_zebra_prefixes); |
2276 | 0 | } |
2277 | 0 | } |
2278 | |
|
2279 | 0 | if (CONF_BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) { |
2280 | 0 | vty_out(vty, "debug bgp allow-martians\n"); |
2281 | 0 | write++; |
2282 | 0 | } |
2283 | |
|
2284 | 0 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)) { |
2285 | 0 | vty_out(vty, "debug bgp vpn leak-from-vrf\n"); |
2286 | 0 | write++; |
2287 | 0 | } |
2288 | 0 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_TO_VRF)) { |
2289 | 0 | vty_out(vty, "debug bgp vpn leak-to-vrf\n"); |
2290 | 0 | write++; |
2291 | 0 | } |
2292 | 0 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT)) { |
2293 | 0 | vty_out(vty, "debug bgp vpn rmap-event\n"); |
2294 | 0 | write++; |
2295 | 0 | } |
2296 | 0 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_LABEL)) { |
2297 | 0 | vty_out(vty, "debug bgp vpn label\n"); |
2298 | 0 | write++; |
2299 | 0 | } |
2300 | 0 | if (CONF_BGP_DEBUG(flowspec, FLOWSPEC)) { |
2301 | 0 | vty_out(vty, "debug bgp flowspec\n"); |
2302 | 0 | write++; |
2303 | 0 | } |
2304 | 0 | if (CONF_BGP_DEBUG(labelpool, LABELPOOL)) { |
2305 | 0 | vty_out(vty, "debug bgp labelpool\n"); |
2306 | 0 | write++; |
2307 | 0 | } |
2308 | |
|
2309 | 0 | if (CONF_BGP_DEBUG(pbr, PBR)) { |
2310 | 0 | vty_out(vty, "debug bgp pbr\n"); |
2311 | 0 | write++; |
2312 | 0 | } |
2313 | 0 | if (CONF_BGP_DEBUG(pbr, PBR_ERROR)) { |
2314 | 0 | vty_out(vty, "debug bgp pbr error\n"); |
2315 | 0 | write++; |
2316 | 0 | } |
2317 | |
|
2318 | 0 | if (CONF_BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) { |
2319 | 0 | vty_out(vty, "debug bgp graceful-restart\n"); |
2320 | 0 | write++; |
2321 | 0 | } |
2322 | |
|
2323 | 0 | if (CONF_BGP_DEBUG(evpn_mh, EVPN_MH_ES)) { |
2324 | 0 | vty_out(vty, "debug bgp evpn mh es\n"); |
2325 | 0 | write++; |
2326 | 0 | } |
2327 | 0 | if (CONF_BGP_DEBUG(evpn_mh, EVPN_MH_RT)) { |
2328 | 0 | vty_out(vty, "debug bgp evpn mh route\n"); |
2329 | 0 | write++; |
2330 | 0 | } |
2331 | |
|
2332 | 0 | if (CONF_BGP_DEBUG(bfd, BFD_LIB)) { |
2333 | 0 | vty_out(vty, "debug bgp bfd\n"); |
2334 | 0 | write++; |
2335 | 0 | } |
2336 | |
|
2337 | 0 | if (CONF_BGP_DEBUG(cond_adv, COND_ADV)) { |
2338 | 0 | vty_out(vty, "debug bgp conditional-advertisement\n"); |
2339 | 0 | write++; |
2340 | 0 | } |
2341 | |
|
2342 | 0 | return write; |
2343 | 0 | } |
2344 | | |
2345 | | static int bgp_config_write_debug(struct vty *vty); |
2346 | | static struct cmd_node debug_node = { |
2347 | | .name = "debug", |
2348 | | .node = DEBUG_NODE, |
2349 | | .prompt = "", |
2350 | | .config_write = bgp_config_write_debug, |
2351 | | }; |
2352 | | |
2353 | | void bgp_debug_init(void) |
2354 | 0 | { |
2355 | 0 | install_node(&debug_node); |
2356 | |
|
2357 | 0 | install_element(ENABLE_NODE, &show_debugging_bgp_cmd); |
2358 | |
|
2359 | 0 | install_element(ENABLE_NODE, &debug_bgp_as4_cmd); |
2360 | 0 | install_element(CONFIG_NODE, &debug_bgp_as4_cmd); |
2361 | 0 | install_element(ENABLE_NODE, &debug_bgp_as4_segment_cmd); |
2362 | 0 | install_element(CONFIG_NODE, &debug_bgp_as4_segment_cmd); |
2363 | |
|
2364 | 0 | install_element(ENABLE_NODE, &debug_bgp_neighbor_events_cmd); |
2365 | 0 | install_element(CONFIG_NODE, &debug_bgp_neighbor_events_cmd); |
2366 | 0 | install_element(ENABLE_NODE, &debug_bgp_nht_cmd); |
2367 | 0 | install_element(CONFIG_NODE, &debug_bgp_nht_cmd); |
2368 | 0 | install_element(ENABLE_NODE, &debug_bgp_keepalive_cmd); |
2369 | 0 | install_element(CONFIG_NODE, &debug_bgp_keepalive_cmd); |
2370 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_cmd); |
2371 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_cmd); |
2372 | 0 | install_element(ENABLE_NODE, &debug_bgp_zebra_cmd); |
2373 | 0 | install_element(CONFIG_NODE, &debug_bgp_zebra_cmd); |
2374 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_groups_cmd); |
2375 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_groups_cmd); |
2376 | 0 | install_element(ENABLE_NODE, &debug_bgp_bestpath_prefix_cmd); |
2377 | 0 | install_element(CONFIG_NODE, &debug_bgp_bestpath_prefix_cmd); |
2378 | |
|
2379 | 0 | install_element(ENABLE_NODE, &debug_bgp_graceful_restart_cmd); |
2380 | 0 | install_element(CONFIG_NODE, &debug_bgp_graceful_restart_cmd); |
2381 | | |
2382 | | /* debug bgp updates (in|out) */ |
2383 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_direct_cmd); |
2384 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_direct_cmd); |
2385 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_direct_cmd); |
2386 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_direct_cmd); |
2387 | | |
2388 | | /* debug bgp updates (in|out) A.B.C.D */ |
2389 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_direct_peer_cmd); |
2390 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_direct_peer_cmd); |
2391 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_direct_peer_cmd); |
2392 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_direct_peer_cmd); |
2393 | | |
2394 | | /* debug bgp updates prefix A.B.C.D/M */ |
2395 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_prefix_cmd); |
2396 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_prefix_cmd); |
2397 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_prefix_cmd); |
2398 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_prefix_cmd); |
2399 | 0 | install_element(ENABLE_NODE, &debug_bgp_update_prefix_afi_safi_cmd); |
2400 | 0 | install_element(CONFIG_NODE, &debug_bgp_update_prefix_afi_safi_cmd); |
2401 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_prefix_afi_safi_cmd); |
2402 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_prefix_afi_safi_cmd); |
2403 | | |
2404 | | /* debug bgp zebra prefix A.B.C.D/M */ |
2405 | 0 | install_element(ENABLE_NODE, &debug_bgp_zebra_prefix_cmd); |
2406 | 0 | install_element(CONFIG_NODE, &debug_bgp_zebra_prefix_cmd); |
2407 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_zebra_prefix_cmd); |
2408 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_zebra_prefix_cmd); |
2409 | |
|
2410 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_as4_cmd); |
2411 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_as4_cmd); |
2412 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_as4_segment_cmd); |
2413 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_as4_segment_cmd); |
2414 | | |
2415 | | /* debug bgp neighbor-events A.B.C.D */ |
2416 | 0 | install_element(ENABLE_NODE, &debug_bgp_neighbor_events_peer_cmd); |
2417 | 0 | install_element(CONFIG_NODE, &debug_bgp_neighbor_events_peer_cmd); |
2418 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_neighbor_events_peer_cmd); |
2419 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_neighbor_events_peer_cmd); |
2420 | | |
2421 | | /* debug bgp keepalive A.B.C.D */ |
2422 | 0 | install_element(ENABLE_NODE, &debug_bgp_keepalive_peer_cmd); |
2423 | 0 | install_element(CONFIG_NODE, &debug_bgp_keepalive_peer_cmd); |
2424 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_keepalive_peer_cmd); |
2425 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_keepalive_peer_cmd); |
2426 | |
|
2427 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_neighbor_events_cmd); |
2428 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_neighbor_events_cmd); |
2429 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_nht_cmd); |
2430 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_nht_cmd); |
2431 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_keepalive_cmd); |
2432 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_keepalive_cmd); |
2433 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_cmd); |
2434 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_cmd); |
2435 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_zebra_cmd); |
2436 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_zebra_cmd); |
2437 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_update_groups_cmd); |
2438 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_update_groups_cmd); |
2439 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_cmd); |
2440 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_bestpath_cmd); |
2441 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_bestpath_cmd); |
2442 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_bestpath_prefix_cmd); |
2443 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_bestpath_prefix_cmd); |
2444 | |
|
2445 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_graceful_restart_cmd); |
2446 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_graceful_restart_cmd); |
2447 | |
|
2448 | 0 | install_element(ENABLE_NODE, &debug_bgp_vpn_cmd); |
2449 | 0 | install_element(CONFIG_NODE, &debug_bgp_vpn_cmd); |
2450 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_vpn_cmd); |
2451 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_vpn_cmd); |
2452 | |
|
2453 | 0 | install_element(ENABLE_NODE, &debug_bgp_labelpool_cmd); |
2454 | 0 | install_element(CONFIG_NODE, &debug_bgp_labelpool_cmd); |
2455 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_labelpool_cmd); |
2456 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_labelpool_cmd); |
2457 | | |
2458 | | /* debug bgp pbr */ |
2459 | 0 | install_element(ENABLE_NODE, &debug_bgp_pbr_cmd); |
2460 | 0 | install_element(CONFIG_NODE, &debug_bgp_pbr_cmd); |
2461 | 0 | install_element(ENABLE_NODE, &no_debug_bgp_pbr_cmd); |
2462 | 0 | install_element(CONFIG_NODE, &no_debug_bgp_pbr_cmd); |
2463 | |
|
2464 | 0 | install_element(ENABLE_NODE, &debug_bgp_evpn_mh_cmd); |
2465 | 0 | install_element(CONFIG_NODE, &debug_bgp_evpn_mh_cmd); |
2466 | | |
2467 | | /* debug bgp bfd */ |
2468 | 0 | install_element(ENABLE_NODE, &debug_bgp_bfd_cmd); |
2469 | 0 | install_element(CONFIG_NODE, &debug_bgp_bfd_cmd); |
2470 | | |
2471 | | /* debug bgp conditional advertisement */ |
2472 | 0 | install_element(ENABLE_NODE, &debug_bgp_cond_adv_cmd); |
2473 | 0 | install_element(CONFIG_NODE, &debug_bgp_cond_adv_cmd); |
2474 | 0 | } |
2475 | | |
2476 | | /* Return true if this prefix is on the per_prefix_list of prefixes to debug |
2477 | | * for BGP_DEBUG_TYPE |
2478 | | */ |
2479 | | static int bgp_debug_per_prefix(const struct prefix *p, |
2480 | | unsigned long term_bgp_debug_type, |
2481 | | unsigned int BGP_DEBUG_TYPE, |
2482 | | struct list *per_prefix_list) |
2483 | 0 | { |
2484 | 0 | struct bgp_debug_filter *filter; |
2485 | 0 | struct listnode *node, *nnode; |
2486 | |
|
2487 | 0 | if (term_bgp_debug_type & BGP_DEBUG_TYPE) { |
2488 | | /* We are debugging all prefixes so return true */ |
2489 | 0 | if (!per_prefix_list || list_isempty(per_prefix_list)) |
2490 | 0 | return 1; |
2491 | | |
2492 | 0 | else { |
2493 | 0 | if (!p) |
2494 | 0 | return 0; |
2495 | | |
2496 | 0 | for (ALL_LIST_ELEMENTS(per_prefix_list, node, nnode, |
2497 | 0 | filter)) |
2498 | 0 | if (filter->p->prefixlen == p->prefixlen |
2499 | 0 | && prefix_match(filter->p, p)) |
2500 | 0 | return 1; |
2501 | | |
2502 | 0 | return 0; |
2503 | 0 | } |
2504 | 0 | } |
2505 | | |
2506 | 0 | return 0; |
2507 | 0 | } |
2508 | | |
2509 | | /* Return true if this peer is on the per_peer_list of peers to debug |
2510 | | * for BGP_DEBUG_TYPE |
2511 | | */ |
2512 | | static bool bgp_debug_per_peer(char *host, unsigned long term_bgp_debug_type, |
2513 | | unsigned int BGP_DEBUG_TYPE, |
2514 | | struct list *per_peer_list) |
2515 | 11.6k | { |
2516 | 11.6k | struct bgp_debug_filter *filter; |
2517 | 11.6k | struct listnode *node, *nnode; |
2518 | | |
2519 | 11.6k | if (term_bgp_debug_type & BGP_DEBUG_TYPE) { |
2520 | | /* We are debugging all peers so return true */ |
2521 | 0 | if (!per_peer_list || list_isempty(per_peer_list)) |
2522 | 0 | return true; |
2523 | | |
2524 | 0 | else { |
2525 | 0 | if (!host) |
2526 | 0 | return false; |
2527 | | |
2528 | 0 | for (ALL_LIST_ELEMENTS(per_peer_list, node, nnode, |
2529 | 0 | filter)) |
2530 | 0 | if (strcmp(filter->host, host) == 0) |
2531 | 0 | return true; |
2532 | | |
2533 | 0 | return false; |
2534 | 0 | } |
2535 | 0 | } |
2536 | | |
2537 | 11.6k | return false; |
2538 | 11.6k | } |
2539 | | |
2540 | | bool bgp_debug_neighbor_events(const struct peer *peer) |
2541 | 7.44k | { |
2542 | 7.44k | char *host = NULL; |
2543 | | |
2544 | 7.44k | if (peer) |
2545 | 7.44k | host = peer->host; |
2546 | | |
2547 | 7.44k | return bgp_debug_per_peer(host, term_bgp_debug_neighbor_events, |
2548 | 7.44k | BGP_DEBUG_NEIGHBOR_EVENTS, |
2549 | 7.44k | bgp_debug_neighbor_events_peers); |
2550 | 7.44k | } |
2551 | | |
2552 | | bool bgp_debug_keepalive(const struct peer *peer) |
2553 | 3 | { |
2554 | 3 | char *host = NULL; |
2555 | | |
2556 | 3 | if (peer) |
2557 | 3 | host = peer->host; |
2558 | | |
2559 | 3 | return bgp_debug_per_peer(host, term_bgp_debug_keepalive, |
2560 | 3 | BGP_DEBUG_KEEPALIVE, |
2561 | 3 | bgp_debug_keepalive_peers); |
2562 | 3 | } |
2563 | | |
2564 | | bool bgp_debug_update(const struct peer *peer, const struct prefix *p, |
2565 | | struct update_group *updgrp, unsigned int inbound) |
2566 | 4.23k | { |
2567 | 4.23k | char *host = NULL; |
2568 | | |
2569 | 4.23k | if (peer) |
2570 | 4.23k | host = peer->host; |
2571 | | |
2572 | 4.23k | if (inbound) { |
2573 | 4.22k | if (bgp_debug_per_peer(host, term_bgp_debug_update, |
2574 | 4.22k | BGP_DEBUG_UPDATE_IN, |
2575 | 4.22k | bgp_debug_update_in_peers)) |
2576 | 0 | return true; |
2577 | 4.22k | } |
2578 | | |
2579 | | /* outbound */ |
2580 | 4 | else { |
2581 | 4 | if (bgp_debug_per_peer(host, term_bgp_debug_update, |
2582 | 4 | BGP_DEBUG_UPDATE_OUT, |
2583 | 4 | bgp_debug_update_out_peers)) |
2584 | 0 | return true; |
2585 | | |
2586 | | /* Check if update debugging implicitly enabled for the group. |
2587 | | */ |
2588 | 4 | if (updgrp && UPDGRP_DBG_ON(updgrp)) |
2589 | 0 | return true; |
2590 | 4 | } |
2591 | | |
2592 | | |
2593 | 4.23k | if (BGP_DEBUG(update, UPDATE_PREFIX)) { |
2594 | 0 | if (bgp_debug_per_prefix(p, term_bgp_debug_update, |
2595 | 0 | BGP_DEBUG_UPDATE_PREFIX, |
2596 | 0 | bgp_debug_update_prefixes)) |
2597 | 0 | return true; |
2598 | 0 | } |
2599 | | |
2600 | 4.23k | return false; |
2601 | 4.23k | } |
2602 | | |
2603 | | bool bgp_debug_bestpath(struct bgp_dest *dest) |
2604 | 0 | { |
2605 | 0 | if (BGP_DEBUG(bestpath, BESTPATH)) { |
2606 | 0 | if (bgp_debug_per_prefix( |
2607 | 0 | bgp_dest_get_prefix(dest), term_bgp_debug_bestpath, |
2608 | 0 | BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes)) |
2609 | 0 | return true; |
2610 | 0 | } |
2611 | | |
2612 | 0 | return false; |
2613 | 0 | } |
2614 | | |
2615 | | bool bgp_debug_zebra(const struct prefix *p) |
2616 | 0 | { |
2617 | 0 | if (BGP_DEBUG(zebra, ZEBRA)) { |
2618 | 0 | if (bgp_debug_per_prefix(p, term_bgp_debug_zebra, |
2619 | 0 | BGP_DEBUG_ZEBRA, |
2620 | 0 | bgp_debug_zebra_prefixes)) |
2621 | 0 | return true; |
2622 | 0 | } |
2623 | | |
2624 | 0 | return false; |
2625 | 0 | } |
2626 | | |
2627 | | const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, |
2628 | | const struct prefix_rd *prd, |
2629 | | union prefixconstptr pu, |
2630 | | mpls_label_t *label, uint32_t num_labels, |
2631 | | int addpath_valid, uint32_t addpath_id, |
2632 | | struct bgp_route_evpn *overlay_index, |
2633 | | char *str, int size) |
2634 | 0 | { |
2635 | 0 | char tag_buf[30]; |
2636 | 0 | char overlay_index_buf[INET6_ADDRSTRLEN + 14]; |
2637 | 0 | const struct prefix_evpn *evp; |
2638 | 0 | int len = 0; |
2639 | | |
2640 | | /* ' with addpath ID ' 17 |
2641 | | * max strlen of uint32 + 10 |
2642 | | * +/- (just in case) + 1 |
2643 | | * null terminator + 1 |
2644 | | * ============================ 29 */ |
2645 | 0 | char pathid_buf[30]; |
2646 | |
|
2647 | 0 | if (size < BGP_PRD_PATH_STRLEN) |
2648 | 0 | return NULL; |
2649 | | |
2650 | | /* Note: Path-id is created by default, but only included in update |
2651 | | * sometimes. */ |
2652 | 0 | pathid_buf[0] = '\0'; |
2653 | 0 | if (addpath_valid) |
2654 | 0 | snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", |
2655 | 0 | addpath_id); |
2656 | |
|
2657 | 0 | overlay_index_buf[0] = '\0'; |
2658 | 0 | if (overlay_index && overlay_index->type == OVERLAY_INDEX_GATEWAY_IP) { |
2659 | 0 | char obuf[INET6_ADDRSTRLEN]; |
2660 | |
|
2661 | 0 | obuf[0] = '\0'; |
2662 | 0 | evp = pu.evp; |
2663 | 0 | if (is_evpn_prefix_ipaddr_v4(evp)) |
2664 | 0 | inet_ntop(AF_INET, &overlay_index->gw_ip, obuf, |
2665 | 0 | sizeof(obuf)); |
2666 | 0 | else if (is_evpn_prefix_ipaddr_v6(evp)) |
2667 | 0 | inet_ntop(AF_INET6, &overlay_index->gw_ip, obuf, |
2668 | 0 | sizeof(obuf)); |
2669 | |
|
2670 | 0 | snprintf(overlay_index_buf, sizeof(overlay_index_buf), |
2671 | 0 | " gateway IP %s", obuf); |
2672 | 0 | } |
2673 | |
|
2674 | 0 | tag_buf[0] = '\0'; |
2675 | 0 | if (bgp_labeled_safi(safi) && num_labels) { |
2676 | |
|
2677 | 0 | if (safi == SAFI_EVPN) { |
2678 | 0 | char tag_buf2[20]; |
2679 | |
|
2680 | 0 | bgp_evpn_label2str(label, num_labels, tag_buf2, 20); |
2681 | 0 | snprintf(tag_buf, sizeof(tag_buf), " label %s", |
2682 | 0 | tag_buf2); |
2683 | 0 | } else { |
2684 | 0 | uint32_t label_value; |
2685 | |
|
2686 | 0 | label_value = decode_label(label); |
2687 | 0 | snprintf(tag_buf, sizeof(tag_buf), " label %u", |
2688 | 0 | label_value); |
2689 | 0 | } |
2690 | 0 | } |
2691 | |
|
2692 | 0 | if (prd) { |
2693 | 0 | len += snprintfrr(str + len, size - len, "RD "); |
2694 | 0 | len += snprintfrr(str + len, size - len, |
2695 | 0 | BGP_RD_AS_FORMAT(bgp_get_asnotation(NULL)), |
2696 | 0 | prd); |
2697 | 0 | snprintfrr(str + len, size - len, " %pFX%s%s%s %s %s", pu.p, |
2698 | 0 | overlay_index_buf, tag_buf, pathid_buf, afi2str(afi), |
2699 | 0 | safi2str(safi)); |
2700 | 0 | } else if (safi == SAFI_FLOWSPEC) { |
2701 | 0 | char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; |
2702 | 0 | const struct prefix_fs *fs = pu.fs; |
2703 | |
|
2704 | 0 | bgp_fs_nlri_get_string((unsigned char *)fs->prefix.ptr, |
2705 | 0 | fs->prefix.prefixlen, |
2706 | 0 | return_string, |
2707 | 0 | NLRI_STRING_FORMAT_DEBUG, NULL, |
2708 | 0 | family2afi(fs->prefix.family)); |
2709 | 0 | snprintf(str, size, "FS %s Match{%s}", afi2str(afi), |
2710 | 0 | return_string); |
2711 | 0 | } else |
2712 | 0 | snprintfrr(str, size, "%pFX%s%s %s %s", pu.p, tag_buf, |
2713 | 0 | pathid_buf, afi2str(afi), safi2str(safi)); |
2714 | |
|
2715 | 0 | return str; |
2716 | 0 | } |