Skip to content

Commit

Permalink
Added support for tunneling and updated tunnel schema (sonic-net#49)
Browse files Browse the repository at this point in the history
* Added support for tunneling and updated tunnel schema:
 - added tunneldecaporch
 - changed orchdaemon and main to include tunneldecaporch
 - updated orchagent Makefile
  • Loading branch information
scsmncao authored and lguohan committed Aug 22, 2016
1 parent d13a829 commit fa786a0
Show file tree
Hide file tree
Showing 10 changed files with 644 additions and 4 deletions.
16 changes: 16 additions & 0 deletions doc/swss-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,28 @@ and reflects the LAG ports into the redis under: `LAG_TABLE:<team0>:port`
###TUNNEL_DECAP_TABLE
; Stores tunnel decap rules
key = TUNNEL_DECAP_TABLE:name
;field value
tunnel_type = "IPINIP"
dst_ip = IP1,IP2 ;IP addresses separated by ","
dscp_mode = "uniform" / "pipe"
ecn_mode = "copy_from_outer" / "standard" ;standard: Behavior defined in RFC 6040 section 4.2
ttl_mode = "uniform" / "pipe"

IP = dec-octet "." dec-octet "." dec-octet "." dec-octet

Example:
127.0.0.1:6379> hgetall TUNNEL_DECAP_TABLE:NETBOUNCER
1) "dscp_mode"
2) "uniform"
3) "dst_ip"
4) "127.0.0.1"
5) "ecn_mode"
6) "copy_from_outer"
7) "ttl_mode"
8) "uniform"
9) "tunnel_type"
10) "IPINIP"

---------------------------------------------

###LLDP_ENTRY_TABLE
Expand Down
2 changes: 1 addition & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else
DBGFLAGS = -g
endif

orchagent_SOURCES = main.cpp orchdaemon.cpp orch.cpp routeorch.cpp neighorch.cpp intfsorch.cpp portsorch.cpp copporch.cpp
orchagent_SOURCES = main.cpp orchdaemon.cpp orch.cpp routeorch.cpp neighorch.cpp intfsorch.cpp portsorch.cpp copporch.cpp tunneldecaporch.cpp

orchagent_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
orchagent_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
Expand Down
20 changes: 20 additions & 0 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ sai_next_hop_group_api_t* sai_next_hop_group_api;
sai_route_api_t* sai_route_api;
sai_lag_api_t* sai_lag_api;
sai_policer_api_t* sai_policer_api;
sai_tunnel_api_t* sai_tunnel_api;

map<string, string> gProfileMap;
sai_object_id_t gVirtualRouterId;
sai_object_id_t underlayIfId;
MacAddress gMacAddress;

const char *test_profile_get_value (
Expand Down Expand Up @@ -86,6 +88,7 @@ void initSaiApi()
sai_api_query(SAI_API_ROUTE, (void **)&sai_route_api);
sai_api_query(SAI_API_LAG, (void **)&sai_lag_api);
sai_api_query(SAI_API_POLICER, (void **)&sai_policer_api);
sai_api_query(SAI_API_TUNNEL, (void **)&sai_tunnel_api);

sai_log_set(SAI_API_SWITCH, SAI_LOG_NOTICE);
sai_log_set(SAI_API_VIRTUAL_ROUTER, SAI_LOG_NOTICE);
Expand All @@ -99,6 +102,7 @@ void initSaiApi()
sai_log_set(SAI_API_ROUTE, SAI_LOG_NOTICE);
sai_log_set(SAI_API_LAG, SAI_LOG_NOTICE);
sai_log_set(SAI_API_POLICER, SAI_LOG_NOTICE);
sai_log_set(SAI_API_TUNNEL, SAI_LOG_NOTICE);
}

int main(int argc, char **argv)
Expand Down Expand Up @@ -174,6 +178,22 @@ int main(int argc, char **argv)

SWSS_LOG_NOTICE("Get switch virtual router ID %llx\n", gVirtualRouterId);

// create the underlay router interface to create a LOOPBACK type router interface (encap)
sai_attribute_t underlay_intf_attrs[2];
underlay_intf_attrs[0].id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID;
underlay_intf_attrs[0].value.oid = gVirtualRouterId;
underlay_intf_attrs[1].id = SAI_ROUTER_INTERFACE_ATTR_TYPE;
underlay_intf_attrs[1].value.s32 = SAI_ROUTER_INTERFACE_TYPE_LOOPBACK;

status = sai_router_intfs_api->create_router_interface(&underlayIfId, 2, underlay_intf_attrs);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to create underlay router interface %d", status);
return false;
}

SWSS_LOG_NOTICE("Created underlay router interface ID %llx\n", underlayIfId);

OrchDaemon *orchDaemon = new OrchDaemon();
if (!orchDaemon->init())
{
Expand Down
5 changes: 3 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ bool OrchDaemon::init()
NeighOrch *neigh_orch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, ports_orch);
RouteOrch *route_orch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, ports_orch, neigh_orch);
CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME);

m_orchList = { ports_orch, intfs_orch, neigh_orch, route_orch, copp_orch };
TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME);

m_orchList = { ports_orch, intfs_orch, neigh_orch, route_orch, copp_orch, tunnel_decap_orch };
m_select = new Select();

return true;
Expand Down
1 change: 1 addition & 0 deletions orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "neighorch.h"
#include "routeorch.h"
#include "copporch.h"
#include "tunneldecaporch.h"

using namespace swss;

Expand Down
Loading

0 comments on commit fa786a0

Please sign in to comment.