FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
dslite.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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_dslite_h__
16 #define __included_dslite_h__
17 
18 #include <vppinfra/dlist.h>
19 #include <vppinfra/bihash_8_8.h>
20 #include <vppinfra/bihash_16_8.h>
21 #include <vppinfra/bihash_24_8.h>
22 
23 #include <nat/lib/lib.h>
24 #include <nat/lib/alloc.h>
25 #include <nat/lib/inlines.h>
26 
27 typedef struct
28 {
32 
33 /* session key (4-tuple) */
34 typedef struct
35 {
36  union
37  {
38  struct
39  {
42  u16 protocol:3, fib_index:13;
43  };
45  };
47 
48 typedef struct
49 {
50  union
51  {
52  struct
53  {
54  ip6_address_t softwire_id;
59  };
60  u64 as_u64[3];
61  };
63 
64 /* *INDENT-OFF* */
65 typedef CLIB_PACKED (struct
66 {
67  nat_session_key_t out2in;
68  dslite_session_key_t in2out;
69  u32 per_b4_index;
70  u32 per_b4_list_head_index;
71  f64 last_heard;
72  u64 total_bytes;
73  u32 total_pkts;
74 }) dslite_session_t;
75 /* *INDENT-ON* */
76 
77 typedef struct
78 {
79  ip6_address_t addr;
82 } dslite_b4_t;
83 
84 typedef struct
85 {
86  /* Main lookup tables */
87  clib_bihash_8_8_t out2in;
88  clib_bihash_24_8_t in2out;
89 
90  /* Find a B4 */
91  clib_bihash_16_8_t b4_hash;
92 
93  /* B4 pool */
95 
96  /* Session pool */
97  dslite_session_t *sessions;
98 
99  /* Pool of doubly-linked list elements */
102 
103 typedef struct
104 {
105  ip6_address_t aftr_ip6_addr;
107  ip6_address_t b4_ip6_addr;
113 
114  /* nat address pool */
116 
117  /* counters/gauges */
120 
121  /* node index */
125 
126  /* If set then the DSLite component behaves as CPE/B4
127  * otherwise it behaves as AFTR */
129 
132 } dslite_main_t;
133 
134 typedef struct
135 {
139 
140 typedef struct
141 {
144 
145 #define foreach_dslite_error \
146 _(IN2OUT, "valid in2out DS-Lite packets") \
147 _(OUT2IN, "valid out2in DS-Lite packets") \
148 _(CE_ENCAP, "valid CE encap DS-Lite packets") \
149 _(CE_DECAP, "valid CE decap DS-Lite packets") \
150 _(NO_TRANSLATION, "no translation") \
151 _(BAD_IP6_PROTOCOL, "bad ip6 protocol") \
152 _(OUT_OF_PORTS, "out of ports") \
153 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
154 _(BAD_ICMP_TYPE, "unsupported icmp type") \
155 _(UNKNOWN, "unknown")
156 
157 typedef enum
158 {
159 #define _(sym,str) DSLITE_ERROR_##sym,
161 #undef _
164 
171 
172 void dslite_set_ce (dslite_main_t * dm, u8 set);
173 int dslite_set_aftr_ip6_addr (dslite_main_t * dm, ip6_address_t * addr);
174 int dslite_set_b4_ip6_addr (dslite_main_t * dm, ip6_address_t * addr);
178  u8 is_add);
179 u8 *format_dslite_trace (u8 * s, va_list * args);
180 u8 *format_dslite_ce_trace (u8 * s, va_list * args);
181 
182 #endif /* __included_dslite_h__ */
183 
184 /*
185  * fd.io coding-style-patch-verification: ON
186  *
187  * Local Variables:
188  * eval: (c-set-style "gnu")
189  * End:
190  */
dslite_b4_t::sessions_per_b4_list_head_index
u32 sessions_per_b4_list_head_index
Definition: dslite.h:80
nat_session_key_t::port
u16 port
Definition: dslite.h:41
lib.h
NAT port/address allocation lib.
bihash_24_8.h
foreach_dslite_error
#define foreach_dslite_error
Definition: dslite.h:145
dslite_ce_decap_node
vlib_node_registration_t dslite_ce_decap_node
(constructor) VLIB_REGISTER_NODE (dslite_ce_decap_node)
Definition: dslite_ce_decap.c:118
DSLITE_N_ERROR
@ DSLITE_N_ERROR
Definition: dslite.h:162
bihash_8_8.h
dslite_per_thread_data_t::b4_hash
clib_bihash_16_8_t b4_hash
Definition: dslite.h:91
nat_session_key_t::addr
ip4_address_t addr
Definition: dslite.h:40
dslite_main_t
Definition: dslite.h:103
dslite_main_t::per_thread_data
dslite_per_thread_data_t * per_thread_data
Definition: dslite.h:109
dslite_main_t::is_ce
u8 is_ce
Definition: dslite.h:128
dslite_main_t::pool
nat_ip4_pool_t pool
Definition: dslite.h:115
dslite_main
dslite_main_t dslite_main
Definition: dslite.c:21
dslite_session_key_t::pad
u8 pad
Definition: dslite.h:58
dslite_per_thread_data_t::sessions
dslite_session_t * sessions
Definition: dslite.h:97
nat_session_key_t::protocol
u16 protocol
Definition: dslite.h:42
echo_header_t
Definition: dslite.h:27
dslite_per_thread_data_t::out2in
clib_bihash_8_8_t out2in
Definition: dslite.h:87
dlist.h
u16
unsigned short u16
Definition: types.h:57
dslite_session_key_t::proto
u8 proto
Definition: dslite.h:57
nat_session_key_t::as_u64
u64 as_u64
Definition: dslite.h:44
dslite_in2out_node
vlib_node_registration_t dslite_in2out_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_node)
Definition: dslite_in2out.c:464
dslite_main_t::is_enabled
u8 is_enabled
Definition: dslite.h:130
dslite_main_t::aftr_ip6_addr
ip6_address_t aftr_ip6_addr
Definition: dslite.h:105
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
dslite_in2out_slowpath_node
vlib_node_registration_t dslite_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_slowpath_node)
Definition: dslite_in2out.c:490
dslite_main_t::msg_id_base
u16 msg_id_base
Definition: dslite.h:131
nat_ip4_pool_s
Definition: alloc.h:60
set
description can t DF set
Definition: map.api:451
dslite_main_t::dslite_in2out_node_index
u32 dslite_in2out_node_index
Definition: dslite.h:122
dslite_b4_t
Definition: dslite.h:77
dslite_trace_t::session_index
u32 session_index
Definition: dslite.h:137
dslite_add_del_pool_addr
int dslite_add_del_pool_addr(dslite_main_t *dm, ip4_address_t *addr, u8 is_add)
dslite_main_t::total_b4s
vlib_simple_counter_main_t total_b4s
Definition: dslite.h:118
dslite_main_t::aftr_ip4_addr
ip4_address_t aftr_ip4_addr
Definition: dslite.h:106
echo_header_t::sequence
u16 sequence
Definition: dslite.h:30
dslite_ce_encap_node
vlib_node_registration_t dslite_ce_encap_node
(constructor) VLIB_REGISTER_NODE (dslite_ce_encap_node)
Definition: dslite_ce_encap.c:111
dslite_ce_trace_t::next_index
u32 next_index
Definition: dslite.h:142
f64
double f64
Definition: types.h:142
dlist_elt_t
Definition: dlist.h:28
ip4_address_t
Definition: ip4_packet.h:50
inlines.h
dslite_session_key_t::softwire_id
ip6_address_t softwire_id
Definition: dslite.h:54
dslite_b4_t::nsessions
u32 nsessions
Definition: dslite.h:81
format_dslite_ce_trace
u8 * format_dslite_ce_trace(u8 *s, va_list *args)
Definition: dslite.c:271
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
dslite_main_t::total_sessions
vlib_simple_counter_main_t total_sessions
Definition: dslite.h:119
alloc.h
NAT port/address allocation lib.
dslite_set_b4_ip4_addr
int dslite_set_b4_ip4_addr(dslite_main_t *dm, ip4_address_t *addr)
Definition: dslite.c:220
CLIB_PACKED
typedef CLIB_PACKED(struct { nat_session_key_t out2in;dslite_session_key_t in2out;u32 per_b4_index;u32 per_b4_list_head_index;f64 last_heard;u64 total_bytes;u32 total_pkts;}) dslite_session_t
dslite_per_thread_data_t::list_pool
dlist_elt_t * list_pool
Definition: dslite.h:100
dslite_set_aftr_ip6_addr
int dslite_set_aftr_ip6_addr(dslite_main_t *dm, ip6_address_t *addr)
Definition: dslite.c:141
u64
unsigned long u64
Definition: types.h:89
format_dslite_trace
u8 * format_dslite_trace(u8 *s, va_list *args)
Definition: dslite.c:258
dslite_main_t::port_per_thread
u16 port_per_thread
Definition: dslite.h:112
u32
unsigned int u32
Definition: types.h:88
dslite_trace_t
Definition: dslite.h:134
dslite_main_t::b4_ip6_addr
ip6_address_t b4_ip6_addr
Definition: dslite.h:107
dslite_main_t::dslite_out2in_node_index
u32 dslite_out2in_node_index
Definition: dslite.h:124
as_u64
u64 as_u64
Definition: bihash_doc.h:63
dslite_main_t::dslite_in2out_slowpath_node_index
u32 dslite_in2out_slowpath_node_index
Definition: dslite.h:123
bihash_16_8.h
dslite_per_thread_data_t::in2out
clib_bihash_24_8_t in2out
Definition: dslite.h:88
dslite_set_ce
void dslite_set_ce(dslite_main_t *dm, u8 set)
Definition: dslite.c:120
echo_header_t::identifier
u16 identifier
Definition: dslite.h:29
dslite_out2in_node
vlib_node_registration_t dslite_out2in_node
(constructor) VLIB_REGISTER_NODE (dslite_out2in_node)
Definition: dslite_out2in.c:270
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
u8
unsigned char u8
Definition: types.h:56
dslite_per_thread_data_t
Definition: dslite.h:84
dslite_ce_trace_t
Definition: dslite.h:140
dslite_main_t::b4_ip4_addr
ip4_address_t b4_ip4_addr
Definition: dslite.h:108
dslite_b4_t::addr
ip6_address_t addr
Definition: dslite.h:79
dslite_trace_t::next_index
u32 next_index
Definition: dslite.h:136
nat_session_key_t
Definition: dslite.h:34
dslite_session_key_t::port
u16 port
Definition: dslite.h:56
dslite_session_key_t::addr
ip4_address_t addr
Definition: dslite.h:55
dslite_set_aftr_ip4_addr
int dslite_set_aftr_ip4_addr(dslite_main_t *dm, ip4_address_t *addr)
Definition: dslite.c:180
dslite_per_thread_data_t::b4s
dslite_b4_t * b4s
Definition: dslite.h:94
dslite_error_t
dslite_error_t
Definition: dslite.h:157
dslite_main_t::first_worker_index
u32 first_worker_index
Definition: dslite.h:111
dslite_set_b4_ip6_addr
int dslite_set_b4_ip6_addr(dslite_main_t *dm, ip6_address_t *addr)
Definition: dslite.c:187
dslite_session_key_t
Definition: dslite.h:48
dslite_main_t::num_workers
u32 num_workers
Definition: dslite.h:110