summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2018-03-01 09:36:01 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-02 09:08:01 +0000
commit9e6356962a0cbb84f7ea9056b954d65aaa231a61 (patch)
tree457cf3c693fa15dad7cd7e11aaaf66e586560812 /src/vnet
parent204591d1bd754f6086edcf8b27a95beab929a78f (diff)
tapv2: CLI and binary API fixes
1. When interface create encouners an error (see test below), the same id cannot be used again. This is due to hash_set is called too early in the function. After the hash entry is set, there are different errors may cause the interface create to be aborted. But we didn't remove the hash entry when error is encountered. The fix is to move the hash_set call near the end which has no more "goto error" DBGvpp# create tap id 1 rx-ring-size 1021 tx-ring-size 1021 create tap id 1 rx-ring-size 1021 tx-ring-size 1021 create tap: ring size must be power of 2 DBGvpp# create tap id 1 rx-ring-size 1024 tx-ring-size 1024 create tap id 1 rx-ring-size 1024 tx-ring-size 1024 create tap: interface already exists DBGvpp# 2. multiple issues exist with api_format.c with the below command binary-api tap_create_v2 id 4 hw-addr 90:e2:ba:76:cf:2f rx-ring-size 1024 tx-ring-size 1024 - hw_addr is not taken due to the test for random mac is inverted - id is an integer, not a string - integer values were not converted to network format Change-Id: I5a669d702a80ad158517df46f0ab089e4d0d692e Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/tap/tap.c4
-rw-r--r--src/vnet/devices/tap/tapv2_api.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index eb5a7a9eb2e..8005b347391 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -130,8 +130,6 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
vif->tap_fd = -1;
vif->id = args->id;
- hash_set (tm->dev_instance_by_interface_id, vif->id, vif->dev_instance);
-
if ((vif->fd = open ("/dev/vhost-net", O_RDWR | O_NONBLOCK)) < 0)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_1;
@@ -383,6 +381,8 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
goto error;
}
+ hash_set (tm->dev_instance_by_interface_id, vif->id, vif->dev_instance);
+
sw = vnet_get_hw_sw_interface (vnm, vif->hw_if_index);
vif->sw_if_index = sw->sw_if_index;
args->sw_if_index = vif->sw_if_index;
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 34472c0ab28..c6da0c9deae 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -59,7 +59,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
memset (ap, 0, sizeof (*ap));
- ap->id = mp->id;
+ ap->id = ntohl (mp->id);
if (!mp->use_random_mac)
{
clib_memcpy (ap->mac_addr, mp->mac_address, 6);