FD.io VPP  v17.01-9-ge7dcee4
Vector Packet Processing
l2sess.h
Go to the documentation of this file.
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 #ifndef __included_l2sess_h__
16 #define __included_l2sess_h__
17 
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/ethernet/ethernet.h>
21 
22 #include <vppinfra/hash.h>
23 #include <vppinfra/error.h>
24 #include <vppinfra/elog.h>
25 #include <vppinfra/timing_wheel.h>
26 
27 #include <vnet/l2/l2_output.h>
28 #include <vnet/l2/l2_input.h>
29 
30 #define _(node_name, node_var, is_out, is_ip6, is_track)
31 #undef _
32 #define foreach_l2sess_node \
33  _("aclp-l2s-input-ip4-add", l2sess_in_ip4_add, 0, 0, 0) \
34  _("aclp-l2s-input-ip6-add", l2sess_in_ip6_add, 0, 1, 0) \
35  _("aclp-l2s-output-ip4-add", l2sess_out_ip4_add, 1, 0, 0) \
36  _("aclp-l2s-output-ip6-add", l2sess_out_ip6_add, 1, 1, 0) \
37  _("aclp-l2s-input-ip4-track", l2sess_in_ip4_track, 0, 0, 1) \
38  _("aclp-l2s-input-ip6-track", l2sess_in_ip6_track, 0, 1, 1) \
39  _("aclp-l2s-output-ip4-track",l2sess_out_ip4_track, 1, 0, 1) \
40  _("aclp-l2s-output-ip6-track", l2sess_out_ip6_track, 1, 1, 1)
41 
42 #define _(node_name, node_var, is_out, is_ip6, is_track) \
43  extern vlib_node_registration_t node_var;
45 #undef _
46 
47 #define TCP_FLAG_FIN 0x01
48 #define TCP_FLAG_SYN 0x02
49 #define TCP_FLAG_RST 0x04
50 #define TCP_FLAG_PUSH 0x08
51 #define TCP_FLAG_ACK 0x10
52 #define TCP_FLAG_URG 0x20
53 #define TCP_FLAG_ECE 0x40
54 #define TCP_FLAG_CWR 0x80
55 #define TCP_FLAGS_RSTFINACKSYN (TCP_FLAG_RST + TCP_FLAG_FIN + TCP_FLAG_SYN + TCP_FLAG_ACK)
56 #define TCP_FLAGS_ACKSYN (TCP_FLAG_SYN + TCP_FLAG_ACK)
57 
58 typedef struct {
59  ip46_address_t addr;
65 
66 enum {
70 };
71 
72 typedef struct {
77  u16 tcp_flags_seen; /* u16 because of two sides */
79 
80 #define PROD
81 #ifdef PROD
82 #define UDP_SESSION_IDLE_TIMEOUT_SEC 600
83 #define TCP_SESSION_IDLE_TIMEOUT_SEC (3600*24)
84 #define TCP_SESSION_TRANSIENT_TIMEOUT_SEC 120
85 #else
86 #define UDP_SESSION_IDLE_TIMEOUT_SEC 15
87 #define TCP_SESSION_IDLE_TIMEOUT_SEC 15
88 #define TCP_SESSION_TRANSIENT_TIMEOUT_SEC 5
89 #endif
90 
91 typedef struct {
92  /*
93  * the next two fields are present for all nodes, but
94  * only one of them is used per node - depending
95  * on whether the node is an input or output one.
96  */
97 #define _(node_name, node_var, is_out, is_ip6, is_track) \
98  u32 node_var ## _feat_next_node_index[32];
100 #undef _
102 
103  /* Next indices of the tracker nodes */
104  u32 next_slot_track_node_by_is_ip6_is_out[2][2];
105 
106  /*
107  * Pairing of "forward" and "reverse" tables by table index.
108  * Each relationship has two entries - for one and the other table,
109  * so it is bidirectional.
110  */
111 
113 
114  /*
115  * The vector of per-interface session pools
116  */
117 
119 
120  /* The session timeouts */
124 
125  /* Timing wheel to time out the idle sessions */
130 
131  /* convenience */
135 
136  /* Counter(s) */
138 } l2sess_main_t;
139 
141 
142 /* Just exposed for acl.c */
143 
144 void
146  int from_early_init);
147 
148 
149 #endif /* __included_l2sess_h__ */
u16 tcp_flags_seen
Definition: l2sess.h:77
u8 l4_proto
Definition: l2sess.h:75
void l2sess_vlib_plugin_register(vlib_main_t *vm, void *hh, int from_early_init)
Definition: l2sess.c:34
unsigned long u64
Definition: types.h:89
ethernet_main_t * ethernet_main
Definition: l2sess.h:134
timing_wheel_t timing_wheel
Definition: l2sess.h:126
l2s_session_t * sessions
Definition: l2sess.h:118
u64 create_time
Definition: l2sess.h:73
#define foreach_l2sess_node
Definition: l2sess.h:32
u32 * fwd_to_rev_by_table_index
Definition: l2sess.h:112
vlib_main_t * vlib_main
Definition: l2sess.h:132
foreach_l2sess_node l2_output_next_nodes_st output_next_nodes
Definition: l2sess.h:101
u64 timer_wheel_next_expiring_time
Definition: l2sess.h:128
u64 timer_wheel_tick
Definition: l2sess.h:129
u32 * data_from_advancing_timing_wheel
Definition: l2sess.h:127
unsigned int u32
Definition: types.h:88
l2sess_main_t l2sess_main
Definition: l2sess.h:140
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
ip46_address_t addr
Definition: l2sess.h:59
u64 udp_session_idle_timeout
Definition: l2sess.h:123
u64 counter_attempted_delete_free_session
Definition: l2sess.h:137
u64 tcp_session_transient_timeout
Definition: l2sess.h:121
u64 tcp_session_idle_timeout
Definition: l2sess.h:122
vnet_main_t * vnet_main
Definition: l2sess.h:133