dispatch-trace: move dispatch trace pcap code to plugin
[vpp.git] / src / vat / ip_types.c
index cd08c54..8edcb13 100644 (file)
@@ -64,9 +64,12 @@ uword
 unformat_ip_prefix (unformat_input_t * input, va_list * args)
 {
   ip_prefix_t *a = va_arg (*args, ip_prefix_t *);
+  /* %d writes more than a u8 */
+  int plen;
   if (unformat (input, "%U/%d", unformat_ip_address, &ip_prefix_addr (a),
-               &ip_prefix_len (a)))
+               &plen))
     {
+      ip_prefix_len (a) = plen;
       if ((ip_prefix_version (a) == AF_IP4 && 32 < ip_prefix_len (a)) ||
          (ip_prefix_version (a) == AF_IP6 && 128 < ip_prefix_len (a)))
        {
@@ -511,16 +514,11 @@ ip6_prefix_max_address_host_order (ip6_address_t * ip, u8 plen,
 u32
 ip6_mask_to_preflen (ip6_address_t * mask)
 {
-  u8 first1, first0;
-  if (mask->as_u64[0] == 0 && mask->as_u64[1] == 0)
-    return 0;
-  first1 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[1]));
-  first0 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[0]));
-
-  if (first1 != 0)
-    return 128 - first1;
-  else
-    return 64 - first0;
+  if (mask->as_u64[1] != 0)
+    return 128 - log2_first_set (clib_net_to_host_u64 (mask->as_u64[1]));
+  if (mask->as_u64[0] != 0)
+    return 64 - log2_first_set (clib_net_to_host_u64 (mask->as_u64[0]));
+  return 0;
 }
 
 /*