tap: add the static assert for api flags
[vpp.git] / src / vnet / devices / tap / tapv2_api.c
index e0121a8..ea61852 100644 (file)
@@ -126,6 +126,25 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
       ap->host_mtu_set = 1;
     }
 
+  STATIC_ASSERT (((int) TAP_API_FLAG_GSO == (int) TAP_FLAG_GSO),
+                "tap gso api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_CSUM_OFFLOAD ==
+                 (int) TAP_FLAG_CSUM_OFFLOAD),
+                "tap checksum offload api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_PERSIST == (int) TAP_FLAG_PERSIST),
+                "tap persist api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_ATTACH == (int) TAP_FLAG_ATTACH),
+                "tap attach api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_TUN == (int) TAP_FLAG_TUN),
+                "tap tun api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_GRO_COALESCE ==
+                 (int) TAP_FLAG_GRO_COALESCE),
+                "tap gro coalesce api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_PACKED == (int) TAP_FLAG_PACKED),
+                "tap packed api flag mismatch");
+  STATIC_ASSERT (((int) TAP_API_FLAG_IN_ORDER ==
+                 (int) TAP_FLAG_IN_ORDER), "tap in-order api flag mismatch");
+
   ap->tap_flags = ntohl (mp->tap_flags);
 
   tap_create_if (vm, ap);
@@ -134,7 +153,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
   /* If a tag was supplied... */
   if (vl_api_string_len (&mp->tag))
     {
-      u8 *tag = format (0, "%s%c", vl_api_from_api_string (&mp->tag), 0);
+      u8 *tag = vl_api_from_api_to_new_vec (mp, &mp->tag);
       vnet_set_sw_interface_tag (vnm, tag, ap->sw_if_index);
     }
 
@@ -164,8 +183,6 @@ vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
 
   rv = tap_delete_if (vm, sw_if_index);
 
-
-
   rmp = vl_msg_api_alloc (sizeof (*rmp));
   rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_V2_REPLY);
   rmp->context = mp->context;
@@ -234,8 +251,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)
@@ -243,9 +260,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);
 }