Skip to content

Commit

Permalink
Merge pull request #12562 from opensourcerouting/fix/add_frrtrace_poi…
Browse files Browse the repository at this point in the history
…nts_for_peer_lock_unlock

bgpd: A bit more tracepoints for lttng
  • Loading branch information
riw777 authored Dec 27, 2022
2 parents 7430278 + eb47318 commit 9d6ac4f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
65 changes: 65 additions & 0 deletions bgpd/bgp_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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++;
Expand All @@ -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--;
Expand Down

0 comments on commit 9d6ac4f

Please sign in to comment.