isisd: match adjacency with source of hellos

isis_pdu.c: match adjacency with source of hellos,
check for source ID on receiving hello

If an adjacency exists, check the adjacency is with the
same router as the source of the hellos. In case a mismatch
is detected, bring down the adjacency and let the next
hellos trigger creating the new adjacency.

Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 8d8a5e0..166dd7c 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -566,6 +566,17 @@
    * the circuit
    */
   adj = circuit->u.p2p.neighbor;
+  /* If an adjacency exists, check it is with the source of the hello
+   * packets */
+  if (adj)
+    {
+      if (memcmp(hdr->source_id, adj->sysid, ISIS_SYS_ID_LEN))
+	{
+          zlog_debug("hello source and adjacency do not match, set adj down\n");
+          isis_adj_state_change (adj, ISIS_ADJ_DOWN, "adj do not exist");
+          return 0;
+        }
+    }
   if (!adj || adj->level != hdr->circuit_t)
     {
       if (!adj)