LCOV - code coverage report
Current view: top level - vnet/fib - ip4_fib_16.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 31 31 100.0 %
Date: 2023-10-26 01:39:38 Functions: 11 11 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 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             : 
      16             : #include <vnet/fib/fib_table.h>
      17             : #include <vnet/fib/fib_entry.h>
      18             : #include <vnet/fib/ip4_fib.h>
      19             : 
      20             : ip4_fib_16_t *ip4_fib_16s;
      21             : 
      22             : void
      23         859 : ip4_fib_16_table_init (ip4_fib_16_t *fib)
      24             : {
      25         859 :     ip4_mtrie_16_init(&fib->mtrie);
      26         859 : }
      27             : 
      28             : void
      29         265 : ip4_fib_16_table_free (ip4_fib_16_t *fib)
      30             : {
      31         265 :     ip4_mtrie_16_free(&fib->mtrie);
      32         265 : }
      33             : 
      34             : /*
      35             :  * ip4_fib_16_table_lookup_exact_match
      36             :  *
      37             :  * Exact match prefix lookup
      38             :  */
      39             : fib_node_index_t
      40      191902 : ip4_fib_16_table_lookup_exact_match (const ip4_fib_16_t *fib,
      41             :                                      const ip4_address_t *addr,
      42             :                                      u32 len)
      43             : {
      44      191902 :     return (ip4_fib_hash_table_lookup_exact_match(&fib->hash, addr, len));
      45             : }
      46             : 
      47             : /*
      48             :  * ip4_fib_16_table_lookup_adj
      49             :  *
      50             :  * Longest prefix match
      51             :  */
      52             : index_t
      53         100 : ip4_fib_16_table_lookup_lb (ip4_fib_16_t *fib,
      54             :                             const ip4_address_t *addr)
      55             : {
      56         100 :     return (ip4_fib_hash_table_lookup_lb(&fib->hash, addr));
      57             : }
      58             : 
      59             : /*
      60             :  * ip4_fib_16_table_lookup
      61             :  *
      62             :  * Longest prefix match
      63             :  */
      64             : fib_node_index_t
      65      119310 : ip4_fib_16_table_lookup (const ip4_fib_16_t *fib,
      66             :                          const ip4_address_t *addr,
      67             :                          u32 len)
      68             : {
      69      119310 :     return (ip4_fib_hash_table_lookup(&fib->hash, addr, len));
      70             : }
      71             : 
      72             : void
      73       22420 : ip4_fib_16_table_entry_insert (ip4_fib_16_t *fib,
      74             :                                const ip4_address_t *addr,
      75             :                                u32 len,
      76             :                                fib_node_index_t fib_entry_index)
      77             : {
      78       22420 :     return (ip4_fib_hash_table_entry_insert(&fib->hash, addr, len, fib_entry_index));
      79             : }
      80             : 
      81             : void
      82       16239 : ip4_fib_16_table_entry_remove (ip4_fib_16_t *fib,
      83             :                                const ip4_address_t *addr,
      84             :                                u32 len)
      85             : {
      86       16239 :     return (ip4_fib_hash_table_entry_remove(&fib->hash, addr, len));
      87             : }
      88             : 
      89             : void
      90       22127 : ip4_fib_16_table_fwding_dpo_update (ip4_fib_16_t *fib,
      91             :                                  const ip4_address_t *addr,
      92             :                                  u32 len,
      93             :                                  const dpo_id_t *dpo)
      94             : {
      95       22127 :     ip4_mtrie_16_route_add(&fib->mtrie, addr, len, dpo->dpoi_index);
      96       22127 : }
      97             : 
      98             : void
      99       15932 : ip4_fib_16_table_fwding_dpo_remove (ip4_fib_16_t *fib,
     100             :                                     const ip4_address_t *addr,
     101             :                                     u32 len,
     102             :                                     const dpo_id_t *dpo,
     103             :                                     u32 cover_index)
     104             : {
     105             :     const fib_prefix_t *cover_prefix;
     106             :     const dpo_id_t *cover_dpo;
     107             : 
     108             :     /*
     109             :      * We need to pass the MTRIE the LB index and address length of the
     110             :      * covering prefix, so it can fill the plys with the correct replacement
     111             :      * for the entry being removed
     112             :      */
     113       15932 :     cover_prefix = fib_entry_get_prefix(cover_index);
     114       15932 :     cover_dpo = fib_entry_contribute_ip_forwarding(cover_index);
     115             : 
     116       15932 :     ip4_mtrie_16_route_del(&fib->mtrie,
     117             :                             addr, len, dpo->dpoi_index,
     118       15932 :                             cover_prefix->fp_len,
     119             :                             cover_dpo->dpoi_index);
     120       15932 : }
     121             : 
     122             : void
     123        3184 : ip4_fib_16_table_walk (ip4_fib_16_t *fib,
     124             :                        fib_table_walk_fn_t fn,
     125             :                        void *ctx)
     126             : {
     127        3184 :     ip4_fib_hash_table_walk(&fib->hash, fn, ctx);
     128        3184 : }
     129             : 
     130             : void
     131          56 : ip4_fib_16_table_sub_tree_walk (ip4_fib_16_t *fib,
     132             :                                 const fib_prefix_t *root,
     133             :                                 fib_table_walk_fn_t fn,
     134             :                                 void *ctx)
     135             : {
     136          56 :     ip4_fib_hash_table_sub_tree_walk(&fib->hash, root, fn, ctx);
     137          56 : }

Generated by: LCOV version 1.14