2 * mpls_lookup.c: MPLS lookup
4 * Copyright (c) 2012-2014 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vlib/vlib.h>
19 #include <vnet/pg/pg.h>
20 #include <vnet/mpls/mpls.h>
21 #include <vnet/fib/mpls_fib.h>
22 #include <vnet/dpo/load_balance_map.h>
23 #include <vnet/dpo/replicate_dpo.h>
26 * Static MPLS VLIB forwarding node
28 static vlib_node_registration_t mpls_lookup_node;
31 * The arc/edge from the MPLS lookup node to the MPLS replicate node
33 static u32 mpls_lookup_to_replicate_edge;
39 u32 label_net_byte_order;
41 } mpls_lookup_trace_t;
44 format_mpls_lookup_trace (u8 * s, va_list * args)
46 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
47 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
48 mpls_lookup_trace_t * t = va_arg (*args, mpls_lookup_trace_t *);
50 s = format (s, "MPLS: next [%d], lookup fib index %d, LB index %d hash %x "
52 t->next_index, t->lfib_index, t->lb_index, t->hash,
53 vnet_mpls_uc_get_label(
54 clib_net_to_host_u32(t->label_net_byte_order)),
55 vnet_mpls_uc_get_s(t->label_net_byte_order));
61 * We'll use it to select which adjacency to use for this flow. And other things.
64 mpls_compute_flow_hash (const mpls_unicast_header_t * hdr,
65 flow_hash_config_t flow_hash_config)
68 * improve this to include:
69 * - all labels in the stack.
70 * - recognise entropy labels.
72 * We need to byte swap so we use the numerical value. i.e. an odd label
73 * leads to an odd bucket. ass opposed to a label above and below value X.
75 return (vnet_mpls_uc_get_label(clib_net_to_host_u32(hdr->label_exp_s_ttl)));
79 mpls_lookup (vlib_main_t * vm,
80 vlib_node_runtime_t * node,
81 vlib_frame_t * from_frame)
83 vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters;
84 u32 n_left_from, next_index, * from, * to_next;
85 mpls_main_t * mm = &mpls_main;
86 u32 thread_index = vlib_get_thread_index();
88 from = vlib_frame_vector_args (from_frame);
89 n_left_from = from_frame->n_vectors;
90 next_index = node->cached_next_index;
92 while (n_left_from > 0)
96 vlib_get_next_frame (vm, node, next_index,
97 to_next, n_left_to_next);
99 while (n_left_from >= 8 && n_left_to_next >= 4)
101 u32 lbi0, next0, lfib_index0, bi0, hash_c0;
102 const mpls_unicast_header_t * h0;
103 const load_balance_t *lb0;
104 const dpo_id_t *dpo0;
106 u32 lbi1, next1, lfib_index1, bi1, hash_c1;
107 const mpls_unicast_header_t * h1;
108 const load_balance_t *lb1;
109 const dpo_id_t *dpo1;
111 u32 lbi2, next2, lfib_index2, bi2, hash_c2;
112 const mpls_unicast_header_t * h2;
113 const load_balance_t *lb2;
114 const dpo_id_t *dpo2;
116 u32 lbi3, next3, lfib_index3, bi3, hash_c3;
117 const mpls_unicast_header_t * h3;
118 const load_balance_t *lb3;
119 const dpo_id_t *dpo3;
122 /* Prefetch next iteration. */
124 vlib_buffer_t * p2, * p3, *p4, *p5;
126 p2 = vlib_get_buffer (vm, from[2]);
127 p3 = vlib_get_buffer (vm, from[3]);
128 p4 = vlib_get_buffer (vm, from[4]);
129 p5 = vlib_get_buffer (vm, from[5]);
131 vlib_prefetch_buffer_header (p2, STORE);
132 vlib_prefetch_buffer_header (p3, STORE);
133 vlib_prefetch_buffer_header (p4, STORE);
134 vlib_prefetch_buffer_header (p5, STORE);
136 CLIB_PREFETCH (p2->data, sizeof (h0[0]), STORE);
137 CLIB_PREFETCH (p3->data, sizeof (h0[0]), STORE);
138 CLIB_PREFETCH (p4->data, sizeof (h0[0]), STORE);
139 CLIB_PREFETCH (p5->data, sizeof (h0[0]), STORE);
142 bi0 = to_next[0] = from[0];
143 bi1 = to_next[1] = from[1];
144 bi2 = to_next[2] = from[2];
145 bi3 = to_next[3] = from[3];
152 b0 = vlib_get_buffer (vm, bi0);
153 b1 = vlib_get_buffer (vm, bi1);
154 b2 = vlib_get_buffer (vm, bi2);
155 b3 = vlib_get_buffer (vm, bi3);
156 h0 = vlib_buffer_get_current (b0);
157 h1 = vlib_buffer_get_current (b1);
158 h2 = vlib_buffer_get_current (b2);
159 h3 = vlib_buffer_get_current (b3);
161 lfib_index0 = vec_elt(mm->fib_index_by_sw_if_index,
162 vnet_buffer(b0)->sw_if_index[VLIB_RX]);
163 lfib_index1 = vec_elt(mm->fib_index_by_sw_if_index,
164 vnet_buffer(b1)->sw_if_index[VLIB_RX]);
165 lfib_index2 = vec_elt(mm->fib_index_by_sw_if_index,
166 vnet_buffer(b2)->sw_if_index[VLIB_RX]);
167 lfib_index3 = vec_elt(mm->fib_index_by_sw_if_index,
168 vnet_buffer(b3)->sw_if_index[VLIB_RX]);
170 lbi0 = mpls_fib_table_forwarding_lookup (lfib_index0, h0);
171 lbi1 = mpls_fib_table_forwarding_lookup (lfib_index1, h1);
172 lbi2 = mpls_fib_table_forwarding_lookup (lfib_index2, h2);
173 lbi3 = mpls_fib_table_forwarding_lookup (lfib_index3, h3);
175 hash_c0 = vnet_buffer(b0)->ip.flow_hash = 0;
176 hash_c1 = vnet_buffer(b1)->ip.flow_hash = 0;
177 hash_c2 = vnet_buffer(b2)->ip.flow_hash = 0;
178 hash_c3 = vnet_buffer(b3)->ip.flow_hash = 0;
180 if (MPLS_IS_REPLICATE & lbi0)
182 next0 = mpls_lookup_to_replicate_edge;
183 vnet_buffer (b0)->ip.adj_index[VLIB_TX] =
184 (lbi0 & ~MPLS_IS_REPLICATE);
188 lb0 = load_balance_get(lbi0);
189 ASSERT (lb0->lb_n_buckets > 0);
190 ASSERT (is_pow2 (lb0->lb_n_buckets));
192 if (PREDICT_FALSE(lb0->lb_n_buckets > 1))
194 hash_c0 = vnet_buffer (b0)->ip.flow_hash =
195 mpls_compute_flow_hash(h0, lb0->lb_hash_config);
196 dpo0 = load_balance_get_fwd_bucket
198 (hash_c0 & (lb0->lb_n_buckets_minus_1)));
202 dpo0 = load_balance_get_bucket_i (lb0, 0);
204 next0 = dpo0->dpoi_next_node;
206 vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
208 vlib_increment_combined_counter
209 (cm, thread_index, lbi0, 1,
210 vlib_buffer_length_in_chain (vm, b0));
212 if (MPLS_IS_REPLICATE & lbi1)
214 next1 = mpls_lookup_to_replicate_edge;
215 vnet_buffer (b1)->ip.adj_index[VLIB_TX] =
216 (lbi1 & ~MPLS_IS_REPLICATE);
220 lb1 = load_balance_get(lbi1);
221 ASSERT (lb1->lb_n_buckets > 0);
222 ASSERT (is_pow2 (lb1->lb_n_buckets));
224 if (PREDICT_FALSE(lb1->lb_n_buckets > 1))
226 hash_c1 = vnet_buffer (b1)->ip.flow_hash =
227 mpls_compute_flow_hash(h1, lb1->lb_hash_config);
228 dpo1 = load_balance_get_fwd_bucket
230 (hash_c1 & (lb1->lb_n_buckets_minus_1)));
234 dpo1 = load_balance_get_bucket_i (lb1, 0);
236 next1 = dpo1->dpoi_next_node;
238 vnet_buffer (b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
240 vlib_increment_combined_counter
241 (cm, thread_index, lbi1, 1,
242 vlib_buffer_length_in_chain (vm, b1));
244 if (MPLS_IS_REPLICATE & lbi2)
246 next2 = mpls_lookup_to_replicate_edge;
247 vnet_buffer (b2)->ip.adj_index[VLIB_TX] =
248 (lbi2 & ~MPLS_IS_REPLICATE);
252 lb2 = load_balance_get(lbi2);
253 ASSERT (lb2->lb_n_buckets > 0);
254 ASSERT (is_pow2 (lb2->lb_n_buckets));
256 if (PREDICT_FALSE(lb2->lb_n_buckets > 1))
258 hash_c2 = vnet_buffer (b2)->ip.flow_hash =
259 mpls_compute_flow_hash(h2, lb2->lb_hash_config);
260 dpo2 = load_balance_get_fwd_bucket
262 (hash_c2 & (lb2->lb_n_buckets_minus_1)));
266 dpo2 = load_balance_get_bucket_i (lb2, 0);
268 next2 = dpo2->dpoi_next_node;
270 vnet_buffer (b2)->ip.adj_index[VLIB_TX] = dpo2->dpoi_index;
272 vlib_increment_combined_counter
273 (cm, thread_index, lbi2, 1,
274 vlib_buffer_length_in_chain (vm, b2));
276 if (MPLS_IS_REPLICATE & lbi3)
278 next3 = mpls_lookup_to_replicate_edge;
279 vnet_buffer (b3)->ip.adj_index[VLIB_TX] =
280 (lbi3 & ~MPLS_IS_REPLICATE);
284 lb3 = load_balance_get(lbi3);
285 ASSERT (lb3->lb_n_buckets > 0);
286 ASSERT (is_pow2 (lb3->lb_n_buckets));
288 if (PREDICT_FALSE(lb3->lb_n_buckets > 1))
290 hash_c3 = vnet_buffer (b3)->ip.flow_hash =
291 mpls_compute_flow_hash(h3, lb3->lb_hash_config);
292 dpo3 = load_balance_get_fwd_bucket
294 (hash_c3 & (lb3->lb_n_buckets_minus_1)));
298 dpo3 = load_balance_get_bucket_i (lb3, 0);
300 next3 = dpo3->dpoi_next_node;
302 vnet_buffer (b3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
304 vlib_increment_combined_counter
305 (cm, thread_index, lbi3, 1,
306 vlib_buffer_length_in_chain (vm, b3));
310 * before we pop the label copy th values we need to maintain.
311 * The label header is in network byte order.
312 * last byte is the TTL.
313 * bits 2 to 4 inclusive are the EXP bits
315 vnet_buffer (b0)->mpls.ttl = ((char*)h0)[3];
316 vnet_buffer (b0)->mpls.exp = (((char*)h0)[2] & 0xe) >> 1;
317 vnet_buffer (b0)->mpls.first = 1;
318 vnet_buffer (b1)->mpls.ttl = ((char*)h1)[3];
319 vnet_buffer (b1)->mpls.exp = (((char*)h1)[2] & 0xe) >> 1;
320 vnet_buffer (b1)->mpls.first = 1;
321 vnet_buffer (b2)->mpls.ttl = ((char*)h2)[3];
322 vnet_buffer (b2)->mpls.exp = (((char*)h2)[2] & 0xe) >> 1;
323 vnet_buffer (b2)->mpls.first = 1;
324 vnet_buffer (b3)->mpls.ttl = ((char*)h3)[3];
325 vnet_buffer (b3)->mpls.exp = (((char*)h3)[2] & 0xe) >> 1;
326 vnet_buffer (b3)->mpls.first = 1;
329 * pop the label that was just used in the lookup
331 vlib_buffer_advance(b0, sizeof(*h0));
332 vlib_buffer_advance(b1, sizeof(*h1));
333 vlib_buffer_advance(b2, sizeof(*h2));
334 vlib_buffer_advance(b3, sizeof(*h3));
336 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
338 mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
340 tr->next_index = next0;
342 tr->lfib_index = lfib_index0;
344 tr->label_net_byte_order = h0->label_exp_s_ttl;
347 if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
349 mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
351 tr->next_index = next1;
353 tr->lfib_index = lfib_index1;
355 tr->label_net_byte_order = h1->label_exp_s_ttl;
358 if (PREDICT_FALSE(b2->flags & VLIB_BUFFER_IS_TRACED))
360 mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
362 tr->next_index = next2;
364 tr->lfib_index = lfib_index2;
366 tr->label_net_byte_order = h2->label_exp_s_ttl;
369 if (PREDICT_FALSE(b3->flags & VLIB_BUFFER_IS_TRACED))
371 mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
373 tr->next_index = next3;
375 tr->lfib_index = lfib_index3;
377 tr->label_net_byte_order = h3->label_exp_s_ttl;
380 vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
381 to_next, n_left_to_next,
383 next0, next1, next2, next3);
386 while (n_left_from > 0 && n_left_to_next > 0)
388 u32 lbi0, next0, lfib_index0, bi0, hash_c0;
389 const mpls_unicast_header_t * h0;
390 const load_balance_t *lb0;
391 const dpo_id_t *dpo0;
401 b0 = vlib_get_buffer (vm, bi0);
402 h0 = vlib_buffer_get_current (b0);
404 lfib_index0 = vec_elt(mm->fib_index_by_sw_if_index,
405 vnet_buffer(b0)->sw_if_index[VLIB_RX]);
407 lbi0 = mpls_fib_table_forwarding_lookup(lfib_index0, h0);
408 hash_c0 = vnet_buffer(b0)->ip.flow_hash = 0;
410 if (MPLS_IS_REPLICATE & lbi0)
412 next0 = mpls_lookup_to_replicate_edge;
413 vnet_buffer (b0)->ip.adj_index[VLIB_TX] =
414 (lbi0 & ~MPLS_IS_REPLICATE);
418 lb0 = load_balance_get(lbi0);
419 ASSERT (lb0->lb_n_buckets > 0);
420 ASSERT (is_pow2 (lb0->lb_n_buckets));
422 if (PREDICT_FALSE(lb0->lb_n_buckets > 1))
424 hash_c0 = vnet_buffer (b0)->ip.flow_hash =
425 mpls_compute_flow_hash(h0, lb0->lb_hash_config);
426 dpo0 = load_balance_get_fwd_bucket
428 (hash_c0 & (lb0->lb_n_buckets_minus_1)));
432 dpo0 = load_balance_get_bucket_i (lb0, 0);
434 next0 = dpo0->dpoi_next_node;
435 vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
437 vlib_increment_combined_counter
438 (cm, thread_index, lbi0, 1,
439 vlib_buffer_length_in_chain (vm, b0));
443 * before we pop the label copy, values we need to maintain.
444 * The label header is in network byte order.
445 * last byte is the TTL.
446 * bits 2 to 4 inclusive are the EXP bits
448 vnet_buffer (b0)->mpls.ttl = ((char*)h0)[3];
449 vnet_buffer (b0)->mpls.exp = (((char*)h0)[2] & 0xe) >> 1;
450 vnet_buffer (b0)->mpls.first = 1;
453 * pop the label that was just used in the lookup
455 vlib_buffer_advance(b0, sizeof(*h0));
457 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
459 mpls_lookup_trace_t *tr = vlib_add_trace (vm, node,
461 tr->next_index = next0;
463 tr->lfib_index = lfib_index0;
465 tr->label_net_byte_order = h0->label_exp_s_ttl;
468 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
469 to_next, n_left_to_next,
473 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
475 vlib_node_increment_counter (vm, mpls_lookup_node.index,
476 MPLS_ERROR_PKTS_DECAP, from_frame->n_vectors);
477 return from_frame->n_vectors;
480 static char * mpls_error_strings[] = {
481 #define mpls_error(n,s) s,
486 VLIB_REGISTER_NODE (mpls_lookup_node, static) = {
487 .function = mpls_lookup,
488 .name = "mpls-lookup",
489 /* Takes a vector of packets. */
490 .vector_size = sizeof (u32),
491 .n_errors = MPLS_N_ERROR,
492 .error_strings = mpls_error_strings,
494 .sibling_of = "mpls-load-balance",
496 .format_buffer = format_mpls_header,
497 .format_trace = format_mpls_lookup_trace,
498 .unformat_buffer = unformat_mpls_header,
501 VLIB_NODE_FUNCTION_MULTIARCH (mpls_lookup_node, mpls_lookup)
507 } mpls_load_balance_trace_t;
510 format_mpls_load_balance_trace (u8 * s, va_list * args)
512 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
513 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
514 mpls_load_balance_trace_t * t = va_arg (*args, mpls_load_balance_trace_t *);
516 s = format (s, "MPLS: next [%d], LB index %d hash %d",
517 t->next_index, t->lb_index, t->hash);
522 mpls_load_balance (vlib_main_t * vm,
523 vlib_node_runtime_t * node,
524 vlib_frame_t * frame)
526 vlib_combined_counter_main_t * cm = &load_balance_main.lbm_via_counters;
527 u32 n_left_from, n_left_to_next, * from, * to_next;
528 u32 thread_index = vlib_get_thread_index();
531 from = vlib_frame_vector_args (frame);
532 n_left_from = frame->n_vectors;
533 next = node->cached_next_index;
535 while (n_left_from > 0)
537 vlib_get_next_frame (vm, node, next,
538 to_next, n_left_to_next);
541 while (n_left_from >= 4 && n_left_to_next >= 2)
543 const load_balance_t *lb0, *lb1;
544 vlib_buffer_t * p0, *p1;
545 u32 pi0, lbi0, hc0, pi1, lbi1, hc1, next0, next1;
546 const mpls_unicast_header_t *mpls0, *mpls1;
547 const dpo_id_t *dpo0, *dpo1;
549 /* Prefetch next iteration. */
551 vlib_buffer_t * p2, * p3;
553 p2 = vlib_get_buffer (vm, from[2]);
554 p3 = vlib_get_buffer (vm, from[3]);
556 vlib_prefetch_buffer_header (p2, STORE);
557 vlib_prefetch_buffer_header (p3, STORE);
559 CLIB_PREFETCH (p2->data, sizeof (mpls0[0]), STORE);
560 CLIB_PREFETCH (p3->data, sizeof (mpls0[0]), STORE);
563 pi0 = to_next[0] = from[0];
564 pi1 = to_next[1] = from[1];
571 p0 = vlib_get_buffer (vm, pi0);
572 p1 = vlib_get_buffer (vm, pi1);
574 mpls0 = vlib_buffer_get_current (p0);
575 mpls1 = vlib_buffer_get_current (p1);
576 lbi0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
577 lbi1 = vnet_buffer (p1)->ip.adj_index[VLIB_TX];
579 lb0 = load_balance_get(lbi0);
580 lb1 = load_balance_get(lbi1);
583 * this node is for via FIBs we can re-use the hash value from the
584 * to node if present.
585 * We don't want to use the same hash value at each level in the recursion
586 * graph as that would lead to polarisation
588 hc0 = vnet_buffer (p0)->ip.flow_hash = 0;
589 hc1 = vnet_buffer (p1)->ip.flow_hash = 0;
591 if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
593 if (PREDICT_TRUE (vnet_buffer(p0)->ip.flow_hash))
595 hc0 = vnet_buffer(p0)->ip.flow_hash = vnet_buffer(p0)->ip.flow_hash >> 1;
599 hc0 = vnet_buffer(p0)->ip.flow_hash = mpls_compute_flow_hash(mpls0, hc0);
601 dpo0 = load_balance_get_fwd_bucket(lb0, (hc0 & lb0->lb_n_buckets_minus_1));
605 dpo0 = load_balance_get_bucket_i (lb0, 0);
607 if (PREDICT_FALSE (lb1->lb_n_buckets > 1))
609 if (PREDICT_TRUE (vnet_buffer(p1)->ip.flow_hash))
611 hc1 = vnet_buffer(p1)->ip.flow_hash = vnet_buffer(p1)->ip.flow_hash >> 1;
615 hc1 = vnet_buffer(p1)->ip.flow_hash = mpls_compute_flow_hash(mpls1, hc1);
617 dpo1 = load_balance_get_fwd_bucket(lb1, (hc1 & lb1->lb_n_buckets_minus_1));
621 dpo1 = load_balance_get_bucket_i (lb1, 0);
624 next0 = dpo0->dpoi_next_node;
625 next1 = dpo1->dpoi_next_node;
627 vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
628 vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
630 vlib_increment_combined_counter
631 (cm, thread_index, lbi0, 1,
632 vlib_buffer_length_in_chain (vm, p0));
633 vlib_increment_combined_counter
634 (cm, thread_index, lbi1, 1,
635 vlib_buffer_length_in_chain (vm, p1));
637 if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED))
639 mpls_load_balance_trace_t *tr = vlib_add_trace (vm, node,
641 tr->next_index = next0;
646 vlib_validate_buffer_enqueue_x2 (vm, node, next,
647 to_next, n_left_to_next,
648 pi0, pi1, next0, next1);
651 while (n_left_from > 0 && n_left_to_next > 0)
653 const load_balance_t *lb0;
655 u32 pi0, lbi0, hc0, next0;
656 const mpls_unicast_header_t *mpls0;
657 const dpo_id_t *dpo0;
666 p0 = vlib_get_buffer (vm, pi0);
668 mpls0 = vlib_buffer_get_current (p0);
669 lbi0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
671 lb0 = load_balance_get(lbi0);
673 hc0 = vnet_buffer (p0)->ip.flow_hash = 0;
674 if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
676 if (PREDICT_TRUE (vnet_buffer(p0)->ip.flow_hash))
678 hc0 = vnet_buffer(p0)->ip.flow_hash = vnet_buffer(p0)->ip.flow_hash >> 1;
682 hc0 = vnet_buffer(p0)->ip.flow_hash = mpls_compute_flow_hash(mpls0, hc0);
684 dpo0 = load_balance_get_fwd_bucket(lb0, (hc0 & lb0->lb_n_buckets_minus_1));
688 dpo0 = load_balance_get_bucket_i (lb0, 0);
691 next0 = dpo0->dpoi_next_node;
692 vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
694 vlib_increment_combined_counter
695 (cm, thread_index, lbi0, 1,
696 vlib_buffer_length_in_chain (vm, p0));
698 vlib_validate_buffer_enqueue_x1 (vm, node, next,
699 to_next, n_left_to_next,
703 vlib_put_next_frame (vm, node, next, n_left_to_next);
706 return frame->n_vectors;
709 VLIB_REGISTER_NODE (mpls_load_balance_node) = {
710 .function = mpls_load_balance,
711 .name = "mpls-load-balance",
712 .vector_size = sizeof (u32),
713 .format_trace = format_mpls_load_balance_trace,
722 VLIB_NODE_FUNCTION_MULTIARCH (mpls_load_balance_node, mpls_load_balance)
725 static clib_error_t *
726 mpls_lookup_init (vlib_main_t * vm)
728 clib_error_t * error;
730 if ((error = vlib_call_init_function (vm, mpls_init)))
733 mpls_lookup_to_replicate_edge =
734 vlib_node_add_named_next(vm,
735 mpls_lookup_node.index,
741 VLIB_INIT_FUNCTION (mpls_lookup_init);