Hi,

Issue Description: LSA ID collision issue is seen with OSPF stub-networks configured and BIRD is acting as ABR
 
BIRD OSPF configuration:
·         Part of 2 areas (say, area-0 and area-100)
·         Stub-networks are configured in area-0
 
Code Flow:
1.       Stubnets are advertised to area-0 by generating router LSA (LSA_T_RT).
o   ospf_disp() -> ospf_update_topology() -> ospf_originate_rt_lsa()->ospf_originate_lsa()
2.       Now, stubnets are added to top graph table (p->gr) with LSA type LSA_T_RT
3.       When creating routing table, these stubnets are added to FIB (p->rtf).
o   ospf_disp() -> ospf_rt_spf() -> ospf_rt_spfa() -> spfa_process_rt() -> add_network() -> ri_install_net()
4.       When BIRD is acting as ABR then, walk through FIB(p->rtf)  and send summary LSA (LSA_T_SUM_NET) with LSA mode as LSA_M_RTCALC. Also, nf pointer is set (stores fib node address) in top_hash_entry.
o    ospf_disp() -> ospf_rt_abr2() -> check_sum_net_lsa() -> ospf_originate_sum_net_lsa() ->ospf_originate_lsa()
5.       Now, stubnets are added to top graph table (p->gr) with LSA type LSA_T_SUM_NET
6.       Stubnets are removed from FIB(p->rtf)
o   ospf_disp() -> rt_sync() -> fib_delete() 
7.       Now, stubnets entries are still present in top graph table (Note: fib_delte() doesn't free the node, it just moves the fib node to free pool, fib_node pointer is still valid)
8.       With any change in network, ospf_rt_spf()is called. In ospf_rt_reset(), LSA mode is updated fromLSA_M_RTCALC to LSA_M_STALE.
9.       Again, steps 3-6 are repeated. In step-3, fib node pointer is changed and in step-4, fib node pointer comparison fails in ospf_originate_lsa()which is leading to LSA id collision.
 
Issue is resolved with below code change. Please review the change and provide your comments. Also, please let me know if any other information is required.
 
diff -rupN bird/proto/ospf/topology.c bird_modified/proto/ospf/topology.c
--- bird/proto/ospf/topology.c    2016-11-28 05:14:19.582761752 -0800
+++ bird_modified/proto/ospf/topology.c     2016-11-28 05:14:01.270761752 -0800
@@ -278,7 +278,7 @@ ospf_originate_lsa(struct ospf_proto *p,
   if (!SNODE_VALID(en))
     s_add_tail(&p->lsal, SNODE en);
 
-  if (!en->nf || !en->lsa_body)
+  if (!en->nf || !en->lsa_body || en->mode == LSA_M_STALE)
     en->nf = lsa->nf;
 
 
Thanks,
Naveen