From 169afe9dfcbf378d8fd9b3c16217a0e025297135 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 11 Feb 2021 19:21:08 -0500 Subject: [PATCH] bgpd: add PEER_HOSTNAME() macro Add macro to get hostname if available or provide a default value if not. Signed-off-by: Quentin Young --- bgpd/bgp_trace.h | 10 +++++----- bgpd/bgpd.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_trace.h b/bgpd/bgp_trace.h index 2566ffb928..9d1a4797ab 100644 --- a/bgpd/bgp_trace.h +++ b/bgpd/bgp_trace.h @@ -43,7 +43,7 @@ TRACEPOINT_EVENT_CLASS( packet_process, TP_ARGS(struct peer *, peer, bgp_size_t, size), TP_FIELDS( - ctf_string(peer, peer->host ? peer->host : "(unknown peer)") + ctf_string(peer, PEER_HOSTNAME(peer)) ) ) @@ -65,7 +65,7 @@ TRACEPOINT_EVENT( packet_read, TP_ARGS(struct peer *, peer, struct stream *, pkt), TP_FIELDS( - ctf_string(peer, peer->host ? peer->host : "(unknown peer)") + ctf_string(peer, PEER_HOSTNAME(peer)) ctf_sequence_hex(uint8_t, packet, pkt->data, size_t, STREAM_READABLE(pkt)) ) @@ -79,7 +79,7 @@ TRACEPOINT_EVENT( TP_ARGS(struct peer *, peer, char *, pfx, uint32_t, addpath_id, afi_t, afi, safi_t, safi, struct attr *, attr), TP_FIELDS( - ctf_string(peer, peer->host ? peer->host : "(unknown peer)") + ctf_string(peer, PEER_HOSTNAME(peer)) ctf_string(prefix, pfx) ctf_integer(uint32_t, addpath_id, addpath_id) ctf_integer(afi_t, afi, afi) @@ -96,7 +96,7 @@ TRACEPOINT_EVENT( TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi, const char *, result), TP_FIELDS( - ctf_string(peer, peer->host ? peer->host : "(unknown peer)") + ctf_string(peer, PEER_HOSTNAME(peer)) ctf_string(prefix, pfx) ctf_integer(afi_t, afi, afi) ctf_integer(safi_t, safi, safi) @@ -112,7 +112,7 @@ TRACEPOINT_EVENT( TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi, const char *, result), TP_FIELDS( - ctf_string(peer, peer->host ? peer->host : "(unknown peer)") + ctf_string(peer, PEER_HOSTNAME(peer)) ctf_string(prefix, pfx) ctf_integer(afi_t, afi, afi) ctf_integer(safi_t, safi, safi) diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 9f453bf1e6..4795bea399 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -955,6 +955,8 @@ enum bgp_fsm_status { BGP_STATUS_MAX, }; +#define PEER_HOSTNAME(peer) ((peer)->host ? (peer)->host : "(unknown peer)") + /* BGP neighbor structure. */ struct peer { /* BGP structure. */ -- 2.39.5