LCOV - code coverage report
Current view: top level - plugins/tracenode - tracenode.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 19 23 82.6 %
Date: 2023-10-26 01:39:38 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2023 Cisco and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : #include <vlib/vlib.h>
      16             : #include <tracenode/tracenode.h>
      17             : 
      18             : tracenode_main_t tracenode_main;
      19             : 
      20             : int
      21           2 : tracenode_feature_enable_disable (u32 sw_if_index, bool is_pcap, bool enable)
      22             : {
      23           2 :   tracenode_main_t *tnm = &tracenode_main;
      24           2 :   char *node_name = is_pcap ? "pcap-filtering" : "trace-filtering";
      25           2 :   int rv = 0;
      26             : 
      27           2 :   if (pool_is_free_index (tnm->vnet_main->interface_main.sw_interfaces,
      28             :                           sw_if_index))
      29           0 :     return VNET_API_ERROR_INVALID_SW_IF_INDEX;
      30             : 
      31           2 :   if (clib_bitmap_get (tnm->feature_enabled_by_sw_if, sw_if_index) == enable)
      32           0 :     return 0;
      33             : 
      34           2 :   if ((rv = vnet_feature_enable_disable ("ip4-unicast", node_name, sw_if_index,
      35             :                                          enable, 0, 0)) != 0)
      36           0 :     return rv;
      37             : 
      38           2 :   if ((rv = vnet_feature_enable_disable ("ip6-unicast", node_name, sw_if_index,
      39             :                                          enable, 0, 0)) != 0)
      40           0 :     return rv;
      41             : 
      42           2 :   tnm->feature_enabled_by_sw_if =
      43           2 :     clib_bitmap_set (tnm->feature_enabled_by_sw_if, sw_if_index, enable);
      44             : 
      45           2 :   return 0;
      46             : }
      47             : 
      48             : static clib_error_t *
      49         575 : tracenode_init (vlib_main_t *vm)
      50             : {
      51         575 :   tracenode_main_t *tnm = &tracenode_main;
      52         575 :   clib_error_t *error = 0;
      53             : 
      54         575 :   memset (tnm, 0, sizeof (*tnm));
      55             : 
      56         575 :   tnm->vnet_main = vnet_get_main ();
      57             : 
      58         575 :   error = tracenode_plugin_api_hookup (vm);
      59             : 
      60         575 :   return error;
      61             : }
      62             : 
      63        1151 : VLIB_INIT_FUNCTION (tracenode_init);
      64             : 
      65             : /*
      66             :  * fd.io coding-style-patch-verification: ON
      67             :  *
      68             :  * Local Variables:
      69             :  * eval: (c-set-style "gnu")
      70             :  * End:
      71             :  */

Generated by: LCOV version 1.14