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 <yamam...@valinux.co.jp> --- README-native-tunneling.md | 2 -- lib/automake.mk | 3 +-- lib/ovs-router-linux.h | 40 ---------------------------------------- lib/ovs-router.c | 4 ++-- lib/ovs-router.h | 3 +++ lib/route-table-bsd.c | 8 ++------ lib/route-table-stub.c | 11 ++++------- lib/route-table.c | 10 +++++++++- lib/route-table.h | 1 + tests/tunnel-push-pop.at | 4 ---- 10 files changed, 22 insertions(+), 64 deletions(-) delete mode 100644 lib/ovs-router-linux.h diff --git a/README-native-tunneling.md b/README-native-tunneling.md index 7666dcc..0ffd82b 100644 --- a/README-native-tunneling.md +++ b/README-native-tunneling.md @@ -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: diff --git a/lib/automake.mk b/lib/automake.mk index 0b2d823..a98f7cc 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -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 \ @@ -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 \ diff --git a/lib/ovs-router-linux.h b/lib/ovs-router-linux.h deleted file mode 100644 index f60f403..0000000 --- a/lib/ovs-router-linux.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014 Nicira, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OVS_TNL_ROUTER_LINUX_H -#define OVS_TNL_ROUTER_LINUX_H 1 - -#include <stddef.h> -#include <stdint.h> -#include <net/if.h> - -#include "packets.h" -#include "timeval.h" -#include "unixctl.h" -#include "util.h" - -#ifdef __cplusplus -extern "C" { -#endif - -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 - -#endif diff --git a/lib/ovs-router.c b/lib/ovs-router.c index e4f8a08..b095f68 100644 --- a/lib/ovs-router.c +++ b/lib/ovs-router.c @@ -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" @@ -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 diff --git a/lib/ovs-router.h b/lib/ovs-router.h index b0042cc..cc0ebc2 100644 --- a/lib/ovs-router.h +++ b/lib/ovs-router.h @@ -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 diff --git a/lib/route-table-bsd.c b/lib/route-table-bsd.c index 6d5fe5c..09f9894 100644 --- a/lib/route-table-bsd.c +++ b/lib/route-table-bsd.c @@ -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; @@ -116,6 +116,7 @@ route_table_get_change_seq(void) void route_table_init(void) { + ovs_router_init(); } void @@ -127,8 +128,3 @@ void route_table_wait(void) { } - -void -ovs_router_init(void) -{ -} diff --git a/lib/route-table-stub.c b/lib/route-table-stub.c index afbd79d..70b1a3d 100644 --- a/lib/route-table-stub.c +++ b/lib/route-table-stub.c @@ -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) { @@ -40,6 +36,7 @@ route_table_get_change_seq(void) void route_table_init(void) { + ovs_router_init(); } void diff --git a/lib/route-table.c b/lib/route-table.c index a1bc887..2c3f64c 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -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" @@ -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 . */ diff --git a/lib/route-table.h b/lib/route-table.h index 5dac29e..54d77f4 100644 --- a/lib/route-table.h +++ b/lib/route-table.h @@ -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 */ diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at index f9ea4c0..f1fac7f 100644 --- a/tests/tunnel-push-pop.at +++ b/tests/tunnel-push-pop.at @@ -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 \ -- 1.9.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev