Skip to content

Commit

Permalink
2005-10-18 Paul Jakma <paul.jakma@sun.com>
Browse files Browse the repository at this point in the history
	* (general) SPF memory management cleanup and fix for rare
	  double-free bug.
	* ospf_spf.h: (struct vertex_parent) New struct to hold parent
	  specific data, eg the backlink and the parent vertex pointer,
	  and point to the appropriate general struct vertex_nexthop.
	  (struct vertex_nexthop) remove parent vertex pointer, so
	  this struct can be shared across vertices.
	  (struct vertex) rename list child to list children. Remove
	  list of nexthops, replace with list of vertex_parents.
	* ospf_spf.c: (update_stat) trivial, remove cast from void *.
	  (vertex_nexthop_new) remove init of parent - field is gone
          from struct vertex_nexthop.
          (ospf_canonical_nexthops_free) Remove the canonical
          vertex_nexthop memory objects. These are the vertex_nexthops
          attached to the first level of router vertices from the root.
          (vertex_parent_new) new function, create a vertex_parent.
          (vertex_parent_free) ditto, but free it.
          (ospf_vertex_new) Update to match changes to struct vertex.
          (ospf_vertex_free) Recursively free a struct vertex and its
          children. The parent list is used as a reference count.
          vertex_nexthops must be free seperately, if required.
          (ospf_vertex_dump) update to match struct vertex changes.
          Print out backlink of parents too.
          (ospf_vertex_add_parent) ditto.
          (ospf_lsa_has_link) update comment.
          (ospf_nexthop_add_unique) removed, not needed anymore.
          (ospf_nexthop_merge) ditto.
          (ospf_spf_consider_nexthop) renamed to ospf_spf_add_parent.
          Simplified to just create vertex_parent and add it.
          (ospf_spf_flush_parents) new function, flush out the parent
	  list.
	  (ospf_nexthop_calculation) Take the relevant route_lsa_link
	  as an argument, which simplifies things and removes the need
	  for the hack in ospf_nexthop_add_unique - ospf_spf_next
	  already knew exactly which link the cost calculated was for.
	  Update to match struct vertex changes too.
	  (ospf_spf_next) Don't create a vertex for W unnecessarily, if
          it's there's a vertex already created for W, use it, and
          hence there's no need to free it either.
          Update some manipulation/comparisons of distance to match.
          Flush the parent list if a lower cost path is found.
          (ospf_spf_route_free) unused, removed.
          (ospf_spf_dump) match the struct vertex changes, and dump the
          ifname if possible.
          (ospf_spf_calculate) At end of SPF, free the canonical nexthops
          and call ospf_vertex_free on the root vertex to free the
	  entire tree.
	* ospf_interface.c: (ospf_vl_set_params) match struct vertex
          changes.
        * ospf_route.c: (ospf_intra_route_add) ditto
          (ospf_route_copy_nexthops_from_vertex) ditto
	* memtypes.c: (memory_list_ospf) Add MTYPE_OSPF_VERTEX_PARENT.
  • Loading branch information
paul committed Oct 18, 2005
1 parent 3623814 commit eb3da6d
Show file tree
Hide file tree
Showing 7 changed files with 374 additions and 323 deletions.
4 changes: 4 additions & 0 deletions lib/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2005-10-18 Paul Jakma <paul.jakma@sun.com>

* memtypes.c: (memory_list_ospf) Add MTYPE_OSPF_VERTEX_PARENT.

2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

* zebra.h: Declare new functions zebra_route_string() and
Expand Down
3 changes: 2 additions & 1 deletion lib/memtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* The script is sensitive to the format (though not whitespace), see
* the top of memtypes.awk for more details.
*
* $Id: memtypes.c,v 1.7 2005/09/21 14:06:35 paul Exp $
* $Id: memtypes.c,v 1.8 2005/10/18 04:20:33 paul Exp $
*/

#include "zebra.h"
Expand Down Expand Up @@ -182,6 +182,7 @@ struct memory_list memory_list_ospf[] =
{ MTYPE_OSPF_PACKET, "OSPF packet" },
{ MTYPE_OSPF_FIFO, "OSPF FIFO queue" },
{ MTYPE_OSPF_VERTEX, "OSPF vertex" },
{ MTYPE_OSPF_VERTEX_PARENT, "OSPF vertex parent", },
{ MTYPE_OSPF_NEXTHOP, "OSPF nexthop" },
{ MTYPE_OSPF_PATH, "OSPF path" },
{ MTYPE_OSPF_VL_DATA, "OSPF VL data" },
Expand Down
54 changes: 54 additions & 0 deletions ospfd/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
2005-10-18 Paul Jakma <paul.jakma@sun.com>

