summaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/api_format.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index c9c62c76e2c..d39a61a813a 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -7810,10 +7810,13 @@ api_tap_create_v2 (vat_main_t * vam)
vl_api_tap_create_v2_t *mp;
u8 mac_address[6];
u8 random_mac = 1;
- u8 name_set = 0;
- u8 *tap_name;
- u8 *net_ns = 0;
- u8 net_ns_set = 0;
+ u8 *tap_name = 0;
+ u8 *host_namespace = 0;
+ u8 *host_bridge = 0;
+ ip4_address_t host_ip4_addr;
+ u32 host_ip4_prefix_len = 0;
+ ip6_address_t host_ip6_addr;
+ u32 host_ip6_prefix_len = 0;
int ret;
int rx_ring_sz = 0, tx_ring_sz = 0;
@@ -7827,9 +7830,17 @@ api_tap_create_v2 (vat_main_t * vam)
random_mac = 0;
}
else if (unformat (i, "name %s", &tap_name))
- name_set = 1;
- else if (unformat (i, "host-ns %s", &net_ns))
- net_ns_set = 1;
+ ;
+ else if (unformat (i, "host-ns %s", &host_namespace))
+ ;
+ else if (unformat (i, "host-bridge %s", &host_bridge))
+ ;
+ else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
+ &host_ip4_addr, &host_ip4_prefix_len))
+ ;
+ else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
+ &host_ip6_addr, &host_ip6_prefix_len))
+ ;
else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
;
else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
@@ -7838,7 +7849,7 @@ api_tap_create_v2 (vat_main_t * vam)
break;
}
- if (name_set == 0)
+ if (tap_name == 0)
{
errmsg ("missing tap name. ");
return -99;
@@ -7848,11 +7859,26 @@ api_tap_create_v2 (vat_main_t * vam)
errmsg ("tap name too long. ");
return -99;
}
- if (vec_len (net_ns) > 63)
+ if (vec_len (host_namespace) > 63)
{
errmsg ("host name space too long. ");
return -99;
}
+ if (vec_len (host_bridge) > 63)
+ {
+ errmsg ("host bridge name too long. ");
+ return -99;
+ }
+ if (host_ip4_prefix_len > 32)
+ {
+ errmsg ("host ip4 prefix length not valid. ");
+ return -99;
+ }
+ if (host_ip6_prefix_len > 128)
+ {
+ errmsg ("host ip6 prefix length not valid. ");
+ return -99;
+ }
if (!is_pow2 (rx_ring_sz))
{
errmsg ("rx ring size must be power of 2. ");
@@ -7882,11 +7908,22 @@ api_tap_create_v2 (vat_main_t * vam)
mp->use_random_mac = random_mac;
clib_memcpy (mp->mac_address, mac_address, 6);
clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
- mp->net_ns_set = net_ns_set;
+ mp->host_namespace_set = host_namespace != 0;
+ mp->host_bridge_set = host_bridge != 0;
+ mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
+ mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
mp->rx_ring_sz = rx_ring_sz;
mp->tx_ring_sz = tx_ring_sz;
- if (net_ns)
- clib_memcpy (mp->net_ns, net_ns, vec_len (net_ns));
+ if (host_namespace)
+ clib_memcpy (mp->host_namespace, host_namespace,
+ vec_len (host_namespace));
+ if (host_bridge)
+ clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
+ if (host_ip4_prefix_len)
+ clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
+ if (host_ip4_prefix_len)
+ clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
+
vec_free (tap_name);