2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

ovs-vswitchd: Do not use system routing table with --disable-system.

The --disable-system option indicates that the user wants to avoid using
the host's datapath.  This is also a good indication that the user does
not want to use other host resources such as the routing table, so this
commit implements that.

This fixes a failure in the test "ptap - recirculate after packet_type
change" when the host routing table contained an entry that affected the
generated flow.  Without this patch, the commands:

led to a failure in that test.

Reported-by: Timothy Redaelli <tredaelli@redhat.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-March/046406.html
Tested-By: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ben Pfaff
2018-03-31 17:12:55 -07:00
parent 966574598a
commit 898d7b0524
3 changed files with 22 additions and 2 deletions

View File

@@ -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 ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
static struct classifier cls; 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 ovs_router_entry {
struct cls_rule cr; struct cls_rule cr;
char output_bridge[IFNAMSIZ]; 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; 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 static bool
ovs_router_lookup_fallback(const struct in6_addr *ip6_dst, char output_bridge[], ovs_router_lookup_fallback(const struct in6_addr *ip6_dst, char output_bridge[],
struct in6_addr *src6, struct in6_addr *gw6) struct in6_addr *src6, struct in6_addr *gw6)
{ {
ovs_be32 src; 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; return false;
} }
if (netdev_get_in4_by_name(output_bridge, (struct in_addr *)&src)) { 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, ovs_router_insert(uint32_t mark, const struct in6_addr *ip_dst, uint8_t plen,
const char output_bridge[], const struct in6_addr *gw) 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 static void

View File

@@ -34,6 +34,9 @@ void ovs_router_insert(uint32_t mark, const struct in6_addr *ip_dst,
uint8_t plen, uint8_t plen,
const char output_bridge[], const struct in6_addr *gw); const char output_bridge[], const struct in6_addr *gw);
void ovs_router_flush(void); void ovs_router_flush(void);
void ovs_router_disable_system_routing_table(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -38,6 +38,7 @@
#include "openflow/openflow.h" #include "openflow/openflow.h"
#include "ovsdb-idl.h" #include "ovsdb-idl.h"
#include "ovs-rcu.h" #include "ovs-rcu.h"
#include "ovs-router.h"
#include "openvswitch/poll-loop.h" #include "openvswitch/poll-loop.h"
#include "simap.h" #include "simap.h"
#include "stream-ssl.h" #include "stream-ssl.h"
@@ -219,6 +220,7 @@ parse_options(int argc, char *argv[], char **unixctl_pathp)
case OPT_DISABLE_SYSTEM: case OPT_DISABLE_SYSTEM:
dp_blacklist_provider("system"); dp_blacklist_provider("system");
ovs_router_disable_system_routing_table();
break; break;
case '?': case '?':