Skip to content

Commit 88a9aa9

Browse files
committed
bfdd: remove control socket obsolete code
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 <[email protected]>
1 parent 7ccd9ca commit 88a9aa9

File tree

12 files changed

+78
-1812
lines changed

12 files changed

+78
-1812
lines changed

bfdd/bfd.c

+8-70
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,8 @@ void gen_bfd_key(struct bfd_key *key, struct sockaddr_any *peer,
256256

257257
struct bfd_session *bs_peer_find(struct bfd_peer_cfg *bpc)
258258
{
259-
struct bfd_session *bs;
260-
struct peer_label *pl;
261259
struct bfd_key key;
262260

263-
/* Try to find label first. */
264-
if (bpc->bpc_has_label) {
265-
pl = pl_find(bpc->bpc_label);
266-
if (pl != NULL) {
267-
bs = pl->pl_bs;
268-
return bs;
269-
}
270-
}
271-
272261
/* Otherwise fallback to peer/local hash lookup. */
273262
gen_bfd_key(&key, &bpc->bpc_peer, &bpc->bpc_local, bpc->bpc_mhop,
274263
bpc->bpc_localif, bpc->bpc_vrfname);
@@ -327,10 +316,8 @@ int bfd_session_enable(struct bfd_session *bs)
327316
bs->ifp = ifp;
328317

329318
/* Attempt to use data plane. */
330-
if (bglobal.bg_use_dplane && bfd_dplane_add_session(bs) == 0) {
331-
control_notify_config(BCM_NOTIFY_CONFIG_ADD, bs);
319+
if (bglobal.bg_use_dplane && bfd_dplane_add_session(bs) == 0)
332320
return 0;
333-
}
334321

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

505-
control_notify(bfd, bfd->ses_state);
492+
ptm_bfd_notify(bfd, bfd->ses_state);
506493

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

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

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

693-
int bfd_session_update_label(struct bfd_session *bs, const char *nlabel)
694-
{
695-
/* New label treatment:
696-
* - Check if the label is taken;
697-
* - Try to allocate the memory for it and register;
698-
*/
699-
if (bs->pl == NULL) {
700-
if (pl_find(nlabel) != NULL) {
701-
/* Someone is already using it. */
702-
return -1;
703-
}
704-
705-
pl_new(nlabel, bs);
706-
707-
return 0;
708-
}
709-
710-
/*
711-
* Test label change consistency:
712-
* - Do nothing if it's the same label;
713-
* - Check if the future label is already taken;
714-
* - Change label;
715-
*/
716-
if (strcmp(nlabel, bs->pl->pl_label) == 0)
717-
return -1;
718-
if (pl_find(nlabel) != NULL)
719-
return -1;
720-
721-
strlcpy(bs->pl->pl_label, nlabel, sizeof(bs->pl->pl_label));
722-
return 0;
723-
}
724-
725680
static void _bfd_session_update(struct bfd_session *bs,
726681
struct bfd_peer_cfg *bpc)
727682
{
@@ -750,9 +705,6 @@ static void _bfd_session_update(struct bfd_session *bs,
750705
bs->peer_profile.min_echo_tx = bs->timers.desired_min_echo_tx;
751706
}
752707

753-
if (bpc->bpc_has_label)
754-
bfd_session_update_label(bs, bpc->bpc_label);
755-
756708
if (bpc->bpc_cbit)
757709
SET_FLAG(bs->flags, BFD_SESS_FLAG_CBIT);
758710
else
@@ -792,8 +744,6 @@ static int bfd_session_update(struct bfd_session *bs, struct bfd_peer_cfg *bpc)
792744

793745
_bfd_session_update(bs, bpc);
794746

795-
control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
796-
797747
return 0;
798748
}
799749

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

822-
pl_free(bs->pl);
823-
824772
XFREE(MTYPE_BFDD_PROFILE, bs->profile_name);
825773
XFREE(MTYPE_BFDD_CONFIG, bs);
826774
}
@@ -917,8 +865,6 @@ struct bfd_session *bs_registrate(struct bfd_session *bfd)
917865
if (bglobal.debug_peer_event)
918866
zlog_debug("session-new: %s", bs_to_string(bfd));
919867

920-
control_notify_config(BCM_NOTIFY_CONFIG_ADD, bfd);
921-
922868
return bfd;
923869
}
924870

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

944-
control_notify_config(BCM_NOTIFY_CONFIG_DELETE, bs);
945-
946890
bfd_session_free(bs);
947891

948892
return 0;
@@ -1166,11 +1110,8 @@ void bs_final_handler(struct bfd_session *bs)
11661110
* When using demand mode we must disable the detection timer
11671111
* for lost control packets.
11681112
*/
1169-
if (bs->demand_mode) {
1170-
/* Notify watchers about changed timers. */
1171-
control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
1113+
if (bs->demand_mode)
11721114
return;
1173-
}
11741115

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

11901131
/* Apply new transmission timer immediately. */
11911132
ptm_bfd_start_xmt_timer(bs, false);
1192-
1193-
/* Notify watchers about changed timers. */
1194-
control_notify_config(BCM_NOTIFY_CONFIG_UPDATE, bs);
11951133
}
11961134

11971135
void bs_set_slow_timers(struct bfd_session *bs)
@@ -1261,7 +1199,7 @@ void bfd_set_shutdown(struct bfd_session *bs, bool shutdown)
12611199
if (bs->bdc) {
12621200
bs->ses_state = PTM_BFD_ADM_DOWN;
12631201
bfd_dplane_update_session(bs);
1264-
control_notify(bs, bs->ses_state);
1202+
ptm_bfd_notify(bs, bs->ses_state);
12651203
return;
12661204
}
12671205

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

12741212
/* Change and notify state change. */
12751213
bs->ses_state = PTM_BFD_ADM_DOWN;
1276-
control_notify(bs, bs->ses_state);
1214+
ptm_bfd_notify(bs, bs->ses_state);
12771215

12781216
/* Don't try to send packets with a disabled session. */
12791217
if (bs->sock != -1)
@@ -1289,13 +1227,13 @@ void bfd_set_shutdown(struct bfd_session *bs, bool shutdown)
12891227
if (bs->bdc) {
12901228
bs->ses_state = PTM_BFD_DOWN;
12911229
bfd_dplane_update_session(bs);
1292-
control_notify(bs, bs->ses_state);
1230+
ptm_bfd_notify(bs, bs->ses_state);
12931231
return;
12941232
}
12951233

12961234
/* Change and notify state change. */
12971235
bs->ses_state = PTM_BFD_DOWN;
1298-
control_notify(bs, bs->ses_state);
1236+
ptm_bfd_notify(bs, bs->ses_state);
12991237

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

0 commit comments

Comments
 (0)