diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2014-04-24 19:29:07 +0200 |
|---|---|---|
| committer | Christian Franke <chris@opensourcerouting.org> | 2017-01-30 13:51:50 +0100 |
| commit | 0964ad9cecf3e60c843c3e55a26eecb522a98a29 (patch) | |
| tree | 16bcb8e70088671ca1c5e4bbfb9a1eb40d965924 /lib/table.c | |
| parent | 61cdc88971be14970d2d9ce56275387a246ac1c3 (diff) | |
lib: add second-level route_table for srcdest
IPv6 srcdest routes need to be keyed by both destination and source
prefix. Since the lookup order is destination first, the simplest thing
to do here is to add a second route_table to destination entries, which
then contain source entries. Sadly, the result is somewhat confusing
since a route_node might now be either a source node or a destination
node.
There are helper functions to get source and destination prefix from a
given route node (which can be either a destination or a source route).
The following bits have been added by Christian Franke
<chris@opensourcerouting.org>:
- make srcdest routing table reusable by moving it into lib
- make the srcdest routing table structure more opaque
- implement a srcdest routing table iterator
- fix a refcounting issue in src_node_lookup
- match route_node_lookup behavior with srcdest_rnode_lookup
- add accessor for the route_node table and table_info
- add string formatter srcdest_rnode2str
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
[v3: adapted for cmaster-next as of 2016-12-05]
Diffstat (limited to 'lib/table.c')
| -rw-r--r-- | lib/table.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/table.c b/lib/table.c index f80f3e81f0..075c5584a8 100644 --- a/lib/table.c +++ b/lib/table.c @@ -28,7 +28,7 @@ #include "sockunion.h" DEFINE_MTYPE( LIB, ROUTE_TABLE, "Route table") -DEFINE_MTYPE_STATIC(LIB, ROUTE_NODE, "Route node") +DEFINE_MTYPE( LIB, ROUTE_NODE, "Route node") static void route_node_delete (struct route_node *); static void route_table_free (struct route_table *); @@ -400,6 +400,14 @@ route_node_delete (struct route_node *node) node->table->count--; + /* WARNING: FRAGILE CODE! + * route_node_free may have the side effect of free'ing the entire table. + * this is permitted only if table->count got decremented to zero above, + * because in that case parent will also be NULL, so that we won't try to + * delete a now-stale parent below. + * + * cf. srcdest_srcnode_destroy() in zebra/zebra_rib.c */ + route_node_free (node->table, node); /* If parent node is stub then delete it also. */ |
