diff options
author | Avneesh Sachdev <avneesh@opensourcerouting.org> | 2012-11-13 22:48:54 +0000 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2012-11-30 21:41:16 +0100 |
commit | 1b5ed1b054b955275bb7cf0f80fb7767094bc28b (patch) | |
tree | b8d886b85615f1b05679e6879c961e5dcb1496c4 /zebra/rib.h | |
parent | 9fd92e3c4bdcc78e0f0d94d53a2d4c7b0e893fcb (diff) | |
download | quagga-1b5ed1b054b955275bb7cf0f80fb7767094bc28b.tar.bz2 quagga-1b5ed1b054b955275bb7cf0f80fb7767094bc28b.tar.xz |
zebra: add way to determine VRF/AFI/SAFI of table
Add some code that allows us to determine which VRF and AFI/SAFI a
given RIB table corresponds to.
* zebra/rib.h
Add rib_table_info_t structure, which contains information about
the VRF, AFI and SAFI that a table is for.
* zebra/zebra_rib.c
- Add the vrf_table_create() function, which creates a table and
sets its 'info' pointer to a newly created rib_table_info_t.
The 'info' pointer allows us to go from a route_node or a table
to the associated vrf.
- vrf_alloc(): Use vrf_create_table() to create tables.
* lib/memtypes.c
Add memory type for rib_table_info_t.
Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/rib.h')
-rw-r--r-- | zebra/rib.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index 084f3516..c98d99a4 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -268,6 +268,24 @@ struct vrf struct route_table *stable[AFI_MAX][SAFI_MAX]; }; +/* + * rib_table_info_t + * + * Structure that is hung off of a route_table that holds information about + * the table. + */ +typedef struct rib_table_info_t_ +{ + + /* + * Back pointer to vrf. + */ + struct vrf *vrf; + afi_t afi; + safi_t safi; + +} rib_table_info_t; + extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int); extern struct nexthop *nexthop_ifname_add (struct rib *, char *); extern struct nexthop *nexthop_blackhole_add (struct rib *); @@ -362,6 +380,15 @@ extern int rib_gc_dest (struct route_node *rn); */ /* + * rib_table_info + */ +static inline rib_table_info_t * +rib_table_info (struct route_table *table) +{ + return (rib_table_info_t *) table->info; +} + +/* * rib_dest_from_rnode */ static inline rib_dest_t * @@ -417,4 +444,13 @@ rib_dest_table (rib_dest_t *dest) return dest->rnode->table; } +/* + * rib_dest_vrf + */ +static inline struct vrf * +rib_dest_vrf (rib_dest_t *dest) +{ + return rib_table_info (rib_dest_table (dest))->vrf; +} + #endif /*_ZEBRA_RIB_H */ |