summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_packet.c
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2009-11-29 11:08:36 +0000
committerDavid Lamparter <equinox@diac24.net>2010-02-03 23:30:19 +0100
commitd1ccf9fd4d0f4e9901742be90cdccdfe0889c28f (patch)
treefe7e147d038882ce921fac392c7b2011f9975933 /ospfd/ospf_packet.c
parentdca6c883ea6219460efbe3dadde4b8b9cb12c845 (diff)
downloadquagga-d1ccf9fd4d0f4e9901742be90cdccdfe0889c28f.tar.bz2
quagga-d1ccf9fd4d0f4e9901742be90cdccdfe0889c28f.tar.xz
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.
Diffstat (limited to 'ospfd/ospf_packet.c')
-rw-r--r--ospfd/ospf_packet.c51
1 files changed, 28 insertions, 23 deletions
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;