Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bfdd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "lib/network.h"

#include "bfd.h"
#include "bfd_trace.h"

DEFINE_MTYPE_STATIC(BFDD, BFDD_CONFIG, "long-lived configuration memory");
DEFINE_MTYPE_STATIC(BFDD, BFDD_PROFILE, "long-lived profile memory");
Expand Down Expand Up @@ -153,6 +154,9 @@ void bfd_profile_apply(const char *profname, struct bfd_session *bs)
/* Point to profile if it exists. */
bs->profile = bp;

if (bp)
frrtrace(2, frr_bfd, profile_apply, bs, profname);

/* Apply configuration. */
bfd_session_apply(bs);
}
Expand Down Expand Up @@ -333,6 +337,7 @@ int bfd_session_enable(struct bfd_session *bs)
if (bs->key.vrfname[0]) {
vrf = vrf_lookup_by_name(bs->key.vrfname);
if (vrf == NULL) {
frrtrace(1, frr_bfd, vrf_not_found, bs->key.vrfname);
zlog_err(
"session-enable: specified VRF %s doesn't exists.",
bs->key.vrfname);
Expand All @@ -347,6 +352,7 @@ int bfd_session_enable(struct bfd_session *bs)
if (bs->key.ifname[0]) {
ifp = if_lookup_by_name(bs->key.ifname, vrf->vrf_id);
if (ifp == NULL) {
frrtrace(2, frr_bfd, interface_not_found, bs->key.ifname, vrf->vrf_id);
zlog_err(
"session-enable: specified interface %s (VRF %s) doesn't exist.",
bs->key.ifname, vrf->name);
Expand Down Expand Up @@ -421,6 +427,8 @@ int bfd_session_enable(struct bfd_session *bs)
/* initialize RTT */
bfd_rtt_init(bs);

frrtrace(2, frr_bfd, session_enable_event, true, bs);

return 0;
}

Expand All @@ -436,6 +444,8 @@ void bfd_session_disable(struct bfd_session *bs)
if (bs->bdc)
return;

frrtrace(2, frr_bfd, session_enable_event, false, bs);

/* Free up socket resources. */
if (bs->sock != -1) {
close(bs->sock);
Expand Down Expand Up @@ -568,6 +578,8 @@ void ptm_bfd_echo_stop(struct bfd_session *bfd)

bfd_echo_xmttimer_delete(bfd);
bfd_echo_recvtimer_delete(bfd);

frrtrace(2, frr_bfd, echo_mode_change, bfd, false);
}

void ptm_bfd_echo_start(struct bfd_session *bfd)
Expand All @@ -576,6 +588,7 @@ void ptm_bfd_echo_start(struct bfd_session *bfd)
if (bfd->echo_detect_TO > 0) {
bfd_echo_recvtimer_update(bfd);
ptm_bfd_echo_xmt_TO(bfd);
frrtrace(2, frr_bfd, echo_mode_change, bfd, true);
}
}

Expand All @@ -595,6 +608,8 @@ void ptm_bfd_sess_up(struct bfd_session *bfd)

ptm_bfd_notify(bfd, bfd->ses_state);

frrtrace(4, frr_bfd, state_change, bfd, old_state, bfd->ses_state, bfd->local_diag);

if (old_state != bfd->ses_state) {
bfd->stats.session_up++;
if (bglobal.debug_peer_event)
Expand Down Expand Up @@ -644,6 +659,8 @@ void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag)
bfd_xmttimer_delete(bfd);
}

frrtrace(4, frr_bfd, state_change, bfd, old_state, bfd->ses_state, bfd->local_diag);

if (old_state != bfd->ses_state) {
bfd->stats.session_down++;
if (bglobal.debug_peer_event)
Expand Down Expand Up @@ -1011,6 +1028,8 @@ void bfd_session_free(struct bfd_session *bs)
{
struct bfd_session_observer *bso;

frrtrace(2, frr_bfd, session_lifecycle, false, bs);

bfd_session_disable(bs);

/* Remove session from data plane if any. */
Expand Down Expand Up @@ -1122,6 +1141,8 @@ struct bfd_session *bs_registrate(struct bfd_session *bfd)
if (bfd->key.ifname[0] || bfd->key.vrfname[0] || bfd->sock == -1)
bs_observer_add(bfd);

frrtrace(2, frr_bfd, session_lifecycle, true, bfd);

if (bglobal.debug_peer_event)
zlog_debug("session-new: %s", bs_to_string(bfd));

Expand All @@ -1139,6 +1160,7 @@ int ptm_bfd_sess_del(struct bfd_peer_cfg *bpc)

/* This pointer is being referenced, don't let it be deleted. */
if (bs->refcount > 0) {
frrtrace(1, frr_bfd, refcount_error, bs->refcount);
zlog_err("session-delete: refcount failure: %" PRIu64" references",
bs->refcount);
return -1;
Expand Down Expand Up @@ -1495,6 +1517,9 @@ void bs_final_handler(struct bfd_session *bs)
if (bglobal.debug_peer_event)
zlog_debug(" calculated xmt_TO=%" PRIu64 " (using slowest rate)", bs->xmt_TO);

frrtrace(6, frr_bfd, timer_negotiation, bs, bs->xmt_TO, bs->cur_timers.required_min_rx,
bs->detect_TO, bs->echo_xmt_TO, bs->echo_detect_TO);

/* Only apply increased transmission interval after Poll Sequence */
if (bs->ses_state == PTM_BFD_UP && bs->xmt_TO > old_xmt_TO && bs->polling) {
if (bglobal.debug_peer_event) {
Expand Down Expand Up @@ -2462,6 +2487,8 @@ static int bfd_vrf_new(struct vrf *vrf)
if (bglobal.debug_zebra)
zlog_debug("VRF Created: %s(%u)", vrf->name, vrf->vrf_id);

frrtrace(2, frr_bfd, vrf_lifecycle, 1, vrf->vrf_id);

bvrf = XCALLOC(MTYPE_BFDD_VRF, sizeof(struct bfd_vrf_global));
bvrf->vrf = vrf;
vrf->info = bvrf;
Expand All @@ -2483,6 +2510,8 @@ static int bfd_vrf_delete(struct vrf *vrf)
if (bglobal.debug_zebra)
zlog_debug("VRF Deletion: %s(%u)", vrf->name, vrf->vrf_id);

frrtrace(2, frr_bfd, vrf_lifecycle, 2, vrf->vrf_id);

XFREE(MTYPE_BFDD_VRF, vrf->info);

return 0;
Expand All @@ -2495,6 +2524,8 @@ static int bfd_vrf_enable(struct vrf *vrf)
if (bglobal.debug_zebra)
zlog_debug("VRF enable add %s id %u", vrf->name, vrf->vrf_id);

frrtrace(2, frr_bfd, vrf_lifecycle, 3, vrf->vrf_id);

/* Don't open sockets when using data plane */
if (bglobal.bg_use_dplane)
goto skip_sockets;
Expand Down Expand Up @@ -2556,6 +2587,8 @@ static int bfd_vrf_disable(struct vrf *vrf)
if (bglobal.debug_zebra)
zlog_debug("VRF disable %s id %d", vrf->name, vrf->vrf_id);

frrtrace(2, frr_bfd, vrf_lifecycle, 4, vrf->vrf_id);

/* Disable read/write poll triggering. */
event_cancel(&bvrf->bg_ev[0]);
event_cancel(&bvrf->bg_ev[1]);
Expand Down
1 change: 1 addition & 0 deletions bfdd/bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct bfd_echo_pkt {
#define BFD_DEMANDBIT 0x02
#define BFD_MBIT 0x01
#define BFD_GETMBIT(flags) (CHECK_FLAG(flags, BFD_MBIT))
#define BFD_GETDEMANDBIT(flags) (CHECK_FLAG(flags, BFD_DEMANDBIT))
#define BFD_SETDEMANDBIT(flags, val) \
{ \
if ((val)) \
Expand Down
Loading
Loading