>From 9948dea9516f015cee536d929becad389b639b78 Mon Sep 17 00:00:00 2001
From: Winston Chen <yoniorchen@gmail.com>
Date: Mon, 30 Sep 2019 22:06:01 +0800
Subject: [PATCH] BFD: Fix reload issue when neighbors change

---
 proto/bfd/bfd.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c
index f774e67b..de42be82 100644
--- a/proto/bfd/bfd.c
+++ b/proto/bfd/bfd.c
@@ -825,22 +825,30 @@ bfd_reconfigure_neighbors(struct bfd_proto *p, struct bfd_config *new)
 {
   struct bfd_config *old = (struct bfd_config *) (p->p.cf);
   struct bfd_neighbor *on, *nn;
+  int found;
 
   WALK_LIST(on, old->neigh_list)
   {
+    found = 0;
     WALK_LIST(nn, new->neigh_list)
+    {
       if (bfd_same_neighbor(nn, on))
       {
-	nn->neigh = on->neigh;
-	if (nn->neigh)
-	  nn->neigh->data = nn;
-
-	nn->req = on->req;
-	nn->active = 1;
-	return;
+        found = 1;
+        break;
       }
-
-    bfd_stop_neighbor(p, on);
+    }
+    if (found)
+    {
+      nn->neigh = on->neigh;
+      if (nn->neigh)
+        nn->neigh->data = nn;
+
+      nn->req = on->req;
+      nn->active = 1;
+    } else {
+      bfd_stop_neighbor(p, on);
+    }
   }
 
   WALK_LIST(nn, new->neigh_list)
-- 
2.23.0

