Skip to content

Commit

Permalink
ovs-router: non-Linux support
Browse files Browse the repository at this point in the history
Refactor ovs-router so that it can work with non-Linux platforms
at least in some extent, using the existing route-table code as
a fallback.  Known restriction: for such platforms, "ovs/router/show"
command does not show "Cached" kernel routes.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
yamt committed Dec 10, 2014
1 parent 6595fb0 commit 88ffdc9
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 64 deletions.
2 changes: 0 additions & 2 deletions README-native-tunneling.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ There are following commands that shows internal tables:
Tunneling related commands:
===========================
Tunnel routing table:
These commands are only available on Linux platform.

To Add route:
ovs-appctl ovs/route/add <IP address>/<prefix length> <output-bridge-name> <gw>
To see all routes configured:
Expand Down
3 changes: 1 addition & 2 deletions lib/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ lib_libopenvswitch_la_SOURCES = \
lib/ovs-rcu.c \
lib/ovs-rcu.h \
lib/ovs-router.h \
lib/ovs-router.c \
lib/ovs-thread.c \
lib/ovs-thread.h \
lib/ovsdb-data.c \
Expand Down Expand Up @@ -331,8 +332,6 @@ lib_libopenvswitch_la_SOURCES += \
lib/netlink-socket.h \
lib/ovs-numa.c \
lib/ovs-numa.h \
lib/ovs-router.c \
lib/ovs-router-linux.h \
lib/rtnetlink-link.c \
lib/rtnetlink-link.h \
lib/route-table.c \
Expand Down
40 changes: 0 additions & 40 deletions lib/ovs-router-linux.h

This file was deleted.

4 changes: 2 additions & 2 deletions lib/ovs-router.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "packets.h"
#include "seq.h"
#include "ovs-router.h"
#include "ovs-router-linux.h"
#include "ovs-thread.h"
#include "route-table.h"
#include "unixctl.h"
#include "util.h"

Expand Down Expand Up @@ -76,7 +76,7 @@ ovs_router_lookup(ovs_be32 ip_dst, char output_bridge[], ovs_be32 *gw)
*gw = p->gw;
return true;
}
return false;
return route_table_fallback_lookup(ip_dst, output_bridge, gw);
}

static void
Expand Down
3 changes: 3 additions & 0 deletions lib/ovs-router.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ extern "C" {

bool ovs_router_lookup(ovs_be32 ip_dst, char out_dev[], ovs_be32 *gw);
void ovs_router_init(void);
void ovs_router_insert(ovs_be32 ip_dst, uint8_t plen,
const char output_bridge[], ovs_be32 gw);
void ovs_router_flush(void);
#ifdef __cplusplus
}
#endif
Expand Down
8 changes: 2 additions & 6 deletions lib/route-table-bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "util.h"

bool
ovs_router_lookup(ovs_be32 ip, char name[], ovs_be32 *gw)
route_table_fallback_lookup(ovs_be32 ip, char name[], ovs_be32 *gw)
{
struct {
struct rt_msghdr rtm;
Expand Down Expand Up @@ -116,6 +116,7 @@ route_table_get_change_seq(void)
void
route_table_init(void)
{
ovs_router_init();
}

void
Expand All @@ -127,8 +128,3 @@ void
route_table_wait(void)
{
}

void
ovs_router_init(void)
{
}
11 changes: 4 additions & 7 deletions lib/route-table-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@
#include "route-table.h"

bool
ovs_router_lookup(ovs_be32 ip_dst OVS_UNUSED, char output_bridge[] OVS_UNUSED,
ovs_be32 *gw)
route_table_fallback_lookup(ovs_be32 ip_dst OVS_UNUSED,
char output_bridge[] OVS_UNUSED,
ovs_be32 *gw)
{
*gw = 0;
return false;
}

void
ovs_router_init(void)
{
}

uint64_t
route_table_get_change_seq(void)
{
Expand All @@ -40,6 +36,7 @@ route_table_get_change_seq(void)
void
route_table_init(void)
{
ovs_router_init();
}

void
Expand Down
10 changes: 9 additions & 1 deletion lib/route-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "netlink-socket.h"
#include "ofpbuf.h"
#include "ovs-router.h"
#include "ovs-router-linux.h"
#include "rtnetlink-link.h"
#include "vlog.h"

Expand Down Expand Up @@ -264,6 +263,15 @@ route_map_clear(void)
ovs_router_flush();
}

bool
route_table_fallback_lookup(ovs_be32 ip_dst OVS_UNUSED,
char output_bridge[] OVS_UNUSED,
ovs_be32 *gw)
{
*gw = 0;
return false;
}


/* name_table . */

Expand Down
1 change: 1 addition & 0 deletions lib/route-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ uint64_t route_table_get_change_seq(void);
void route_table_init(void);
void route_table_run(void);
void route_table_wait(void);
bool route_table_fallback_lookup(ovs_be32, char [], ovs_be32 *);

#endif /* route-table.h */
4 changes: 0 additions & 4 deletions tests/tunnel-push-pop.at
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ AT_BANNER([tunnel_push_pop])

AT_SETUP([tunnel_push_pop - action])

dnl ovs router is commands are only supported on Linux for now.
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_SKIP_IF([test "$IS_BSD" = "yes"])

OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1])
AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy], [0])
AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \
Expand Down

0 comments on commit 88ffdc9

Please sign in to comment.