diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f4b01ab2727c..e478abc44a67 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -277,8 +277,10 @@ struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *pi) } /* Free bgp route information. */ -static void bgp_path_info_free(struct bgp_path_info *path) +void bgp_path_info_free_with_caller(const char *name, + struct bgp_path_info *path) { + frrtrace(2, frr_bgp, bgp_path_info_free, path, name); bgp_attr_unintern(&path->attr); bgp_unlink_nexthop(path); @@ -389,8 +391,10 @@ static int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete) return -1; } -void bgp_path_info_add(struct bgp_dest *dest, struct bgp_path_info *pi) +void bgp_path_info_add_with_caller(const char *name, struct bgp_dest *dest, + struct bgp_path_info *pi) { + frrtrace(2, frr_bgp, bgp_path_info_add, dest, pi, name); struct bgp_path_info *top; top = bgp_dest_get_bgp_path_info(dest); diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 152a8a0a7250..e16e07702956 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -883,4 +883,12 @@ bgp_path_selection_reason2str(enum bgp_path_selection_reason reason); extern bool bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi); extern const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest, safi_t safi); +extern void bgp_path_info_free_with_caller(const char *caller, + struct bgp_path_info *path); +extern void bgp_path_info_add_with_caller(const char *caller, + struct bgp_dest *dest, + struct bgp_path_info *pi); +#define bgp_path_info_add(A, B) \ + bgp_path_info_add_with_caller(__func__, (A), (B)) +#define bgp_path_info_free(B) bgp_path_info_free_with_caller(__func__, (B)) #endif /* _QUAGGA_BGP_ROUTE_H */ diff --git a/bgpd/bgp_trace.h b/bgpd/bgp_trace.h index 14149b5139a6..7cc8f24e06be 100644 --- a/bgpd/bgp_trace.h +++ b/bgpd/bgp_trace.h @@ -247,6 +247,71 @@ TRACEPOINT_EVENT( ) TRACEPOINT_LOGLEVEL(frr_bgp, bgp_dest_unlock, TRACE_INFO) +/* + * peer_lock/peer_unlock + */ +TRACEPOINT_EVENT( + frr_bgp, + bgp_peer_lock, + TP_ARGS(struct peer *, peer, + const char *, name), + TP_FIELDS( + ctf_string(caller, name) + ctf_string(peer, PEER_HOSTNAME(peer)) + ctf_integer(unsigned int, count, peer->lock) + ) +) +TRACEPOINT_LOGLEVEL(frr_bgp, bgp_peer_lock, TRACE_INFO) + +TRACEPOINT_EVENT( + frr_bgp, + bgp_peer_unlock, + TP_ARGS(struct peer *, peer, + const char *, name), + TP_FIELDS( + ctf_string(caller, name) + ctf_string(peer, PEER_HOSTNAME(peer)) + ctf_integer(unsigned int, count, peer->lock) + ) +) +TRACEPOINT_LOGLEVEL(frr_bgp, bgp_peer_unlock, TRACE_INFO) + +/* + * bgp_path_info_add/bgp_path_info_free + */ +TRACEPOINT_EVENT( + frr_bgp, + bgp_path_info_add, + TP_ARGS(struct bgp_dest *, dest, + struct bgp_path_info *, bpi, + const char *, name), + TP_FIELDS( + ctf_string(caller, name) + ctf_string(prefix, bgp_dest_get_prefix_str(dest)) + ctf_string(peer, PEER_HOSTNAME(bpi->peer)) + ctf_integer(unsigned int, dest_lock, + bgp_dest_get_lock_count(dest)) + ctf_integer(unsigned int, peer_lock, bpi->peer->lock) + ) +) +TRACEPOINT_LOGLEVEL(frr_bgp, bgp_path_info_add, TRACE_INFO) + +TRACEPOINT_EVENT( + frr_bgp, + bgp_path_info_free, + TP_ARGS(struct bgp_path_info *, bpi, + const char *, name), + TP_FIELDS( + ctf_string(caller, name) + ctf_string(prefix, bgp_dest_get_prefix_str(bpi->net)) + ctf_string(peer, PEER_HOSTNAME(bpi->peer)) + ctf_integer(unsigned int, dest_lock, + bgp_dest_get_lock_count(bpi->net)) + ctf_integer(unsigned int, peer_lock, bpi->peer->lock) + ) +) +TRACEPOINT_LOGLEVEL(frr_bgp, bgp_path_info_free, TRACE_INFO) + TRACEPOINT_EVENT( frr_bgp, evpn_mac_ip_zsend, diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 734e44f2525d..9b4aa38d7af8 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -93,6 +93,7 @@ #include "bgpd/bgp_evpn_mh.h" #include "bgpd/bgp_mac.h" #include "bgpd/bgp_orr.h" +#include "bgp_trace.h" DEFINE_MTYPE_STATIC(BGPD, PEER_TX_SHUTDOWN_MSG, "Peer shutdown message (TX)"); DEFINE_MTYPE_STATIC(BGPD, BGP_EVPN_INFO, "BGP EVPN instance information"); @@ -1194,6 +1195,7 @@ static void peer_free(struct peer *peer) /* increase reference count on a struct peer */ struct peer *peer_lock_with_caller(const char *name, struct peer *peer) { + frrtrace(2, frr_bgp, bgp_peer_lock, peer, name); assert(peer && (peer->lock >= 0)); peer->lock++; @@ -1206,6 +1208,7 @@ struct peer *peer_lock_with_caller(const char *name, struct peer *peer) */ struct peer *peer_unlock_with_caller(const char *name, struct peer *peer) { + frrtrace(2, frr_bgp, bgp_peer_unlock, peer, name); assert(peer && (peer->lock > 0)); peer->lock--;