Skip to content

Commit

Permalink
bfdd: remove control socket obsolete code
Browse files Browse the repository at this point in the history
Let's remove the obsolete BFD control socket. If the functionality is
needed then YANG/northbound notifications / getting should be used
instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
  • Loading branch information
rzalamena committed Jul 25, 2024
1 parent 7ccd9ca commit 88a9aa9
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 1,812 deletions.
78 changes: 8 additions & 70 deletions bfdd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,8 @@ void gen_bfd_key(struct bfd_key *key, struct sockaddr_any *peer,

struct bfd_session *bs_peer_find(struct bfd_peer_cfg *bpc)
{
struct bfd_session *bs;
struct peer_label *pl;
struct bfd_key key;

/* Try to find label first. */
if (bpc->bpc_has_label) {
pl = pl_find(bpc->bpc_label);
if (pl != NULL) {
bs = pl->pl_bs;
return bs;
}
}

/* Otherwise fallback to peer/local hash lookup. */
gen_bfd_key(&key, &bpc->bpc_peer, &bpc->bpc_local, bpc->bpc_mhop,
bpc->bpc_localif, bpc->bpc_vrfname);
Expand Down Expand Up @@ -327,10 +316,8 @@ int bfd_session_enable(struct bfd_session *bs)
bs->ifp = ifp;

/* Attempt to use data plane. */
if (bglobal.bg_use_dplane && bfd_dplane_add_session(bs) == 0) {
control_notify_config(BCM_NOTIFY_CONFIG_ADD, bs);
if (bglobal.bg_use_dplane && bfd_dplane_add_session(bs) == 0)
return 0;
}

/* Sanity check: don't leak open sockets. */
if (bs->sock != -1) {
Expand Down Expand Up @@ -502,7 +489,7 @@ void ptm_bfd_sess_up(struct bfd_session *bfd)
/* Start sending control packets with poll bit immediately. */
ptm_bfd_snd(bfd, 0);

control_notify(bfd, bfd->ses_state);
ptm_bfd_notify(bfd, bfd->ses_state);

if (old_state != bfd->ses_state) {
bfd->stats.session_up++;
Expand Down Expand Up @@ -538,7 +525,7 @@ void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag)

/* only signal clients when going from up->down state */
if (old_state == PTM_BFD_UP)
control_notify(bfd, PTM_BFD_DOWN);
ptm_bfd_notify(bfd, PTM_BFD_DOWN);

/* Stop echo packet transmission if they are active */
if (CHECK_FLAG(bfd->flags, BFD_SESS_FLAG_ECHO_ACTIVE))
Expand Down Expand Up @@ -690,38 +677,6 @@ struct bfd_session *bfd_session_new(void)
return bs;
}

int bfd_session_update_label(struct bfd_session *bs, const char *nlabel)
{
/* New label treatment:
* - Check if the label is taken;
* - Try to allocate the memory for it and register;
*/
if (bs->pl == NULL) {
if (pl_find(nlabel) != NULL) {
/* Someone is already using it. */
return -1;
}

pl_new(nlabel, bs);

return 0;
}

/*
* Test label change consistency:
* - Do nothing if it's the same label;
* - Check if the future label is already taken;
* - Change label;
*/
if (strcmp(nlabel, bs->pl->pl_label) == 0)
return -1;
if (pl_find(nlabel) != NULL)
return -1;

strlcpy(bs->pl->pl_label, nlabel, sizeof(bs->pl->pl_label));
return 0;
}

static void _bfd_session_update(struct bfd_session *bs,
struct bfd_peer_cfg *bpc)
{
Expand Down Expand Up @@ -750,9 +705,6 @@ static void _bfd_session_update(struct bfd_session *bs,
bs->peer_profile.min_echo_tx = bs->timers.desired_min_echo_tx;
}

if (bpc->bpc_has_label)
bfd_session_update_label(bs, bpc->bpc_label);

if (bpc->bpc_cbit)
SET_FLAG(bs->flags, BFD_SESS_FLAG_CBIT);
else
Expand Down Expand Up @@ -792,8 +744,6 @@ static int bfd_session_update(struct bfd_session *bs, struct bfd_peer_cfg *bpc)

_bfd_session_update(bs, bpc);

control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);

return 0;
}

Expand All @@ -819,8 +769,6 @@ void bfd_session_free(struct bfd_session *bs)
if (bso != NULL)
bs_observer_del(bso);

pl_free(bs->pl);

XFREE(MTYPE_BFDD_PROFILE, bs->profile_name);
XFREE(MTYPE_BFDD_CONFIG, bs);
}
Expand Down Expand Up @@ -917,8 +865,6 @@ struct bfd_session *bs_registrate(struct bfd_session *bfd)
if (bglobal.debug_peer_event)
zlog_debug("session-new: %s", bs_to_string(bfd));

control_notify_config(BCM_NOTIFY_CONFIG_ADD, bfd);

return bfd;
}

Expand All @@ -941,8 +887,6 @@ int ptm_bfd_sess_del(struct bfd_peer_cfg *bpc)
if (bglobal.debug_peer_event)
zlog_debug("%s: %s", __func__, bs_to_string(bs));

control_notify_config(BCM_NOTIFY_CONFIG_DELETE, bs);

bfd_session_free(bs);

return 0;
Expand Down Expand Up @@ -1166,11 +1110,8 @@ void bs_final_handler(struct bfd_session *bs)
* When using demand mode we must disable the detection timer
* for lost control packets.
*/
if (bs->demand_mode) {
/* Notify watchers about changed timers. */
control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
if (bs->demand_mode)
return;
}

/*
* Calculate transmission time based on new timers.
Expand All @@ -1189,9 +1130,6 @@ void bs_final_handler(struct bfd_session *bs)

/* Apply new transmission timer immediately. */
ptm_bfd_start_xmt_timer(bs, false);

/* Notify watchers about changed timers. */
control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
}

void bs_set_slow_timers(struct bfd_session *bs)
Expand Down Expand Up @@ -1261,7 +1199,7 @@ void bfd_set_shutdown(struct bfd_session *bs, bool shutdown)
if (bs->bdc) {
bs->ses_state = PTM_BFD_ADM_DOWN;
bfd_dplane_update_session(bs);
control_notify(bs, bs->ses_state);
ptm_bfd_notify(bs, bs->ses_state);
return;
}

Expand All @@ -1273,7 +1211,7 @@ void bfd_set_shutdown(struct bfd_session *bs, bool shutdown)

/* Change and notify state change. */
bs->ses_state = PTM_BFD_ADM_DOWN;
control_notify(bs, bs->ses_state);
ptm_bfd_notify(bs, bs->ses_state);

/* Don't try to send packets with a disabled session. */
if (bs->sock != -1)
Expand All @@ -1289,13 +1227,13 @@ void bfd_set_shutdown(struct bfd_session *bs, bool shutdown)
if (bs->bdc) {
bs->ses_state = PTM_BFD_DOWN;
bfd_dplane_update_session(bs);
control_notify(bs, bs->ses_state);
ptm_bfd_notify(bs, bs->ses_state);
return;
}

/* Change and notify state change. */
bs->ses_state = PTM_BFD_DOWN;
control_notify(bs, bs->ses_state);
ptm_bfd_notify(bs, bs->ses_state);

/* Enable timers if non passive, otherwise stop them. */
if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_PASSIVE)) {
Expand Down
Loading

0 comments on commit 88a9aa9

Please sign in to comment.