- vnet_hw_interface_t * hi;
- if (vec_len (vxm->free_vxlan_tunnel_hw_if_indices) > 0)
- {
- vnet_interface_main_t * im = &vnm->interface_main;
- hw_if_index = vxm->free_vxlan_tunnel_hw_if_indices
- [vec_len (vxm->free_vxlan_tunnel_hw_if_indices)-1];
- _vec_len (vxm->free_vxlan_tunnel_hw_if_indices) -= 1;
-
- hi = vnet_get_hw_interface (vnm, hw_if_index);
- hi->dev_instance = t - vxm->tunnels;
- hi->hw_instance = hi->dev_instance;
-
- /* clear old stats of freed tunnel before reuse */
- sw_if_index = hi->sw_if_index;
- vnet_interface_counter_lock(im);
- vlib_zero_combined_counter
- (&im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX], sw_if_index);
- vlib_zero_combined_counter
- (&im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX], sw_if_index);
- vlib_zero_simple_counter
- (&im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP], sw_if_index);
- vnet_interface_counter_unlock(im);
- }
- else
- {
- hw_if_index = vnet_register_interface
- (vnm, vxlan_device_class.index, t - vxm->tunnels,
- vxlan_hw_class.index, t - vxm->tunnels);
- hi = vnet_get_hw_interface (vnm, hw_if_index);
- }
-
- t->hw_if_index = hw_if_index;