From d1ccf9fd4d0f4e9901742be90cdccdfe0889c28f Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Sun, 29 Nov 2009 11:08:36 +0000 Subject: ospfd: ospf_hello() should only kick state machine once. The 2 last bullets in RFC 2328, section 10.5 are mutually exclusive, make is so. --- ospfd/ospf_packet.c | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 1066e64f..f0cba5c4 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -902,10 +902,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, (old_state == NSM_Down || old_state == NSM_Attempt)) { OSPF_NSM_EVENT_EXECUTE (nbr, NSM_OneWayReceived); - nbr->priority = hello->priority; - nbr->d_router = hello->d_router; - nbr->bd_router = hello->bd_router; - return; + goto done; } if (ospf_nbr_bidirectional (&oi->ospf->router_id, hello->neighbors, @@ -917,42 +914,50 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, else { OSPF_NSM_EVENT_EXECUTE (nbr, NSM_OneWayReceived); - /* Set neighbor information. */ - nbr->priority = hello->priority; - nbr->d_router = hello->d_router; - nbr->bd_router = hello->bd_router; - return; + goto done; } + /* Neighbor priority check. */ + if (nbr->priority >= 0 && nbr->priority != hello->priority) + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + /* If neighbor itself declares DR and no BDR exists, cause event BackupSeen */ - if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router)) - if (hello->bd_router.s_addr == 0 && oi->state == ISM_Waiting) - OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen); - - /* neighbor itself declares BDR. */ if (oi->state == ISM_Waiting && - IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router)) - OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen); - + IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router) && + hello->bd_router.s_addr == 0) + { + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen); + goto done; + } /* had not previously. */ if ((IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router) && IPV4_ADDR_CMP (&nbr->address.u.prefix4, &nbr->d_router)) || (IPV4_ADDR_CMP (&nbr->address.u.prefix4, &hello->d_router) && IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->d_router))) - OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + { + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + goto done; + } + /* neighbor itself declares BDR. */ + if (oi->state == ISM_Waiting && + IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router)) + { + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen); + goto done; + } /* had not previously. */ if ((IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router) && IPV4_ADDR_CMP (&nbr->address.u.prefix4, &nbr->bd_router)) || (IPV4_ADDR_CMP (&nbr->address.u.prefix4, &hello->bd_router) && IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->bd_router))) - OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); - - /* Neighbor priority check. */ - if (nbr->priority >= 0 && nbr->priority != hello->priority) - OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + { + OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); + goto done; + } + done: /* Set neighbor information. */ nbr->priority = hello->priority; nbr->d_router = hello->d_router; -- cgit v1.2.3