From 6bdb4a42acda17c2127032acc3495a1e7af4b13f Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 17 Apr 2019 18:01:11 +0200 Subject: [PATCH 1/2] bfdd: avoid having bfd config inherited from operation context there are cases where bfd sessions are created from remote daemons. in that case, the bfd daemon were appearing in both operational and configuration contexts of bfd. Change that by only keeping operational contexts. Signed-off-by: Philippe Guibert --- bfdd/bfd.h | 1 + bfdd/bfdd_vty.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/bfdd/bfd.h b/bfdd/bfd.h index a69ff9a1a7..78122baf7a 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -166,6 +166,7 @@ enum bfd_session_flags { * expires */ BFD_SESS_FLAG_SHUTDOWN = 1 << 7, /* disable BGP peer function */ + BFD_SESS_FLAG_CONFIG = 1 << 8, /* Session configured with bfd NB API */ }; #define BFD_SET_FLAG(field, flag) (field |= flag) diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index c139492076..4efdd817c1 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -158,6 +158,12 @@ DEFUN_NOSH( } } + if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG)) { + if (bs->refcount) + vty_out(vty, "%% session peer is now configurable via bfd daemon.\n"); + BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG); + } + VTY_PUSH_CONTEXT(BFD_PEER_NODE, bs); return CMD_SUCCESS; @@ -984,6 +990,9 @@ static void _bfdd_peer_write_config_iter(struct hash_bucket *hb, void *arg) struct vty *vty = arg; struct bfd_session *bs = hb->data; + if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG)) + return; + _bfdd_peer_write_config(vty, bs); } From 4c741971a53c4af575d06b618065c22a79c218a4 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 17 Apr 2019 18:25:55 +0200 Subject: [PATCH 2/2] bfdd: remove operational bfd sessions from remote daemons when a remote daemon wants to get rid of a session, a request is sent, but the deletion of the bfd session was not done. The flush is done, provided that there is not someone else that is using that session. Signed-off-by: Philippe Guibert --- bfdd/ptm_adapter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index 8d80b9468d..e92500cd80 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -431,6 +431,10 @@ static void bfdd_dest_deregister(struct stream *msg) /* Unregister client peer notification. */ pcn = pcn_lookup(pc, bs); pcn_free(pcn); + if (bs->refcount || + BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG)) + return; + ptm_bfd_ses_del(&bpc); } /*