[Olsr-dev] [PATCH v1 2/3] hello reception: remove duplicate neighbors

Ferry Huberts (spam-protected)
Tue Feb 7 14:14:17 CET 2017


From: "Iwan G. Flameling" <(spam-protected)>

See the explanations in the descriptions of commits 2f38613 and
5089a79.

To fix the issue more thoroughly we need to ensure that no duplicate
neighbours are sent or received because that confuses the receiver.
This is especially true when the HELLO messages are fragmented, and
even more so when the fragments have some delay between them since
that causes link instability.

This commit fixes that for the receiving side.

Signed-off-by: Iwan G. Flameling <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/process_package.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/process_package.c b/src/process_package.c
index bd6932b..7f4e229 100644
--- a/src/process_package.c
+++ b/src/process_package.c
@@ -385,6 +385,29 @@ deserialize_hello(struct hello_message *hello, const void *ser)
     }
   }
 
+  {
+    struct hello_neighbor *neigh;
+    for (neigh = hello->neighbors; neigh; neigh = neigh->next) {
+      struct hello_neighbor *neigh_cull;
+      struct hello_neighbor *neigh_cull_prev;
+      struct hello_neighbor *neigh_cull_next;
+
+      for (neigh_cull_prev = neigh, neigh_cull = neigh->next;
+           neigh_cull;
+           neigh_cull = neigh_cull_next) {
+        neigh_cull_next = neigh_cull->next;
+
+        if (!ipequal(&neigh_cull->address, &neigh->address)) {
+          neigh_cull_prev = neigh_cull;
+          continue;
+        }
+
+        neigh_cull_prev->next = neigh_cull_next;
+        free(neigh_cull);
+      }
+    }
+  }
+
   return 0;
 }
 
-- 
2.9.3




More information about the Olsr-dev mailing list