ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 09 72 00 00 05 0c 08 02 00 00 00 18 e2 6f | .PNG........IHDR...r...........o |
0020 | b9 00 00 01 7c 69 43 43 50 49 43 43 20 50 72 6f 66 69 6c 65 00 00 28 91 63 60 60 2a 49 2c 28 c8 | ....|iCCPICC.Profile..(.c``*I,(. |
0040 | 61 61 60 60 c8 cd 2b 29 0a 72 77 52 88 88 8c 52 60 bf c3 c0 cd c0 c3 20 c4 60 c5 20 9e 98 5c 5c | aa``..+).rwR...R`........`....\\ |
0060 | e0 18 10 e0 c3 80 13 7c bb c6 c0 08 a2 2f eb 82 cc 4a f3 fc 79 d3 a6 b5 7c fe 16 36 af 99 72 56 | .......|...../...J..y...|..6..rV |
0080 | 25 3a b8 f5 81 01 77 4a 6a 71 32 03 03 23 07 90 9d 9c 52 9c 9c 0b 64 e7 00 d9 3a c9 05 45 25 40 | %:....wJjq2..#....R...d...:..E%@ |
00a0 | f6 0c 20 5b b7 bc a4 00 c4 3e 01 64 8b 14 01 1d 08 64 df 01 b1 d3 21 ec 0f 20 76 12 98 cd c4 02 | ...[.....>.d.....d....!...v..... |
00c0 | 56 13 12 e4 0c 64 4b 00 d9 02 49 10 b6 06 88 9d 0e 61 5b 80 d8 c9 19 89 29 40 b6 07 c8 2e 88 1b | V....dK...I......a[.....)@...... |
00e0 | c0 80 d3 c3 45 c1 dc c0 52 d7 91 80 bb 49 06 b9 39 a5 30 3b 40 a1 c5 93 9a 17 1a 0c 72 07 10 cb | ....E...R....I..9.0;@.......r... |
0100 | 30 78 30 b8 30 28 30 98 33 18 30 58 32 e8 32 38 96 a4 56 94 80 14 3a e7 17 54 16 65 a6 67 94 28 | 0x0.0(0.3.0X2.28..V...:..T.e.g.( |
0120 | 38 02 43 36 55 c1 39 3f b7 a0 b4 24 b5 48 47 c1 33 2f 59 4f 47 c1 c8 c0 d0 00 a4 0e 14 67 10 a3 | 8.C6U.9?...$.HG.3/YOG........g.. |
0140 | 3f 07 81 4d 67 14 3b 8f 10 cb 5f c8 c0 60 a9 cc c0 c0 dc 83 10 4b 9a c6 c0 b0 7d 0f 03 83 c4 29 | ?..Mg.;..._..`.......K....}....) |
0160 | 84 98 ca 3c 06 06 7e 6b 06 86 6d e7 0a 12 8b 12 e1 0e 67 fc c6 42 88 5f 9c 66 6c 04 61 f3 38 31 | ...<..~k..m.......g..B._.fl.a.81 |
0180 | 30 b0 de fb ff ff b3 1a 03 03 fb 24 06 86 bf 13 ff ff ff bd e8 ff ff bf 8b 81 f6 03 e3 ec 40 0e | 0..........$..................@. |
01a0 | 00 24 77 69 e0 8c 6b 12 0f 00 00 00 09 70 48 59 73 00 00 16 25 00 00 16 25 01 49 52 24 f0 00 00 | .$wi..k......pHYs...%...%.IR$... |
01c0 | 02 06 69 54 58 74 58 4d 4c 3a 63 6f 6d 2e 61 64 6f 62 65 2e 78 6d 70 00 00 00 00 00 3c 78 3a 78 | ..iTXtXML:com.adobe.xmp.....<x:x |
01e0 | 6d 70 6d 65 74 61 20 78 6d 6c 6e 73 3a 78 3d 22 61 64 6f 62 65 3a 6e 73 3a 6d 65 74 61 2f 22 20 | mpmeta.xmlns:x="adobe:ns:meta/". |
0200 | 78 3a 78 6d 70 74 6b 3d 22 58 4d 50 20 43 6f 72 65 20 35 2e 34 2e 30 22 3e 0a 20 20 20 3c 72 64 | x:xmptk="XMP.Core.5.4.0">....<rd |
0220 | 66 3a 52 44 46 20 78 6d 6c 6e 73 3a 72 64 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 77 33 2e 6f | f:RDF.xmlns:rdf="http://www.w3.o |
0240 | 72 67 2f 31 39 39 39 2f 30 32 2f 32 32 2d 72 64 66 2d 73 79 6e 74 61 78 2d 6e 73 23 22 3e 0a 20 | rg/1999/02/22-rdf-syntax-ns#">.. |
0260 | 20 20 20 20 20 3c 72 64 66 3a 44 65 73 63 72 69 70 74 69 6f 6e 20 72 64 66 3a 61 62 6f 75 74 3d | .....<rdf:Description.rdf:about= |
0280 | 22 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 78 6d 6c 6e 73 3a 65 78 69 66 3d 22 68 74 74 70 3a | "".............xmlns:exif="http: |
02a0 | 2f 2f 6e 73 2e 61 64 6f 62 65 2e 63 6f 6d 2f 65 78 69 66 2f 31 2e 30 2f 22 0a 20 20 20 20 20 20 | //ns.adobe.com/exif/1.0/"....... |
02c0 | 20 20 20 20 20 20 78 6d 6c 6e 73 3a 74 69 66 66 3d 22 68 74 74 70 3a 2f 2f 6e 73 2e 61 64 6f 62 | ......xmlns:tiff="http://ns.adob |
02e0 | 65 2e 63 6f 6d 2f 74 69 66 66 2f 31 2e 30 2f 22 3e 0a 20 20 20 20 20 20 20 20 20 3c 65 78 69 66 | e.com/tiff/1.0/">..........<exif |
0300 | 3a 50 69 78 65 6c 59 44 69 6d 65 6e 73 69 6f 6e 3e 31 32 39 32 3c 2f 65 78 69 66 3a 50 69 78 65 | :PixelYDimension>1292</exif:Pixe |
0320 | 6c 59 44 69 6d 65 6e 73 69 6f 6e 3e 0a 20 20 20 20 20 20 20 20 20 3c 65 78 69 66 3a 50 69 78 65 | lYDimension>..........<exif:Pixe |
0340 | 6c 58 44 69 6d 65 6e 73 69 6f 6e 3e 32 34 31 38 3c 2f 65 78 69 66 3a 50 69 78 65 6c 58 44 69 6d | lXDimension>2418</exif:PixelXDim |
0360 | 65 6e 73 69 6f 6e 3e 0a 20 20 20 20 20 20 20 20 20 3c 74 69 66 66 3a 4f 72 69 65 6e 74 61 74 69 | ension>..........<tiff:Orientati |
0380 | 6f 6e 3e 31 3c 2f 74 69 66 66 3a 4f 72 69 65 6e 74 61 74 69 6f 6e 3e 0a 20 20 20 20 20 20 3c 2f | on>1</tiff:Orientation>.......</ |
03a0 | 72 64 66 3a 44 65 73 63 72 69 70 74 69 6f 6e 3e 0a 20 20 20 3c 2f 72 64 66 3a 52 44 46 3e 0a 3c | rdf:Description>....</rdf:RDF>.< |
03c0 | 2f 78 3a 78 6d 70 6d 65 74 61 3e 0a 56 1d e9 90 00 00 40 00 49 44 41 54 78 01 ec dd 07 9c 1d 55 | /x:xmpmeta>.V.....@.IDATx......U |
03e0 | d9 80 f1 dd f4 de 3b 81 14 48 42 6f a1 77 10 a4 4a 55 40 51 11 c1 82 f8 29 36 b0 80 82 88 82 05 | ......;..HBo.w..JU@Q....)6...... |
0400 | 2b d2 a4 23 52 05 11 a4 d7 d0 49 02 a1 a7 10 12 d2 7b ef d9 dd ef d9 4c 72 32 99 3b b7 ec dd bb | +..#R.....I......{.....Lr2.;.... |
0420 | c9 66 f7 b9 f2 8b b3 53 ce 9c f9 cf 99 76 de 39 67 ca ab aa aa ca fc 29 a0 80 02 0a 28 a0 80 02 | .f.....S.....v.9g......)....(... |
0440 | 0a 28 a0 80 02 0a 28 a0 80 02 0a 28 a0 80 02 0a 28 a0 80 02 0a 28 a0 80 02 d9 05 9a 64 9f e4 14 | .(....(....(....(....(......d... |
0460 | 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 | ..P@...P@...P@...P@...P@...P@... |
0480 | 50 a0 5a c0 b0 a2 e5 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 | P.Z....@...P@...P@...P@...P@...P |
04a0 | 40 01 05 14 50 40 01 05 f2 08 18 56 cc 03 e4 64 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 | @...P@.....V...d..P@...P@...P@.. |
04c0 | 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 30 ac 68 19 50 40 01 05 14 50 40 01 05 14 50 40 | .P@...P@...P@...0.h.P@...P@...P@ |
04e0 | 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 81 3c 02 86 15 f3 00 39 59 01 05 14 | ...P@...P@...P@...P@.<.....9Y... |
0500 | 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 0c 2b 5a | P@...P@...P@...P@...P@...P@...+Z |
0520 | 06 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 | ..P@...P@...P@...P@...P@...P@... |
0540 | 50 20 8f 80 61 c5 3c 40 4e 56 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 | P...a.<@NV@...P@...P@...P@...P@. |
0560 | 05 14 50 40 01 05 14 50 40 01 c3 8a 96 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 | ..P@...P@.......P@...P@...P@...P |
0580 | 40 01 05 14 50 40 01 05 14 50 40 01 05 14 c8 23 60 58 31 0f 90 93 15 50 40 01 05 14 50 40 01 05 | @...P@...P@....#`X1....P@...P@.. |
05a0 | 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 c0 b0 a2 65 40 01 05 14 50 40 | .P@...P@...P@...P@...P...e@...P@ |
05c0 | 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 f2 08 18 56 cc | ...P@...P@...P@...P@...P@.....V. |
05e0 | 03 e4 64 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 | ..d..P@...P@...P@...P@...P@...P@ |
0600 | 01 05 14 30 ac 68 19 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 | ...0.h.P@...P@...P@...P@...P@... |
0620 | 50 40 01 05 14 50 40 81 3c 02 86 15 f3 00 39 59 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 | P@...P@.<.....9Y...P@...P@...P@. |
0640 | 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 0c 2b 5a 06 14 50 40 01 05 14 50 40 01 05 14 50 | ..P@...P@...P@...+Z..P@...P@...P |
0660 | 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 20 8f 80 61 c5 3c 40 4e 56 40 01 05 | @...P@...P@...P@...P...a.<@NV@.. |
0680 | 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 c3 8a 96 | .P@...P@...P@...P@...P@...P@.... |
06a0 | 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 | ...P@...P@...P@...P@...P@...P@.. |
06c0 | 14 c8 23 60 58 31 0f 90 93 15 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 | ..#`X1....P@...P@...P@...P@...P@ |
06e0 | 01 05 14 50 40 01 05 14 50 c0 b0 a2 65 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 | ...P@...P...e@...P@...P@...P@... |
0700 | 50 40 01 05 14 50 40 01 05 14 50 40 01 05 f2 08 18 56 cc 03 e4 64 05 14 50 40 01 05 14 50 40 01 | P@...P@...P@.....V...d..P@...P@. |
0720 | 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 30 ac 68 19 50 40 01 05 14 50 | ..P@...P@...P@...P@...0.h.P@...P |
0740 | 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 81 3c 02 86 15 f3 | @...P@...P@...P@...P@...P@.<.... |
0760 | 00 39 59 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 | .9Y...P@...P@...P@...P@...P@...P |
0780 | 40 01 05 0c 2b 5a 06 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 | @...+Z..P@...P@...P@...P@...P@.. |
07a0 | 14 50 40 01 05 14 50 20 8f 80 61 c5 3c 40 4e 56 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 | .P@...P...a.<@NV@...P@...P@...P@ |
07c0 | 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 c3 8a 96 01 05 14 50 40 01 05 14 50 40 01 05 14 | ...P@...P@...P@.......P@...P@... |
07e0 | 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 c8 23 60 58 31 0f 90 93 15 50 40 01 | P@...P@...P@...P@....#`X1....P@. |
0800 | 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 c0 b0 a2 65 | ..P@...P@...P@...P@...P@...P...e |
0820 | 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 | @...P@...P@...P@...P@...P@...P@. |
0840 | 05 f2 08 18 56 cc 03 e4 64 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 40 01 05 14 50 | ....V...d..P@...P@...P@...P@/*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vnet/mpls/mpls.h>
#include <vnet/dpo/mpls_label_dpo.h>
#include <vnet/dpo/load_balance.h>
#include <vnet/dpo/drop_dpo.h>
#include <vnet/fib/fib_path_ext.h>
#include <vnet/fib/fib_entry_src.h>
#include <vnet/fib/fib_path.h>
#include <vnet/fib/fib_path_list.h>
#include <vnet/fib/fib_internal.h>
const char *fib_path_ext_adj_flags_names[] = FIB_PATH_EXT_ADJ_ATTR_NAMES;
u8 *
format_fib_path_ext (u8 * s, va_list * args)
{
fib_path_ext_t *path_ext;
u32 ii;
path_ext = va_arg (*args, fib_path_ext_t *);
s = format(s, "path:%d ", path_ext->fpe_path_index);
switch (path_ext->fpe_type)
{
case FIB_PATH_EXT_MPLS:
s = format(s, "labels:",
path_ext->fpe_path_index);
for (ii = 0; ii < vec_len(path_ext->fpe_path.frp_label_stack); ii++)
{
s = format(s, "%U ",
format_mpls_unicast_label,
path_ext->fpe_path.frp_label_stack[ii]);
}
break;
case FIB_PATH_EXT_ADJ: {
fib_path_ext_adj_attr_t attr;
s = format(s, "adj-flags:");
if (path_ext->fpe_adj_flags)
{
FOR_EACH_PATH_EXT_ADJ_ATTR(attr)
{
s = format(s, "%s", fib_path_ext_adj_flags_names[attr]);
}
}
else
{
s = format(s, "None");
}
break;
}
}
return (s);
}
int
fib_path_ext_cmp (fib_path_ext_t *path_ext,
const fib_route_path_t *rpath)
{
return (fib_route_path_cmp(&path_ext->fpe_path, rpath));
}
static fib_path_list_walk_rc_t
fib_path_ext_match (fib_node_index_t pl_index,
fib_node_index_t path_index,
void *ctx)
{
fib_path_ext_t *path_ext = ctx;
if (!fib_path_cmp_w_route_path(path_index,
&path_ext->fpe_path))
{
path_ext->fpe_path_index = path_index;
return (FIB_PATH_LIST_WALK_STOP);
}
return (FIB_PATH_LIST_WALK_CONTINUE);
}
void
fib_path_ext_resolve (fib_path_ext_t *path_ext,
fib_node_index_t path_list_index)
{
/*
* Find the path on the path list that this is an extension for
*/
path_ext->fpe_path_index = FIB_NODE_INDEX_INVALID;
fib_path_list_walk(path_list_index,
fib_path_ext_match,
path_ext);
}
void
fib_path_ext_init (fib_path_ext_t *path_ext,
fib_node_index_t path_list_index,
fib_path_ext_type_t ext_type,
const fib_route_path_t *rpath)
{
path_ext->fpe_path = *rpath;
path_ext->fpe_path_index = FIB_NODE_INDEX_INVALID;
path_ext->fpe_adj_flags = FIB_PATH_EXT_ADJ_FLAG_NONE;
path_ext->fpe_type = ext_type;
fib_path_ext_resolve(path_ext, path_list_index);
}
/**
* @brief Return true if the label stack is implicit null
*/
static int
fib_path_ext_is_imp_null (fib_path_ext_t *path_ext)
{
return ((1 == vec_len(path_ext->fpe_label_stack)) &&
(MPLS_IETF_IMPLICIT_NULL_LABEL == path_ext->fpe_label_stack[0]));
}
load_balance_path_t *
fib_path_ext_stack (fib_path_ext_t *path_ext,
fib_forward_chain_type_t child_fct,
fib_forward_chain_type_t imp_null_fct,
load_balance_path_t *nhs)
{
fib_forward_chain_type_t parent_fct;
load_balance_path_t *nh;
if (!fib_path_is_resolved(path_ext->fpe_path_index))
return (nhs);
/*
* Since we are stacking this path-extension, it must have a valid out
* label. From the chain type request by the child, determine what
* chain type we will request from the parent.
*/
switch (child_fct)
{
case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
{
/*
* The EOS chain is a tricky since, when the path has an imp NULL one cannot know
* the adjacency to link to without knowing what the packets payload protocol
* will be once the label is popped.
*/
if (fib_path_ext_is_imp_null(path_ext))
{
parent_fct = imp_null_fct;
}
else
{
/*
* we have a label to stack. packets will thus be labelled when
* they encounter the child, ergo, non-eos.
*/
parent_fct = FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS;
}
break;
}
case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
if (fib_path_ext_is_imp_null(path_ext))
{
/*
* implicit-null label for the eos or IP chain, need to pick up
* the IP adj
*/
parent_fct = child_fct;
}
else
{
/*
* we have a label to stack. packets will thus be labelled when
* they encounter the child, ergo, non-eos.
*/
parent_fct = FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS;
}
break;
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
parent_fct = child_fct;
break;
default:
return (nhs);
break;
}
dpo_id_t via_dpo = DPO_INVALID;
/*
* The next object in the graph after the imposition of the label
* will be the DPO contributed by the path through which the packets
* are to be sent. We stack the MPLS Label DPO on this path DPO
*/
fib_path_contribute_forwarding(path_ext->fpe_path_index,
parent_fct,
&via_dpo);
if (dpo_is_drop(&via_dpo) ||
load_balance_is_drop(&via_dpo))
{
/*
* don't stack a path extension on a drop. doing so will create
* a LB bucket entry on drop, and we will lose a percentage of traffic.
*/
}
else
{
vec_add2(nhs, nh, 1);
nh->path_weight = fib_path_get_weight(path_ext->fpe_path_index);
nh->path_index = path_ext->fpe_path_index;
dpo_copy(&nh->path_dpo, &via_dpo);
/*
* The label is stackable for this chain type
* construct the mpls header that will be imposed in the data-path
*/
if (!fib_path_ext_is_imp_null(path_ext))
{
/*
* we use the parent protocol for the label so that
* we pickup the correct MPLS imposition nodes to do
* ip[46] processing.
*/
dpo_proto_t chain_proto;
mpls_eos_bit_t eos;
index_t mldi;
eos = (child_fct == FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS ?
MPLS_NON_EOS :
MPLS_EOS);
chain_proto = fib_forw_chain_type_to_dpo_proto(child_fct);
mldi = mpls_label_dpo_create(path_ext->fpe_label_stack,
eos, 255, 0,
chain_proto,
&nh->path_dpo);
dpo_set(&nh->path_dpo,
DPO_MPLS_LABEL,
chain_proto,
mldi);
}
}
dpo_reset(&via_dpo);
return (nhs);
}
fib_path_ext_t *
fib_path_ext_list_find (const fib_path_ext_list_t *list,
fib_path_ext_type_t ext_type,
const fib_route_path_t *rpath)
{
fib_path_ext_t *path_ext;
vec_foreach(path_ext, list->fpel_exts)
{
if ((path_ext->fpe_type == ext_type) &&
!fib_path_ext_cmp(path_ext, rpath) )
{
return (path_ext);
}
}
return (NULL);
}
fib_path_ext_t *
fib_path_ext_list_find_by_path_index (const fib_path_ext_list_t *list,
fib_node_index_t path_index)
{
fib_path_ext_t *path_ext;
vec_foreach(path_ext, list->fpel_exts)
{
if (path_ext->fpe_path_index == path_index)
{
return (path_ext);
}
}
return (NULL);
}
fib_path_ext_t *
fib_path_ext_list_push_back (fib_path_ext_list_t *list,
fib_node_index_t path_list_index,
fib_path_ext_type_t ext_type,
const fib_route_path_t *rpath)
{
fib_path_ext_t *path_ext;
path_ext = fib_path_ext_list_find(list, ext_type, rpath);
if (NULL == path_ext)
{
vec_add2(list->fpel_exts, path_ext, 1);
fib_path_ext_init(path_ext, path_list_index, ext_type, rpath);
}
return (path_ext);
}
/*
* insert, sorted, a path extension to the entry's list.
* It's not strictly necessary to sort the path extensions, since each
* extension has the path index to which it resolves. However, by being
* sorted the load-balance produced has a deterministic order, not an order
* based on the sequence of extension additions. this is a considerable benefit.
*/
fib_path_ext_t *
fib_path_ext_list_insert (fib_path_ext_list_t *list,
fib_node_index_t path_list_index,
fib_path_ext_type_t ext_type,
const fib_route_path_t *rpath)
{
fib_path_ext_t new_path_ext, *path_ext;
int i = 0;
if (0 == fib_path_ext_list_length(list))
{
return (fib_path_ext_list_push_back(list, path_list_index,
ext_type, rpath));
}
fib_path_ext_init(&new_path_ext, path_list_index, ext_type, rpath);
vec_foreach(path_ext, list->fpel_exts)
{
if (fib_path_ext_cmp(path_ext, rpath) < 0)
{
i++;
}
else
{
break;
}
}
vec_insert_elts(list->fpel_exts, &new_path_ext, 1, i);
return (&(list->fpel_exts[i]));
}
void
fib_path_ext_list_resolve (fib_path_ext_list_t *list,
fib_node_index_t path_list_index)
{
fib_path_ext_t *path_ext;
vec_foreach(path_ext, list->fpel_exts)
{
fib_path_ext_resolve(path_ext, path_list_index);
};
}
void
fib_path_ext_list_remove (fib_path_ext_list_t *list,
fib_path_ext_type_t ext_type,
const fib_route_path_t *rpath)
{
fib_path_ext_t *path_ext;
path_ext = fib_path_ext_list_find(list, ext_type, rpath);
if (NULL != path_ext)
{
/*
* delete the element moving the remaining elements down 1 position.
* this preserves the sorted order.
*/
vec_free(path_ext->fpe_label_stack);
vec_delete(list->fpel_exts, 1, (path_ext - list->fpel_exts));
}
}
void
fib_path_ext_list_flush (fib_path_ext_list_t *list)
{
fib_path_ext_t *path_ext;
vec_foreach(path_ext, list->fpel_exts)
{
vec_free(path_ext->fpe_label_stack);
};
vec_free(list->fpel_exts);
list->fpel_exts = NULL;
}
u8*
format_fib_path_ext_list (u8 * s, va_list * args)
{
fib_path_ext_list_t *list;
fib_path_ext_t *path_ext;
list = va_arg (*args, fib_path_ext_list_t *);
if (fib_path_ext_list_length(list))
{
s = format(s, " Extensions:");
vec_foreach(path_ext, list->fpel_exts)
{
s = format(s, "\n %U", format_fib_path_ext, path_ext);
};
}
return (s);
}
int
fib_path_ext_list_length (const fib_path_ext_list_t *list)
{
return (vec_len(list->fpel_exts));
}
|