blob: 380ca324b6404257ac226e4d2e64662aa7f0f6fe [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
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/*
16 * ip/ip4_fib.h: ip4 mtrie fib
17 *
18 * Copyright (c) 2012 Eliot Dresselhaus
19 *
20 * Permission is hereby granted, free of charge, to any person obtaining
21 * a copy of this software and associated documentation files (the
22 * "Software"), to deal in the Software without restriction, including
23 * without limitation the rights to use, copy, modify, merge, publish,
24 * distribute, sublicense, and/or sell copies of the Software, and to
25 * permit persons to whom the Software is furnished to do so, subject to
26 * the following conditions:
27 *
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
30 *
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 */
39
40#include <vnet/ip/ip.h>
Neale Rannsa3af3372017-03-28 03:49:52 -070041#include <vnet/ip/ip4_mtrie.h>
42#include <vnet/fib/ip4_fib.h>
43
44
45/**
46 * Global pool of IPv4 8bit PLYs
47 */
48ip4_fib_mtrie_8_ply_t *ip4_ply_pool;
Ed Warnickecb9cada2015-12-08 15:45:58 -070049
Neale Ranns04a75e32017-03-23 06:46:01 -070050always_inline u32
Neale Rannsa3af3372017-03-28 03:49:52 -070051ip4_fib_mtrie_leaf_is_non_empty (ip4_fib_mtrie_8_ply_t * p, u8 dst_byte)
Ed Warnickecb9cada2015-12-08 15:45:58 -070052{
Neale Ranns04a75e32017-03-23 06:46:01 -070053 /*
54 * It's 'non-empty' if the length of the leaf stored is greater than the
55 * length of a leaf in the covering ply. i.e. the leaf is more specific
56 * than it's would be cover in the covering ply
57 */
58 if (p->dst_address_bits_of_leaves[dst_byte] > p->dst_address_bits_base)
59 return (1);
60 return (0);
61}
62
63always_inline ip4_fib_mtrie_leaf_t
64ip4_fib_mtrie_leaf_set_adj_index (u32 adj_index)
65{
66 ip4_fib_mtrie_leaf_t l;
67 l = 1 + 2 * adj_index;
68 ASSERT (ip4_fib_mtrie_leaf_get_adj_index (l) == adj_index);
69 return l;
70}
71
72always_inline u32
73ip4_fib_mtrie_leaf_is_next_ply (ip4_fib_mtrie_leaf_t n)
74{
75 return (n & 1) == 0;
76}
77
78always_inline u32
79ip4_fib_mtrie_leaf_get_next_ply_index (ip4_fib_mtrie_leaf_t n)
80{
81 ASSERT (ip4_fib_mtrie_leaf_is_next_ply (n));
82 return n >> 1;
83}
84
85always_inline ip4_fib_mtrie_leaf_t
86ip4_fib_mtrie_leaf_set_next_ply_index (u32 i)
87{
88 ip4_fib_mtrie_leaf_t l;
89 l = 0 + 2 * i;
90 ASSERT (ip4_fib_mtrie_leaf_get_next_ply_index (l) == i);
91 return l;
92}
93
Neale Rannsa3af3372017-03-28 03:49:52 -070094#ifndef __ALTIVEC__
95#define PLY_X4_SPLAT_INIT(init_x4, init) \
96 init_x4 = u32x4_splat (init);
97#else
98#define PLY_X4_SPLAT_INIT(init_x4, init) \
99{ \
100 u32x4_union_t y; \
101 y.as_u32[0] = init; \
102 y.as_u32[1] = init; \
103 y.as_u32[2] = init; \
104 y.as_u32[3] = init; \
105 init_x4 = y.as_u32x4; \
106}
107#endif
108
109#ifdef CLIB_HAVE_VEC128
110#define PLY_INIT_LEAVES(p) \
111{ \
112 u32x4 *l, init_x4; \
113 \
114 PLY_X4_SPLAT_INIT(init_x4, init); \
115 for (l = p->leaves_as_u32x4; \
116 l < p->leaves_as_u32x4 + ARRAY_LEN (p->leaves_as_u32x4); \
117 l += 4) \
118 { \
119 l[0] = init_x4; \
120 l[1] = init_x4; \
121 l[2] = init_x4; \
122 l[3] = init_x4; \
123 } \
124}
125#else
126#define PLY_INIT_LEAVES(p) \
127{ \
128 u32 *l; \
129 \
130 for (l = p->leaves; l < p->leaves + ARRAY_LEN (p->leaves); l += 4) \
131 { \
132 l[0] = init; \
133 l[1] = init; \
134 l[2] = init; \
135 l[3] = init; \
136 } \
137}
138#endif
139
140#define PLY_INIT(p, init, prefix_len, ply_base_len) \
141{ \
142 /* \
143 * A leaf is 'empty' if it represents a leaf from the covering PLY \
144 * i.e. if the prefix length of the leaf is less than or equal to \
145 * the prefix length of the PLY \
146 */ \
147 p->n_non_empty_leafs = (prefix_len > ply_base_len ? \
148 ARRAY_LEN (p->leaves) : 0); \
Dave Barachb7b92992018-10-17 10:38:51 -0400149 clib_memset (p->dst_address_bits_of_leaves, prefix_len, \
Neale Rannsa3af3372017-03-28 03:49:52 -0700150 sizeof (p->dst_address_bits_of_leaves)); \
151 p->dst_address_bits_base = ply_base_len; \
152 \
153 /* Initialize leaves. */ \
154 PLY_INIT_LEAVES(p); \
155}
156
Neale Ranns04a75e32017-03-23 06:46:01 -0700157static void
Neale Rannsa3af3372017-03-28 03:49:52 -0700158ply_8_init (ip4_fib_mtrie_8_ply_t * p,
159 ip4_fib_mtrie_leaf_t init, uword prefix_len, u32 ply_base_len)
Neale Ranns04a75e32017-03-23 06:46:01 -0700160{
Neale Rannsa3af3372017-03-28 03:49:52 -0700161 PLY_INIT (p, init, prefix_len, ply_base_len);
162}
163
164static void
165ply_16_init (ip4_fib_mtrie_16_ply_t * p,
166 ip4_fib_mtrie_leaf_t init, uword prefix_len)
167{
Dave Barachb7b92992018-10-17 10:38:51 -0400168 clib_memset (p->dst_address_bits_of_leaves, prefix_len,
169 sizeof (p->dst_address_bits_of_leaves));
Neale Rannsa3af3372017-03-28 03:49:52 -0700170 PLY_INIT_LEAVES (p);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171}
172
173static ip4_fib_mtrie_leaf_t
Neale Ranns04a75e32017-03-23 06:46:01 -0700174ply_create (ip4_fib_mtrie_t * m,
175 ip4_fib_mtrie_leaf_t init_leaf,
176 u32 leaf_prefix_len, u32 ply_base_len)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700177{
Neale Rannsa3af3372017-03-28 03:49:52 -0700178 ip4_fib_mtrie_8_ply_t *p;
Neale Ranns1ec36522017-11-29 05:20:37 -0800179 void *old_heap;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700180 /* Get cache aligned ply. */
Neale Ranns1ec36522017-11-29 05:20:37 -0800181
182 old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap);
Neale Rannsa3af3372017-03-28 03:49:52 -0700183 pool_get_aligned (ip4_ply_pool, p, CLIB_CACHE_LINE_BYTES);
Neale Ranns1ec36522017-11-29 05:20:37 -0800184 clib_mem_set_heap (old_heap);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700185
Neale Rannsa3af3372017-03-28 03:49:52 -0700186 ply_8_init (p, init_leaf, leaf_prefix_len, ply_base_len);
187 return ip4_fib_mtrie_leaf_set_next_ply_index (p - ip4_ply_pool);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700188}
189
Neale Rannsa3af3372017-03-28 03:49:52 -0700190always_inline ip4_fib_mtrie_8_ply_t *
Ed Warnickecb9cada2015-12-08 15:45:58 -0700191get_next_ply_for_leaf (ip4_fib_mtrie_t * m, ip4_fib_mtrie_leaf_t l)
192{
193 uword n = ip4_fib_mtrie_leaf_get_next_ply_index (l);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700194
Neale Rannsa3af3372017-03-28 03:49:52 -0700195 return pool_elt_at_index (ip4_ply_pool, n);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700196}
197
Dave Barachd7cb1b52016-12-09 09:52:16 -0500198void
Neale Rannsa3af3372017-03-28 03:49:52 -0700199ip4_mtrie_free (ip4_fib_mtrie_t * m)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700200{
Lijian.Zhang33af8c12019-09-16 16:22:36 +0800201 /* the root ply is embedded so there is nothing to do,
Neale Rannsa3af3372017-03-28 03:49:52 -0700202 * the assumption being that the IP4 FIB table has emptied the trie
203 * before deletion.
204 */
205#if CLIB_DEBUG > 0
206 int i;
207 for (i = 0; i < ARRAY_LEN (m->root_ply.leaves); i++)
208 {
209 ASSERT (!ip4_fib_mtrie_leaf_is_next_ply (m->root_ply.leaves[i]));
210 }
211#endif
212}
213
214void
215ip4_mtrie_init (ip4_fib_mtrie_t * m)
216{
217 ply_16_init (&m->root_ply, IP4_FIB_MTRIE_LEAF_EMPTY, 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700218}
219
Dave Barachd7cb1b52016-12-09 09:52:16 -0500220typedef struct
221{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700222 ip4_address_t dst_address;
223 u32 dst_address_length;
224 u32 adj_index;
Neale Ranns04a75e32017-03-23 06:46:01 -0700225 u32 cover_address_length;
226 u32 cover_adj_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700227} ip4_fib_mtrie_set_unset_leaf_args_t;
228
229static void
230set_ply_with_more_specific_leaf (ip4_fib_mtrie_t * m,
Neale Rannsa3af3372017-03-28 03:49:52 -0700231 ip4_fib_mtrie_8_ply_t * ply,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700232 ip4_fib_mtrie_leaf_t new_leaf,
233 uword new_leaf_dst_address_bits)
234{
235 ip4_fib_mtrie_leaf_t old_leaf;
236 uword i;
237
238 ASSERT (ip4_fib_mtrie_leaf_is_terminal (new_leaf));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700239
240 for (i = 0; i < ARRAY_LEN (ply->leaves); i++)
241 {
242 old_leaf = ply->leaves[i];
243
244 /* Recurse into sub plies. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500245 if (!ip4_fib_mtrie_leaf_is_terminal (old_leaf))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700246 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700247 ip4_fib_mtrie_8_ply_t *sub_ply =
248 get_next_ply_for_leaf (m, old_leaf);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500249 set_ply_with_more_specific_leaf (m, sub_ply, new_leaf,
250 new_leaf_dst_address_bits);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700251 }
252
253 /* Replace less specific terminal leaves with new leaf. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500254 else if (new_leaf_dst_address_bits >=
255 ply->dst_address_bits_of_leaves[i])
Ed Warnickecb9cada2015-12-08 15:45:58 -0700256 {
jaszha03ee743762019-09-27 12:52:18 -0500257 clib_atomic_store_rel_n (&ply->leaves[i], new_leaf);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700258 ply->dst_address_bits_of_leaves[i] = new_leaf_dst_address_bits;
Neale Ranns04a75e32017-03-23 06:46:01 -0700259 ply->n_non_empty_leafs += ip4_fib_mtrie_leaf_is_non_empty (ply, i);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700260 }
261 }
262}
263
264static void
265set_leaf (ip4_fib_mtrie_t * m,
Neale Rannsa3af3372017-03-28 03:49:52 -0700266 const ip4_fib_mtrie_set_unset_leaf_args_t * a,
Dave Barachd7cb1b52016-12-09 09:52:16 -0500267 u32 old_ply_index, u32 dst_address_byte_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268{
269 ip4_fib_mtrie_leaf_t old_leaf, new_leaf;
270 i32 n_dst_bits_next_plies;
271 u8 dst_byte;
Neale Rannsa3af3372017-03-28 03:49:52 -0700272 ip4_fib_mtrie_8_ply_t *old_ply;
273
274 old_ply = pool_elt_at_index (ip4_ply_pool, old_ply_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700275
Neale Rannsf0609302017-04-11 09:13:39 -0700276 ASSERT (a->dst_address_length <= 32);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277 ASSERT (dst_address_byte_index < ARRAY_LEN (a->dst_address.as_u8));
278
Neale Rannsa3af3372017-03-28 03:49:52 -0700279 /* how many bits of the destination address are in the next PLY */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500280 n_dst_bits_next_plies =
281 a->dst_address_length - BITS (u8) * (dst_address_byte_index + 1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700282
283 dst_byte = a->dst_address.as_u8[dst_address_byte_index];
284
285 /* Number of bits next plies <= 0 => insert leaves this ply. */
286 if (n_dst_bits_next_plies <= 0)
287 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700288 /* The mask length of the address to insert maps to this ply */
Neale Ranns6ff05492017-06-06 06:52:14 -0700289 uword old_leaf_is_terminal;
290 u32 i, n_dst_bits_this_ply;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700291
Neale Rannsa3af3372017-03-28 03:49:52 -0700292 /* The number of bits, and hence slots/buckets, we will fill */
Neale Ranns04a75e32017-03-23 06:46:01 -0700293 n_dst_bits_this_ply = clib_min (8, -n_dst_bits_next_plies);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500294 ASSERT ((a->dst_address.as_u8[dst_address_byte_index] &
295 pow2_mask (n_dst_bits_this_ply)) == 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700296
Neale Rannsa3af3372017-03-28 03:49:52 -0700297 /* Starting at the value of the byte at this section of the v4 address
298 * fill the buckets/slots of the ply */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700299 for (i = dst_byte; i < dst_byte + (1 << n_dst_bits_this_ply); i++)
300 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700301 ip4_fib_mtrie_8_ply_t *new_ply;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700302
303 old_leaf = old_ply->leaves[i];
304 old_leaf_is_terminal = ip4_fib_mtrie_leaf_is_terminal (old_leaf);
305
Ed Warnickecb9cada2015-12-08 15:45:58 -0700306 if (a->dst_address_length >= old_ply->dst_address_bits_of_leaves[i])
307 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700308 /* The new leaf is more or equally specific than the one currently
309 * occupying the slot */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700310 new_leaf = ip4_fib_mtrie_leaf_set_adj_index (a->adj_index);
311
312 if (old_leaf_is_terminal)
313 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700314 /* The current leaf is terminal, we can replace it with
315 * the new one */
Neale Ranns04a75e32017-03-23 06:46:01 -0700316 old_ply->n_non_empty_leafs -=
317 ip4_fib_mtrie_leaf_is_non_empty (old_ply, i);
Neale Rannsa3af3372017-03-28 03:49:52 -0700318
Dave Barachd7cb1b52016-12-09 09:52:16 -0500319 old_ply->dst_address_bits_of_leaves[i] =
320 a->dst_address_length;
jaszha03ee743762019-09-27 12:52:18 -0500321 clib_atomic_store_rel_n (&old_ply->leaves[i], new_leaf);
Neale Ranns04a75e32017-03-23 06:46:01 -0700322
Dave Barachd7cb1b52016-12-09 09:52:16 -0500323 old_ply->n_non_empty_leafs +=
Neale Ranns04a75e32017-03-23 06:46:01 -0700324 ip4_fib_mtrie_leaf_is_non_empty (old_ply, i);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500325 ASSERT (old_ply->n_non_empty_leafs <=
326 ARRAY_LEN (old_ply->leaves));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700327 }
328 else
329 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700330 /* Existing leaf points to another ply. We need to place
331 * new_leaf into all more specific slots. */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700332 new_ply = get_next_ply_for_leaf (m, old_leaf);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500333 set_ply_with_more_specific_leaf (m, new_ply, new_leaf,
334 a->dst_address_length);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700335 }
336 }
Dave Barachd7cb1b52016-12-09 09:52:16 -0500337 else if (!old_leaf_is_terminal)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700338 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700339 /* The current leaf is less specific and not termial (i.e. a ply),
340 * recurse on down the trie */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700341 new_ply = get_next_ply_for_leaf (m, old_leaf);
Neale Rannsa3af3372017-03-28 03:49:52 -0700342 set_leaf (m, a, new_ply - ip4_ply_pool,
Dave Barachd7cb1b52016-12-09 09:52:16 -0500343 dst_address_byte_index + 1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700344 }
Neale Rannsa3af3372017-03-28 03:49:52 -0700345 /*
346 * else
347 * the route we are adding is less specific than the leaf currently
348 * occupying this slot. leave it there
349 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700350 }
351 }
352 else
353 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700354 /* The address to insert requires us to move down at a lower level of
355 * the trie - recurse on down */
356 ip4_fib_mtrie_8_ply_t *new_ply;
Neale Ranns04a75e32017-03-23 06:46:01 -0700357 u8 ply_base_len;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700358
Neale Ranns04a75e32017-03-23 06:46:01 -0700359 ply_base_len = 8 * (dst_address_byte_index + 1);
Neale Rannsa3af3372017-03-28 03:49:52 -0700360
Ed Warnickecb9cada2015-12-08 15:45:58 -0700361 old_leaf = old_ply->leaves[dst_byte];
Neale Rannsa3af3372017-03-28 03:49:52 -0700362
Ed Warnickecb9cada2015-12-08 15:45:58 -0700363 if (ip4_fib_mtrie_leaf_is_terminal (old_leaf))
364 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700365 /* There is a leaf occupying the slot. Replace it with a new ply */
Neale Ranns04a75e32017-03-23 06:46:01 -0700366 old_ply->n_non_empty_leafs -=
367 ip4_fib_mtrie_leaf_is_non_empty (old_ply, dst_byte);
368
mu.duojiao59a82952018-10-11 14:27:30 +0800369 new_leaf =
370 ply_create (m, old_leaf,
371 old_ply->dst_address_bits_of_leaves[dst_byte],
372 ply_base_len);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700373 new_ply = get_next_ply_for_leaf (m, new_leaf);
374
375 /* Refetch since ply_create may move pool. */
Neale Rannsa3af3372017-03-28 03:49:52 -0700376 old_ply = pool_elt_at_index (ip4_ply_pool, old_ply_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700377
jaszha03ee743762019-09-27 12:52:18 -0500378 clib_atomic_store_rel_n (&old_ply->leaves[dst_byte], new_leaf);
Neale Ranns04a75e32017-03-23 06:46:01 -0700379 old_ply->dst_address_bits_of_leaves[dst_byte] = ply_base_len;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700380
Neale Rannsa3af3372017-03-28 03:49:52 -0700381 old_ply->n_non_empty_leafs +=
382 ip4_fib_mtrie_leaf_is_non_empty (old_ply, dst_byte);
Neale Ranns04a75e32017-03-23 06:46:01 -0700383 ASSERT (old_ply->n_non_empty_leafs >= 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700384 }
385 else
386 new_ply = get_next_ply_for_leaf (m, old_leaf);
387
Neale Rannsa3af3372017-03-28 03:49:52 -0700388 set_leaf (m, a, new_ply - ip4_ply_pool, dst_address_byte_index + 1);
389 }
390}
391
392static void
393set_root_leaf (ip4_fib_mtrie_t * m,
394 const ip4_fib_mtrie_set_unset_leaf_args_t * a)
395{
396 ip4_fib_mtrie_leaf_t old_leaf, new_leaf;
397 ip4_fib_mtrie_16_ply_t *old_ply;
398 i32 n_dst_bits_next_plies;
399 u16 dst_byte;
400
401 old_ply = &m->root_ply;
402
Neale Rannsf0609302017-04-11 09:13:39 -0700403 ASSERT (a->dst_address_length <= 32);
Neale Rannsa3af3372017-03-28 03:49:52 -0700404
405 /* how many bits of the destination address are in the next PLY */
406 n_dst_bits_next_plies = a->dst_address_length - BITS (u16);
407
408 dst_byte = a->dst_address.as_u16[0];
409
410 /* Number of bits next plies <= 0 => insert leaves this ply. */
411 if (n_dst_bits_next_plies <= 0)
412 {
413 /* The mask length of the address to insert maps to this ply */
Neale Ranns6ff05492017-06-06 06:52:14 -0700414 uword old_leaf_is_terminal;
415 u32 i, n_dst_bits_this_ply;
Neale Rannsa3af3372017-03-28 03:49:52 -0700416
417 /* The number of bits, and hence slots/buckets, we will fill */
418 n_dst_bits_this_ply = 16 - a->dst_address_length;
419 ASSERT ((clib_host_to_net_u16 (a->dst_address.as_u16[0]) &
420 pow2_mask (n_dst_bits_this_ply)) == 0);
421
422 /* Starting at the value of the byte at this section of the v4 address
423 * fill the buckets/slots of the ply */
424 for (i = 0; i < (1 << n_dst_bits_this_ply); i++)
425 {
426 ip4_fib_mtrie_8_ply_t *new_ply;
427 u16 slot;
428
429 slot = clib_net_to_host_u16 (dst_byte);
430 slot += i;
431 slot = clib_host_to_net_u16 (slot);
432
433 old_leaf = old_ply->leaves[slot];
434 old_leaf_is_terminal = ip4_fib_mtrie_leaf_is_terminal (old_leaf);
435
436 if (a->dst_address_length >=
437 old_ply->dst_address_bits_of_leaves[slot])
438 {
439 /* The new leaf is more or equally specific than the one currently
440 * occupying the slot */
441 new_leaf = ip4_fib_mtrie_leaf_set_adj_index (a->adj_index);
442
443 if (old_leaf_is_terminal)
444 {
445 /* The current leaf is terminal, we can replace it with
446 * the new one */
447 old_ply->dst_address_bits_of_leaves[slot] =
448 a->dst_address_length;
jaszha03ee743762019-09-27 12:52:18 -0500449 clib_atomic_store_rel_n (&old_ply->leaves[slot], new_leaf);
Neale Rannsa3af3372017-03-28 03:49:52 -0700450 }
451 else
452 {
453 /* Existing leaf points to another ply. We need to place
454 * new_leaf into all more specific slots. */
455 new_ply = get_next_ply_for_leaf (m, old_leaf);
456 set_ply_with_more_specific_leaf (m, new_ply, new_leaf,
457 a->dst_address_length);
458 }
459 }
460 else if (!old_leaf_is_terminal)
461 {
462 /* The current leaf is less specific and not termial (i.e. a ply),
463 * recurse on down the trie */
464 new_ply = get_next_ply_for_leaf (m, old_leaf);
465 set_leaf (m, a, new_ply - ip4_ply_pool, 2);
466 }
467 /*
468 * else
469 * the route we are adding is less specific than the leaf currently
470 * occupying this slot. leave it there
471 */
472 }
473 }
474 else
475 {
476 /* The address to insert requires us to move down at a lower level of
477 * the trie - recurse on down */
478 ip4_fib_mtrie_8_ply_t *new_ply;
479 u8 ply_base_len;
480
481 ply_base_len = 16;
482
483 old_leaf = old_ply->leaves[dst_byte];
484
485 if (ip4_fib_mtrie_leaf_is_terminal (old_leaf))
486 {
487 /* There is a leaf occupying the slot. Replace it with a new ply */
mu.duojiao59a82952018-10-11 14:27:30 +0800488 new_leaf =
489 ply_create (m, old_leaf,
490 old_ply->dst_address_bits_of_leaves[dst_byte],
491 ply_base_len);
Neale Rannsa3af3372017-03-28 03:49:52 -0700492 new_ply = get_next_ply_for_leaf (m, new_leaf);
493
jaszha03ee743762019-09-27 12:52:18 -0500494 clib_atomic_store_rel_n (&old_ply->leaves[dst_byte], new_leaf);
Neale Rannsa3af3372017-03-28 03:49:52 -0700495 old_ply->dst_address_bits_of_leaves[dst_byte] = ply_base_len;
496 }
497 else
498 new_ply = get_next_ply_for_leaf (m, old_leaf);
499
500 set_leaf (m, a, new_ply - ip4_ply_pool, 2);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700501 }
502}
503
504static uword
505unset_leaf (ip4_fib_mtrie_t * m,
Neale Rannsa3af3372017-03-28 03:49:52 -0700506 const ip4_fib_mtrie_set_unset_leaf_args_t * a,
507 ip4_fib_mtrie_8_ply_t * old_ply, u32 dst_address_byte_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700508{
509 ip4_fib_mtrie_leaf_t old_leaf, del_leaf;
510 i32 n_dst_bits_next_plies;
Dave Barach6f6f34f2016-08-08 13:05:31 -0400511 i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700512 u8 dst_byte;
513
Neale Rannsf0609302017-04-11 09:13:39 -0700514 ASSERT (a->dst_address_length <= 32);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700515 ASSERT (dst_address_byte_index < ARRAY_LEN (a->dst_address.as_u8));
516
Dave Barachd7cb1b52016-12-09 09:52:16 -0500517 n_dst_bits_next_plies =
518 a->dst_address_length - BITS (u8) * (dst_address_byte_index + 1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700519
520 dst_byte = a->dst_address.as_u8[dst_address_byte_index];
521 if (n_dst_bits_next_plies < 0)
522 dst_byte &= ~pow2_mask (-n_dst_bits_next_plies);
523
Dave Barachd7cb1b52016-12-09 09:52:16 -0500524 n_dst_bits_this_ply =
525 n_dst_bits_next_plies <= 0 ? -n_dst_bits_next_plies : 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700526 n_dst_bits_this_ply = clib_min (8, n_dst_bits_this_ply);
527
528 del_leaf = ip4_fib_mtrie_leaf_set_adj_index (a->adj_index);
529
530 for (i = dst_byte; i < dst_byte + (1 << n_dst_bits_this_ply); i++)
531 {
532 old_leaf = old_ply->leaves[i];
533 old_leaf_is_terminal = ip4_fib_mtrie_leaf_is_terminal (old_leaf);
534
535 if (old_leaf == del_leaf
Dave Barachd7cb1b52016-12-09 09:52:16 -0500536 || (!old_leaf_is_terminal
537 && unset_leaf (m, a, get_next_ply_for_leaf (m, old_leaf),
538 dst_address_byte_index + 1)))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700539 {
Neale Ranns04a75e32017-03-23 06:46:01 -0700540 old_ply->n_non_empty_leafs -=
541 ip4_fib_mtrie_leaf_is_non_empty (old_ply, i);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700542
jaszha0304c01302019-09-27 15:42:02 -0500543 clib_atomic_store_rel_n (&old_ply->leaves[i],
544 ip4_fib_mtrie_leaf_set_adj_index
545 (a->cover_adj_index));
mu.duojiao9744e6d2018-10-17 10:59:09 +0800546 old_ply->dst_address_bits_of_leaves[i] = a->cover_address_length;
Neale Ranns04a75e32017-03-23 06:46:01 -0700547
548 old_ply->n_non_empty_leafs +=
549 ip4_fib_mtrie_leaf_is_non_empty (old_ply, i);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700550
551 ASSERT (old_ply->n_non_empty_leafs >= 0);
552 if (old_ply->n_non_empty_leafs == 0 && dst_address_byte_index > 0)
553 {
Neale Rannsa3af3372017-03-28 03:49:52 -0700554 pool_put (ip4_ply_pool, old_ply);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700555 /* Old ply was deleted. */
556 return 1;
557 }
Neale Ranns04a75e32017-03-23 06:46:01 -0700558#if CLIB_DEBUG > 0
559 else if (dst_address_byte_index)
560 {
561 int ii, count = 0;
562 for (ii = 0; ii < ARRAY_LEN (old_ply->leaves); ii++)
563 {
564 count += ip4_fib_mtrie_leaf_is_non_empty (old_ply, ii);
565 }
566 ASSERT (count);
567 }
568#endif
Ed Warnickecb9cada2015-12-08 15:45:58 -0700569 }
570 }
571
572 /* Old ply was not deleted. */
573 return 0;
574}
575
Neale Rannsa3af3372017-03-28 03:49:52 -0700576static void
577unset_root_leaf (ip4_fib_mtrie_t * m,
578 const ip4_fib_mtrie_set_unset_leaf_args_t * a)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700579{
Neale Rannsa3af3372017-03-28 03:49:52 -0700580 ip4_fib_mtrie_leaf_t old_leaf, del_leaf;
581 i32 n_dst_bits_next_plies;
582 i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
583 u16 dst_byte;
584 ip4_fib_mtrie_16_ply_t *old_ply;
585
Neale Rannsf0609302017-04-11 09:13:39 -0700586 ASSERT (a->dst_address_length <= 32);
Neale Rannsa3af3372017-03-28 03:49:52 -0700587
588 old_ply = &m->root_ply;
589 n_dst_bits_next_plies = a->dst_address_length - BITS (u16);
590
591 dst_byte = a->dst_address.as_u16[0];
592
593 n_dst_bits_this_ply = (n_dst_bits_next_plies <= 0 ?
594 (16 - a->dst_address_length) : 0);
595
596 del_leaf = ip4_fib_mtrie_leaf_set_adj_index (a->adj_index);
597
598 /* Starting at the value of the byte at this section of the v4 address
599 * fill the buckets/slots of the ply */
600 for (i = 0; i < (1 << n_dst_bits_this_ply); i++)
601 {
602 u16 slot;
603
604 slot = clib_net_to_host_u16 (dst_byte);
605 slot += i;
606 slot = clib_host_to_net_u16 (slot);
607
608 old_leaf = old_ply->leaves[slot];
609 old_leaf_is_terminal = ip4_fib_mtrie_leaf_is_terminal (old_leaf);
610
611 if (old_leaf == del_leaf
612 || (!old_leaf_is_terminal
613 && unset_leaf (m, a, get_next_ply_for_leaf (m, old_leaf), 2)))
614 {
jaszha0304c01302019-09-27 15:42:02 -0500615 clib_atomic_store_rel_n (&old_ply->leaves[slot],
616 ip4_fib_mtrie_leaf_set_adj_index
617 (a->cover_adj_index));
Neale Rannsa3af3372017-03-28 03:49:52 -0700618 old_ply->dst_address_bits_of_leaves[slot] = a->cover_address_length;
619 }
620 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700621}
622
623void
Neale Rannsa3af3372017-03-28 03:49:52 -0700624ip4_fib_mtrie_route_add (ip4_fib_mtrie_t * m,
625 const ip4_address_t * dst_address,
626 u32 dst_address_length, u32 adj_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700627{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700628 ip4_fib_mtrie_set_unset_leaf_args_t a;
Dave Barachd7cb1b52016-12-09 09:52:16 -0500629 ip4_main_t *im = &ip4_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700630
Ed Warnickecb9cada2015-12-08 15:45:58 -0700631 /* Honor dst_address_length. Fib masks are in network byte order */
Neale Rannsa3af3372017-03-28 03:49:52 -0700632 a.dst_address.as_u32 = (dst_address->as_u32 &
633 im->fib_masks[dst_address_length]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700634 a.dst_address_length = dst_address_length;
635 a.adj_index = adj_index;
636
Neale Rannsa3af3372017-03-28 03:49:52 -0700637 set_root_leaf (m, &a);
638}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700639
Neale Rannsa3af3372017-03-28 03:49:52 -0700640void
641ip4_fib_mtrie_route_del (ip4_fib_mtrie_t * m,
642 const ip4_address_t * dst_address,
643 u32 dst_address_length,
644 u32 adj_index,
645 u32 cover_address_length, u32 cover_adj_index)
646{
647 ip4_fib_mtrie_set_unset_leaf_args_t a;
648 ip4_main_t *im = &ip4_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700649
Neale Rannsa3af3372017-03-28 03:49:52 -0700650 /* Honor dst_address_length. Fib masks are in network byte order */
651 a.dst_address.as_u32 = (dst_address->as_u32 &
652 im->fib_masks[dst_address_length]);
653 a.dst_address_length = dst_address_length;
654 a.adj_index = adj_index;
655 a.cover_adj_index = cover_adj_index;
656 a.cover_address_length = cover_address_length;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700657
Neale Rannsa3af3372017-03-28 03:49:52 -0700658 /* the top level ply is never removed */
659 unset_root_leaf (m, &a);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700660}
661
Ed Warnickecb9cada2015-12-08 15:45:58 -0700662/* Returns number of bytes of memory used by mtrie. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500663static uword
Neale Rannsa3af3372017-03-28 03:49:52 -0700664mtrie_ply_memory_usage (ip4_fib_mtrie_t * m, ip4_fib_mtrie_8_ply_t * p)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700665{
666 uword bytes, i;
667
Ed Warnickecb9cada2015-12-08 15:45:58 -0700668 bytes = sizeof (p[0]);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500669 for (i = 0; i < ARRAY_LEN (p->leaves); i++)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700670 {
671 ip4_fib_mtrie_leaf_t l = p->leaves[i];
672 if (ip4_fib_mtrie_leaf_is_next_ply (l))
Neale Rannsa3af3372017-03-28 03:49:52 -0700673 bytes += mtrie_ply_memory_usage (m, get_next_ply_for_leaf (m, l));
674 }
675
676 return bytes;
677}
678
679/* Returns number of bytes of memory used by mtrie. */
Neale Rannsc87aafa2017-11-29 00:59:31 -0800680uword
681ip4_fib_mtrie_memory_usage (ip4_fib_mtrie_t * m)
Neale Rannsa3af3372017-03-28 03:49:52 -0700682{
683 uword bytes, i;
684
685 bytes = sizeof (*m);
686 for (i = 0; i < ARRAY_LEN (m->root_ply.leaves); i++)
687 {
688 ip4_fib_mtrie_leaf_t l = m->root_ply.leaves[i];
689 if (ip4_fib_mtrie_leaf_is_next_ply (l))
690 bytes += mtrie_ply_memory_usage (m, get_next_ply_for_leaf (m, l));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700691 }
692
693 return bytes;
694}
695
Dave Barachd7cb1b52016-12-09 09:52:16 -0500696static u8 *
697format_ip4_fib_mtrie_leaf (u8 * s, va_list * va)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700698{
699 ip4_fib_mtrie_leaf_t l = va_arg (*va, ip4_fib_mtrie_leaf_t);
700
Neale Ranns04a75e32017-03-23 06:46:01 -0700701 if (ip4_fib_mtrie_leaf_is_terminal (l))
702 s = format (s, "lb-index %d", ip4_fib_mtrie_leaf_get_adj_index (l));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700703 else
704 s = format (s, "next ply %d", ip4_fib_mtrie_leaf_get_next_ply_index (l));
705 return s;
706}
707
mu.duojiao59a82952018-10-11 14:27:30 +0800708#define FORMAT_PLY(s, _p, _a, _i, _base_address, _ply_max_len, _indent) \
Neale Rannsa3af3372017-03-28 03:49:52 -0700709({ \
710 u32 a, ia_length; \
711 ip4_address_t ia; \
712 ip4_fib_mtrie_leaf_t _l = p->leaves[(_i)]; \
713 \
mu.duojiao59a82952018-10-11 14:27:30 +0800714 a = (_base_address) + ((_a) << (32 - (_ply_max_len))); \
Neale Rannsa3af3372017-03-28 03:49:52 -0700715 ia.as_u32 = clib_host_to_net_u32 (a); \
716 ia_length = (_p)->dst_address_bits_of_leaves[(_i)]; \
mu.duojiao59a82952018-10-11 14:27:30 +0800717 s = format (s, "\n%U%U %U", \
718 format_white_space, (_indent) + 4, \
Neale Rannsa3af3372017-03-28 03:49:52 -0700719 format_ip4_address_and_length, &ia, ia_length, \
720 format_ip4_fib_mtrie_leaf, _l); \
721 \
722 if (ip4_fib_mtrie_leaf_is_next_ply (_l)) \
mu.duojiao59a82952018-10-11 14:27:30 +0800723 s = format (s, "\n%U", \
724 format_ip4_fib_mtrie_ply, m, a, (_indent) + 8, \
Neale Rannsa3af3372017-03-28 03:49:52 -0700725 ip4_fib_mtrie_leaf_get_next_ply_index (_l)); \
726 s; \
727})
728
Dave Barachd7cb1b52016-12-09 09:52:16 -0500729static u8 *
730format_ip4_fib_mtrie_ply (u8 * s, va_list * va)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700731{
Dave Barachd7cb1b52016-12-09 09:52:16 -0500732 ip4_fib_mtrie_t *m = va_arg (*va, ip4_fib_mtrie_t *);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700733 u32 base_address = va_arg (*va, u32);
mu.duojiao59a82952018-10-11 14:27:30 +0800734 u32 indent = va_arg (*va, u32);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700735 u32 ply_index = va_arg (*va, u32);
Neale Rannsa3af3372017-03-28 03:49:52 -0700736 ip4_fib_mtrie_8_ply_t *p;
Neale Rannsa3af3372017-03-28 03:49:52 -0700737 int i;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700738
Neale Rannsa3af3372017-03-28 03:49:52 -0700739 p = pool_elt_at_index (ip4_ply_pool, ply_index);
mu.duojiao59a82952018-10-11 14:27:30 +0800740 s = format (s, "%Uply index %d, %d non-empty leaves",
741 format_white_space, indent, ply_index, p->n_non_empty_leafs);
Neale Rannsa3af3372017-03-28 03:49:52 -0700742
Ed Warnickecb9cada2015-12-08 15:45:58 -0700743 for (i = 0; i < ARRAY_LEN (p->leaves); i++)
744 {
Neale Ranns04a75e32017-03-23 06:46:01 -0700745 if (ip4_fib_mtrie_leaf_is_non_empty (p, i))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700746 {
mu.duojiao59a82952018-10-11 14:27:30 +0800747 s = FORMAT_PLY (s, p, i, i, base_address,
Neale Ranns756cd942018-04-06 09:18:11 -0700748 p->dst_address_bits_base + 8, indent);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700749 }
750 }
751
752 return s;
753}
754
Dave Barachd7cb1b52016-12-09 09:52:16 -0500755u8 *
756format_ip4_fib_mtrie (u8 * s, va_list * va)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700757{
Dave Barachd7cb1b52016-12-09 09:52:16 -0500758 ip4_fib_mtrie_t *m = va_arg (*va, ip4_fib_mtrie_t *);
Neale Ranns39194252017-11-27 01:03:25 -0800759 int verbose = va_arg (*va, int);
Neale Rannsa3af3372017-03-28 03:49:52 -0700760 ip4_fib_mtrie_16_ply_t *p;
761 u32 base_address = 0;
762 int i;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700763
Neale Rannsa3af3372017-03-28 03:49:52 -0700764 s = format (s, "%d plies, memory usage %U\n",
765 pool_elts (ip4_ply_pool),
Neale Rannsc87aafa2017-11-29 00:59:31 -0800766 format_memory_size, ip4_fib_mtrie_memory_usage (m));
767 s = format (s, "root-ply");
768 p = &m->root_ply;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700769
Neale Ranns39194252017-11-27 01:03:25 -0800770 if (verbose)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700771 {
Neale Ranns39194252017-11-27 01:03:25 -0800772 s = format (s, "root-ply");
773 p = &m->root_ply;
Neale Rannsa3af3372017-03-28 03:49:52 -0700774
Neale Ranns39194252017-11-27 01:03:25 -0800775 for (i = 0; i < ARRAY_LEN (p->leaves); i++)
Neale Rannsa3af3372017-03-28 03:49:52 -0700776 {
Neale Ranns39194252017-11-27 01:03:25 -0800777 u16 slot;
778
779 slot = clib_host_to_net_u16 (i);
780
781 if (p->dst_address_bits_of_leaves[slot] > 0)
782 {
mu.duojiao59a82952018-10-11 14:27:30 +0800783 s = FORMAT_PLY (s, p, i, slot, base_address, 16, 0);
Neale Ranns39194252017-11-27 01:03:25 -0800784 }
Neale Rannsa3af3372017-03-28 03:49:52 -0700785 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700786 }
787
788 return s;
789}
Dave Barachd7cb1b52016-12-09 09:52:16 -0500790
Neale Ranns1ec36522017-11-29 05:20:37 -0800791/** Default heap size for the IPv4 mtries */
792#define IP4_FIB_DEFAULT_MTRIE_HEAP_SIZE (32<<20)
793
Neale Rannsa3af3372017-03-28 03:49:52 -0700794static clib_error_t *
795ip4_mtrie_module_init (vlib_main_t * vm)
796{
Neale Rannsa3af3372017-03-28 03:49:52 -0700797 CLIB_UNUSED (ip4_fib_mtrie_8_ply_t * p);
Neale Ranns1ec36522017-11-29 05:20:37 -0800798 ip4_main_t *im = &ip4_main;
799 clib_error_t *error = NULL;
800 uword *old_heap;
Neale Rannsa3af3372017-03-28 03:49:52 -0700801
Neale Ranns1ec36522017-11-29 05:20:37 -0800802 if (0 == im->mtrie_heap_size)
803 im->mtrie_heap_size = IP4_FIB_DEFAULT_MTRIE_HEAP_SIZE;
Dave Barach6a5adc32018-07-04 10:56:23 -0400804#if USE_DLMALLOC == 0
Neale Ranns1ec36522017-11-29 05:20:37 -0800805 im->mtrie_mheap = mheap_alloc (0, im->mtrie_heap_size);
Dave Barach6a5adc32018-07-04 10:56:23 -0400806#else
807 im->mtrie_mheap = create_mspace (im->mtrie_heap_size, 1 /* locked */ );
808#endif
Neale Ranns1ec36522017-11-29 05:20:37 -0800809
810 /* Burn one ply so index 0 is taken */
811 old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap);
Neale Rannsa3af3372017-03-28 03:49:52 -0700812 pool_get (ip4_ply_pool, p);
Neale Ranns1ec36522017-11-29 05:20:37 -0800813 clib_mem_set_heap (old_heap);
Neale Rannsa3af3372017-03-28 03:49:52 -0700814
Neale Ranns1ec36522017-11-29 05:20:37 -0800815 return (error);
Neale Rannsa3af3372017-03-28 03:49:52 -0700816}
817
818VLIB_INIT_FUNCTION (ip4_mtrie_module_init);
819
Dave Barachd7cb1b52016-12-09 09:52:16 -0500820/*
821 * fd.io coding-style-patch-verification: ON
822 *
823 * Local Variables:
824 * eval: (c-set-style "gnu")
825 * End:
826 */