From 98dda61bc222aeccb754915954175d3ac8f8768d Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Thu, 13 Aug 2009 15:39:42 +0000 Subject: ospfd: Update SPF calculation for unnumbered links Add support for real unnumbered PtP interfaces in ospf_nexthop_calculation(). Add ospf_if_lookup_by_ifindex() to support Unnumbered PtP links. This version does not support: - Multiple numbered PtP interfaces with the same IP address between the same two routers. - Unnumbered PtP on just one end of the link. * ospfd/ospf_interface.c: Add ospf_if_lookup_by_ifindex(). * ospfd/ospf_interface.h: ditto. * ospfd/ospf_spf.c: ospf_nexthop_calculation (), call ospf_if_lookup_by_ifindex() for Unnumbered PtP links. --- ospfd/ospf_interface.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ospfd/ospf_interface.c') diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index afe3acf1..775b121f 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -479,6 +479,20 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src, return match; } + +struct ospf_interface * +ospf_if_lookup_by_ifindex(struct ospf_area *area, unsigned int ifindex) +{ + struct listnode *node; + struct ospf_interface *oi; + + for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi)) + { + if (oi->ifp->ifindex == ifindex) + return oi; + } + return NULL; +} void ospf_if_stream_set (struct ospf_interface *oi) -- cgit v1.2.3 From 472870f49a5c1eb18bfd30f1b06c1bff08ecd233 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Thu, 13 Aug 2009 15:39:43 +0000 Subject: ospfd: Optimize and improve SPF nexthop calculation Maintain router LSA positions in OSPF interface. Find the OSPF interface in nexthop_calculation using the position in the router LSA. This has the following advantages: - Multiple numbered PtP interfaces with the same IP address between the same two routers. - Use Unnumbered PtP on just one end of the link. - Faster OI lookup for the OSPF interface and only done once for PtoP links. *ospf_interface.h: (struct ospf_interface) Add storage for storing router LSA position. *ospf_interface.c: (ospf_if_lookup_by_lsa_pos) lookup OSPF I/F in an area using LSA position. (ospf_lsa_pos_set) assign LSA position to OSPF interface. *ospf_lsa.c: (router_lsa_link_set) Call ospf_lsa_pos_set() to record LSA position. *ospf_spf.c: (ospf_spf_next) Count and pass along lsa position. (ospf_nexthop_calculation) Add lsa position argument. call ospf_if_lookup_by_lsa_pos() for OSFP interface handle. Clean up and remove all calls ospf_if_is_configured() the rest. Adjust a few debug logs. --- ospfd/ospf_interface.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'ospfd/ospf_interface.c') diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 775b121f..67e34f21 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -211,7 +211,9 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p) } else return oi; - + + ospf_lsa_pos_set(-1,-1, oi); /* delete position in router LSA */ + /* Set zebra interface pointer. */ oi->ifp = ifp; oi->address = p; @@ -397,6 +399,29 @@ ospf_if_exists (struct ospf_interface *oic) return NULL; } +/* Lookup OSPF interface by router LSA posistion */ +struct ospf_interface * +ospf_if_lookup_by_lsa_pos (struct ospf_area *area, int lsa_pos) +{ + struct listnode *node; + struct ospf_interface *oi; + + for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi)) + { + if (lsa_pos >= oi->lsa_pos_beg && lsa_pos < oi->lsa_pos_end) + return oi; + } + return NULL; +} + +/* Set OSPF interface position in router LSA */ +void +ospf_lsa_pos_set(int pos_beg, int pos_end, struct ospf_interface *oi) +{ + oi->lsa_pos_beg = pos_beg; + oi->lsa_pos_end = pos_end; +} + struct ospf_interface * ospf_if_lookup_by_local_addr (struct ospf *ospf, struct interface *ifp, struct in_addr address) @@ -817,6 +842,7 @@ ospf_if_down (struct ospf_interface *oi) return 0; OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); + ospf_lsa_pos_set(-1, -1, oi); /* delete position in router LSA */ /* Shutdown packet reception and sending */ ospf_if_stream_unset (oi); -- cgit v1.2.3