Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1 | /* |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 Cisco and/or its affiliates. |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 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 | #ifndef SRC_VNET_SESSION_SESSION_TABLE_H_ |
| 17 | #define SRC_VNET_SESSION_SESSION_TABLE_H_ |
| 18 | |
| 19 | #include <vppinfra/bihash_16_8.h> |
| 20 | #include <vppinfra/bihash_48_8.h> |
| 21 | |
| 22 | typedef struct _session_lookup_table |
| 23 | { |
| 24 | /** |
| 25 | * Lookup tables for established sessions and listeners |
| 26 | */ |
| 27 | clib_bihash_16_8_t v4_session_hash; |
| 28 | clib_bihash_48_8_t v6_session_hash; |
| 29 | |
| 30 | /** |
| 31 | * Lookup tables for half-open sessions |
| 32 | */ |
| 33 | clib_bihash_16_8_t v4_half_open_hash; |
| 34 | clib_bihash_48_8_t v6_half_open_hash; |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Per fib proto and transport proto session rules tables |
| 38 | */ |
Steven Luong | c4b5d10 | 2024-07-30 13:44:01 -0700 | [diff] [blame] | 39 | u32 srtg_handle; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 40 | |
| 41 | /** Flag that indicates if table has local scope */ |
| 42 | u8 is_local; |
| 43 | |
| 44 | /** Namespace this table belongs to */ |
| 45 | u32 appns_index; |
| 46 | |
| 47 | /** For global tables only one fib proto is active. This is a |
| 48 | * byproduct of fib table ids not necessarily being the same for |
| 49 | * identical fib idices of v4 and v6 fib protos */ |
| 50 | u8 active_fib_proto; |
Dave Barach | eb987d3 | 2018-05-03 08:26:39 -0400 | [diff] [blame] | 51 | /* Required for pool_get_aligned(...) */ |
| 52 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 53 | } session_table_t; |
| 54 | |
| 55 | #define SESSION_TABLE_INVALID_INDEX ((u32)~0) |
| 56 | #define SESSION_LOCAL_TABLE_PREFIX ((u32)~0) |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 57 | #define SESSION_DROP_HANDLE (((u64)~0) - 1) |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 58 | |
| 59 | typedef int (*ip4_session_table_walk_fn_t) (clib_bihash_kv_16_8_t * kvp, |
| 60 | void *ctx); |
| 61 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 62 | void ip4_session_table_walk (clib_bihash_16_8_t * hash, |
| 63 | ip4_session_table_walk_fn_t fn, void *arg); |
| 64 | |
| 65 | session_table_t *session_table_alloc (void); |
| 66 | session_table_t *session_table_get (u32 table_index); |
| 67 | u32 session_table_index (session_table_t * slt); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 68 | void session_table_init (session_table_t * slt, u8 fib_proto); |
Nathan Skrzypczak | b3ea73e | 2021-08-05 10:22:52 +0200 | [diff] [blame] | 69 | void session_table_free (session_table_t *slt, u8 fib_proto); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 70 | |
Florin Coras | 894d0a6 | 2023-11-17 16:35:04 -0800 | [diff] [blame] | 71 | u32 session_table_memory_size (session_table_t *st); |
| 72 | u8 *format_session_table (u8 *s, va_list *args); |
| 73 | |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 74 | /* Internal, try not to use it! */ |
| 75 | session_table_t *_get_session_tables (); |
| 76 | |
| 77 | #define session_table_foreach(VAR, BODY) \ |
Damjan Marion | b2c31b6 | 2020-12-13 21:47:40 +0100 | [diff] [blame] | 78 | pool_foreach (VAR, _get_session_tables ()) BODY |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 79 | |
Steven Luong | 5682ca8 | 2024-07-17 16:16:05 -0700 | [diff] [blame] | 80 | void session_lookup_table_cleanup (u32 fib_proto, u32 fib_index); |
| 81 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 82 | #endif /* SRC_VNET_SESSION_SESSION_TABLE_H_ */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 83 | /* |
| 84 | * fd.io coding-style-patch-verification: ON |
| 85 | * |
| 86 | * Local Variables: |
| 87 | * eval: (c-set-style "gnu") |
| 88 | * End: |
| 89 | */ |