diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2020-08-24 14:46:36 -0300 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2020-08-26 20:16:19 -0300 | 
| commit | 52a7c25e63a3d62072aa4fb1ed415fe478ce2ef9 (patch) | |
| tree | 1c5275b3da3fac27e478dd03781f183b870f21b5 /isisd/isis_route.c | |
| parent | 7b36d36e0ed2a233c3a908c9e821e3f45c68d4e8 (diff) | |
tests, isisd: add IS-IS SPF unit tests
Now that the IS-IS SPF code is more modular, write some unit tests
for it.
This commit includes a new test program called "test_isis_spf" which
can load any test topology (there are 13 different ones available)
and run SPF on any desired node. In the future this same test program
and topologies will also be used to test reverse SPF and TI-LFA.
The "test_common.c" file contains helper functions used to parse the
topology descriptions from "test_topologies.c" into LSP databases
that can be used as an input to the SPF code.
This commit also introduces the F_ISIS_UNIT_TEST flag which is used
to prevent the IS-IS code from scheduling any event when running
under the context of an unit test.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'isisd/isis_route.c')
| -rw-r--r-- | isisd/isis_route.c | 20 | 
1 files changed, 20 insertions, 0 deletions
diff --git a/isisd/isis_route.c b/isisd/isis_route.c index c12f9fd339..c83a7c04bb 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -159,6 +159,17 @@ static void adjinfo2nexthop(int family, struct list *nexthops,  	}  } +static void isis_route_add_dummy_nexthops(struct isis_route_info *rinfo, +					  const uint8_t *sysid) +{ +	struct isis_nexthop *nh; + +	nh = XCALLOC(MTYPE_ISIS_NEXTHOP, sizeof(struct isis_nexthop)); +	memcpy(nh->sysid, sysid, sizeof(nh->sysid)); +	isis_sr_nexthop_reset(&nh->sr); +	listnode_add(rinfo->nexthops, nh); +} +  static struct isis_route_info *isis_route_info_new(struct prefix *prefix,  						   struct prefix_ipv6 *src_p,  						   uint32_t cost, @@ -176,6 +187,15 @@ static struct isis_route_info *isis_route_info_new(struct prefix *prefix,  		struct isis_spf_adj *sadj = vadj->sadj;  		struct isis_adjacency *adj = sadj->adj; +		/* +		 * Create dummy nexthops when running SPF on a testing +		 * environment. +		 */ +		if (CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) { +			isis_route_add_dummy_nexthops(rinfo, sadj->id); +			continue; +		} +  		/* check for force resync this route */  		if (CHECK_FLAG(adj->circuit->flags,  			       ISIS_CIRCUIT_FLAPPED_AFTER_SPF))  | 