* (general) SPF memory management cleanup and fix for rare
double-free bug.
* ospf_spf.h: (struct vertex_parent) New struct to hold parent
specific data, eg the backlink and the parent vertex pointer,
and point to the appropriate general struct vertex_nexthop.
(struct vertex_nexthop) remove parent vertex pointer, so
this struct can be shared across vertices.
(struct vertex) rename list child to list children. Remove
list of nexthops, replace with list of vertex_parents.
* ospf_spf.c: (update_stat) trivial, remove cast from void *.
(vertex_nexthop_new) remove init of parent - field is gone
from struct vertex_nexthop.
(ospf_canonical_nexthops_free) Remove the canonical
vertex_nexthop memory objects. These are the vertex_nexthops
attached to the first level of router vertices from the root.
(vertex_parent_new) new function, create a vertex_parent.
(vertex_parent_free) ditto, but free it.
(ospf_vertex_new) Update to match changes to struct vertex.
(ospf_vertex_free) Recursively free a struct vertex and its
children. The parent list is used as a reference count.
vertex_nexthops must be free seperately, if required.
(ospf_vertex_dump) update to match struct vertex changes.
Print out backlink of parents too.
(ospf_vertex_add_parent) ditto.
(ospf_lsa_has_link) update comment.
(ospf_nexthop_add_unique) removed, not needed anymore.
(ospf_nexthop_merge) ditto.
(ospf_spf_consider_nexthop) renamed to ospf_spf_add_parent.
Simplified to just create vertex_parent and add it.
(ospf_spf_flush_parents) new function, flush out the parent
list.
(ospf_nexthop_calculation) Take the relevant route_lsa_link
as an argument, which simplifies things and removes the need
for the hack in ospf_nexthop_add_unique - ospf_spf_next
already knew exactly which link the cost calculated was for.
Update to match struct vertex changes too.
(ospf_spf_next) Don't create a vertex for W unnecessarily, if
it's there's a vertex already created for W, use it, and
hence there's no need to free it either.
Update some manipulation/comparisons of distance to match.
Flush the parent list if a lower cost path is found.
(ospf_spf_route_free) unused, removed.
(ospf_spf_dump) match the struct vertex changes, and dump the
ifname if possible.
(ospf_spf_calculate) At end of SPF, free the canonical nexthops
and call ospf_vertex_free on the root vertex to free the
entire tree.
* ospf_interface.c: (ospf_vl_set_params) match struct vertex
changes.
* ospf_route.c: (ospf_intra_route_add) ditto
(ospf_route_copy_nexthops_from_vertex) ditto

2005-10-11 Paul Jakma <paul.jakma@sun.com>

* ospf_api.c: sign warnings.
Expand Down
12 changes: 6 additions & 6 deletions ospfd/ospf_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
int changed = 0;
struct ospf_interface *voi;
struct listnode *node;
struct vertex_nexthop *nh;
struct vertex_parent *vp = NULL;
int i;
struct router_lsa *rl;

Expand All @@ -1012,9 +1012,9 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
changed = 1;
}

for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nh))
for (ALL_LIST_ELEMENTS_RO (v->parents, node, vp))
{
vl_data->out_oi = (struct ospf_interface *) nh->oi;
vl_data->out_oi = vp->nexthop->oi;

if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
&vl_data->out_oi->address->u.prefix4))
Expand All @@ -1031,12 +1031,12 @@ ospf_vl_set_params (struct ospf_vl_data *vl_data, struct vertex *v)
/* use SPF determined backlink index in struct vertex
* for virtual link destination address
*/
if (v->backlink >= 0)
if (vp && vp->backlink >= 0)
{
if (!IPV4_ADDR_SAME (&vl_data->peer_addr,
&rl->link[v->backlink].link_data))
&rl->link[vp->backlink].link_data))
changed = 1;
vl_data->peer_addr = rl->link[v->backlink].link_data;
vl_data->peer_addr = rl->link[vp->backlink].link_data;
}
else
{
Expand Down
11 changes: 7 additions & 4 deletions ospfd/ospf_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ ospf_intra_route_add (struct route_table *rt, struct vertex *v,
struct ospf_route *or;
struct prefix_ipv4 p;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
struct vertex_parent *parent;
struct listnode *node, *nnode;

p.family = AF_INET;
Expand Down Expand Up @@ -306,10 +306,10 @@ ospf_intra_route_add (struct route_table *rt, struct vertex *v,
{
or->type = OSPF_DESTINATION_NETWORK;

for (ALL_LIST_ELEMENTS (v->nexthop, node, nnode, nexthop))
for (ALL_LIST_ELEMENTS (v->parents, node, nnode, parent))
{
path = ospf_path_new ();
path->nexthop = nexthop->router;
path->nexthop = parent->nexthop->router;
listnode_add (or->paths, path);
}
}
Expand Down Expand Up @@ -799,11 +799,14 @@ ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
struct listnode *node;
struct ospf_path *path;
struct vertex_nexthop *nexthop;
struct vertex_parent *vp;

assert (to->paths);

for (ALL_LIST_ELEMENTS_RO (v->nexthop, node, nexthop))
for (ALL_LIST_ELEMENTS_RO (v->parents, node, vp))
{
nexthop = vp->nexthop;

if (nexthop->oi != NULL)
{
if (! ospf_path_exist (to->paths, nexthop->router, nexthop->oi))
Expand Down
Loading

0 comments on commit eb3da6d

Please sign in to comment.