@@ -284,6 +284,12 @@ static void vl_api_mactime_add_del_range_t_handler
284284 if (clib_bihash_search_8_8 (lut , & kv , & kv ) < 0 )
285285 found = 0 ;
286286
287+ if (mp -> no_udp_10001 )
288+ clib_warning ("no_udp_10001 is deprecated and ignored" );
289+
290+ /* Null Terminate the device name, for sure... */
291+ mp -> device_name [ARRAY_LEN (mp -> device_name ) - 1 ] = 0 ;
292+
287293 /* Add an entry? */
288294 if (mp -> is_add )
289295 {
@@ -298,7 +304,6 @@ static void vl_api_mactime_add_del_range_t_handler
298304 vlib_validate_combined_counter (& mm -> drop_counters ,
299305 dp - mm -> devices );
300306 vlib_zero_combined_counter (& mm -> drop_counters , dp - mm -> devices );
301- mp -> device_name [ARRAY_LEN (mp -> device_name ) - 1 ] = 0 ;
302307 dp -> device_name = format (0 , "%s%c" , mp -> device_name , 0 );
303308 memcpy (dp -> mac_address , mp -> mac_address , sizeof (mp -> mac_address ));
304309 for (i = 0 ; i < clib_net_to_host_u32 (mp -> count ); i ++ )
@@ -327,18 +332,21 @@ static void vl_api_mactime_add_del_range_t_handler
327332 if (mp -> allow )
328333 dp -> flags = MACTIME_DEVICE_FLAG_STATIC_ALLOW ;
329334 }
330- if (mp -> no_udp_10001 )
331- dp -> flags |= MACTIME_DEVICE_FLAG_DROP_UDP_10001 ;
332335
333336 dp -> data_quota = data_quota ;
334337
335338 /* Add the hash table entry */
336339 kv .value = dp - mm -> devices ;
337340 clib_bihash_add_del_8_8 (lut , & kv , 1 /* is_add */ );
338341 }
339- else /* add more ranges, flags, etc. */
342+ else
340343 {
341344 dp = pool_elt_at_index (mm -> devices , kv .value );
345+ /* Reset the range vector */
346+ vec_reset_length (dp -> ranges );
347+ /* And the device name */
348+ vec_free (dp -> device_name );
349+ dp -> device_name = format (0 , "%s%c" , mp -> device_name , 0 );
342350
343351 for (i = 0 ; i < clib_net_to_host_u32 (mp -> count ); i ++ )
344352 {
@@ -366,8 +374,6 @@ static void vl_api_mactime_add_del_range_t_handler
366374 if (mp -> allow )
367375 dp -> flags = MACTIME_DEVICE_FLAG_STATIC_ALLOW ;
368376 }
369- if (mp -> no_udp_10001 )
370- dp -> flags |= MACTIME_DEVICE_FLAG_DROP_UDP_10001 ;
371377
372378 dp -> data_quota = data_quota ;
373379 }
@@ -386,6 +392,7 @@ static void vl_api_mactime_add_del_range_t_handler
386392 /* Remove it from the lookup table */
387393 clib_bihash_add_del_8_8 (lut , & kv , 0 /* is_add */ );
388394 vec_free (dp -> ranges );
395+ vec_free (dp -> device_name );
389396 pool_put (mm -> devices , dp );
390397 }
391398
@@ -532,6 +539,9 @@ show_mactime_command_fn (vlib_main_t * vm,
532539 (0 ,
533540 "Feature not initialized, suggest 'help mactime enable-disable'..." );
534541
542+ if (pool_elts (mm -> devices ) == 0 )
543+ return clib_error_return (0 , "No device data..." );
544+
535545 vec_reset_length (mm -> arp_cache_copy );
536546 /* Walk all ip4 neighbours on all interfaces */
537547 ip_neighbor_walk (AF_IP4 , ~0 , mactime_ip_neighbor_copy , mm );
0 commit comments