mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 05:47:55 +00:00
ovs-router: non-Linux support
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 <yamamoto@valinux.co.jp> Acked-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
parent
6595fb00f0
commit
88ffdc93c8
@ -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:
|
||||
|
@ -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 \
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 . */
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user