aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/devices/tap/FEATURE.yaml3
-rw-r--r--src/vnet/devices/tap/tapv2.api12
-rw-r--r--src/vnet/devices/tap/tapv2_api.c10
-rw-r--r--test/test_tap.py14
-rw-r--r--test/vpp_devices.py14
5 files changed, 31 insertions, 22 deletions
diff --git a/src/vnet/devices/tap/FEATURE.yaml b/src/vnet/devices/tap/FEATURE.yaml
index a143d333a48..5d1726d3b0b 100644
--- a/src/vnet/devices/tap/FEATURE.yaml
+++ b/src/vnet/devices/tap/FEATURE.yaml
@@ -7,8 +7,5 @@ features:
- attach to existing tap at host
description: "Create a tap v2 device interface, which connects to a
tap interface on the host system."
-missing:
-
- - API dump filtering by sw_if_index
state: production
properties: [API, CLI, STATS, MULTITHREAD]
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index 9113458852f..61b6720a0d3 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -40,8 +40,8 @@ enum tap_flags {
@param use_random_mac - let the system generate a unique mac address
@param mac_address - mac addr to assign to the interface if use_random not set
@param num_rx_queues - number of rx queues
- @param tx_ring_sz - the number of entries of TX ring
- @param rx_ring_sz - the number of entries of RX ring
+ @param tx_ring_sz - the number of entries of TX ring, optional, default is 256 entries, must be power of 2
+ @param rx_ring_sz - the number of entries of RX ring, optional, default is 256 entries, must be power of 2
@param host_mtu_set - host MTU should be set
@param host_mtu_size - host MTU size
@param host_mac_addr_set - host side interface mac address should be set
@@ -57,7 +57,7 @@ enum tap_flags {
@param tap_flags - flags for the TAP interface creation
@param host_if_name_set - host side interface name should be set
@param host_if_name - host side interface name
- @param host_namespace_set - host namespece should be set
+ @param host_namespace_set - host namespace should be set
@param host_namespace - host namespace to attach interface to
@param host_bridge_set - host bridge should be set
@param host_bridge - host bridge to attach interface to
@@ -71,8 +71,8 @@ define tap_create_v2
bool use_random_mac [default=true];
vl_api_mac_address_t mac_address;
u8 num_rx_queues [default=1];
- u16 tx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
- u16 rx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
+ u16 tx_ring_sz [default=256];
+ u16 rx_ring_sz [default=256];
bool host_mtu_set;
u32 host_mtu_size;
bool host_mac_addr_set;
@@ -120,7 +120,7 @@ autoreply define tap_delete_v2
};
/** \brief Dump tap interfaces request
- @param sw_if_index - filter by sw_if_index UNIMPLEMENTED
+ @param sw_if_index - filter by sw_if_index
*/
define sw_interface_tap_v2_dump
{
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 9e09459c9ab..05679377d2a 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -232,8 +232,8 @@ vl_api_sw_interface_tap_v2_dump_t_handler (vl_api_sw_interface_tap_v2_dump_t *
return;
filter_sw_if_index = htonl (mp->sw_if_index);
- if (filter_sw_if_index != ~0)
- return; /* UNIMPLEMENTED */
+ if (mp->sw_if_index != ~0)
+ VALIDATE_SW_IF_INDEX (mp);
rv = tap_dump_ifs (&tapifs);
if (rv)
@@ -241,9 +241,11 @@ vl_api_sw_interface_tap_v2_dump_t_handler (vl_api_sw_interface_tap_v2_dump_t *
vec_foreach (tap_if, tapifs)
{
- tap_send_sw_interface_details (am, reg, tap_if, mp->context);
+ if ((filter_sw_if_index == ~0)
+ || (tap_if->sw_if_index == filter_sw_if_index))
+ tap_send_sw_interface_details (am, reg, tap_if, mp->context);
}
-
+ BAD_SW_IF_INDEX_LABEL;
vec_free (tapifs);
}
diff --git a/test/test_tap.py b/test/test_tap.py
index b47b1a275a0..0e5b315963e 100644
--- a/test/test_tap.py
+++ b/test/test_tap.py
@@ -19,6 +19,20 @@ class TestTAP(VppTestCase):
tap0.add_vpp_config()
self.assertTrue(tap0.query_vpp_config())
+ def test_tap_dump(self):
+ """ Test api dump w/ and w/o sw_if_index filtering"""
+ MAX_INSTANCES = 10
+ tap_instances = []
+ for instance in range(MAX_INSTANCES):
+ i = VppTAPInterface(self, tap_id=instance)
+ i.add_vpp_config()
+ tap_instances.append(i)
+ details = self.vapi.sw_interface_tap_v2_dump()
+ self.assertEqual(MAX_INSTANCES, len(details))
+ details = self.vapi.sw_interface_tap_v2_dump(
+ tap_instances[5].sw_if_index)
+ self.assertEqual(1, len(details))
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
diff --git a/test/vpp_devices.py b/test/vpp_devices.py
index 7e18eca65a9..9e272cafe32 100644
--- a/test/vpp_devices.py
+++ b/test/vpp_devices.py
@@ -14,16 +14,14 @@ class VppTAPInterface(VppInterface):
self._mac_addr = mac_addr
def get_vpp_dump(self):
- dump = self._test.vapi.sw_interface_tap_v2_dump()
- for entry in dump:
- if entry.sw_if_index == self.sw_if_index:
- return entry
+ dump = self._test.vapi.sw_interface_tap_v2_dump(
+ sw_if_index=self.sw_if_index)
+ return dump
def add_vpp_config(self):
- use_random_mac = True if self._mac_addr else False
reply = self._test.vapi.tap_create_v2(
id=self._tap_id,
- use_random_mac=use_random_mac,
+ use_random_mac=bool(self._mac_addr),
mac_address=self._mac_addr)
self.set_sw_if_index(reply.sw_if_index)
self._test.registry.register(self, self.test.logger)
@@ -33,9 +31,7 @@ class VppTAPInterface(VppInterface):
def query_vpp_config(self):
dump = self.get_vpp_dump()
- if dump:
- return True
- return False
+ return bool(dump)
def object_id(self):
return "tap-%s" % self._tap_id