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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __included_l2sess_h__
16 #define __included_l2sess_h__
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/ethernet/ethernet.h>
22 #include <vppinfra/hash.h>
23 #include <vppinfra/error.h>
24 #include <vppinfra/elog.h>
25 #include <vppinfra/timing_wheel.h>
27 #include <vnet/l2/l2_output.h>
28 #include <vnet/l2/l2_input.h>
30 #define _(node_name, node_var, is_out, is_ip6, is_track)
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)
42 #define _(node_name, node_var, is_out, is_ip6, is_track) \
43 extern vlib_node_registration_t node_var;
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)
67 L2S_SESSION_SIDE_IN = 0,
74 l2s_session_side_t side[L2S_N_SESSION_SIDES];
77 u16 tcp_flags_seen; /* u16 because of two sides */
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
86 #define UDP_SESSION_IDLE_TIMEOUT_SEC 15
87 #define TCP_SESSION_IDLE_TIMEOUT_SEC 15
88 #define TCP_SESSION_TRANSIENT_TIMEOUT_SEC 5
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.
97 #define _(node_name, node_var, is_out, is_ip6, is_track) \
98 u32 node_var ## _feat_next_node_index[32];
101 l2_output_next_nodes_st output_next_nodes;
103 /* Next indices of the tracker nodes */
104 u32 next_slot_track_node_by_is_ip6_is_out[2][2];
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.
112 u32 *fwd_to_rev_by_table_index;
115 * The vector of per-interface session pools
118 l2s_session_t *sessions;
120 /* The session timeouts */
121 u64 tcp_session_transient_timeout;
122 u64 tcp_session_idle_timeout;
123 u64 udp_session_idle_timeout;
125 /* Timing wheel to time out the idle sessions */
126 timing_wheel_t timing_wheel;
127 u32 *data_from_advancing_timing_wheel;
128 u64 timer_wheel_next_expiring_time;
129 u64 timer_wheel_tick;
132 vlib_main_t * vlib_main;
133 vnet_main_t * vnet_main;
136 u64 counter_attempted_delete_free_session;
139 l2sess_main_t l2sess_main;
141 /* Just exposed for acl.c */
144 l2sess_vlib_plugin_register (vlib_main_t * vm, void * hh,
145 int from_early_init);
148 #endif /* __included_l2sess_h__ */