FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ad-flow.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 #ifndef __included_srv6_ad_flow_h__
16 #define __included_srv6_ad_flow_h__
17 
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/srv6/sr.h>
21 #include <vnet/srv6/sr_packet.h>
22 
23 #include <vppinfra/error.h>
24 #include <vppinfra/elog.h>
25 
26 #include <vppinfra/dlist.h>
27 #include <vppinfra/bihash_40_8.h>
28 
29 #define AD_TYPE_IP4 IP_PROTOCOL_IP_IN_IP
30 #define AD_TYPE_IP6 IP_PROTOCOL_IPV6
31 
32 #define SRV6_AD_FLOW_DEFAULT_CACHE_SIZE 100
33 #define SRV6_AD_CACHE_TIMEOUT 300
34 
35 /*
36  * Cache entries
37  */
38 typedef struct
39 {
40  /* Cache key (5-tuple) */
41  struct
42  {
43  ip46_address_t s_addr;
44  ip46_address_t d_addr;
48  } key;
49 
50  /* Cached encapsulation headers */
53 
54  /* Index in global LRU list */
56 
57  /* Last update timestamp */
59 
60  /* Last heard timestamp */
63 
64 /*
65  * This is the memory that will be stored per each localsid
66  * the user instantiates
67  */
68 typedef struct
69 {
70  ip46_address_t nh_addr; /**< Proxied device address */
71  u32 sw_if_index_out; /**< Outgoing iface to proxied dev. */
72  u32 nh_adj; /**< Adjacency index for out. iface */
74 
75  u32 sw_if_index_in; /**< Incoming iface from proxied dev. */
76 
80 
81  clib_bihash_40_8_t ftable; /**< Flow table */
82  srv6_ad_flow_entry_t *cache; /**< Cache table */
85 
88 
89 typedef struct
90 {
91  u16 msg_id_base; /**< API message ID base */
92 
93  vlib_main_t *vlib_main; /**< [convenience] vlib main */
94  vnet_main_t *vnet_main; /**< [convenience] vnet main */
95 
97 
98  u32 srv6_localsid_behavior_id; /**< SRv6 LocalSID behavior number */
99 
100  u32 *sw_iface_localsid2; /**< Retrieve local SID from iface */
101  u32 *sw_iface_localsid4; /**< Retrieve local SID from iface */
102  u32 *sw_iface_localsid6; /**< Retrieve local SID from iface */
103 
104  srv6_ad_flow_localsid_t **sids; /**< Pool of AD SID pointers */
105 
107  sid_bypass_counters; /**< Packets/bytes bypassing NF */
108  vlib_combined_counter_main_t sid_punt_counters; /**< Packets/bytes punted */
110 
112  rw_valid_counters; /**< Valid rewrite counters */
114  rw_invalid_counters; /**< Invalid rewrite counters */
116 
117 typedef struct
118 {
122 
124 
127 
128 void srv6_ad_flow_dpo_lock (dpo_id_t *dpo);
130 
132 
133 #endif /* __included_srv6_ad_flow_h__ */
134 
135 /*
136  * fd.io coding-style-patch-verification: ON
137  *
138  * Local Variables:
139  * eval: (c-set-style "gnu")
140  * End:
141  */
srv6_ad_flow_main_t::srv6_localsid_behavior_id
u32 srv6_localsid_behavior_id
SRv6 LocalSID behavior number.
Definition: ad-flow.h:98
srv6_ad_flow_localsid_node
vlib_node_registration_t srv6_ad_flow_localsid_node
(constructor) VLIB_REGISTER_NODE (srv6_ad_flow_localsid_node)
Definition: node.c:658
srv6_ad_flow_localsid_t::cache_buckets
u32 cache_buckets
Definition: ad-flow.h:78
srv6_ad_flow_entry_t::d_addr
ip46_address_t d_addr
Definition: ad-flow.h:44
elog.h
srv6_ad_flow_localsid_t::cache
srv6_ad_flow_entry_t * cache
Cache table.
Definition: ad-flow.h:82
srv6_ad_flow_entry_t::last_lru_update
f64 last_lru_update
Definition: ad-flow.h:58
srv6_ad_flow_entry_t::s_port
u16 s_port
Definition: ad-flow.h:46
dlist.h
u16
unsigned short u16
Definition: types.h:57
srv6_ad_flow_localsid_t::inner_type
u8 inner_type
Definition: ad-flow.h:73
srv6_ad_flow_entry_t::lru_index
u32 lru_index
Definition: ad-flow.h:55
srv6_ad_flow_localsid_t::cache_memory_size
uword cache_memory_size
Definition: ad-flow.h:79
srv6_ad_flow_main_t::vlib_main
vlib_main_t * vlib_main
[convenience] vlib main
Definition: ad-flow.h:93
srv6_ad_flow_localsid_t::sw_if_index_in
u32 sw_if_index_in
Incoming iface from proxied dev.
Definition: ad-flow.h:75
srv6_ad_flow_entry_t::proto
u8 proto
Definition: ad-flow.h:45
srv6_ad_flow_main_t::rw_valid_counters
vlib_combined_counter_main_t rw_valid_counters
Valid rewrite counters.
Definition: ad-flow.h:112
key
typedef key
Definition: ipsec_types.api:88
srv6_ad_flow_main_t::sw_iface_localsid2
u32 * sw_iface_localsid2
Retrieve local SID from iface.
Definition: ad-flow.h:100
sr_packet.h
srv6_ad_flow_localsid_t::index
u32 index
Definition: ad-flow.h:86
srv6_ad_flow_main_t::sw_iface_localsid6
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: ad-flow.h:102
srv6_ad_is_idle_entry_ctx_t::ls
srv6_ad_flow_localsid_t * ls
Definition: ad-flow.h:119
srv6_ad_flow_entry_t::last_heard
f64 last_heard
Definition: ad-flow.h:61
sr.h
Segment Routing data structures definitions.
srv6_ad_flow_entry_t::d_port
u16 d_port
Definition: ad-flow.h:47
srv6_ad_flow_main_t::msg_id_base
u16 msg_id_base
API message ID base.
Definition: ad-flow.h:91
error.h
srv6_ad_flow_localsid_t
Definition: ad-flow.h:68
srv6_ad_is_idle_entry_ctx_t::now
f64 now
Definition: ad-flow.h:120
srv6_ad_flow_localsid_t::ftable
clib_bihash_40_8_t ftable
Flow table.
Definition: ad-flow.h:81
uword
u64 uword
Definition: types.h:112
dpo_type_t
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type()
srv6_ad_flow_main_t
Definition: ad-flow.h:89
srv6_ad_flow_dpo_unlock
void srv6_ad_flow_dpo_unlock(dpo_id_t *dpo)
Definition: ad-flow.c:402
f64
double f64
Definition: types.h:142
dlist_elt_t
Definition: dlist.h:28
srv6_ad_flow_main
srv6_ad_flow_main_t srv6_ad_flow_main
Definition: ad-flow.c:41
srv6_ad_flow_entry_t
Definition: ad-flow.h:38
srv6_ad_flow_localsid_t::lru_pool
dlist_elt_t * lru_pool
Definition: ad-flow.h:83
srv6_ad_flow_localsid_t::nh_adj
u32 nh_adj
Adjacency index for out.
Definition: ad-flow.h:72
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
srv6_ad_flow_main_t::srv6_ad_flow_dpo_type
dpo_type_t srv6_ad_flow_dpo_type
DPO type.
Definition: ad-flow.h:96
srv6_ad_flow_main_t::sid_bypass_counters
vlib_combined_counter_main_t sid_bypass_counters
Packets/bytes bypassing NF.
Definition: ad-flow.h:107
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
srv6_ad_flow_main_t::sid_punt_counters
vlib_combined_counter_main_t sid_punt_counters
Packets/bytes punted.
Definition: ad-flow.h:108
vnet_main_t
Definition: vnet.h:76
srv6_ad_flow_entry_t::s_addr
ip46_address_t s_addr
Definition: ad-flow.h:43
srv6_ad_flow_main_t::vnet_main
vnet_main_t * vnet_main
[convenience] vnet main
Definition: ad-flow.h:94
srv6_ad_flow_localsid_t::sw_if_index_out
u32 sw_if_index_out
Outgoing iface to proxied dev.
Definition: ad-flow.h:71
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
srv6_ad_flow_main_t::sw_iface_localsid4
u32 * sw_iface_localsid4
Retrieve local SID from iface.
Definition: ad-flow.h:101
unformat_srv6_ad_flow_localsid
unformat_function_t unformat_srv6_ad_flow_localsid
Definition: ad-flow.h:126
srv6_ad_flow_dpo_lock
void srv6_ad_flow_dpo_lock(dpo_id_t *dpo)
Definition: ad-flow.c:397
srv6_ad_flow_main_t::sids
srv6_ad_flow_localsid_t ** sids
Pool of AD SID pointers.
Definition: ad-flow.h:104
ip.h
u32
unsigned int u32
Definition: types.h:88
bihash_40_8.h
srv6_ad_flow_main_t::sid_cache_full_counters
vlib_combined_counter_main_t sid_cache_full_counters
Definition: ad-flow.h:109
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:225
srv6_ad_flow_main_t::rw_invalid_counters
vlib_combined_counter_main_t rw_invalid_counters
Invalid rewrite counters.
Definition: ad-flow.h:114
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
srv6_ad_flow_localsid_t::cache_size
u32 cache_size
Definition: ad-flow.h:77
srv6_ad_flow_localsid_t::lru_head_index
u32 lru_head_index
Definition: ad-flow.h:84
srv6_ad_flow_localsid_t::nh_addr
ip46_address_t nh_addr
Proxied device address.
Definition: ad-flow.h:70
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
format_srv6_ad_flow_localsid
format_function_t format_srv6_ad_flow_localsid
Definition: ad-flow.h:125
srv6_ad_flow_entry_t::rw_data
u8 * rw_data
Definition: ad-flow.h:52
srv6_ad_is_idle_entry_ctx_t
Definition: ad-flow.h:117
vnet.h
srv6_ad_flow_entry_t::rw_len
u32 rw_len
Definition: ad-flow.h:51