summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-04-25 16:16:00 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-04-28 07:59:19 +0000
commit5445f5fd9b9d020b285d48e571c86528932ac071 (patch)
treecaf9dc716ad1b6456d53d13f8a55eba773a89c52 /src/vnet
parentc903793662e16309a67161a58500f6a1a15d37f6 (diff)
vhost: Disallow duplicate path name for vhost interface
When creating or modifying a vhost interface, verify if the path name already existed and reject the command. Change-Id: I8b2d33b77c847f774492874f7d194fa72c488479 Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/virtio/vhost-user.c36
-rw-r--r--src/vnet/devices/virtio/vhost-user.h2
2 files changed, 37 insertions, 1 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 3ac76977099..acc7bf8205e 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -1349,6 +1349,8 @@ vhost_user_init (vlib_main_t * vm)
vum->random = random_default_seed ();
+ mhash_init_c_string (&vum->if_index_by_sock_name, sizeof (uword));
+
return 0;
}
@@ -2525,6 +2527,7 @@ static void
vhost_user_term_if (vhost_user_intf_t * vui)
{
int q;
+ vhost_user_main_t *vum = &vhost_user_main;
// Delete configured thread pinning
vec_reset_length (vui->workers);
@@ -2546,6 +2549,9 @@ vhost_user_term_if (vhost_user_intf_t * vui)
vui->unix_server_index = ~0;
unlink (vui->sock_filename);
}
+
+ mhash_unset (&vum->if_index_by_sock_name, vui->sock_filename,
+ &vui->if_index);
}
int
@@ -2692,13 +2698,14 @@ vhost_user_vui_init (vnet_main_t * vnm,
vnet_sw_interface_t *sw;
sw = vnet_get_hw_sw_interface (vnm, vui->hw_if_index);
int q;
+ vhost_user_main_t *vum = &vhost_user_main;
if (server_sock_fd != -1)
{
unix_file_t template = { 0 };
template.read_function = vhost_user_socksvr_accept_ready;
template.file_descriptor = server_sock_fd;
- template.private_data = vui - vhost_user_main.vhost_user_interfaces; //hw index
+ template.private_data = vui - vum->vhost_user_interfaces; //hw index
vui->unix_server_index = unix_file_add (&unix_main, &template);
}
else
@@ -2715,6 +2722,9 @@ vhost_user_vui_init (vnet_main_t * vnm,
vui->unix_file_index = ~0;
vui->log_base_addr = 0;
vui->operation_mode = operation_mode;
+ vui->if_index = vui - vum->vhost_user_interfaces;
+ mhash_set_mem (&vum->if_index_by_sock_name, vui->sock_filename,
+ &vui->if_index, 0);
for (q = 0; q < VHOST_VRING_MAX_N; q++)
vhost_user_vring_init (vui, q);
@@ -2842,6 +2852,7 @@ vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm,
int rv = 0;
int server_sock_fd = -1;
vhost_user_main_t *vum = &vhost_user_main;
+ uword *if_index;
if ((operation_mode != VHOST_USER_POLLING_MODE) &&
(operation_mode != VHOST_USER_INTERRUPT_MODE))
@@ -2852,6 +2863,17 @@ vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm,
return VNET_API_ERROR_INVALID_ARGUMENT;
}
+ if_index = mhash_get (&vum->if_index_by_sock_name, (void *) sock_filename);
+ if (if_index)
+ {
+ if (sw_if_index)
+ {
+ vui = &vum->vhost_user_interfaces[*if_index];
+ *sw_if_index = vui->sw_if_index;
+ }
+ return VNET_API_ERROR_IF_ALREADY_EXISTS;
+ }
+
if (is_server)
{
if ((rv =
@@ -2901,6 +2923,7 @@ vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm,
int server_sock_fd = -1;
int rv = 0;
vnet_hw_interface_t *hwif;
+ uword *if_index;
if ((operation_mode != VHOST_USER_POLLING_MODE) &&
(operation_mode != VHOST_USER_INTERRUPT_MODE))
@@ -2909,8 +2932,19 @@ vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm,
hwif->dev_class_index != vhost_user_dev_class.index)
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ if (sock_filename == NULL || !(strlen (sock_filename) > 0))
+ return VNET_API_ERROR_INVALID_ARGUMENT;
+
vui = vec_elt_at_index (vum->vhost_user_interfaces, hwif->dev_instance);
+ /*
+ * Disallow changing the interface to have the same path name
+ * as other interface
+ */
+ if_index = mhash_get (&vum->if_index_by_sock_name, (void *) sock_filename);
+ if (if_index && (*if_index != vui->if_index))
+ return VNET_API_ERROR_IF_ALREADY_EXISTS;
+
// First try to open server socket
if (is_server)
if ((rv = vhost_user_init_server_sock (sock_filename,
diff --git a/src/vnet/devices/virtio/vhost-user.h b/src/vnet/devices/virtio/vhost-user.h
index 80f58a20018..56b65477b19 100644
--- a/src/vnet/devices/virtio/vhost-user.h
+++ b/src/vnet/devices/virtio/vhost-user.h
@@ -228,6 +228,7 @@ typedef struct
u32 unix_file_index;
char sock_filename[256];
int sock_errno;
+ uword if_index;
u32 hw_if_index, sw_if_index;
//Feature negotiation
@@ -311,6 +312,7 @@ typedef struct
typedef struct
{
+ mhash_t if_index_by_sock_name;
u32 mtu_bytes;
vhost_user_intf_t *vhost_user_interfaces;
u32 *show_dev_instance_by_real_dev_instance;
163 164 165 166 167 168 169 170 171 172 173 174
# Copyright (c) 2017 Cisco and/or its affiliates.
# 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.

*** Settings ***
| Resource | resources/libraries/robot/performance/performance_setup.robot
| ...
| Force Tags | 3_NODE_SINGLE_LINK_TOPO | PERFTEST | HW_ENV | NDRPDRDISC
| ... | NIC_Intel-X520-DA2 | ETH | IP4FWD | FEATURE | ACL | ACL_STATELESS
| ... | OACL | ACL50 | 100_FLOWS
| ...
| Suite Setup | Run Keywords
| ... | Set up 3-node performance topology with DUT's NIC model | L3
| ... | Intel-X520-DA2
| ... | AND | Set up performance test suite with ACL
| Suite Teardown | Tear down 3-node performance topology
| ...
| Test Setup | Set up performance test
| ...
| Test Teardown | Tear down performance test with ACL
| ... | ${min_rate}pps | ${framesize} | ${traffic_profile}
| ...
| Documentation | *RFC2544: Packet throughput IPv4 test cases with ACL*
| ...
| ... | *[Top] Network Topologies:* TG-DUT1-DUT2-TG 3-node circular topology\
| ... | with single links between nodes.
| ... | *[Enc] Packet Encapsulations:* Eth-IPv4-UDP for L2 switching of IPv4.
| ... | *[Cfg] DUT configuration:* DUT1 is configured with L2 bridge domain\
| ... | and MAC learning enabled. DUT2 is configured with L2 cross-connects.\
| ... | Required ACL rules are applied to input paths of both DUT1 intefaces.\
| ... | DUT1 and DUT2 are tested with 2p10GE NIC X520 Niantic by Intel.\
| ... | *[Ver] TG verification:* TG finds and reports throughput NDR (Non Drop\
| ... | Rate) with zero packet loss tolerance or throughput PDR (Partial Drop\
| ... | Rate) with non-zero packet loss tolerance (LT) expressed in percentage\
| ... | of packets transmitted. NDR and PDR are discovered for different\
| ... | Ethernet L2 frame sizes using either binary search or linear search\
| ... | algorithms with configured starting rate and final step that determines\
| ... | throughput measurement resolution. Test packets are generated by TG on\
| ... | links to DUTs. TG traffic profile contains two L3 flow-groups\
| ... | (flow-group per direction, ${flows_per_dir} flows per flow-group) with\
| ... | all packets containing Ethernet header, IPv4 header with UDP header and\
| ... | static payload. MAC addresses are matching MAC addresses of the TG node\
| ... | interfaces.
| ... | *[Ref] Applicable standard specifications:* RFC2544.

*** Variables ***
# X520-DA2 bandwidth limit
| ${s_limit}= | ${10000000000}

# ACL test setup
| ${acl_action}= | permit
| ${acl_apply_type}= | output
| ${no_hit_aces_number}= | 50
| ${flows_per_dir}= | 100

# starting points for non-hitting ACLs
| ${src_ip_start}= | 30.30.30.1
| ${dst_ip_start}= | 40.40.40.1
| ${ip_step}= | ${1}
| ${sport_start}= | ${1000}
| ${dport_start}= | ${1000}
| ${port_step}= | ${1}
| ${trex_stream1_subnet}= | 10.10.10.0/24
| ${trex_stream2_subnet}= | 20.20.20.0/24

*** Keywords ***
| Discover NDR or PDR for IPv4 routing with ACLs
| | [Arguments] | ${wt} | ${rxq} | ${framesize} | ${min_rate} | ${search_type}
| | Set Test Variable | ${framesize}
| | Set Test Variable | ${min_rate}
| | ${max_rate}= | Calculate pps | ${s_limit} | ${framesize}
| | ${binary_min}= | Set Variable | ${min_rate}
| | ${binary_max}= | Set Variable | ${max_rate}
| | ${threshold}= | Set Variable | ${min_rate}
| | Given Add '${wt}' worker threads and '${rxq}' rxqueues in 3-node single-link circular topology
| | And Add PCI devices to DUTs in 3-node single link topology
| | ${get_framesize}= | Get Frame Size | ${framesize}
| | And Run Keyword If | ${get_framesize} < ${1522} | Add no multi seg to all DUTs
| | And Apply startup configuration on all VPP DUTs
| | ${ip_nr}= | Set Variable | 10
| | When Initialize IPv4 routing for '${ip_nr}' addresses with IPv4 ACLs on DUT1 in 3-node circular topology
| | ${traffic_profile}= | Set Variable | trex-sl-3n-ethip4udp-10u10p-conc
| | Set Test Variable | ${traffic_profile}
| | Then Run Keyword If | '${search_type}' == 'NDR'
| | ... | Find NDR using binary search and pps
| | ... | ${framesize} | ${binary_min} | ${binary_max} | ${traffic_profile}
| | ... | ${min_rate} | ${max_rate} | ${threshold}
| | ... | ELSE IF | '${search_type}' == 'PDR'
| | ... | Find PDR using binary search and pps
| | ... | ${framesize} | ${binary_min} | ${binary_max} | ${traffic_profile}
| | ... | ${min_rate} | ${max_rate} | ${threshold}
| | ... | ${perf_pdr_loss_acceptance} | ${perf_pdr_loss_acceptance_type}

*** Test Cases ***
| tc01-64B-1t1c-ethip4udp-ip4base-oacl50-stateless-flows100-ndrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 1 thread, 1 phy core, 1 receive queue per NIC port.
| | ... | [Ver] Find NDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps.
| | ...
| | [Tags] | 64B | 1T1C | STHREAD | NDRDISC
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=1 | rxq=1 | framesize=${64} | min_rate=${50000} | search_type=NDR

| tc02-64B-1t1c-ethip4udp-ip4base-oacl50-stateless-flows100-pdrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 1 thread, 1 phy core, 1 receive queue per NIC port.
| | ... | [Ver] Find PDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps, LT=0.5%.
| | ...
| | [Tags] | 64B | 1T1C | STHREAD | PDRDISC | SKIP_PATCH
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=1 | rxq=1 | framesize=${64} | min_rate=${50000} | search_type=PDR

| tc03-64B-2t2c-ethip4udp-ip4base-oacl50-stateless-flows100-ndrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 2 threads, 2 phy cores, 1 receive queue per NIC port.
| | ... | [Ver] Find NDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps.
| | ...
| | [Tags] | 64B | 2T2C | MTHREAD | NDRDISC
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=2 | rxq=1 | framesize=${64} | min_rate=${50000} | search_type=NDR

| tc04-64B-2t2c-ethip4udp-ip4base-oacl50-stateless-flows100-pdrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 2 threads, 2 phy cores, 1 receive queue per NIC port.
| | ... | [Ver] Find PDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps, LT=0.5%.
| | ...
| | [Tags] | 64B | 2T2C | MTHREAD | PDRDISC | SKIP_PATCH
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=2 | rxq=1 | framesize=${64} | min_rate=${50000} | search_type=PDR

| tc05-64B-4t4c-ethip4udp-ip4base-oacl50-stateless-flows100-ndrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 4 threads, 4 phy cores, 2 receive queues per NIC port.
| | ... | [Ver] Find NDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps.
| | ...
| | [Tags] | 64B | 4T4C | MTHREAD | NDRDISC
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=4 | rxq=2 | framesize=${64} | min_rate=${50000} | search_type=NDR

| tc06-64B-4t4c-ethip4udp-ip4base-oacl50-stateless-flows100-pdrdisc
| | [Documentation]
| | ... | [Cfg] DUT runs IPv4 routing config with ACL with\
| | ... | 4 threads, 4 phy cores, 2 receive queues per NIC port.
| | ... | [Ver] Find PDR for 64 Byte frames using binary search start at 10GE\
| | ... | linerate, step 50kpps, LT=0.5%.
| | ...
| | [Tags] | 64B | 4T4C | MTHREAD | PDRDISC | SKIP_PATCH
| | ...
| | [Template] | Discover NDR or PDR for IPv4 routing with ACLs
| | wt=4 | rxq=2 | framesize=${64} | min_rate=${50000} | search_type=PDR