diff options
author | Neale Ranns <nranns@cisco.com> | 2020-03-17 14:24:09 +0000 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2020-03-19 07:55:52 +0000 |
commit | f14578972a21fe10cd3ff72aaaaea43da4d74d20 (patch) | |
tree | cda62f1323b43c6006de59b9873cf6ae9737403f | |
parent | 6d97e62c009086030cddb38c5432c8f860b1c02c (diff) |
fib: format functions for path
Type: improvement
Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: Ib7a9e457cb2462e6ce9e5e2af53d1f997f4ae6cf
-rw-r--r-- | src/vnet/fib/fib_types.c | 62 | ||||
-rw-r--r-- | src/vnet/fib/fib_types.h | 10 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c index dcb1c3a659c..b5576161d80 100644 --- a/src/vnet/fib/fib_types.c +++ b/src/vnet/fib/fib_types.c @@ -92,6 +92,68 @@ fib_prefix_from_ip46_addr (const ip46_address_t *addr, pfx->___fp___pad = 0; } +u8 * +format_fib_route_path_flags (u8 *s, va_list *ap) +{ + fib_route_path_flags_t flags = va_arg (*ap, fib_route_path_flags_t); + + if (flags & FIB_ROUTE_PATH_RESOLVE_VIA_HOST) + s = format (s, "via-host"); + if (flags & FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED) + s = format (s, "via-attached,"); + if (flags & FIB_ROUTE_PATH_LOCAL) + s = format (s, "local,"); + if (flags & FIB_ROUTE_PATH_ATTACHED) + s = format (s, "attached,"); + if (flags & FIB_ROUTE_PATH_DROP) + s = format (s, "drop,"); + if (flags & FIB_ROUTE_PATH_EXCLUSIVE) + s = format (s, "exclusive,"); + if (flags & FIB_ROUTE_PATH_INTF_RX) + s = format (s, "intf-rx,"); + if (flags & FIB_ROUTE_PATH_RPF_ID) + s = format (s, "rpf-id,"); + if (flags & FIB_ROUTE_PATH_SOURCE_LOOKUP) + s = format (s, "src-lkup,"); + if (flags & FIB_ROUTE_PATH_UDP_ENCAP) + s = format (s, "udp-encap,"); + if (flags & FIB_ROUTE_PATH_BIER_FMASK) + s = format (s, "bier-fmask,"); + if (flags & FIB_ROUTE_PATH_BIER_TABLE) + s = format (s, "bier-table,"); + if (flags & FIB_ROUTE_PATH_BIER_IMP) + s = format (s, "bier-imp,"); + if (flags & FIB_ROUTE_PATH_DEAG) + s = format (s, "deag,"); + if (flags & FIB_ROUTE_PATH_DVR) + s = format (s, "dvr,"); + if (flags & FIB_ROUTE_PATH_ICMP_UNREACH) + s = format (s, "imcp-unreach,"); + if (flags & FIB_ROUTE_PATH_ICMP_PROHIBIT) + s = format (s, "icmp-prohibit,"); + if (flags & FIB_ROUTE_PATH_CLASSIFY) + s = format (s, "classify,"); + if (flags & FIB_ROUTE_PATH_POP_PW_CW) + s = format (s, "pop-pw-cw,"); + + return (s); +} + +u8 * +format_fib_route_path (u8 *s, va_list *ap) +{ + fib_route_path_t *rpath = va_arg (*ap, fib_route_path_t*); + + s = format (s, "%U %U, %U, [%U]", + format_dpo_proto, rpath->frp_proto, + format_ip46_address, &rpath->frp_addr, IP46_TYPE_ANY, + format_vnet_sw_if_index_name, vnet_get_main (), + rpath->frp_sw_if_index, + format_fib_route_path_flags, rpath->frp_flags); + + return (s); +} + void fib_prefix_from_mpls_label (mpls_label_t label, mpls_eos_bit_t eos, diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h index 333b2abd240..f5e53038c2d 100644 --- a/src/vnet/fib/fib_types.h +++ b/src/vnet/fib/fib_types.h @@ -397,6 +397,11 @@ typedef enum fib_route_path_flags_t_ } fib_route_path_flags_t; /** + * Format route path flags + */ +extern u8 * format_fib_route_path_flags(u8 *s, va_list *ap); + +/** * An RPF-ID is numerical value that is used RPF validate. An entry * has-a RPF-ID, when a packet egress from (e.g. an LSP) it gains an * RPF-ID, these two are compared for the RPF check. @@ -601,6 +606,11 @@ typedef struct fib_route_path_t_ { extern uword unformat_fib_route_path(unformat_input_t * input, va_list * args); /** + * Format route path flags + */ +extern u8 * format_fib_route_path(u8 *s, va_list *ap); + +/** * A help string to list the FIB path options */ #define FIB_ROUTE_PATH_HELP "[next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]" |