diff options
author | Quentin Young <qlyoung@nvidia.com> | 2020-09-17 01:16:35 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@nvidia.com> | 2020-10-23 21:13:51 +0200 |
commit | 6401252f7fe68123c6dc122958649dfd384c98e6 (patch) | |
tree | 393c938d78e6fa558710a57c625c5cc42178d8d3 /bgpd | |
parent | bgpd: add basic packet-related tracepoints (diff) | |
download | frr-6401252f7fe68123c6dc122958649dfd384c98e6.tar.xz frr-6401252f7fe68123c6dc122958649dfd384c98e6.zip |
bgpd: route processing tracepoints
Add tracepoints for route process, input filter and output filter.
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_route.c | 72 | ||||
-rw-r--r-- | bgpd/bgp_trace.h | 48 |
2 files changed, 105 insertions, 15 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 68ba73caa..e3c6c463a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -70,6 +70,7 @@ #include "bgpd/bgp_addpath.h" #include "bgpd/bgp_mac.h" #include "bgpd/bgp_network.h" +#include "bgpd/bgp_trace.h" #ifdef ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -1288,6 +1289,7 @@ static enum filter_type bgp_input_filter(struct peer *peer, safi_t safi) { struct bgp_filter *filter; + enum filter_type ret = FILTER_PERMIT; filter = &peer->filter[afi][safi]; @@ -1299,26 +1301,43 @@ static enum filter_type bgp_input_filter(struct peer *peer, if (DISTRIBUTE_IN_NAME(filter)) { FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); - if (access_list_apply(DISTRIBUTE_IN(filter), p) == FILTER_DENY) - return FILTER_DENY; + if (access_list_apply(DISTRIBUTE_IN(filter), p) + == FILTER_DENY) { + ret = FILTER_DENY; + goto done; + } } if (PREFIX_LIST_IN_NAME(filter)) { FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); - if (prefix_list_apply(PREFIX_LIST_IN(filter), p) == PREFIX_DENY) - return FILTER_DENY; + if (prefix_list_apply(PREFIX_LIST_IN(filter), p) + == PREFIX_DENY) { + ret = FILTER_DENY; + goto done; + } } if (FILTER_LIST_IN_NAME(filter)) { FILTER_EXIST_WARN(FILTER_LIST, as, filter); if (as_list_apply(FILTER_LIST_IN(filter), attr->aspath) - == AS_FILTER_DENY) - return FILTER_DENY; + == AS_FILTER_DENY) { + ret = FILTER_DENY; + goto done; + } } - return FILTER_PERMIT; +done: + if (tracepoint_enabled(frr_bgp, input_filter)) { + char pfxprint[PREFIX2STR_BUFFER]; + + prefix2str(p, pfxprint, sizeof(pfxprint)); + tracepoint(frr_bgp, input_filter, peer, pfxprint, afi, safi, + ret == FILTER_PERMIT ? "permit" : "deny"); + } + + return ret; #undef FILTER_EXIST_WARN } @@ -1328,6 +1347,7 @@ static enum filter_type bgp_output_filter(struct peer *peer, safi_t safi) { struct bgp_filter *filter; + enum filter_type ret = FILTER_PERMIT; filter = &peer->filter[afi][safi]; @@ -1339,27 +1359,43 @@ static enum filter_type bgp_output_filter(struct peer *peer, if (DISTRIBUTE_OUT_NAME(filter)) { FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); - if (access_list_apply(DISTRIBUTE_OUT(filter), p) == FILTER_DENY) - return FILTER_DENY; + if (access_list_apply(DISTRIBUTE_OUT(filter), p) + == FILTER_DENY) { + ret = FILTER_DENY; + goto done; + } } if (PREFIX_LIST_OUT_NAME(filter)) { FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); if (prefix_list_apply(PREFIX_LIST_OUT(filter), p) - == PREFIX_DENY) - return FILTER_DENY; + == PREFIX_DENY) { + ret = FILTER_DENY; + goto done; + } } if (FILTER_LIST_OUT_NAME(filter)) { FILTER_EXIST_WARN(FILTER_LIST, as, filter); if (as_list_apply(FILTER_LIST_OUT(filter), attr->aspath) - == AS_FILTER_DENY) - return FILTER_DENY; + == AS_FILTER_DENY) { + ret = FILTER_DENY; + goto done; + } + } + + if (tracepoint_enabled(frr_bgp, output_filter)) { + char pfxprint[PREFIX2STR_BUFFER]; + + prefix2str(p, pfxprint, sizeof(pfxprint)); + tracepoint(frr_bgp, output_filter, peer, pfxprint, afi, safi, + ret == FILTER_PERMIT ? "permit" : "deny"); } - return FILTER_PERMIT; +done: + return ret; #undef FILTER_EXIST_WARN } @@ -3427,6 +3463,14 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, uint8_t pi_type = 0; uint8_t pi_sub_type = 0; + if (tracepoint_enabled(frr_bgp, process_update)) { + char pfxprint[PREFIX2STR_BUFFER]; + + prefix2str(p, pfxprint, sizeof(pfxprint)); + tracepoint(frr_bgp, process_update, peer, pfxprint, addpath_id, + afi, safi, attr); + } + #ifdef ENABLE_BGP_VNC int vnc_implicit_withdraw = 0; #endif diff --git a/bgpd/bgp_trace.h b/bgpd/bgp_trace.h index fd0d26bd5..4b79155ef 100644 --- a/bgpd/bgp_trace.h +++ b/bgpd/bgp_trace.h @@ -68,11 +68,57 @@ TRACEPOINT_EVENT( TP_ARGS(struct peer *, peer, struct stream *, pkt), TP_FIELDS( ctf_string(peer, peer->host ? peer->host : "(unknown peer)") - ctf_integer(size_t, size, STREAM_READABLE(pkt)) ctf_sequence_hex(uint8_t, packet, pkt->data, size_t, STREAM_READABLE(pkt)) ) ) +TRACEPOINT_LOGLEVEL(frr_bgp, packet_read, TRACE_INFO) + +TRACEPOINT_EVENT( + frr_bgp, + process_update, + 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(prefix, pfx) + ctf_integer(uint32_t, addpath_id, addpath_id) + ctf_integer(afi_t, afi, afi) + ctf_integer(safi_t, safi, safi) + ctf_integer_hex(intptr_t, attribute_ptr, attr) + ) +) + +TRACEPOINT_LOGLEVEL(frr_bgp, process_update, TRACE_INFO) + +TRACEPOINT_EVENT( + frr_bgp, + input_filter, + 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(prefix, pfx) + ctf_integer(afi_t, afi, afi) + ctf_integer(safi_t, safi, safi) + ctf_string(action, result) + ) +) + +TRACEPOINT_LOGLEVEL(frr_bgp, input_filter, TRACE_INFO) + +TRACEPOINT_EVENT( + frr_bgp, + output_filter, + 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(prefix, pfx) + ctf_integer(afi_t, afi, afi) + ctf_integer(safi_t, safi, safi) + ctf_string(action, result) + ) +) + +TRACEPOINT_LOGLEVEL(frr_bgp, output_filter, TRACE_INFO) #include <lttng/tracepoint-event.h> |