diff options
Diffstat (limited to 'lib/ovs-router.c')
-rw-r--r-- | lib/ovs-router.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/ovs-router.c b/lib/ovs-router.c index 0f1103b0e..ad8bd629e 100644 --- a/lib/ovs-router.c +++ b/lib/ovs-router.c @@ -54,6 +54,10 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER; static struct classifier cls; +/* By default, use the system routing table. For system-independent testing, + * the unit tests disable using the system routing table. */ +static bool use_system_routing_table = true; + struct ovs_router_entry { struct cls_rule cr; char output_bridge[IFNAMSIZ]; @@ -71,13 +75,22 @@ ovs_router_entry_cast(const struct cls_rule *cr) return cr ? CONTAINER_OF(cr, struct ovs_router_entry, cr) : NULL; } +/* Disables obtaining routes from the system routing table, for testing + * purposes. */ +void +ovs_router_disable_system_routing_table(void) +{ + use_system_routing_table = false; +} + static bool ovs_router_lookup_fallback(const struct in6_addr *ip6_dst, char output_bridge[], struct in6_addr *src6, struct in6_addr *gw6) { ovs_be32 src; - if (!route_table_fallback_lookup(ip6_dst, output_bridge, gw6)) { + if (!use_system_routing_table + || !route_table_fallback_lookup(ip6_dst, output_bridge, gw6)) { return false; } if (netdev_get_in4_by_name(output_bridge, (struct in_addr *)&src)) { @@ -238,7 +251,9 @@ void ovs_router_insert(uint32_t mark, const struct in6_addr *ip_dst, uint8_t plen, const char output_bridge[], const struct in6_addr *gw) { - ovs_router_insert__(mark, plen, ip_dst, plen, output_bridge, gw); + if (use_system_routing_table) { + ovs_router_insert__(mark, plen, ip_dst, plen, output_bridge, gw); + } } static void |