diff options
author | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2009-11-29 11:08:39 +0000 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-04 02:19:14 +0100 |
commit | 950867369b038a2d71394314ce4193c5c1c063b6 (patch) | |
tree | 3c0bd872c095ebde092d7a502f0c81819dbd9fb6 /ospfd/ospf_packet.c | |
parent | aadbf3af3385d9bd394beafa17aa1a50c6141dfc (diff) | |
download | quagga-950867369b038a2d71394314ce4193c5c1c063b6.tar.bz2 quagga-950867369b038a2d71394314ce4193c5c1c063b6.tar.xz |
ospfd: delete address in struct ospf_neighbor
address is the same as src so it is redundant.
This will save both memory and CPU when processing Hellos.
Diffstat (limited to 'ospfd/ospf_packet.c')
-rw-r--r-- | ospfd/ospf_packet.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 22cce7a3..bc00def4 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -745,7 +745,6 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, struct ospf_hello *hello; struct ospf_neighbor *nbr; int old_state; - struct prefix p; /* increment statistics. */ oi->hello_in++; @@ -765,20 +764,15 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, return; } - /* get neighbor prefix. */ - p.family = AF_INET; - p.prefixlen = ip_masklen (hello->network_mask); - p.u.prefix4 = iph->ip_src; - /* Compare network mask. */ /* Checking is ignored for Point-to-Point and Virtual link. */ if (oi->type != OSPF_IFTYPE_POINTOPOINT && oi->type != OSPF_IFTYPE_VIRTUALLINK) - if (oi->address->prefixlen != p.prefixlen) + if (oi->address->prefixlen != ip_masklen (hello->network_mask)) { zlog_warn ("Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).", inet_ntoa(ospfh->router_id), IF_NAME(oi), - (int)oi->address->prefixlen, (int)p.prefixlen); + (int)oi->address->prefixlen, (int)ip_masklen (hello->network_mask)); return; } @@ -873,7 +867,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, } /* get neighbour struct */ - nbr = ospf_nbr_get (oi, ospfh, iph, &p); + nbr = ospf_nbr_get (oi, ospfh, iph); /* neighbour must be valid, ospf_nbr_get creates if none existed */ assert (nbr); @@ -924,17 +918,17 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, /* If neighbor itself declares DR and no BDR exists, cause event BackupSeen */ if (oi->state == ISM_Waiting && - IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router) && + IPV4_ADDR_SAME (&nbr->src, &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))) + if ((IPV4_ADDR_SAME (&nbr->src, &hello->d_router) && + IPV4_ADDR_CMP (&nbr->src, &nbr->d_router)) || + (IPV4_ADDR_CMP (&nbr->src, &hello->d_router) && + IPV4_ADDR_SAME (&nbr->src, &nbr->d_router))) { OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); goto done; @@ -942,16 +936,16 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, /* neighbor itself declares BDR. */ if (oi->state == ISM_Waiting && - IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router)) + IPV4_ADDR_SAME (&nbr->src, &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))) + if ((IPV4_ADDR_SAME (&nbr->src, &hello->bd_router) && + IPV4_ADDR_CMP (&nbr->src, &nbr->bd_router)) || + (IPV4_ADDR_CMP (&nbr->src, &hello->bd_router) && + IPV4_ADDR_SAME (&nbr->src, &nbr->bd_router))) { OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); goto done; @@ -1265,7 +1259,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh, CHECK_FLAG (nbr->options, OSPF_OPTION_O) ? "" : "NOT "); if (! CHECK_FLAG (nbr->options, OSPF_OPTION_O) - && IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4)) + && IPV4_ADDR_SAME (&DR (oi), &nbr->src)) { zlog_warn ("DR-neighbor[%s] is NOT opaque-capable; " "Opaque-LSAs cannot be reliably advertised " @@ -3052,7 +3046,7 @@ ospf_hello_reply_timer (struct thread *thread) zlog (NULL, LOG_DEBUG, "NSM[%s:%s]: Timer (hello-reply timer expire)", IF_NAME (nbr->oi), inet_ntoa (nbr->router_id)); - ospf_hello_send_sub (nbr->oi, &nbr->address.u.prefix4); + ospf_hello_send_sub (nbr->oi, &nbr->src); return 0; } @@ -3097,8 +3091,8 @@ ospf_hello_send (struct ospf_interface *oi) Designated Router and the Backup Designated Router (if they exist). */ if (PRIORITY(oi) == 0 && - IPV4_ADDR_CMP(&DR(oi), &nbr->address.u.prefix4) && - IPV4_ADDR_CMP(&BDR(oi), &nbr->address.u.prefix4)) + IPV4_ADDR_CMP(&DR(oi), &nbr->src) && + IPV4_ADDR_CMP(&BDR(oi), &nbr->src)) continue; /* If the router is eligible to become Designated Router, it @@ -3114,7 +3108,7 @@ ospf_hello_send (struct ospf_interface *oi) struct ospf_packet *op_dup; op_dup = ospf_packet_dup(op); - op_dup->dst = nbr->address.u.prefix4; + op_dup->dst = nbr->src; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op_dup); @@ -3167,7 +3161,7 @@ ospf_db_desc_send (struct ospf_neighbor *nbr) if (oi->type == OSPF_IFTYPE_POINTOPOINT) op->dst.s_addr = htonl (OSPF_ALLSPFROUTERS); else - op->dst = nbr->address.u.prefix4; + op->dst = nbr->src; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op); @@ -3229,7 +3223,7 @@ ospf_ls_req_send (struct ospf_neighbor *nbr) if (oi->type == OSPF_IFTYPE_POINTOPOINT) op->dst.s_addr = htonl (OSPF_ALLSPFROUTERS); else - op->dst = nbr->address.u.prefix4; + op->dst = nbr->src; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op); @@ -3436,7 +3430,7 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag) else if (oi->type == OSPF_IFTYPE_POINTOPOINT) p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); else if (flag == OSPF_SEND_PACKET_DIRECT) - p.prefix = nbr->address.u.prefix4; + p.prefix = nbr->src; else if (oi->state == ISM_DR || oi->state == ISM_Backup) p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); else if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT) @@ -3516,7 +3510,7 @@ ospf_ls_ack_send (struct ospf_neighbor *nbr, struct ospf_lsa *lsa) struct ospf_interface *oi = nbr->oi; if (listcount (oi->ls_ack_direct.ls_ack) == 0) - oi->ls_ack_direct.dst = nbr->address.u.prefix4; + oi->ls_ack_direct.dst = nbr->src; listnode_add (oi->ls_ack_direct.ls_ack, ospf_lsa_lock (lsa)); @@ -3544,7 +3538,7 @@ ospf_ls_ack_send_delayed (struct ospf_interface *oi) for (ALL_LIST_ELEMENTS_RO (oi->nbrs, node, nbr)) if (nbr != oi->nbr_self && nbr->state >= NSM_Exchange) while (listcount (oi->ls_ack)) - ospf_ls_ack_send_list (oi, oi->ls_ack, nbr->address.u.prefix4); + ospf_ls_ack_send_list (oi, oi->ls_ack, nbr->src); return; } if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |