Skip to content

Commit

Permalink
* Allocate mpls label serially in dpdk mode
Browse files Browse the repository at this point in the history
Mpls label were allocated at steps of 16 for dpdk mode
removing the same.
Closes-bug:#1554940

Change-Id: I257f5b5484da58c4f8c2b1d78fe5e92c1a8f5dd2
  • Loading branch information
naveen-n committed Mar 10, 2016
1 parent d0f708b commit 3231c66
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 14 deletions.
17 changes: 4 additions & 13 deletions src/vnsw/agent/oper/mpls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,10 @@ void MplsTable::CreateTableLabel(const Agent *agent,
}

void MplsTable::ReserveLabel(uint32_t start, uint32_t end) {
if (agent()->vrouter_on_host_dpdk() == true) {
//In case of vrouter running in dpdk mode,
//label allocation has to be done at interval
//of 16, for example 16,32 and 48 are valid label
//Reserver label 0
InsertAtIndex(start, NULL);
set_mpls_shift_bits(kDpdkShiftBits);
} else {
// We want to allocate labels from an offset
// Pre-allocate entries
for (unsigned int i = start; i < end; i++) {
InsertAtIndex(i, NULL);
}
// We want to allocate labels from an offset
// Pre-allocate entries
for (unsigned int i = start; i < end; i++) {
InsertAtIndex(i, NULL);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ test_scale_walk = AgentEnv.MakeTestCmd(env, 'test_scale_walk', flaky_agent_suite
service_instance_test = AgentEnv.MakeTestCmd(env, 'service_instance_test',
flaky_agent_suite)
test_ecmp6 = AgentEnv.MakeTestCmd(env, 'test_ecmp6', agent_suite)
test_dpdk_mpls = AgentEnv.MakeTestCmd(env, 'test_dpdk_mpls', agent_suite)

flaky_test = env.TestSuite('agent-flaky-test', flaky_agent_suite)
env.Alias('controller/src/vnsw/agent:flaky_test', flaky_test)
Expand Down
43 changes: 43 additions & 0 deletions src/vnsw/agent/test/test_dpdk_mpls.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "base/os.h"
#include "test/test_cmn_util.h"

void RouterIdDepInit(Agent *agent) {
}

class MplsTest : public ::testing::Test {

virtual void SetUp() {
agent_ = Agent::GetInstance();
client->WaitForIdle();
}

virtual void TearDown() {
client->WaitForIdle();
}
protected:
Agent *agent_;
};

TEST_F(MplsTest, agent_dpdk_mode) {
uint16_t label1 = agent_->mpls_table()->AllocLabel();
uint16_t label2 = agent_->mpls_table()->AllocLabel();

EXPECT_TRUE(label1 == MplsTable::kStartLabel);
EXPECT_TRUE(label2 == MplsTable::kStartLabel + 1);

agent_->mpls_table()->FreeLabel(label1);
agent_->mpls_table()->FreeLabel(label2);
}

int main(int argc, char *argv[]) {
GETUSERARGS();
client = TestInit(DEFAULT_VNSW_DPDK_CONFIG_FILE,
ksync_init, true, true, true,
AgentParam::kAgentStatsInterval,
AgentParam::kFlowStatsInterval, true, false);
int ret = RUN_ALL_TESTS();
client->WaitForIdle();
TestShutdown();
return ret;
}

3 changes: 2 additions & 1 deletion src/vnsw/agent/test/test_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ using namespace std;
#define TUN_INTF_CLONE_DEV "/dev/net/tun"
#define DEFAULT_VNSW_CONFIG_FILE "controller/src/vnsw/agent/test/vnswa_cfg.ini"
#define DEFAULT_VNSW_TSN_CONFIG_FILE "controller/src/vnsw/agent/test/vnswa_tsn_cfg.ini"

#define DEFAULT_VNSW_DPDK_CONFIG_FILE \
"controller/src/vnsw/agent/test/vnswa_dpdk_cfg.ini"
#define GETUSERARGS() \
bool ksync_init = false; \
char init_file[1024]; \
Expand Down
142 changes: 142 additions & 0 deletions src/vnsw/agent/test/vnswa_dpdk_cfg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#
# Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
#
# Vnswad configuration options
#

[CONTROL-NODE]
# IP address to be used to connect to control-node. If IP is not configured
# for server1, value provided by discovery service will be used.
server=127.0.0.1

[DEFAULT]
# IP address and port to be used to connect to collector. If these are not
# configured, value provided by discovery service will be used. Multiple
# IP:port strings separated by space can be provided
# collectors=127.0.0.1:8086

# Agent mode : can be vrouter / tsn / tor
# agent_mode=

# Aging time for flow-records in seconds
# flow_cache_timeout=0

# Hostname of compute-node. If this is not configured value from `hostname`
# will be taken
# hostname=

# Http server port for inspecting vnswad state (useful for debugging)
# http_server_port=8085

# Category for logging. Default value is '*'
# log_category=

# Local log file name
log_file=vrouter.log

# Log severity levels. Possible values are SYS_EMERG, SYS_ALERT, SYS_CRIT,
# SYS_ERR, SYS_WARN, SYS_NOTICE, SYS_INFO and SYS_DEBUG. Default is SYS_DEBUG
# log_level=SYS_DEBUG

# Enable/Disable local file logging. Possible values are 0 (disable) and 1 (enable)
# log_local=0

# Encapsulation type for tunnel. Possible values are MPLSoGRE, MPLSoUDP, VXLAN
# tunnel_type=

# Execute agent in headless mode where it does not flush config and route on losing
# connection with control node. In turn it continues with last good config.
# Possible values are true and false
# headless=

# DHCP relay mode (true or false) to determine if a DHCP request in fabric
# interface with an unconfigured IP should be relayed or not
# dhcp_relay_mode=

#Mode in which vrouter is running, possible values include dpdk, nic or empty
platform=dpdk

# Agent base directory
agent_base_directory=.

[DISCOVERY]
# IP address and port of discovery server
# port=5998
# server=127.0.0.1

# Number of control-nodes info to be provided by Discovery service. Possible
# values are 1 and 2
# max_control_nodes=1

[DNS]
# IP address and port to be used to connect to dns-node. Maximum of 2 IP
# addresses (separated by a space) can be provided. If no IP is configured then
# the value provided by discovery service will be used.
server=127.0.0.1:53

[HYPERVISOR]
# Hypervisor type. Possible values are kvm, xen and vmware
# type=kvm

# Link-local IP address and prefix in ip/prefix_len format (for xen)
# xen_ll_ip=

# Link-local interface name when hypervisor type is Xen
# xen_ll_interface=

# Physical interface name when hypervisor type is vmware
# vmware_physical_interface=

[FLOWS]
# Maximum flows allowed per VM (given as % of maximum system flows)
max_vm_flows=100
# Maximum number of link-local flows allowed across all VMs
max_system_linklocal_flows=3
# Maximum number of link-local flows allowed per VM
max_vm_linklocal_flows=2

[METADATA]
# Shared secret for metadata proxy service
metadata_proxy_secret=contrail

[NETWORKS]
# control-channel IP address used by WEB-UI to connect to vnswad to fetch
# required information
# control_network_ip=

[VIRTUAL-HOST-INTERFACE]
# name of virtual host interface
name=vhost0

# IP address and prefix in ip/prefix_len format
ip=10.1.1.1/24

# Gateway IP address for virtual host
gateway=10.1.1.254

# Physical interface name to which virtual host interface maps to
physical_interface=vnet0

[GATEWAY-0]
# Name of the routing_instance for which the gateway is being configured
# routing_instance=default-domain:admin:public:public

# Gateway interface name
# interface=vgw

# Virtual network ip blocks for which gateway service is required.
# ip_blocks=1.1.1.1/24

[GATEWAY-1]
# Name of the routing_instance for which the gateway is being configured
# routing_instance=default-domain:admin:public1:public1

# Gateway interface name
# interface=vgw1

# Virtual network ip blocks for which gateway service is required.
# ip_blocks=2.2.1.0/24, 2.2.2.0/24

# Routes to be exported in routing_instance
# routes= 10.10.10.1/24, 11.11.11.1/24

0 comments on commit 3231c66

Please sign in to comment.