2 *------------------------------------------------------------------
5 * Copyright (c) 2021 Graphiant.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #include <vnet/ip/ip_path_mtu.h>
21 #include <vnet/ip/ip_frag.h>
22 #include <vnet/adj/adj_delegate.h>
23 #include <vnet/adj/adj_nbr.h>
24 #include <vnet/fib/fib_table.h>
25 #include <vnet/fib/fib_entry_track.h>
27 #include <vnet/dpo/drop_dpo.h>
32 * A path is a peer. A peer is known by an IP address (in a table).
33 * Insert a DPO in the forwarding chain for the peer to perform the
35 * For attached peers, all traffic will use the peer's adjacency, there
36 * is already an MTU chekc in the adjacency (for the link's MTU) so as an
37 * optimisation, instead of using a DPO, we add a delegate to the adjacency
38 * to set the adjacency's MTU to the path MTU.
44 static vlib_log_class_t ip_pmtu_logger;
46 static adj_delegate_type_t ip_pmtu_adj_delegate_type;
47 static fib_source_t ip_pmtu_source;
52 ip_pmtu_dpo_t *ip_pmtu_dpo_pool;
55 * DPO type registered for these GBP FWD
57 static dpo_type_t ip_pmtu_dpo_type;
60 * Fib node type for the tracker
62 static fib_node_type_t ip_pmtu_fib_type;
65 * Path MTU tracker pool
67 ip_pmtu_t *ip_pmtu_pool;
70 * Delegate added to adjacencies to track path MTU
72 typedef struct ip_path_mtu_adj_delegate_t_
75 } ip_path_mtu_adj_delegate_t;
77 static ip_path_mtu_adj_delegate_t *ip_path_mtu_adj_delegate_pool;
79 /* DB of all FIB PMTU settings */
80 typedef struct ip_pmtu_key_t_
84 fib_protocol_t fproto;
85 } __clib_packed ip_pmtu_key_t;
87 static uword *ip_pmtu_db;
89 #define IP_PMTU_TRKR_DBG(_ipt, _fmt, _args...) \
91 vlib_log_debug (ip_pmtu_logger, "[%U]: " _fmt ": ", format_ip_pmtu, \
92 _ipt - ip_pmtu_pool, ##_args); \
94 #define IP_PMTU_DBG(_fmt, _args...) \
96 vlib_log_debug (ip_pmtu_logger, _fmt ": ", ##_args); \
100 format_ip_pmtu_flags (u8 *s, va_list *ap)
102 ip_pmtu_flags_t f = va_arg (*ap, ip_pmtu_flags_t);
106 #define _(a, b, c) else if (f & IP_PMTU_FLAG_##a) s = format (s, "%s ", c);
114 ip_pmtu_get_table_id (const ip_pmtu_t *ipt)
116 const fib_prefix_t *pfx;
119 pfx = fib_entry_get_prefix (ipt->ipt_fib_entry);
120 fib_index = fib_entry_get_fib_index (ipt->ipt_fib_entry);
122 return (fib_table_get_table_id (fib_index, pfx->fp_proto));
126 ip_pmtu_get_ip (const ip_pmtu_t *ipt, ip_address_t *ip)
128 const fib_prefix_t *pfx;
130 pfx = fib_entry_get_prefix (ipt->ipt_fib_entry);
131 ip_address_from_46 (&pfx->fp_addr, pfx->fp_proto, ip);
135 format_ip_pmtu (u8 *s, va_list *ap)
138 index_t ipti = va_arg (*ap, index_t);
139 const fib_prefix_t *pfx;
142 ipt = pool_elt_at_index (ip_pmtu_pool, ipti);
143 pfx = fib_entry_get_prefix (ipt->ipt_fib_entry);
144 fib_index = fib_entry_get_fib_index (ipt->ipt_fib_entry);
147 format (s, "[%d] [tbl:[%d:%d]] %U pmtu:[cfg:%d, oper:%d, parent:%d] [%U]",
148 ipti, ip_pmtu_get_table_id (ipt), fib_index, format_fib_prefix,
149 pfx, ipt->ipt_cfg_pmtu, ipt->ipt_oper_pmtu, ipt->ipt_parent_pmtu,
150 format_ip_pmtu_flags, ipt->ipt_flags);
156 format_ip_path_mtu_adj_delegate (const adj_delegate_t *aed, u8 *s)
158 ip_path_mtu_adj_delegate_t *ip_adj;
160 ip_adj = pool_elt_at_index (ip_path_mtu_adj_delegate_pool, aed->ad_index);
162 s = format (s, "IP path-MTU: %d", ip_adj->pmtu);
168 ip_pmtu_adj_delegate_adj_created (adj_index_t ai)
170 ip_path_mtu_adj_delegate_t *ipp_ad;
171 const ip_pmtu_t *ipt;
178 switch (adj->lookup_next_index)
180 case IP_LOOKUP_NEXT_DROP:
181 case IP_LOOKUP_NEXT_PUNT:
182 case IP_LOOKUP_NEXT_LOCAL:
183 case IP_LOOKUP_NEXT_GLEAN:
184 case IP_LOOKUP_NEXT_MCAST:
185 case IP_LOOKUP_NEXT_BCAST:
186 case IP_LOOKUP_NEXT_MCAST_MIDCHAIN:
187 case IP_LOOKUP_NEXT_ICMP_ERROR:
188 case IP_LOOKUP_N_NEXT:
191 case IP_LOOKUP_NEXT_ARP:
192 case IP_LOOKUP_NEXT_REWRITE:
193 case IP_LOOKUP_NEXT_MIDCHAIN:
197 table_id = fib_table_get_table_id_for_sw_if_index (
198 adj->ia_nh_proto, adj->rewrite_header.sw_if_index);
200 ip_pmtu_key_t key = {
201 .nh = adj->sub_type.nbr.next_hop,
202 .table_id = table_id,
203 .fproto = adj->ia_nh_proto,
206 p = hash_get_mem (ip_pmtu_db, &key);
211 ipt = pool_elt_at_index (ip_pmtu_pool, p[0]);
213 pool_get (ip_path_mtu_adj_delegate_pool, ipp_ad);
214 ipp_ad->pmtu = ipt->ipt_cfg_pmtu;
216 adj_delegate_add (adj, ip_pmtu_adj_delegate_type,
217 ipp_ad - ip_path_mtu_adj_delegate_pool);
219 adj_nbr_set_mtu (ai, ipp_ad->pmtu);
221 IP_PMTU_TRKR_DBG (ipt, "adj-added:", ai);
225 ip_pmtu_adj_delegate_adj_deleted (adj_delegate_t *ad)
227 pool_put_index (ip_path_mtu_adj_delegate_pool, ad->ad_index);
231 ip_pmtu_adj_delegate_adj_modified (adj_delegate_t *ad)
233 ip_path_mtu_adj_delegate_t *ipp_ad;
235 ipp_ad = pool_elt_at_index (ip_path_mtu_adj_delegate_pool, ad->ad_index);
237 adj_nbr_set_mtu (ad->ad_adj_index, ipp_ad->pmtu);
240 const adj_delegate_vft_t ip_path_adj_delegate_vft = {
241 .adv_format = format_ip_path_mtu_adj_delegate,
242 .adv_adj_deleted = ip_pmtu_adj_delegate_adj_deleted,
243 .adv_adj_modified = ip_pmtu_adj_delegate_adj_modified,
244 .adv_adj_created = ip_pmtu_adj_delegate_adj_created,
248 ip_path_mtu_value_invalid (u16 pmtu)
250 return (pmtu == 0 || pmtu == 0xffff);
254 ip_ptmu_adj_walk_remove (adj_index_t ai, void *ctx)
258 ad = adj_delegate_get (adj_get (ai), ip_pmtu_adj_delegate_type);
262 adj_nbr_set_mtu (ai, 0);
264 pool_put_index (ip_path_mtu_adj_delegate_pool, ad->ad_index);
265 adj_delegate_remove (ai, ip_pmtu_adj_delegate_type);
267 return (ADJ_WALK_RC_CONTINUE);
271 ip_ptmu_adj_walk_update (adj_index_t ai, void *ctx)
273 ip_path_mtu_adj_delegate_t *ipp_ad;
278 ad = adj_delegate_get (adj_get (ai), ip_pmtu_adj_delegate_type);
281 ipp_ad = pool_elt_at_index (ip_path_mtu_adj_delegate_pool, ad->ad_index);
284 pool_get (ip_path_mtu_adj_delegate_pool, ipp_ad);
286 adj_delegate_add (adj_get (ai), ip_pmtu_adj_delegate_type,
287 ipp_ad - ip_path_mtu_adj_delegate_pool);
290 ipp_ad->pmtu = *pmtup;
292 adj_nbr_set_mtu (ai, ipp_ad->pmtu);
294 return (ADJ_WALK_RC_CONTINUE);
297 static ip_pmtu_dpo_t *
298 ip_pmtu_dpo_alloc (void)
300 vlib_main_t *vm = vlib_get_main ();
301 u8 need_barrier_sync = 0;
304 pool_get_aligned_will_expand (ip_pmtu_dpo_pool, need_barrier_sync,
305 sizeof (ip_pmtu_dpo_t));
307 if (need_barrier_sync)
308 vlib_worker_thread_barrier_sync (vm);
310 pool_get_aligned_zero (ip_pmtu_dpo_pool, ipm, sizeof (ip_pmtu_dpo_t));
312 if (need_barrier_sync)
313 vlib_worker_thread_barrier_release (vm);
318 static ip_pmtu_dpo_t *
319 ip_pmtu_dpo_get_from_dpo (const dpo_id_t *dpo)
321 ASSERT (ip_pmtu_dpo_type == dpo->dpoi_type);
323 return (ip_pmtu_dpo_get (dpo->dpoi_index));
327 ip_pmtu_dpo_get_index (ip_pmtu_dpo_t *ipm)
329 return (ipm - ip_pmtu_dpo_pool);
333 ip_pmtu_dpo_lock (dpo_id_t *dpo)
337 ipm = ip_pmtu_dpo_get_from_dpo (dpo);
342 ip_pmtu_dpo_unlock (dpo_id_t *dpo)
346 ipm = ip_pmtu_dpo_get_from_dpo (dpo);
349 if (0 == ipm->ipm_locks)
351 dpo_reset (&ipm->ipm_dpo);
352 pool_put (ip_pmtu_dpo_pool, ipm);
357 ip_pmtu_dpo_get_urpf (const dpo_id_t *dpo)
361 ipm = ip_pmtu_dpo_get_from_dpo (dpo);
363 return (dpo_get_urpf (&ipm->ipm_dpo));
367 ip_pmtu_dpo_add_or_lock (u16 pmtu, const dpo_id_t *parent, dpo_id_t *dpo)
371 ipm = ip_pmtu_dpo_alloc ();
373 ipm->ipm_proto = parent->dpoi_proto;
374 ipm->ipm_pmtu = pmtu;
376 dpo_stack (ip_pmtu_dpo_type, ipm->ipm_proto, &ipm->ipm_dpo, parent);
377 dpo_set (dpo, ip_pmtu_dpo_type, ipm->ipm_proto, ip_pmtu_dpo_get_index (ipm));
381 format_ip_pmtu_dpo (u8 *s, va_list *ap)
383 index_t index = va_arg (*ap, index_t);
384 u32 indent = va_arg (*ap, u32);
385 ip_pmtu_dpo_t *ipm = ip_pmtu_dpo_get (index);
387 s = format (s, "ip-pmtu-dpo: %U, mtu:%d", format_dpo_proto, ipm->ipm_proto,
389 s = format (s, "\n%U", format_white_space, indent + 2);
390 s = format (s, "%U", format_dpo_id, &ipm->ipm_dpo, indent + 4);
396 * Interpose a path MTU DPO
399 ip_pmtu_dpo_interpose (const dpo_id_t *original, const dpo_id_t *parent,
402 ip_pmtu_dpo_t *ipm, *ipm_clone;
404 ipm_clone = ip_pmtu_dpo_alloc ();
405 ipm = ip_pmtu_dpo_get (original->dpoi_index);
407 ipm_clone->ipm_proto = ipm->ipm_proto;
408 ipm_clone->ipm_pmtu = ipm->ipm_pmtu;
410 dpo_stack (ip_pmtu_dpo_type, ipm_clone->ipm_proto, &ipm_clone->ipm_dpo,
412 dpo_set (clone, ip_pmtu_dpo_type, ipm_clone->ipm_proto,
413 ip_pmtu_dpo_get_index (ipm_clone));
417 ip_pmtu_dpo_get_mtu (const dpo_id_t *dpo)
421 ipd = pool_elt_at_index (ip_pmtu_dpo_pool, dpo->dpoi_index);
423 return (ipd->ipm_pmtu);
426 const static dpo_vft_t ip_pmtu_dpo_vft = {
427 .dv_lock = ip_pmtu_dpo_lock,
428 .dv_unlock = ip_pmtu_dpo_unlock,
429 .dv_format = format_ip_pmtu_dpo,
430 .dv_get_urpf = ip_pmtu_dpo_get_urpf,
431 .dv_mk_interpose = ip_pmtu_dpo_interpose,
432 .dv_get_mtu = ip_pmtu_dpo_get_mtu,
436 * @brief The per-protocol VLIB graph nodes that are assigned to a glean
439 * this means that these graph nodes are ones from which a glean is the
440 * parent object in the DPO-graph.
442 const static char *const ip_pmtu_dpo_ip4_nodes[] = {
447 const static char *const ip_pmtu_dpo_ip6_nodes[] = {
452 const static char *const *const ip_pmtu_dpo_nodes[DPO_PROTO_NUM] = {
453 [DPO_PROTO_IP4] = ip_pmtu_dpo_ip4_nodes,
454 [DPO_PROTO_IP6] = ip_pmtu_dpo_ip6_nodes,
458 ip_mtu_fib_entry_is_attached (fib_node_index_t fib_entry)
460 const fib_prefix_t *pfx;
461 u32 cover, fib_index;
463 fib_index = fib_entry_get_fib_index (fib_entry);
464 pfx = fib_entry_get_prefix (fib_entry);
467 * If the tracked prefix's cover is attached, then all packets that
468 * are forwarded to this neighbour will use the adjacency, this is a
469 * more efficient place to perform the MTU check and fragging
471 cover = fib_table_get_less_specific (fib_index, pfx);
473 return (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags (cover) ||
474 FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags (fib_entry));
478 ip_pmtu_alloc (u32 fib_index, const fib_prefix_t *pfx,
479 const ip_pmtu_key_t *key, u16 pmtu)
481 dpo_id_t ip_dpo = DPO_INVALID;
483 fib_node_index_t cover;
484 const dpo_id_t *lb_dpo;
487 pool_get (ip_pmtu_pool, ipt);
488 fib_node_init (&(ipt->ipt_node), ip_pmtu_fib_type);
490 ipti = ipt - ip_pmtu_pool;
491 hash_set_mem_alloc (&ip_pmtu_db, key, ipti);
493 ipt->ipt_cfg_pmtu = pmtu;
494 ipt->ipt_fib_entry = fib_entry_track (fib_index, pfx, ip_pmtu_fib_type, ipti,
498 * If the tracked prefix's cover is attached, then all packets that
499 * are forwarded to this neighbour will use the adjacency, this is a
500 * more efficient place to perform the MTU check and fragging
502 cover = fib_table_get_less_specific (fib_index, pfx);
504 if (ip_mtu_fib_entry_is_attached (ipt->ipt_fib_entry))
508 ipt->ipt_flags |= IP_PMTU_FLAG_ATTACHED;
509 ipt->ipt_oper_pmtu = ipt->ipt_cfg_pmtu;
511 sw_if_index = fib_entry_get_resolving_interface (cover);
513 /* walk all adjs to add/update delegate */
514 adj_nbr_walk_nh (sw_if_index, pfx->fp_proto, &pfx->fp_addr,
515 ip_ptmu_adj_walk_update, &ipt->ipt_oper_pmtu);
519 ipt->ipt_flags |= IP_PMTU_FLAG_REMOTE;
521 lb_dpo = fib_entry_contribute_ip_forwarding (ipt->ipt_fib_entry);
523 ipt->ipt_oper_pmtu = clib_min (dpo_get_mtu (lb_dpo), ipt->ipt_cfg_pmtu);
526 * interpose a policy DPO from the nh so that MTU is applied
528 ip_pmtu_dpo_add_or_lock (ipt->ipt_oper_pmtu,
529 drop_dpo_get (fib_proto_to_dpo (pfx->fp_proto)),
532 fib_table_entry_special_dpo_add (fib_index, pfx, ip_pmtu_source,
533 FIB_ENTRY_FLAG_INTERPOSE, &ip_dpo);
537 IP_PMTU_TRKR_DBG (ipt, "create");
543 ip_pmtu_stack (ip_pmtu_t *ipt)
545 bool was_attached, is_attached;
546 const fib_prefix_t *pfx;
549 pfx = fib_entry_get_prefix (ipt->ipt_fib_entry);
550 fib_index = fib_entry_get_fib_index (ipt->ipt_fib_entry);
552 was_attached = !!(ipt->ipt_flags & IP_PMTU_FLAG_ATTACHED);
553 is_attached = ip_mtu_fib_entry_is_attached (ipt->ipt_fib_entry);
555 if (was_attached && !is_attached)
557 /* transition from attached to remote - walk all adjs to remove delegate
559 adj_nbr_walk_nh (fib_entry_get_resolving_interface (ipt->ipt_fib_entry),
560 pfx->fp_proto, &pfx->fp_addr, ip_ptmu_adj_walk_remove,
561 &ipt->ipt_oper_pmtu);
562 ipt->ipt_flags &= ~IP_PMTU_FLAG_ATTACHED;
564 if (!was_attached && is_attached)
566 /* transition from remote to attached - remove the DPO */
567 fib_table_entry_special_remove (fib_index, pfx, ip_pmtu_source);
568 ipt->ipt_flags &= ~IP_PMTU_FLAG_REMOTE;
573 /* walk all adjs to add/update delegate */
574 ipt->ipt_oper_pmtu = ipt->ipt_cfg_pmtu;
575 adj_nbr_walk_nh (fib_entry_get_resolving_interface (ipt->ipt_fib_entry),
576 pfx->fp_proto, &pfx->fp_addr, ip_ptmu_adj_walk_update,
577 &ipt->ipt_oper_pmtu);
578 ipt->ipt_flags |= IP_PMTU_FLAG_ATTACHED;
582 const dpo_id_t *lb_dpo;
585 fib_table_entry_special_remove (fib_index, pfx, ip_pmtu_source);
587 ipt->ipt_flags |= IP_PMTU_FLAG_REMOTE;
588 lb_dpo = fib_entry_contribute_ip_forwarding (ipt->ipt_fib_entry);
589 dpo_mtu = dpo_get_mtu (lb_dpo);
591 ipt->ipt_oper_pmtu = clib_min (dpo_mtu, ipt->ipt_cfg_pmtu);
594 * if the configured path-MTU is less that the egress/interface then
595 * interpose a policy DPO from the nh so that MTU is applied
597 if (ipt->ipt_oper_pmtu < dpo_mtu)
599 dpo_id_t ip_dpo = DPO_INVALID;
601 ip_pmtu_dpo_add_or_lock (
603 drop_dpo_get (fib_proto_to_dpo (pfx->fp_proto)), &ip_dpo);
605 fib_table_entry_special_dpo_update (
606 fib_index, pfx, ip_pmtu_source, FIB_ENTRY_FLAG_INTERPOSE, &ip_dpo);
610 IP_PMTU_TRKR_DBG (ipt, "stack");
614 ip_pmtu_update (index_t ipti, u16 pmtu)
618 ipt = pool_elt_at_index (ip_pmtu_pool, ipti);
619 ipt->ipt_flags &= ~IP_PMTU_FLAG_STALE;
620 ipt->ipt_cfg_pmtu = pmtu;
626 ip_pmtu_destroy (index_t ipti, const ip_pmtu_key_t *key)
629 const fib_prefix_t *pfx;
631 ipt = pool_elt_at_index (ip_pmtu_pool, ipti);
632 pfx = fib_entry_get_prefix (ipt->ipt_fib_entry);
634 IP_PMTU_TRKR_DBG (ipt, "destroy");
636 if (ipt->ipt_flags & IP_PMTU_FLAG_REMOTE)
637 fib_table_entry_special_remove (
638 fib_entry_get_fib_index (ipt->ipt_fib_entry), pfx, ip_pmtu_source);
640 /* remove the delegate from all the adjacencies */
641 adj_nbr_walk_nh (fib_entry_get_resolving_interface (ipt->ipt_fib_entry),
642 pfx->fp_proto, &pfx->fp_addr, ip_ptmu_adj_walk_remove,
646 * Drop the fib entry we're tracking
648 fib_entry_untrack (ipt->ipt_fib_entry, ipt->ipt_sibling);
651 * remove from DB and return to pool
653 hash_unset_mem_free (&ip_pmtu_db, key);
654 pool_put (ip_pmtu_pool, ipt);
660 ip_path_mtu_update (const ip_address_t *nh, u32 table_id, u16 pmtu)
666 ip_address_to_fib_prefix (nh, &pfx);
667 fib_index = fib_table_find (pfx.fp_proto, table_id);
670 return (VNET_API_ERROR_NO_SUCH_TABLE);
672 ip_pmtu_key_t key = {
673 .fproto = pfx.fp_proto,
674 .table_id = table_id,
678 p = hash_get_mem (ip_pmtu_db, &key);
680 if (!ip_path_mtu_value_invalid (pmtu))
682 /* Add or update of path MTU */
684 ip_pmtu_alloc (fib_index, &pfx, &key, pmtu);
686 ip_pmtu_update (p[0], pmtu);
691 ip_pmtu_destroy (p[0], &key);
698 ip_path_mtu_walk_mark (index_t ipti, void *ctx)
702 ipt = ip_path_mtu_get (ipti);
704 ipt->ipt_flags |= IP_PMTU_FLAG_STALE;
706 return (WALK_CONTINUE);
709 typedef struct ip_path_mtu_walk_sweep_ctx_t_
712 } ip_path_mtu_walk_sweep_ctx_t;
715 ip_path_mtu_walk_sweep (index_t ipti, void *arg)
717 ip_path_mtu_walk_sweep_ctx_t *ctx = arg;
720 ipt = ip_path_mtu_get (ipti);
722 if (ipt->ipt_flags & IP_PMTU_FLAG_STALE)
724 vec_add1 (ctx->indicies, ipti);
727 return (WALK_CONTINUE);
731 ip_path_mtu_replace_begin (void)
733 IP_PMTU_DBG ("replace-begin");
735 ip_path_mtu_walk (ip_path_mtu_walk_mark, NULL);
741 ip_path_mtu_replace_end (void)
745 IP_PMTU_DBG ("replace-end");
748 * not safe to walk the pool whilst deleting, so create
749 * temporary storage of stale entries
751 ip_path_mtu_walk_sweep_ctx_t ctx = {
755 ip_path_mtu_walk (ip_path_mtu_walk_sweep, &ctx);
757 vec_foreach (ipti, ctx.indicies)
762 ipt = ip_path_mtu_get (*ipti);
763 ip_pmtu_get_ip (ipt, &ip);
764 ip_path_mtu_update (&ip, ip_pmtu_get_table_id (ipt), 0);
767 vec_free (ctx.indicies);
773 ip_path_mtu_walk (ip_path_mtu_walk_t fn, void *ctx)
777 pool_foreach_index (ipmi, ip_pmtu_pool)
779 if (WALK_STOP == fn (ipmi, ctx))
785 ip_pmtu_get_node (fib_node_index_t index)
789 ipt = pool_elt_at_index (ip_pmtu_pool, index);
791 return (&(ipt->ipt_node));
795 ip_pmtu_get_from_node (fib_node_t *node)
798 (ip_pmtu_t *) (((char *) node) - STRUCT_OFFSET_OF (ip_pmtu_t, ipt_node)));
802 ip_pmtu_last_lock_gone (fib_node_t *node)
805 * the lifetime of the entry is managed by the API.
811 * A back walk has reached this BIER entry
813 static fib_node_back_walk_rc_t
814 ip_pmtu_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
817 * re-populate the ECMP tables with new choices
819 ip_pmtu_t *ipr = ip_pmtu_get_from_node (node);
824 * no need to propagate further up the graph, since there's nothing there
826 return (FIB_NODE_BACK_WALK_CONTINUE);
829 static const fib_node_vft_t ip_ptmu_fib_node_vft = {
830 .fnv_get = ip_pmtu_get_node,
831 .fnv_last_lock = ip_pmtu_last_lock_gone,
832 .fnv_back_walk = ip_pmtu_back_walk_notify,
835 static clib_error_t *
836 ip_path_module_init (vlib_main_t *vm)
838 ip_pmtu_adj_delegate_type =
839 adj_delegate_register_new_type (&ip_path_adj_delegate_vft);
840 ip_pmtu_source = fib_source_allocate ("path-mtu", FIB_SOURCE_PRIORITY_HI,
841 FIB_SOURCE_BH_SIMPLE);
843 fib_node_register_new_type ("ip-pmtu", &ip_ptmu_fib_node_vft);
845 ip_pmtu_db = hash_create_mem (0, sizeof (ip_pmtu_key_t), sizeof (index_t));
846 ip_pmtu_logger = vlib_log_register_class ("ip", "pmtu");
848 dpo_register_new_type (&ip_pmtu_dpo_vft, ip_pmtu_dpo_nodes);
853 VLIB_INIT_FUNCTION (ip_path_module_init);
855 static clib_error_t *
856 show_ip_pmtu_command (vlib_main_t *vm, unformat_input_t *input,
857 vlib_cli_command_t *cmd)
861 if (unformat (input, "%d", &ipti))
866 if (!pool_is_free_index (ip_pmtu_pool, ipti))
867 vlib_cli_output (vm, "%U", format_ip_pmtu, ipti);
869 vlib_cli_output (vm, "entry %d invalid", ipti);
876 pool_foreach_index (ipti, ip_pmtu_pool)
878 vlib_cli_output (vm, "%U", format_ip_pmtu, ipti);
885 VLIB_CLI_COMMAND (show_fib_entry, static) = {
886 .path = "show ip pmtu",
887 .function = show_ip_pmtu_command,
888 .short_help = "show ip path MTU",
892 * fd.io coding-style-patch-verification: ON
895 * eval: (c-set-style "gnu")