summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/tapv2_api.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-12-01 13:34:24 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-02 10:11:25 +0000
commit91c6ef7cae2d20ca17a69003a44090614412c63f (patch)
tree28a0ae8030e840a0bc8f65e28f9d5bc2868bf39d /src/vnet/devices/virtio/tapv2_api.c
parent9fa1581cc40b656b6e00d77479fc2424cd50a126 (diff)
tap_v2: multiple improvements
- add support for assigning tap interface to the bridge - add support for assigning tap interface host side ip4 and ip6 address - host namespace can be specified as PID (pid:12345) or full path to file - automatically bring linux interface up Change-Id: I1cf7c3cad9a740e430cc1b9c2bb0aad0ba4cc8d8 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/tapv2_api.c')
-rw-r--r--src/vnet/devices/virtio/tapv2_api.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/vnet/devices/virtio/tapv2_api.c b/src/vnet/devices/virtio/tapv2_api.c
index 1c559e6c28e..7a6adca083f 100644
--- a/src/vnet/devices/virtio/tapv2_api.c
+++ b/src/vnet/devices/virtio/tapv2_api.c
@@ -53,7 +53,6 @@ static void
vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
- int rv;
vl_api_tap_create_v2_reply_t *rmp;
unix_shared_memory_queue_t *q;
tap_create_if_args_t _a, *ap = &_a;
@@ -69,10 +68,26 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
ap->rx_ring_sz = mp->rx_ring_sz;
ap->tx_ring_sz = mp->tx_ring_sz;
ap->sw_if_index = (u32) ~ 0;
- if (mp->net_ns_set)
- ap->net_ns = mp->net_ns;
- rv = tap_create_if (vm, ap);
+ if (mp->host_namespace_set)
+ ap->host_namespace = mp->host_namespace;
+
+ if (mp->host_bridge_set)
+ ap->host_bridge = mp->host_bridge;
+
+ if (mp->host_ip4_addr_set)
+ {
+ clib_memcpy (&ap->host_ip4_addr.as_u8, mp->host_ip4_addr, 4);
+ ap->host_ip4_prefix_len = mp->host_ip4_prefix_len;
+ }
+
+ if (mp->host_ip6_addr_set)
+ {
+ clib_memcpy (&ap->host_ip6_addr, mp->host_ip6_addr, 16);
+ ap->host_ip6_prefix_len = mp->host_ip6_prefix_len;
+ }
+
+ tap_create_if (vm, ap);
q = vl_api_client_index_to_input_queue (mp->client_index);
if (!q)
@@ -81,7 +96,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
rmp = vl_msg_api_alloc (sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_TAP_CREATE_V2_REPLY);
rmp->context = mp->context;
- rmp->retval = ntohl (rv);
+ rmp->retval = ntohl (ap->rv);
rmp->sw_if_index = ntohl (ap->sw_if_index);
vl_msg_api_send_shmem (q, (u8 *) & rmp);