Line data Source code
1 : /* 2 : * Copyright (c) 2019 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 : /** 17 : * A L3 cross connect will send all traffic that is received on the input 18 : * interface to the [set of] paths requested. 19 : * It is a much more memory efficient solution than using a separate IP table 20 : * for each input interface and much faster than an ABF match all rule. 21 : */ 22 : 23 : #ifndef __L3XC_H__ 24 : #define __L3XC_H__ 25 : 26 : #include <vnet/fib/fib_node.h> 27 : 28 : #define L3XC_PLUGIN_VERSION_MAJOR 1 29 : #define L3XC_PLUGIN_VERSION_MINOR 0 30 : 31 : /** 32 : */ 33 : typedef struct l3xc_t_ 34 : { 35 : CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); 36 : /** 37 : * Linkage into the FIB graph 38 : */ 39 : fib_node_t l3xc_node; 40 : 41 : /** 42 : * The path-list describing how to forward in case of a match 43 : */ 44 : fib_node_index_t l3xc_pl; 45 : 46 : fib_protocol_t l3xc_proto; 47 : 48 : /** 49 : * Sibling index on the path-list 50 : */ 51 : u32 l3xc_sibling; 52 : 53 : /** 54 : * The input interface 55 : */ 56 : u32 l3xc_sw_if_index; 57 : 58 : /** 59 : * DPO for forwarding 60 : */ 61 : dpo_id_t l3xc_dpo; 62 : } l3xc_t; 63 : 64 : /** 65 : * Create or update an L3XC Policy 66 : * 67 : * @param sw_if_index the input interface 68 : * @param is_ipv6 - 0 if ip4, 1 if ip6 69 : * @param rpaths The set of paths to add to the forwarding set 70 : * @return error code 71 : */ 72 : extern int l3xc_update (u32 sw_if_index, 73 : u8 is_ip6, const fib_route_path_t * rpaths); 74 : 75 : /** 76 : * Delete an L3XC. 77 : * 78 : * @param sw_if_index the input interface 79 : * @param is_ipv6 - 0 if ip4, 1 if ip6 80 : */ 81 : extern int l3xc_delete (u32 sw_if_index, u8 is_ip6); 82 : 83 : /** 84 : * Callback function invoked during a walk of all policies 85 : */ 86 : typedef int (*l3xc_walk_cb_t) (index_t l3xci, void *ctx); 87 : 88 : /** 89 : * Walk/visit each of the L3XC policies 90 : */ 91 : extern void l3xc_walk (l3xc_walk_cb_t cb, void *ctx); 92 : 93 : /** 94 : * Find a L3 XC object from an interface and FIB protocol 95 : */ 96 : extern index_t l3xc_find (u32 sw_if_index, fib_protocol_t fproto); 97 : 98 : /** 99 : * Data-plane functions 100 : */ 101 : extern l3xc_t *l3xc_pool; 102 : 103 : static_always_inline l3xc_t * 104 75 : l3xc_get (u32 index) 105 : { 106 75 : return (pool_elt_at_index (l3xc_pool, index)); 107 : } 108 : 109 : extern vlib_node_registration_t l3xc_ip4_node; 110 : extern vlib_node_registration_t l3xc_ip6_node; 111 : 112 : /* 113 : * fd.io coding-style-patch-verification: ON 114 : * 115 : * Local Variables: 116 : * eval: (c-set-style "gnu") 117 : * End: 118 : */ 119 : 120 : #endif