From f10a3579786f825ed29e898000a5f3ba8913285a Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Mon, 6 Jun 2022 10:58:06 -0700 Subject: [PATCH 1/6] lib: Minor enhancement of bitfield affinity-map and flex_algo library This commit introduces few enhancements to bitfield affinity-map and flex_algo ibrary. Signed-off-by: Pushpasis Sarkar --- .clang-format | 2 + lib/admin_group.h | 4 ++ lib/affinitymap.h | 2 +- lib/affinitymap_cli.c | 43 ++++++++++++ lib/bitfield.h | 64 +++++++++++++++++ lib/flex_algo.c | 3 + lib/flex_algo.h | 156 +++++++++++++++++++++++++++++++++++++++++- 7 files changed, 270 insertions(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index d16263da2e8f..4324369dd5d6 100644 --- a/.clang-format +++ b/.clang-format @@ -110,6 +110,8 @@ ForEachMacros: - 'FOREACH_CMT_REC' - 'FOREACH_MGMTD_BE_CLIENT_ID' - 'FOREACH_MGMTD_DS_ID' + - 'FOREACH_ADMIN_GROUP_BITS' + - 'FOREACH_FLEX_ALGO_DEFN' - 'FOREACH_SAFI' - 'FOREACH_SESSION_IN_LIST' - 'FOREACH_TXN_CFG_BATCH_IN_LIST' diff --git a/lib/admin_group.h b/lib/admin_group.h index 60f4a05f2beb..30a428ba52a1 100644 --- a/lib/admin_group.h +++ b/lib/admin_group.h @@ -34,6 +34,10 @@ struct admin_group { bitfield_t bitmap; }; +#define FOREACH_ADMIN_GROUP_BITS(admngrp, bitpos) \ + bf_for_each_set_bit((admngrp)->bitmap, (bitpos), \ + EXT_ADMIN_GROUP_MAX_POSITIONS) + char *admin_group_string(char *out, size_t sz, int indent, const struct admin_group *ag); char *admin_group_standard_print(char *out, int indent, uint32_t bitmap); diff --git a/lib/affinitymap.h b/lib/affinitymap.h index 19edf5a269ea..af48991dddca 100644 --- a/lib/affinitymap.h +++ b/lib/affinitymap.h @@ -81,7 +81,7 @@ void cli_show_affinity_map(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void affinity_map_init(void); - +void affinity_map_set_nb_bypass(bool bypass); #ifdef __cplusplus } diff --git a/lib/affinitymap_cli.c b/lib/affinitymap_cli.c index d417ae195156..cb3ad1405e56 100644 --- a/lib/affinitymap_cli.c +++ b/lib/affinitymap_cli.c @@ -39,6 +39,37 @@ static struct cmd_node affinitymap_node = { .config_write = affinity_map_config_write, }; +static bool bypass_nb; + +static int affinity_map_update(struct vty *vty, const char *name, + const int position, bool delete) +{ + char *old = NULL; + struct affinity_map *map; + + if (position >= 0) + old = affinity_map_name_get(position); + map = affinity_map_get(name); + if (!delete) { + if (old && strncmp(old, name, AFFINITY_NAME_SIZE)) { + vty_out(vty, "Bit '%d' already mapped to name '%s'\n", + position, old); + return CMD_WARNING_CONFIG_FAILED; + } + + if (!old) + affinity_map_set(name, position); + } else { + if (map) + affinity_map_unset(name); + } + + zlog_err("%s: %sd affinity-map '%s', bit %d", + __func__, delete ? "Delete" : "Update", name, position); + + return CMD_SUCCESS; +} + /* max value is EXT_ADMIN_GROUP_MAX_POSITIONS - 1 */ DEFPY_YANG_NOSH(affinity_map, affinity_map_cmd, "affinity-map NAME$name bit-position (0-1023)$position", @@ -49,6 +80,9 @@ DEFPY_YANG_NOSH(affinity_map, affinity_map_cmd, { char xpathr[XPATH_MAXLEN]; + if (bypass_nb) + return affinity_map_update(vty, name, position, false); + snprintf( xpathr, sizeof(xpathr), "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", @@ -68,6 +102,10 @@ DEFPY_YANG_NOSH(no_affinity_map, no_affinity_map_cmd, { char xpathr[XPATH_MAXLEN]; + if (bypass_nb) + return affinity_map_update( + vty, name, argc > 3 ? (int) position : -1, true); + snprintf(xpathr, sizeof(xpathr), "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']", name); @@ -105,3 +143,8 @@ void affinity_map_init(void) install_element(CONFIG_NODE, &affinity_map_cmd); install_element(CONFIG_NODE, &no_affinity_map_cmd); } + +void affinity_map_set_nb_bypass(bool bypass) +{ + bypass_nb = bypass; +} diff --git a/lib/bitfield.h b/lib/bitfield.h index cc8c31141610..87cee905a06c 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -95,6 +95,15 @@ DECLARE_MTYPE(BITFIELD); /* compare two bitmaps of the same length */ #define bf_cmp(v1, v2) (memcmp((v1).data, (v2).data, ((v1).m * sizeof(word_t)))) +/* return number bits in the allocated bitmap data so far */ +#define bf_bit_size(v) ((v).m * WORD_SIZE) + +/* return number of bytes in the allocated bitmap data so far */ +#define bf_byte_size(v) ((v).m * sizeof(word_t)) + +/* return number of words in the allocated bitmap data so far */ +#define bf_word_size(v) (v).m + /* * return 0th index back to bitfield */ @@ -268,6 +277,61 @@ static inline bitfield_t bf_copy(bitfield_t src) return dst; } +/* + * Encode a bitmap to a word-stream. Returns the number of bytes encoded + * instead of words. + */ +static inline void bf_encode_to_buf(bitfield_t *v, u_int8_t *buf, + u_int16_t *buflen) +{ + u_int16_t bm_len, len; + int indx; + word_t *w; + + if (!bf_is_inited(*v) || !buflen) + return; + + bm_len = (u_int16_t)bf_byte_size(*v); + len = (u_int16_t)bf_word_size(*v); + if (*buflen < bm_len) { + *buflen = 0; + return; + } + + w = (word_t *)buf; + *buflen = 0; + for (indx = 0; indx < len; indx++) { + w[indx] = htonl(v->data[indx]); + + /* Avoid encoding trailing zeroes */ + if (w[indx]) + *buflen = indx + 1; + } + (*buflen) *= sizeof(word_t); +} + +/* + * Decode a bitmap from a word-stream. + */ +static inline void bf_decode_from_buf(bitfield_t *v, u_int8_t *buf, + u_int16_t buflen) +{ + size_t indx; + word_t *w; + + assert(buflen); + v->n = 0; + v->m = buflen / sizeof(word_t); + v->data = (word_t *)XCALLOC(MTYPE_BITFIELD, v->m * sizeof(word_t)); + + w = (word_t *)buf; + for (indx = 0; indx < v->m; indx++) { + v->data[indx] = ntohl(w[indx]); + if (v->data[indx]) + v->n = indx + 1; + } +} + #ifdef __cplusplus } diff --git a/lib/flex_algo.c b/lib/flex_algo.c index f48117ff1b15..da89f49b7206 100644 --- a/lib/flex_algo.c +++ b/lib/flex_algo.c @@ -54,6 +54,9 @@ struct flex_algo *flex_algo_alloc(struct flex_algos *flex_algos, fa = XCALLOC(MTYPE_FLEX_ALGO, sizeof(struct flex_algo)); fa->algorithm = algorithm; + fa->metric_type = MT_DEFAULT; + fa->calc_type = CALC_TYPE_DEFAULT; + fa->priority = FLEX_ALGO_PRIO_DEFAULT; if (flex_algos->allocator) fa->data = flex_algos->allocator(arg); admin_group_init(&fa->admin_group_exclude_any); diff --git a/lib/flex_algo.h b/lib/flex_algo.h index e617e7cae849..b6472ae49a3d 100644 --- a/lib/flex_algo.h +++ b/lib/flex_algo.h @@ -21,9 +21,50 @@ #include "prefix.h" #include "segment_routing.h" +#define FLEX_ALGO_PRIO_MIN 0 #define FLEX_ALGO_PRIO_DEFAULT 128 +#define FLEX_ALGO_PRIO_MAX 255 -#define CALC_TYPE_SPF 0 +enum flex_algo_calc_type { + CALC_TYPE_MIN = 0, + CALC_TYPE_SPF = CALC_TYPE_MIN, + CALC_TYPE_MAX, +}; + +#define CALC_TYPE_DEFAULT CALC_TYPE_SPF +#define CALC_TYPE_SPF_STR "spf" + +static const char *flexalgo_ct2str[CALC_TYPE_MAX] = { + CALC_TYPE_SPF_STR, /* CALC_TYPE_SPF */ +}; + +static inline const char* +flex_algo_calc_type2str(enum flex_algo_calc_type ct) +{ + switch(ct) { + case CALC_TYPE_SPF: + return flexalgo_ct2str[ct]; + case CALC_TYPE_MAX: + default: + break; + } + + return "Invalid"; +} + +static inline enum flex_algo_calc_type +flex_algo_str2calc_type(const char* str) +{ + size_t len = strlen(str); + enum flex_algo_calc_type ct; + + for (ct = CALC_TYPE_MIN; ct < CALC_TYPE_MAX; ct++) { + if (!strncmp(str, flexalgo_ct2str[ct], len)) + return ct; + } + + return CALC_TYPE_MAX; +} /* flex-algo definition flags */ @@ -32,15 +73,60 @@ */ #define FAD_FLAG_M 0x80 +#define FLEX_ALGO_PREFIX_METRIC_SET(fad) \ + ((fad)->flags & FAD_FLAG_M) + /* * Metric Type values from RFC9350 section 5.1 */ enum flex_algo_metric_type { - MT_IGP = 0, + MT_MIN = 0, + MT_IGP = MT_MIN, MT_MIN_UNI_LINK_DELAY = 1, MT_TE_DEFAULT = 2, + MT_MAX +}; + +#define MT_DEFAULT MT_IGP +#define MT_IGP_STR "igp" +#define MT_MIN_UNI_LINK_DELAY_STR "delay" +#define MT_TE_DEFAULT_STR "te" + +static const char *flexalgo_mt2str[MT_MAX] = { + MT_IGP_STR, /* MT_IGP */ + MT_MIN_UNI_LINK_DELAY_STR, /* MT_MIN_UNI_LINK_DELAY */ + MT_TE_DEFAULT_STR, /* MT_TE_DEFAULT */ }; +static inline const char* +flex_algo_metric_type2str(enum flex_algo_metric_type mt) +{ + switch(mt) { + case MT_IGP: + case MT_MIN_UNI_LINK_DELAY: + case MT_TE_DEFAULT: + return flexalgo_mt2str[mt]; + case MT_MAX: + default: + break; + } + + return "Invalid"; +} + +static inline enum flex_algo_metric_type +flex_algo_str2metric_type(const char* str) +{ + size_t len = strlen(str); + enum flex_algo_metric_type mt; + + for (mt = MT_MIN; mt < MT_MAX; mt++) { + if (!strncmp(str, flexalgo_mt2str[mt], len)) + return mt; + } + + return MT_MAX; +} /* Flex-Algo data about a given algorithm. * It includes the definition and some local data. @@ -62,6 +148,17 @@ struct flex_algo { * True if a Exclude SRLG Sub-TLV has been found */ bool exclude_srlg; + /* + * For now used admin_groups for Exclude SRLGs. + */ + struct admin_group srlgs_exclude; + + /* + * The prefix advertise metric to be added to the corresponding + * FAPM SubTLVs. Applicable only when the M-Flag is set for + * the Flex-Algo Definition. + */ + uint32_t prefix_adv_metric; /* True if an unsupported sub-TLV other Exclude SRLG * has been received. @@ -98,6 +195,15 @@ struct flex_algo { void *data; }; +#define FLEX_ALGO_ALGO_MIN 128 +#define FLEX_ALGO_ALGO_MAX 255 + +#define FOREACH_FLEX_ALGO_ADMIN_GROUP(admngrps, admingroup) \ + FOREACH_ADMIN_GROUP_BITS(admngrps, admingroup) + +#define FOREACH_FLEX_ALGO_SRLG(srlgs, srlg) \ + FOREACH_ADMIN_GROUP_BITS(srlgs, srlg) + typedef void *(*flex_algo_allocator_t)(void *); typedef void (*flex_algo_releaser_t)(void *); @@ -107,6 +213,22 @@ struct flex_algos { struct list *flex_algos; }; +#define FOREACH_FLEX_ALGO_DEFN(flxalgs, node, nnode, flexalgo) \ + for (ALL_LIST_ELEMENTS ((flxalgs)->flex_algos, node, nnode, \ + flexalgo)) + +static inline size_t +flex_algos_count(struct flex_algos *flex_algos) +{ + return (flex_algos->flex_algos ? flex_algos->flex_algos->count : 0); +} + +static inline bool +flex_algos_empty(struct flex_algos *flex_algos) +{ + return (flex_algos_count(flex_algos) ? false : true); +} + /* * Flex-Algo Utilities */ @@ -117,7 +239,6 @@ struct flex_algo *flex_algo_alloc(struct flex_algos *flex_algos, uint8_t algorithm, void *arg); struct flex_algo *flex_algo_lookup(struct flex_algos *flex_algos, uint8_t algorithm); -void flex_algos_free(struct flex_algos *flex_algos); bool flex_algo_definition_cmp(struct flex_algo *fa1, struct flex_algo *fa2); void flex_algo_delete(struct flex_algos *flex_algos, uint8_t algorithm); bool flex_algo_id_valid(uint16_t algorithm); @@ -128,4 +249,33 @@ bool flex_algo_get_state(struct flex_algos *flex_algos, uint8_t algorithm); void flex_algo_set_state(struct flex_algos *flex_algos, uint8_t algorithm, bool state); + +static inline void +flex_algo_set_prefix_metric(struct flex_algo *fa, uint32_t metric) +{ + fa->flags |= FAD_FLAG_M; + fa->prefix_adv_metric = metric; +} + +static inline void +flex_algo_reset_prefix_metric(struct flex_algo *fa) +{ + fa->flags &= ~FAD_FLAG_M; + fa->prefix_adv_metric = 0; +} + +static inline void +flex_algo_encode_admin_group(struct admin_group *ag, uint8_t *buf, + uint16_t *buflen) +{ + bf_encode_to_buf(&ag->bitmap, buf, buflen); +} + +static inline void +flex_algo_decode_admin_group(struct admin_group *ag, uint8_t *buf, + uint16_t buflen) +{ + bf_decode_from_buf(&ag->bitmap, buf, buflen); +} + #endif /* _FRR_FLEX_ALGO_H */ From 0464efbd8b3da168eb43803f10b1d90948d355af Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Mon, 6 Jun 2022 12:13:46 -0700 Subject: [PATCH 2/6] ospfd: Configure and show Flex-Algo definitions parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds/modifies following configuration/show commands that lets user to configure and retrieve Flexible-Algorithm definitions in OSPF’s Global Flex-Algo Database. Config-commands: router ospf flexible-algorithm metric-type flexible-algorithm calculation-type flexible-algorithm priority flexible-algorithm exclude-admin-group flexible-algorithm include-all-admin-group flexible-algorithm include-any-admin-group flexible-algorithm include-any-admin-group flexible-algorithm exclude-srlg flexible-algorithm flags flexible-algorithm prefix-advertise-metric Show commands: show running-config (for router ospf) show ip ospf router-info Signed-off-by: Pushpasis Sarkar --- lib/flex_algo.c | 13 +- ospfd/ospf_affinitymap.c | 79 +++++ ospfd/ospf_affinitymap.h | 22 ++ ospfd/ospf_main.c | 4 + ospfd/ospf_memory.c | 6 + ospfd/ospf_memory.h | 6 + ospfd/ospf_opaque.h | 11 + ospfd/ospf_ri.c | 653 +++++++++++++++++++++++++++++++++++++-- ospfd/ospf_ri.h | 22 ++ ospfd/ospf_sr.h | 1 - ospfd/ospfd.h | 1 + ospfd/subdir.am | 3 + vtysh/vtysh.h | 2 +- 13 files changed, 788 insertions(+), 35 deletions(-) create mode 100644 ospfd/ospf_affinitymap.c create mode 100644 ospfd/ospf_affinitymap.h diff --git a/lib/flex_algo.c b/lib/flex_algo.c index da89f49b7206..07ca0c4ae497 100644 --- a/lib/flex_algo.c +++ b/lib/flex_algo.c @@ -158,17 +158,8 @@ bool flex_algo_id_valid(uint16_t algorithm) char *flex_algo_metric_type_print(char *type_str, size_t sz, enum flex_algo_metric_type metric_type) { - switch (metric_type) { - case MT_IGP: - snprintf(type_str, sz, "igp"); - break; - case MT_MIN_UNI_LINK_DELAY: - snprintf(type_str, sz, "delay"); - break; - case MT_TE_DEFAULT: - snprintf(type_str, sz, "te"); - break; - } + snprintf(type_str, sz, "%s", + flex_algo_metric_type2str(metric_type)); return type_str; } diff --git a/ospfd/ospf_affinitymap.c b/ospfd/ospf_affinitymap.c new file mode 100644 index 000000000000..534d0c97d311 --- /dev/null +++ b/ospfd/ospf_affinitymap.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* OSPFv2 affinity-map + * Copyright 2023 VMware, Inc. + * Pushpasis Sarkar + */ + +#include +#include "lib/if.h" +#include "lib/vrf.h" +#include "lib/mpls.h" +#include "ospfd/ospfd.h" +#include "ospfd/ospf_opaque.h" +#include "ospfd/ospf_sr.h" +#include "ospfd/ospf_ri.h" +#include "ospfd/ospf_affinitymap.h" + +static bool ospf_affinity_map_check_use(const char *affmap_name) +{ + struct listnode *curr, *next; + struct flex_algo *fad; + struct affinity_map *map; + uint16_t pos; + + map = affinity_map_get(affmap_name); + pos = map->bit_position; + + FOREACH_FLEX_ALGO_DEFN(OspfRI.fad_info.fads, curr, next, fad) { + if (admin_group_get(&fad->admin_group_exclude_any, pos) || + admin_group_get(&fad->admin_group_include_any, pos) || + admin_group_get(&fad->admin_group_include_all, pos)) + return true; + } + return false; +} + +static void ospf_affinity_map_update(const char *affmap_name, uint16_t old_pos, + uint16_t new_pos) +{ + struct listnode *curr, *next; + struct flex_algo *fad; + bool changed; + + changed = false; + FOREACH_FLEX_ALGO_DEFN(OspfRI.fad_info.fads, curr, next, fad) { + if (admin_group_get(&fad->admin_group_exclude_any, old_pos)) { + admin_group_unset(&fad->admin_group_exclude_any, + old_pos); + admin_group_set(&fad->admin_group_exclude_any, + new_pos); + changed = true; + } + if (admin_group_get(&fad->admin_group_include_any, old_pos)) { + admin_group_unset(&fad->admin_group_include_any, + old_pos); + admin_group_set(&fad->admin_group_include_any, + new_pos); + changed = true; + } + if (admin_group_get(&fad->admin_group_include_all, old_pos)) { + admin_group_unset(&fad->admin_group_include_all, + old_pos); + admin_group_set(&fad->admin_group_include_all, + new_pos); + changed = true; + } + } + + if (changed) + ospf_router_info_schedule(REFRESH_THIS_LSA); +} + +void ospf_affinity_map_init(void) +{ + affinity_map_init(); + affinity_map_set_nb_bypass(true); + + affinity_map_set_check_use_hook(ospf_affinity_map_check_use); + affinity_map_set_update_hook(ospf_affinity_map_update); +} diff --git a/ospfd/ospf_affinitymap.h b/ospfd/ospf_affinitymap.h new file mode 100644 index 000000000000..aad5178ded4c --- /dev/null +++ b/ospfd/ospf_affinitymap.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* OSPFv2 affinity-map + * Copyright 2023 VMware, Inc. + * Pushpasis Sarkar + */ + +#ifndef __OSPF_AFFINITYMAP_H__ +#define __OSPF_AFFINITYMAP_H__ + +#include "lib/affinitymap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void ospf_affinity_map_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __OSPF_AFFINITYMAP_H__ */ diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index a2a1c4a94f22..ad8c5a700498 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -44,6 +44,7 @@ #include "ospfd/ospf_errors.h" #include "ospfd/ospf_ldp_sync.h" #include "ospfd/ospf_routemap_nb.h" +#include "ospfd/ospf_affinitymap.h" /* ospfd privileges */ zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, @@ -234,6 +235,9 @@ int main(int argc, char **argv) ospf_vty_show_init(); ospf_vty_clear_init(); + /* OSPF Affinity maps init */ + ospf_affinity_map_init(); + /* OSPF BFD init */ ospf_bfd_init(master); diff --git a/ospfd/ospf_memory.c b/ospfd/ospf_memory.c index 9854c8cae80b..ada5d64ee965 100644 --- a/ospfd/ospf_memory.c +++ b/ospfd/ospf_memory.c @@ -45,3 +45,9 @@ DEFINE_MTYPE(OSPFD, OSPF_GR_HELPER, "OSPF Graceful Restart Helper"); DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_RT_AGGR, "OSPF External Route Summarisation"); DEFINE_MTYPE(OSPFD, OSPF_P_SPACE, "OSPF TI-LFA P-Space"); DEFINE_MTYPE(OSPFD, OSPF_Q_SPACE, "OSPF TI-LFA Q-Space"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_TLV, "OSPF RI FAD TLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV, "OSPF RI FAD Exclude AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV, "OSPF RI FAD Include-Any AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV, "OSPF RI FAD Include-All AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_FLAGS_SUBTLV, "OSPF RI FAD Flags SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_SRLG_SUBTLV, "OSPF RI FAD Exclude SRLG SubTLV"); diff --git a/ospfd/ospf_memory.h b/ospfd/ospf_memory.h index d11b69abb01b..4ad1e92d6a4c 100644 --- a/ospfd/ospf_memory.h +++ b/ospfd/ospf_memory.h @@ -44,5 +44,11 @@ DECLARE_MTYPE(OSPF_GR_HELPER); DECLARE_MTYPE(OSPF_EXTERNAL_RT_AGGR); DECLARE_MTYPE(OSPF_P_SPACE); DECLARE_MTYPE(OSPF_Q_SPACE); +DECLARE_MTYPE(OSPF_RI_FAD_TLV); +DECLARE_MTYPE(OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV); +DECLARE_MTYPE(OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV); +DECLARE_MTYPE(OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV); +DECLARE_MTYPE(OSPF_RI_FAD_FLAGS_SUBTLV); +DECLARE_MTYPE(OSPF_RI_FAD_EXC_SRLG_SUBTLV); #endif /* _QUAGGA_OSPF_MEMORY_H */ diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index 54651f8f58a6..943dc2fe63b2 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -78,6 +78,17 @@ struct tlv_header { uint16_t length; /* Length of Value portion only, in bytes */ }; +PREDECL_LIST(tlv_list); +struct tlv { + struct tlv_list_item linkage; + struct tlv_header hdr; + /* Body follows */ + uint8_t body[0]; +}; +DECLARE_LIST(tlv_list, struct tlv, linkage); +#define FOREACH_TLV_IN_LIST(list, tlv) \ + frr_each_safe(tlv_list, list, tlv) + #define TLV_HDR_SIZE (sizeof(struct tlv_header)) #define TLV_BODY_SIZE(tlvh) (ROUNDUP(ntohs((tlvh)->length), sizeof(uint32_t))) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index c6aaf3f5a075..836aa8daac8a 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -24,6 +24,8 @@ #include "hash.h" #include "sockunion.h" /* for inet_aton() */ #include "mpls.h" +#include "affinitymap.h" +#include "segment_routing.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -43,12 +45,13 @@ #include "ospfd/ospf_sr.h" #include "ospfd/ospf_ri.h" #include "ospfd/ospf_errors.h" +#include "ospfd/ospf_ri_clippy.c" /* * Global variable to manage Opaque-LSA/Router Information on this node. * Note that all parameter values are stored in network byte order. */ -static struct ospf_router_info OspfRI; +struct ospf_router_info OspfRI; /*------------------------------------------------------------------------------* * Following are initialize/terminate functions for Router Information @@ -93,6 +96,9 @@ int ospf_router_info_init(void) /* Initialize Segment Routing information structure */ OspfRI.sr_info.enabled = false; + /* Initialize the Flex-Algo database */ + OspfRI.fad_info.fads = flex_algos_alloc(NULL, NULL); + ospf_router_info_register_vty(); return 0; @@ -156,6 +162,10 @@ void ospf_router_info_term(void) list_delete(&OspfRI.area_info); list_delete(&OspfRI.pce_info.pce_domain); list_delete(&OspfRI.pce_info.pce_neighbor); + if (OspfRI.enabled && OspfRI.fad_info.fads) { + flex_algos_free(OspfRI.fad_info.fads); + OspfRI.fad_info.fads = NULL; + } OspfRI.enabled = false; @@ -176,6 +186,10 @@ void ospf_router_info_finish(void) list_delete_all_node(OspfRI.pce_info.pce_domain); list_delete_all_node(OspfRI.pce_info.pce_neighbor); + if (OspfRI.enabled && OspfRI.fad_info.fads) { + flex_algos_free(OspfRI.fad_info.fads); + OspfRI.fad_info.fads = NULL; + } OspfRI.enabled = false; } @@ -1583,6 +1597,9 @@ static void ospf_router_info_config_write_router(struct vty *vty) struct ri_pce_subtlv_domain *domain; struct ri_pce_subtlv_neighbor *neighbor; struct in_addr tmp; + struct flex_algo *fad; + struct listnode *curr, *next; + uint32_t admin_grp, srlg; if (!OspfRI.enabled) return; @@ -1633,14 +1650,53 @@ static void ospf_router_info_config_write_router(struct vty *vty) vty_out(vty, " pce scope 0x%x\n", ntohl(OspfRI.pce_info.pce_scope.value)); } + + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + vty_out(vty, " flexible-algorithm %u\n", fad->algorithm); + if (fad->metric_type != MT_DEFAULT) + vty_out(vty, " flexible-algorithm %u metric-type %s\n", fad->algorithm, + flex_algo_metric_type2str(fad->metric_type)); + if (fad->calc_type != CALC_TYPE_DEFAULT) + vty_out(vty, " flexible-algorithm %u calculation-type %s\n", + fad->algorithm, flex_algo_calc_type2str(fad->calc_type)); + if (fad->priority != FLEX_ALGO_PRIO_DEFAULT) + vty_out(vty, " flexible-algorithm %u priority %u\n", fad->algorithm, + fad->priority); + FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_exclude_any, admin_grp) { + vty_out(vty, + " flexible-algorithm %u exclude-admin-group %s\n", + fad->algorithm, affinity_map_name_get((int)admin_grp)); + } + FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_all, + admin_grp) { + vty_out(vty, + " flexible-algorithm %u include-all-admin-group %s\n", + fad->algorithm, affinity_map_name_get((int)admin_grp)); + } + FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_any, + admin_grp) { + vty_out(vty, + " flexible-algorithm %u include-any-admin-group %s\n", + fad->algorithm, affinity_map_name_get((int)admin_grp)); + } + FOREACH_FLEX_ALGO_SRLG (&fad->srlgs_exclude, srlg) { + vty_out(vty, " flexible-algorithm %u exclude-srlg %u\n", + fad->algorithm, srlg); + } + if (FLEX_ALGO_PREFIX_METRIC_SET(fad)) { + vty_out(vty, + " flexible-algorithm %u advertise-prefix-metric %u\n", + fad->algorithm, fad->prefix_adv_metric); + } + } + return; } -/*------------------------------------------------------------------------* - * Following are vty command functions. - *------------------------------------------------------------------------*/ -/* Simple wrapper schedule RI LSA action in function of the scope */ -static void ospf_router_info_schedule(enum lsa_opcode opcode) +/* + * Schedule RI LSA action in function of the scope + */ +void ospf_router_info_schedule(enum lsa_opcode opcode) { struct listnode *node, *nnode; struct ospf_ri_area_info *ai; @@ -1658,6 +1714,9 @@ static void ospf_router_info_schedule(enum lsa_opcode opcode) } } +/*------------------------------------------------------------------------* + * Following are vty command functions. + *------------------------------------------------------------------------*/ DEFUN (router_info, router_info_area_cmd, "router-info ", @@ -1720,13 +1779,14 @@ DEFUN (router_info, return CMD_SUCCESS; } - DEFUN (no_router_info, no_router_info_cmd, "no router-info", NO_STR "Disable the Router Information functionality\n") { + struct flex_algo *fad; + struct listnode *curr, *next; if (!OspfRI.enabled) return CMD_SUCCESS; @@ -1734,6 +1794,11 @@ DEFUN (no_router_info, if (IS_DEBUG_OSPF_EVENT) zlog_debug("RI-> Router Information: ON -> OFF"); + /* Remove all Flexible-Algo-Defns from DB. */ + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + flex_algo_delete(OspfRI.fad_info.fads, fad->algorithm);; + } + ospf_router_info_schedule(FLUSH_THIS_LSA); OspfRI.enabled = false; @@ -2032,13 +2097,461 @@ DEFUN (no_pce_cap_flag, return CMD_SUCCESS; } -DEFUN (show_ip_ospf_router_info, - show_ip_ospf_router_info_cmd, - "show ip ospf router-info", - SHOW_STR - IP_STR - OSPF_STR - "Router Information\n") +DEFPY(flex_algo_defn, flex_algo_defn_cmd, + "[no$no] flexible-algorithm (128-255)$id", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the Flexible Algorithm\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && fad) { + flex_algo_delete(OspfRI.fad_info.fads, fad->algorithm);; + OspfRI.fad_info.num_fads--; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + /* Re-originate RI LSA if required */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + if (!fad) + return CMD_ERR_NO_MATCH; + + + return CMD_SUCCESS; +} + +DEFPY(flex_algo_metric_type, flex_algo_metric_type_cmd, + "[no$no] flexible-algorithm (128-255)$id metric-type [$typestr]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Metric type to be used for the Flexible Algorithm\n" + "IGP metric type\n") +{ + enum flex_algo_metric_type metric_type; + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + if (no) + metric_type = MT_DEFAULT; + else { + if (!typestr) + return CMD_ERR_INCOMPLETE; + metric_type = flex_algo_str2metric_type(typestr); + if (metric_type < MT_MIN || metric_type >= MT_MAX) + return CMD_ERR_NO_MATCH; + } + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + if (fad->metric_type != metric_type) { + fad->metric_type = metric_type; + update_lsa = true; + } + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +DEFPY(flex_algo_calc_type, flex_algo_calc_type_cmd, + "[no$no] flexible-algorithm (128-255)$id calculation-type [$typestr]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Calculation type to be used for the Flexible Algorithm\n" + "Shortest Path First\n") +{ + enum flex_algo_calc_type calc_type; + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + if (no) + calc_type = CALC_TYPE_DEFAULT; + else { + if (!typestr) + return CMD_ERR_INCOMPLETE; + calc_type = flex_algo_str2calc_type(typestr); + if (calc_type < CALC_TYPE_MIN || + calc_type < CALC_TYPE_MIN) + return CMD_ERR_NO_MATCH; + } + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + if (fad->calc_type != calc_type) { + fad->calc_type = calc_type; + update_lsa = true; + } + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +DEFPY(flex_algo_priority, flex_algo_priority_cmd, + "[no$no] flexible-algorithm (128-255)$id priority [(0-4294967295)$prio]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Assign a priority to be used for the Flexible Algorithm\n" + "Priority to be used for the Flexible Algorithm\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + if (no) + prio = FLEX_ALGO_PRIO_DEFAULT; + else { + if (prio > FLEX_ALGO_PRIO_MAX) + return CMD_ERR_NO_MATCH; + } + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + if (fad->priority != (uint8_t)prio) { + fad->priority = (uint8_t)prio; + update_lsa = true; + } + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +static int ospf_flex_algo_admin_group_update( + bool delete, struct admin_group *admin_group, + const char *name, bool update_lsa) +{ + struct affinity_map *map = NULL; + int found_ag; + + if (!delete && !name) + return CMD_ERR_INCOMPLETE; + + map = affinity_map_get(name); + if (name && !map) { + zlog_err("Couldn't find any affinity by name '%s'", name); + return CMD_WARNING_CONFIG_FAILED; + } + + found_ag = admin_group_get(admin_group, map->bit_position); + if (!delete) { + if (!found_ag) { + admin_group_set(admin_group, + map->bit_position); + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + } else { + if (!found_ag) + return CMD_ERR_NO_MATCH; + + admin_group_unset(admin_group, + map->bit_position); + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +DEFPY(flex_algo_exc_admngrp, flex_algo_exc_admngrp_cmd, + "[no$no] flexible-algorithm (128-255)$id exclude-admin-group [NAME$name]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Add a Admin-Group to the Exclude list\n" + "Name of the admin group to be added(or deleted)\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + return ospf_flex_algo_admin_group_update(no ? true : false, + &fad->admin_group_exclude_any, name, update_lsa); +} + +DEFPY(flex_algo_incall_admngrp, flex_algo_incall_admngrp_cmd, + "[no$no] flexible-algorithm (128-255)$id include-all-admin-group [NAME$name]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Add a Admin-Group to the Include-All list\n" + "Name of the admin group to be added(or deleted)\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + return ospf_flex_algo_admin_group_update(no ? true : false, + &fad->admin_group_include_all, name, update_lsa); +} + +DEFPY(flex_algo_incany_admngrp, flex_algo_incany_admngrp_cmd, + "[no$no] flexible-algorithm (128-255)$id include-any-admin-group [NAME$name]", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Add a Admin-Group to the Include-Any list\n" + "Name of the admin group to be added (or deleted)\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); + OspfRI.fad_info.num_fads++; + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + + if (no && !fad) + return CMD_ERR_NO_MATCH; + + return ospf_flex_algo_admin_group_update(no ? true : false, + &fad->admin_group_include_any, name, update_lsa); +} + +#if 0 +DEFPY(flex_algo_exc_srlg, flex_algo_exc_srlg_cmd, + "flexible-algorithm (128-255)$id exclude-srlg (0-4294967295)$srlgval", + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Add a SRLG to the Exclude list\n" + "SRLG to be included\n") +{ + uint32_t srlg; + struct flex_algo *fad; + struct flex_algo_srlg *fsrlg; + bool update_lsa = false; + bool new_fad = false; + bool new_srlg = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + srlg = (uint32_t)srlgval; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + assert(fad); + if (new_fad) { + OspfRI.fad_info.num_fads++; + new_fad = true; + update_lsa = true; + } + + fsrlg = flex_algo_lookup_srlg(&fad->srlgs_exclude, srlg, true, + &new_srlg); + assert(fsrlg); + if (new_srlg) + update_lsa = true; + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +DEFPY(no_flex_algo_exc_srlg, no_flex_algo_exc_srlg_cmd, + "no flexible-algorithm (128-255)$id exclude-srlg (0-4294967295)$srlgval", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Remove a specfic or all SRLG(s) from the Exclude list\n" + "SRLG to be removed\n") +{ + uint32_t srlg; + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + srlg = (uint32_t)srlgval; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!fad) + return CMD_ERR_NO_MATCH; + + flex_algo_delete_srlg(&fad->srlgs_exclude, srlg, &update_lsa); + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} + +DEFPY(no_flex_algo_exc_srlg_all, no_flex_algo_exc_srlg_all_cmd, + "no flexible-algorithm (128-255)$id exclude-srlg", + NO_STR + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Remove a specfic or all SRLG(s) from the Exclude list\n") +{ + struct flex_algo *fad; + bool update_lsa = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + if (!fad) + return CMD_ERR_NO_MATCH; + + if (flxalg_srlgs_count(&fad->srlgs_exclude)) { + update_lsa = true; + flex_algo_flush_srlgs(&fad->srlgs_exclude); + } + + /* Refresh/Re-originate RI LSA if already engaged */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); + + return CMD_SUCCESS; +} +#endif + +DEFPY(flex_algo_prfx_metric, flex_algo_prfx_metric_cmd, + "flexible-algorithm (128-255)$id prefix-advertise-metric (0-4294967295)$prefmetric", + "Specify a Flexible Algorithm Definition\n" + "Unique number assigned to the new Flexible Algorithm\n" + "Specify a default prefix advertise metric\n" + "Default prefix metric to be advertised\n") +{ + uint32_t metric; + struct flex_algo *fad; + bool update_lsa = false; + bool new_fad = false; + + if (!ospf_ri_enabled(vty)) + return CMD_WARNING_CONFIG_FAILED; + + metric = (uint32_t)prefmetric; + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); + assert(fad); + if (new_fad) { + OspfRI.fad_info.num_fads++; + new_fad = true; + update_lsa = true; + } + + if (!!FLEX_ALGO_PREFIX_METRIC_SET(fad) || + fad->prefix_adv_metric != metric) { + flex_algo_set_prefix_metric(fad, metric); + update_lsa = true; + } + + /* + * TODO: Refresh/Re-originate all EXT Prefix LSAs if already engaged. + if (update_lsa) + ospf_ext_update_all_prefix_fapms(); + */ + + return CMD_SUCCESS; +} + +DEFUN(show_ip_ospf_router_info, show_ip_ospf_router_info_cmd, + "show ip ospf router-info", + SHOW_STR IP_STR OSPF_STR "Router Information\n") { if (OspfRI.enabled) { @@ -2052,14 +2565,11 @@ DEFUN (show_ip_ospf_router_info, return CMD_SUCCESS; } -DEFUN (show_ip_opsf_router_info_pce, - show_ip_ospf_router_info_pce_cmd, - "show ip ospf router-info pce", - SHOW_STR - IP_STR - OSPF_STR - "Router Information\n" - "PCE information\n") +DEFUN(show_ip_opsf_router_info_pce, show_ip_ospf_router_info_pce_cmd, + "show ip ospf router-info pce", + SHOW_STR IP_STR OSPF_STR + "Router Information\n" + "PCE information\n") { struct ospf_pce_info *pce = &OspfRI.pce_info; @@ -2101,11 +2611,99 @@ DEFUN (show_ip_opsf_router_info_pce, return CMD_SUCCESS; } +static void show_vty_flxalg_info(struct vty *vty, struct flex_algo *fad) +{ + uint32_t admin_grp; + // uint32_t srlg; + + vty_out(vty, " Flexible-Algorithm: %u\n", fad->algorithm); + vty_out(vty, " Metric-Type: \t%s\n", + flex_algo_metric_type2str(fad->metric_type)); + vty_out(vty, " Calculation-Type: \t%s\n", + flex_algo_calc_type2str(fad->calc_type)); + vty_out(vty, " Priority: \t%u\n", fad->priority); + vty_out(vty, " Flags: \t0x%02x\n", fad->flags); + vty_out(vty, " Advt-Prefix-Metric: \t%s\n", + FLEX_ALGO_PREFIX_METRIC_SET(fad) ? "Y" : "N"); + if (FLEX_ALGO_PREFIX_METRIC_SET(fad)) + vty_out(vty, " Prefix-Metric: \t%u\n", + fad->prefix_adv_metric); + + if (admin_group_size(&fad->admin_group_exclude_any)) { + vty_out(vty, " Exclude-Admin-Groups: \n"); + FOREACH_FLEX_ALGO_ADMIN_GROUP(&fad->admin_group_exclude_any, admin_grp) + { + vty_out(vty, " \t - %u\n", admin_grp); + } + } + + if (admin_group_size(&fad->admin_group_include_any)) { + vty_out(vty, " Include-Any-Admin-Groups: \n"); + FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_any, + admin_grp) { + vty_out(vty, " \t - %u\n", admin_grp); + } + } + + if (admin_group_size(&fad->admin_group_include_all)) { + vty_out(vty, " Include-All-Admin-Groups: \n"); + FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_all, + admin_grp) { + vty_out(vty, " \t - %u\n", admin_grp); + } + } + + // if (flxalg_srlgs_count(&fad->srlgs_exclude)) { + // vty_out(vty, " Exclude-SRLGs: \n"); + // FOREACH_FLEX_ALGO_SRLG (&fad->srlgs_exclude, srlg) { + // vty_out(vty, " \t - %u\n", srlg); + // } + // } +} + +DEFPY(show_ip_opsf_router_info_flxalg, show_ip_ospf_router_info_flxalg_cmd, + "show ip ospf router-info flexible-algorithms [(128-255)$id]", + SHOW_STR IP_STR OSPF_STR + "Router Information\n" + "Flexible-Algorithm information\n" + "Unique identifier for the flexible algorithm\n") +{ + struct flex_algo *fad; + struct listnode *curr, *next; + + if ((OspfRI.enabled) && !flex_algos_empty(OspfRI.fad_info.fads)) { + if (!id) { + vty_out(vty, "--- Flexible-Algorithm parameters ---\n"); + + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + show_vty_flxalg_info(vty, fad); + } + } else { + if (id < FLEX_ALGO_ALGO_MIN || id > FLEX_ALGO_ALGO_MAX) { + vty_out(vty, " Invalid algorithm identifier '%ld'!\n", id); + return CMD_SUCCESS; + } + + fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint32_t)id); + if (!fad) { + vty_out(vty, "No such Flexible algorithm '%ld'!\n", id); + } else { + show_vty_flxalg_info(vty, fad); + } + } + } else { + vty_out(vty, " No Flexible-Algoritthms on this router\n"); + } + + return CMD_SUCCESS; +} + /* Install new CLI commands */ static void ospf_router_info_register_vty(void) { install_element(VIEW_NODE, &show_ip_ospf_router_info_cmd); install_element(VIEW_NODE, &show_ip_ospf_router_info_pce_cmd); + install_element(VIEW_NODE, &show_ip_ospf_router_info_flxalg_cmd); install_element(OSPF_NODE, &router_info_area_cmd); install_element(OSPF_NODE, &no_router_info_cmd); @@ -2119,6 +2717,17 @@ static void ospf_router_info_register_vty(void) install_element(OSPF_NODE, &no_pce_neighbor_cmd); install_element(OSPF_NODE, &pce_cap_flag_cmd); install_element(OSPF_NODE, &no_pce_cap_flag_cmd); + install_element(OSPF_NODE, &flex_algo_defn_cmd); + install_element(OSPF_NODE, &flex_algo_metric_type_cmd); + install_element(OSPF_NODE, &flex_algo_calc_type_cmd); + install_element(OSPF_NODE, &flex_algo_priority_cmd); + install_element(OSPF_NODE, &flex_algo_exc_admngrp_cmd); + install_element(OSPF_NODE, &flex_algo_incany_admngrp_cmd); + install_element(OSPF_NODE, &flex_algo_incall_admngrp_cmd); + // install_element(OSPF_NODE, &flex_algo_exc_srlg_cmd); + // install_element(OSPF_NODE, &no_flex_algo_exc_srlg_cmd); + // install_element(OSPF_NODE, &no_flex_algo_exc_srlg_all_cmd); + install_element(OSPF_NODE, &flex_algo_prfx_metric_cmd); return; } diff --git a/ospfd/ospf_ri.h b/ospfd/ospf_ri.h index 0870938cf11a..5c521fdee2fc 100644 --- a/ospfd/ospf_ri.h +++ b/ospfd/ospf_ri.h @@ -199,6 +199,17 @@ struct ospf_ri_sr_info { struct ri_sr_tlv_node_msd msd; }; +/* + * Store Flexibe Algorithm Definition information + */ +#define MAX_NUM_FLEX_ALGO_DEFN 16 +struct ospf_ri_fad_info { + uint8_t num_fads; + + /* Algorithms supported by the node */ + struct flex_algos *fads; +}; + /* Store area information to flood LSA per area */ struct ospf_ri_area_info { @@ -228,8 +239,17 @@ struct ospf_router_info { /* Store SR capability LSA */ struct ospf_ri_sr_info sr_info; + + /* Store Flex-Algo Definitions */ + struct ospf_ri_fad_info fad_info; }; +/* + * Global variable to manage Opaque-LSA/Router Information on this node. + * Note that all parameter values are stored in network byte order. + */ + extern struct ospf_router_info OspfRI; + /* Prototypes. */ extern int ospf_router_info_init(void); extern void ospf_router_info_term(void); @@ -237,4 +257,6 @@ extern void ospf_router_info_finish(void); extern int ospf_router_info_enable(void); extern void ospf_router_info_update_sr(bool enable, struct sr_node *self); extern struct scope_info ospf_router_info_get_flooding_scope(void); +extern void ospf_router_info_schedule(enum lsa_opcode opcode); + #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */ diff --git a/ospfd/ospf_sr.h b/ospfd/ospf_sr.h index fa61f669a715..9606bdcdcdd5 100644 --- a/ospfd/ospf_sr.h +++ b/ospfd/ospf_sr.h @@ -68,7 +68,6 @@ struct ri_sr_tlv_sr_algorithm { struct tlv_header header; #define SR_ALGORITHM_SPF 0 #define SR_ALGORITHM_STRICT_SPF 1 -#define SR_ALGORITHM_UNSET 255 #define ALGORITHM_COUNT 4 /* Only 4 algorithms supported in this code */ uint8_t value[ALGORITHM_COUNT]; diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index 2ab7db119e46..a61dd67b444a 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -16,6 +16,7 @@ #include "filter.h" #include "log.h" #include "vrf.h" +#include "flex_algo.h" #include "ospf_memory.h" #include "ospf_dump_api.h" diff --git a/ospfd/subdir.am b/ospfd/subdir.am index 4803aae68d84..8f7c669b6243 100644 --- a/ospfd/subdir.am +++ b/ospfd/subdir.am @@ -20,6 +20,7 @@ ospfd_libfrrospfclient_a_SOURCES = \ ospfd_libfrrospf_a_SOURCES = \ ospfd/ospf_abr.c \ + ospfd/ospf_affinitymap.c \ ospfd/ospf_api.c \ ospfd/ospf_apiserver.c \ ospfd/ospf_asbr.c \ @@ -80,10 +81,12 @@ clippy_scan += \ ospfd/ospf_ldp_sync.c \ ospfd/ospf_dump.c \ ospfd/ospf_gr.c \ + ospfd/ospf_ri.c \ # end noinst_HEADERS += \ ospfd/ospf_abr.h \ + ospfd/ospf_affinitymap.h \ ospfd/ospf_apiserver.h \ ospfd/ospf_ase.h \ ospfd/ospf_bfd.h \ diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 65733ca61b4c..9799d5cf8898 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -50,7 +50,7 @@ extern struct event_loop *master; VTYSH_SHARPD | VTYSH_PBRD | VTYSH_STATICD | VTYSH_BFDD | \ VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD #define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA -#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD +#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD | VTYSH_OSPFD #define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD #define VTYSH_INTERFACE_SUBSET \ VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \ From f25a6a6edf8b54374f21a85401bf0560d34edf30 Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Mon, 6 Jun 2022 12:57:58 -0700 Subject: [PATCH 3/6] ospfd: Generate and parse RI-LSA FAD TLVs and SubTLVs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds code to generate required RI-LSA FAD TLVs and SubTLVs based on local Flex-Algo configurations, as well as parse RI-LSA FAD TLVs and SubTLVs received from remote router on-the-wire. The parsed result can be displayed using ’show ip ospf database opaque-area’. Signed-off-by: Pushpasis Sarkar --- ospfd/ospf_opaque.h | 10 + ospfd/ospf_ri.c | 1140 ++++++++++++++++++++++++++++++++++++------- ospfd/ospf_ri.h | 82 +++- ospfd/ospf_sr.c | 14 +- ospfd/ospf_sr.h | 4 +- 5 files changed, 1072 insertions(+), 178 deletions(-) diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index 943dc2fe63b2..ebe6999796e4 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -110,6 +110,16 @@ DECLARE_LIST(tlv_list, struct tlv, linkage); #define TLV_LEN(tlvh) tlvh.header.length #define TLV_HDR(tlvh) tlvh.header +static inline void tlvh_get_json_values(struct tlv_header *tlvh, + json_object *json, const char *type) +{ + if (json) { + json_object_string_add(json, "name", type); + json_object_int_add(json, "type", ntohs(tlvh->type)); + json_object_int_add(json, "length", ntohs(tlvh->length)); + } +} + /* Following declaration concerns the Opaque LSA management */ enum lsa_opcode { REORIGINATE_THIS_LSA, REFRESH_THIS_LSA, FLUSH_THIS_LSA }; diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 836aa8daac8a..a4a6b2fadb21 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -45,7 +45,9 @@ #include "ospfd/ospf_sr.h" #include "ospfd/ospf_ri.h" #include "ospfd/ospf_errors.h" +#ifndef VTYSH_EXTRACT_PL #include "ospfd/ospf_ri_clippy.c" +#endif /* * Global variable to manage Opaque-LSA/Router Information on this node. @@ -72,6 +74,7 @@ static void ospf_router_info_register_vty(void); static int ospf_router_info_lsa_update(struct ospf_lsa *lsa); static void del_area_info(void *val); static void del_pce_info(void *val); +static void flush_ri_fad_tlvs(void); int ospf_router_info_init(void) { @@ -98,6 +101,7 @@ int ospf_router_info_init(void) /* Initialize the Flex-Algo database */ OspfRI.fad_info.fads = flex_algos_alloc(NULL, NULL); + tlv_list_init(&OspfRI.fad_info.ri_fad_tlvs); ospf_router_info_register_vty(); @@ -162,6 +166,7 @@ void ospf_router_info_term(void) list_delete(&OspfRI.area_info); list_delete(&OspfRI.pce_info.pce_domain); list_delete(&OspfRI.pce_info.pce_neighbor); + flush_ri_fad_tlvs(); if (OspfRI.enabled && OspfRI.fad_info.fads) { flex_algos_free(OspfRI.fad_info.fads); OspfRI.fad_info.fads = NULL; @@ -186,6 +191,7 @@ void ospf_router_info_finish(void) list_delete_all_node(OspfRI.pce_info.pce_domain); list_delete_all_node(OspfRI.pce_info.pce_neighbor); + flush_ri_fad_tlvs(); if (OspfRI.enabled && OspfRI.fad_info.fads) { flex_algos_free(OspfRI.fad_info.fads); OspfRI.fad_info.fads = NULL; @@ -667,6 +673,278 @@ void ospf_router_info_update_sr(bool enable, struct sr_node *srn) } } +static void flush_ri_fad_subtlvs(struct ri_fad_tlv *fad_tlv) +{ + struct tlv *subtlv; + + FOREACH_TLV_IN_LIST (&fad_tlv->sub_tlvs, subtlv) { + tlv_list_del(&fad_tlv->sub_tlvs, subtlv); + + switch (ntohs(subtlv->hdr.type)) { + case RI_FAD_EXC_ADMINGRP_SUBTLV: + /* SubTLV-specific cleanup */ + XFREE(MTYPE_OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV, subtlv); + break; + case RI_FAD_INCANY_ADMINGRP_SUBTLV: + /* SubTLV-specific cleanup */ + XFREE(MTYPE_OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV, subtlv); + break; + case RI_FAD_INCALL_ADMINGRP_SUBTLV: + /* SubTLV-specific cleanup */ + XFREE(MTYPE_OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV, subtlv); + break; + case RI_FAD_FLAGS_SUBTLV: + /* SubTLV-specific cleanup */ + XFREE(MTYPE_OSPF_RI_FAD_FLAGS_SUBTLV, subtlv); + break; + case RI_FAD_EXC_SRLG_SUBTLV: + /* SubTLV-specific cleanup */ + XFREE(MTYPE_OSPF_RI_FAD_EXC_SRLG_SUBTLV, subtlv); + break; + default: + break; + } + } + + tlv_list_fini(&fad_tlv->sub_tlvs); +} + +static void flush_ri_fad_tlvs(void) +{ + struct tlv *tlv; + struct ri_fad_tlv *fad_tlv; + + if (OspfRI.fad_info.num_fads) { + FOREACH_TLV_IN_LIST (&OspfRI.fad_info.ri_fad_tlvs, tlv) { + fad_tlv = (struct ri_fad_tlv *)&tlv->hdr; + flush_ri_fad_subtlvs(fad_tlv); + tlv_list_del(&OspfRI.fad_info.ri_fad_tlvs, tlv); + XFREE(MTYPE_OSPF_RI_FAD_TLV, tlv); + } + } +} + +static void update_ri_fad_tlv(struct flex_algo *fad) +{ + struct tlv *tlv, *subtlv; + struct ri_fad_tlv *fad_tlv; + struct ri_fad_exclude_admingrp_subtlv *exc_admngrp_subtlv; + struct ri_fad_include_any_admingrp_subtlv *incany_admngrp_subtlv; + struct ri_fad_include_all_admingrp_subtlv *incall_admngrp_subtlv; + struct ri_fad_flags_subtlv *flags_subtlv; + struct ri_fad_exclude_srlg_subtlv *exc_srlg_subtlv; + uint16_t tlv_len, subtlv_len; + size_t num_items; + struct admin_group *ag; + + tlv = XCALLOC(MTYPE_OSPF_RI_FAD_TLV, + sizeof(tlv) + sizeof(struct ri_fad_tlv)); + assert(tlv); + fad_tlv = (struct ri_fad_tlv *)&tlv->hdr; + + tlv_list_init(&fad_tlv->sub_tlvs); + tlv_len = RI_FAD_TLV_MIN_LEN; + fad_tlv->header.type = htons(RI_FAD_TLV); + fad_tlv->algorithm_id = fad->algorithm; + fad_tlv->calc_type = fad->calc_type; + fad_tlv->metric_type = fad->metric_type; + fad_tlv->priority = fad->priority; + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("Generate RI-FAD-TLV (type:%u, id:%u)", + ntohs(fad_tlv->header.type), fad_tlv->algorithm_id); + + /* Add Exclude Admin Group SubTLVs (if any) */ + num_items = admin_group_size(&fad->admin_group_exclude_any); + if (num_items) { + ag = &fad->admin_group_exclude_any; + subtlv_len = (bf_word_size(ag->bitmap) * sizeof(uint32_t)); + subtlv = XCALLOC( + MTYPE_OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV, + sizeof(tlv) + + sizeof(struct ri_fad_exclude_admingrp_subtlv) + + subtlv_len); + assert(subtlv); + exc_admngrp_subtlv = + (struct ri_fad_exclude_admingrp_subtlv *)&subtlv->hdr; + exc_admngrp_subtlv->header.type = + htons(RI_FAD_EXC_ADMINGRP_SUBTLV); + + flex_algo_encode_admin_group(ag, + (uint8_t *)exc_admngrp_subtlv->admin_groups, + &subtlv_len); + exc_admngrp_subtlv->header.length = htons(subtlv_len); + tlv_len += subtlv_len + sizeof(struct tlv_header); + + tlv_list_add_tail(&fad_tlv->sub_tlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Generate RI-FAD-EXC-ADMGRP-SUBTLV (type:%u/%u, " + "len: %u/%u, num-admin-groups: %u), total_len: %u", + ntohs(exc_admngrp_subtlv->header.type), + ntohs(subtlv->hdr.type), subtlv_len, + ntohs(subtlv->hdr.length), (uint32_t)num_items, + tlv_len); + } + + /* Add Include-Any Admin Group SubTLVs (if any) */ + num_items = admin_group_size(&fad->admin_group_include_any); + if (num_items) { + ag = &fad->admin_group_include_any; + subtlv_len = (bf_word_size(ag->bitmap) * sizeof(uint32_t)); + subtlv = XCALLOC( + MTYPE_OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV, + sizeof(tlv) + + sizeof(struct + ri_fad_include_any_admingrp_subtlv) + + subtlv_len); + assert(subtlv); + incany_admngrp_subtlv = + (struct ri_fad_include_any_admingrp_subtlv *)&subtlv + ->hdr; + incany_admngrp_subtlv->header.type = + htons(RI_FAD_INCANY_ADMINGRP_SUBTLV); + + flex_algo_encode_admin_group(ag, + (uint8_t *)incany_admngrp_subtlv->admin_groups, + &subtlv_len); + incany_admngrp_subtlv->header.length = htons(subtlv_len); + tlv_len += subtlv_len + sizeof(struct tlv_header); + + tlv_list_add_tail(&fad_tlv->sub_tlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Generate RI-FAD-INCANY-ADMGRP-SUBTLV (type:%u, " + "len: %u, num-admin-groups: %u), total_len: %u", + ntohs(incany_admngrp_subtlv->header.type), + ntohs(incany_admngrp_subtlv->header.length), + (uint32_t)num_items, tlv_len); + } + + /* Add Include-All Admin Group SubTLVs (if any) */ + num_items = admin_group_size(&fad->admin_group_include_all); + if (num_items) { + ag = &fad->admin_group_include_all; + subtlv_len = (bf_word_size(ag->bitmap) * sizeof(uint32_t)); + subtlv = XCALLOC( + MTYPE_OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV, + sizeof(tlv) + + sizeof(struct + ri_fad_include_all_admingrp_subtlv) + + subtlv_len); + assert(subtlv); + incall_admngrp_subtlv = + (struct ri_fad_include_all_admingrp_subtlv *)&subtlv + ->hdr; + incall_admngrp_subtlv->header.type = + htons(RI_FAD_INCALL_ADMINGRP_SUBTLV); + + flex_algo_encode_admin_group(ag, + (uint8_t *)incall_admngrp_subtlv->admin_groups, + &subtlv_len); + incall_admngrp_subtlv->header.length = htons(subtlv_len); + tlv_len += subtlv_len + sizeof(struct tlv_header); + + tlv_list_add_tail(&fad_tlv->sub_tlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Generate RI-FAD-INCALL-ADMGRP-SUBTLV (type:%u, " + "len: %u, num-admin-groups: %u), total_len: %u", + ntohs(incall_admngrp_subtlv->header.type), + ntohs(incall_admngrp_subtlv->header.length), + (uint32_t)num_items, tlv_len); + } + + /* Add Flags SubTLVs (if any) */ + if (fad->flags) { + subtlv_len = ROUNDUP(sizeof(fad->flags), sizeof(uint32_t)); + subtlv = XCALLOC(MTYPE_OSPF_RI_FAD_FLAGS_SUBTLV, + sizeof(tlv) + + sizeof(struct ri_fad_flags_subtlv) + + subtlv_len); + assert(subtlv); + flags_subtlv = (struct ri_fad_flags_subtlv *)&subtlv->hdr; + flags_subtlv->header.type = htons(RI_FAD_FLAGS_SUBTLV); + flags_subtlv->header.length = htons(subtlv_len); + memcpy(flags_subtlv->flags, &fad->flags, sizeof(fad->flags)); + tlv_len += subtlv_len + sizeof(struct tlv_header); + + tlv_list_add_tail(&fad_tlv->sub_tlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Generate RI-FAD-FLAGS-SUBTLV (type:%u, " + "len: %u/%u), total_len: %u", + ntohs(flags_subtlv->header.type), + ntohs(flags_subtlv->header.length), + (uint32_t)subtlv_len, tlv_len); + } + + /* Add Exclude SRLG SubTLVs (if any) */ + num_items = admin_group_size(&fad->srlgs_exclude); + if (num_items) { + ag = &fad->srlgs_exclude; + subtlv_len = (bf_word_size(ag->bitmap) * sizeof(uint32_t)); + subtlv = XCALLOC( + MTYPE_OSPF_RI_FAD_EXC_SRLG_SUBTLV, + sizeof(tlv) + + sizeof(struct + ri_fad_exclude_srlg_subtlv) + + subtlv_len); + assert(subtlv); + exc_srlg_subtlv = + (struct ri_fad_exclude_srlg_subtlv *)&subtlv + ->hdr; + exc_srlg_subtlv->header.type = + htons(RI_FAD_EXC_SRLG_SUBTLV); + + flex_algo_encode_admin_group(ag, + (uint8_t *)exc_srlg_subtlv->srlgs, + &subtlv_len); + exc_srlg_subtlv->header.length = htons(subtlv_len); + tlv_len += subtlv_len + sizeof(struct tlv_header); + + tlv_list_add_tail(&fad_tlv->sub_tlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Generate RI-FAD-EXC-SRLG-SUBTLV (type:%u, " + "len: %u, num-srlgs: %u), total_len: %u", + ntohs(exc_srlg_subtlv->header.type), + ntohs(exc_srlg_subtlv->header.length), + (uint32_t)num_items, tlv_len); + } + + fad_tlv->header.length = htons(tlv_len); + tlv_list_add_tail(&OspfRI.fad_info.ri_fad_tlvs, tlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("Final RI-FAD-TLV (len:%u/%u)", + ntohs(fad_tlv->header.length), tlv_len); +} + +static void update_ri_fad_tlvs(void) +{ + struct flex_algo *fad; + struct listnode *curr, *next; + + flush_ri_fad_tlvs(); + + if (OspfRI.fad_info.fads && OspfRI.fad_info.num_fads) { + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + update_ri_fad_tlv(fad); + } + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("Added total %u RI-FAD-TLVs", + (uint32_t)tlv_list_count( + &OspfRI.fad_info.ri_fad_tlvs)); + } +} + /*------------------------------------------------------------------------* * Following are callback functions against generic Opaque-LSAs handling. *------------------------------------------------------------------------*/ @@ -713,6 +991,87 @@ static void build_tlv(struct stream *s, struct tlv_header *tlvh) return; } +static void ri_lsa_add_fad_tlvs(struct stream *s) +{ + struct tlv *tlv, *subtlv; + struct tlv_header *tlvh, *hdr; + struct ri_fad_tlv *fad_tlv; + uint16_t *tlv_lenp, orig_len; + size_t tlv_begin, tlv_end; + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Adding %d/%d Flex-Algo-Definitions", + OspfRI.fad_info.num_fads, + (uint32_t)tlv_list_count(&OspfRI.fad_info.ri_fad_tlvs)); + + if (OspfRI.fad_info.num_fads) { + FOREACH_TLV_IN_LIST (&OspfRI.fad_info.ri_fad_tlvs, tlv) { + fad_tlv = (struct ri_fad_tlv *)&tlv->hdr; + + /* + * Prepare TLV to write it onto the stream without + * the sub-TLVs. + */ + hdr = &fad_tlv->header; + tlv_lenp = &hdr->length; + orig_len = ntohs(*tlv_lenp); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Got %u bytes of RI-FAD-TLV (type:%u, " + "len: %u, id:%u/%u, metric:%u/%u, calc:%u/%u, prio:%u/%u)", + orig_len, ntohs(hdr->type), + ntohs(hdr->length), tlv->body[0], + fad_tlv->algorithm_id, tlv->body[1], + fad_tlv->metric_type, tlv->body[2], + fad_tlv->calc_type, tlv->body[3], + fad_tlv->priority); + + /* Note the tlv header position in the stream buffer */ + tlv_begin = stream_get_endp(s); + tlvh = (struct tlv_header *)(STREAM_DATA(s) + + stream_get_endp(s)); + + /* Write out the tlv header in the stream buffer */ + *tlv_lenp = htons(RI_FAD_TLV_MIN_LEN); + build_tlv(s, hdr); + + FOREACH_TLV_IN_LIST (&fad_tlv->sub_tlvs, subtlv) { + switch (ntohs(subtlv->hdr.type)) { + case RI_FAD_EXC_ADMINGRP_SUBTLV: + case RI_FAD_INCANY_ADMINGRP_SUBTLV: + case RI_FAD_INCALL_ADMINGRP_SUBTLV: + case RI_FAD_FLAGS_SUBTLV: + case RI_FAD_EXC_SRLG_SUBTLV: + build_tlv(s, &subtlv->hdr); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Wrote Sub-TLV (type:%u, len: %u)", + ntohs(subtlv->hdr.type), + ntohs(subtlv->hdr + .length)); + break; + default: + break; + } + } + + /* Restore the original TLV-len in the stream buffer */ + tlv_end = stream_get_endp(s); + tlv_lenp = &tlvh->length; + *tlv_lenp = htons(orig_len); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "Wrote %u/%u bytes of RI-FAD-TLV (type:%u, len: %u)", + orig_len, + (uint32_t)(tlv_end - tlv_begin), + ntohs(tlvh->type), ntohs(tlvh->length)); + } + } +} + static void ospf_router_info_lsa_body_set(struct stream *s) { @@ -764,6 +1123,10 @@ static void ospf_router_info_lsa_body_set(struct stream *s) build_tlv(s, &OspfRI.pce_info.pce_cap_flag.header); } + /* Add Flex-Algo definitions */ + update_ri_fad_tlvs(); + ri_lsa_add_fad_tlvs(s); + return; } @@ -1230,13 +1593,55 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa) } \ } while (0) -static uint16_t show_vty_router_cap(struct vty *vty, struct tlv_header *tlvh) +#define check_tlv_min_size(size, msg) \ + do { \ + if (ntohs(tlvh->length) < size) { \ + if (vty != NULL) \ + vty_out(vty, \ + " Insuffcient %s TLV size: %d, " \ + "Minimum expected: %d\n", \ + msg, ntohs(tlvh->length), size); \ + else \ + zlog_debug( \ + " Insuffcient %s TLV size: %d," \ + "Minimum expected: %d", \ + msg, ntohs(tlvh->length), size); \ + return size + TLV_HDR_SIZE; \ + } \ + } while (0) + +#define check_tlv_size_multiple_of(unitsize, msg) \ + do { \ + if (ntohs(tlvh->length) % unitsize) { \ + if (vty != NULL) \ + vty_out(vty, \ + " %s TLV size: %d not mutiple of" \ + " %d bytes\n", \ + msg, ntohs(tlvh->length), \ + (int)unitsize); \ + else \ + zlog_debug( \ + " %s TLV size: %d not mutiple of " \ + "%d bytes", \ + msg, ntohs(tlvh->length), \ + (int)unitsize); \ + return ntohs(tlvh->length) + TLV_HDR_SIZE; \ + } \ + } while (0) + + +static uint16_t show_vty_router_cap(struct vty *vty, struct tlv_header *tlvh, + json_object *json) { struct ri_tlv_router_cap *top = (struct ri_tlv_router_cap *)tlvh; check_tlv_size(RI_TLV_CAPABILITIES_SIZE, "Router Capabilities"); - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "Router Capabilities TLV"); + json_object_string_addf(json, "capabilities", "0x%x", + ntohl(top->value)); + } else if (vty != NULL) vty_out(vty, " Router Capabilities: 0x%x\n", ntohl(top->value)); else @@ -1246,14 +1651,19 @@ static uint16_t show_vty_router_cap(struct vty *vty, struct tlv_header *tlvh) } static uint16_t show_vty_pce_subtlv_address(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ri_pce_subtlv_address *top = (struct ri_pce_subtlv_address *)tlvh; if (ntohs(top->address.type) == PCE_ADDRESS_IPV4) { check_tlv_size(PCE_ADDRESS_IPV4_SIZE, "PCE Address"); - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Address SubTLV"); + json_object_string_addf(json, "pceAddress", "%pI4", + &top->address.value); + } else if (vty != NULL) vty_out(vty, " PCE Address: %pI4\n", &top->address.value); else @@ -1281,14 +1691,18 @@ static uint16_t show_vty_pce_subtlv_address(struct vty *vty, } static uint16_t show_vty_pce_subtlv_path_scope(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ri_pce_subtlv_path_scope *top = (struct ri_pce_subtlv_path_scope *)tlvh; check_tlv_size(RI_PCE_SUBTLV_PATH_SCOPE_SIZE, "PCE Path Scope"); - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Path Scope SubTLV"); + json_object_int_add(json, "pcePathScope", ntohl(top->value)); + } else if (vty != NULL) vty_out(vty, " PCE Path Scope: 0x%x\n", ntohl(top->value)); else zlog_debug(" PCE Path Scope: 0x%x", ntohl(top->value)); @@ -1297,7 +1711,8 @@ static uint16_t show_vty_pce_subtlv_path_scope(struct vty *vty, } static uint16_t show_vty_pce_subtlv_domain(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ri_pce_subtlv_domain *top = (struct ri_pce_subtlv_domain *)tlvh; struct in_addr tmp; @@ -1306,18 +1721,33 @@ static uint16_t show_vty_pce_subtlv_domain(struct vty *vty, if (ntohs(top->type) == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = top->value; - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Domain SubTLV"); + json_object_string_add(json, "domainType", "Area"); + json_object_string_addf(json, "domainArea", "%pI4", + &tmp); + } else if (vty != NULL) vty_out(vty, " PCE Domain Area: %pI4\n", &tmp); else zlog_debug(" PCE Domain Area: %pI4", &tmp); } else if (ntohs(top->type) == PCE_DOMAIN_TYPE_AS) { - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Domain SubTLV"); + json_object_string_add(json, "domainType", "AS"); + json_object_int_add(json, "pceDomainAS", + ntohl(top->value)); + } else if (vty != NULL) vty_out(vty, " PCE Domain AS: %d\n", ntohl(top->value)); else zlog_debug(" PCE Domain AS: %d", ntohl(top->value)); } else { - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Domain SubTLV"); + json_object_string_addf(json, "domainType", + "Unknown (%d)", + ntohl(top->type)); + } else if (vty != NULL) vty_out(vty, " Wrong PCE Domain type: %d\n", ntohl(top->type)); else @@ -1329,7 +1759,8 @@ static uint16_t show_vty_pce_subtlv_domain(struct vty *vty, } static uint16_t show_vty_pce_subtlv_neighbor(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ri_pce_subtlv_neighbor *top = @@ -1340,19 +1771,34 @@ static uint16_t show_vty_pce_subtlv_neighbor(struct vty *vty, if (ntohs(top->type) == PCE_DOMAIN_TYPE_AREA) { tmp.s_addr = top->value; - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Neighbor SubTLV"); + json_object_string_add(json, "domainType", "Area"); + json_object_string_addf(json, "neighborArea", "%pI4", + &tmp); + } else if (vty != NULL) vty_out(vty, " PCE Neighbor Area: %pI4\n", &tmp); else zlog_debug(" PCE Neighbor Area: %pI4", &tmp); } else if (ntohs(top->type) == PCE_DOMAIN_TYPE_AS) { - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Neighbor SubTLV"); + json_object_string_add(json, "domainType", "AS"); + json_object_int_add(json, "neighborAS", + ntohl(top->value)); + } else if (vty != NULL) vty_out(vty, " PCE Neighbor AS: %d\n", ntohl(top->value)); else zlog_debug(" PCE Neighbor AS: %d", ntohl(top->value)); } else { - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Neighbor SubTLV"); + json_object_string_addf(json, "domainType", + "Unknown (%d)", + ntohl(top->type)); + } else if (vty != NULL) vty_out(vty, " Wrong PCE Neighbor type: %d\n", ntohl(top->type)); else @@ -1364,14 +1810,19 @@ static uint16_t show_vty_pce_subtlv_neighbor(struct vty *vty, } static uint16_t show_vty_pce_subtlv_cap_flag(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ri_pce_subtlv_cap_flag *top = (struct ri_pce_subtlv_cap_flag *)tlvh; check_tlv_size(RI_PCE_SUBTLV_CAP_FLAG_SIZE, "PCE Capabilities"); - if (vty != NULL) + if (json) { + tlvh_get_json_values(tlvh, json, "PCE Capabilities SubTLV"); + json_object_string_addf(json, "flag", "0x%x", + ntohl(top->value)); + } else if (vty != NULL) vty_out(vty, " PCE Capabilities Flag: 0x%x\n", ntohl(top->value)); else @@ -1382,21 +1833,25 @@ static uint16_t show_vty_pce_subtlv_cap_flag(struct vty *vty, } static uint16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh, - size_t buf_size) + size_t buf_size, json_object *json) { if (TLV_SIZE(tlvh) > buf_size) { if (vty != NULL) vty_out(vty, - " TLV size %d exceeds buffer size. Abort!", - TLV_SIZE(tlvh)); + " TLV type %d, size %d exceeds buffer size %d. Abort!\n", + ntohs(tlvh->length), TLV_SIZE(tlvh), + (int)buf_size); else zlog_debug( - " TLV size %d exceeds buffer size. Abort!", - TLV_SIZE(tlvh)); + " TLV type %d, size %d exceeds buffer size %d. Abort!", + ntohs(tlvh->length), TLV_SIZE(tlvh), + (int)buf_size); return buf_size; } - if (vty != NULL) + if (json) + tlvh_get_json_values(tlvh, json, "Unknown"); + else if (vty != NULL) vty_out(vty, " Unknown TLV: [type(0x%x), length(0x%x)]\n", ntohs(tlvh->type), ntohs(tlvh->length)); else @@ -1407,11 +1862,13 @@ static uint16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh, } static uint16_t show_vty_pce_info(struct vty *vty, struct tlv_header *ri, - size_t buf_size) + size_t buf_size, json_object *json) { struct tlv_header *tlvh; uint16_t length = ntohs(ri->length); uint16_t sum = 0; + json_object *stlvs_json = NULL; + json_object *stlv_json = NULL; /* Verify that TLV length is valid against remaining buffer size */ if (length > buf_size) { @@ -1421,25 +1878,41 @@ static uint16_t show_vty_pce_info(struct vty *vty, struct tlv_header *ri, return buf_size; } + if (json) { + tlvh_get_json_values(ri, json, "PCE Information TLV"); + stlvs_json = json_object_new_array(); + json_object_object_add(json, "subTLVs", stlvs_json); + } + for (tlvh = ri; sum < length; tlvh = TLV_HDR_NEXT(tlvh)) { + if (stlvs_json) { + stlv_json = json_object_new_object(); + json_object_array_add(stlvs_json, stlv_json); + } + switch (ntohs(tlvh->type)) { case RI_PCE_SUBTLV_ADDRESS: - sum += show_vty_pce_subtlv_address(vty, tlvh); + sum += show_vty_pce_subtlv_address(vty, tlvh, + stlv_json); break; case RI_PCE_SUBTLV_PATH_SCOPE: - sum += show_vty_pce_subtlv_path_scope(vty, tlvh); + sum += show_vty_pce_subtlv_path_scope(vty, tlvh, + stlv_json); break; case RI_PCE_SUBTLV_DOMAIN: - sum += show_vty_pce_subtlv_domain(vty, tlvh); + sum += show_vty_pce_subtlv_domain(vty, tlvh, stlv_json); break; case RI_PCE_SUBTLV_NEIGHBOR: - sum += show_vty_pce_subtlv_neighbor(vty, tlvh); + sum += show_vty_pce_subtlv_neighbor(vty, tlvh, + stlv_json); break; case RI_PCE_SUBTLV_CAP_FLAG: - sum += show_vty_pce_subtlv_cap_flag(vty, tlvh); + sum += show_vty_pce_subtlv_cap_flag(vty, tlvh, + stlv_json); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length - sum); + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + stlv_json); break; } } @@ -1447,15 +1920,27 @@ static uint16_t show_vty_pce_info(struct vty *vty, struct tlv_header *ri, } /* Display Segment Routing Algorithm TLV information */ -static uint16_t show_vty_sr_algorithm(struct vty *vty, struct tlv_header *tlvh) +static uint16_t show_vty_sr_algorithm(struct vty *vty, struct tlv_header *tlvh, + json_object *json) { struct ri_sr_tlv_sr_algorithm *algo = (struct ri_sr_tlv_sr_algorithm *)tlvh; int i; + json_object *algos_json; + json_object *algo_json; check_tlv_size(ALGORITHM_COUNT, "Segment Routing Algorithm"); - if (vty != NULL) { + if (json) { + tlvh_get_json_values(tlvh, json, "SR Algorithm TLV"); + algos_json = json_object_new_array(); + json_object_object_add(json, "algorithms", algos_json); + for (i = 0; i < ntohs(algo->header.length); i++) { + algo_json = + json_object_new_int((int64_t)algo->value[i]); + json_object_array_add(algos_json, algo_json); + } + } else if (vty != NULL) { vty_out(vty, " Segment Routing Algorithm TLV:\n"); for (i = 0; i < ntohs(algo->header.length); i++) { switch (algo->value[i]) { @@ -1494,14 +1979,25 @@ static uint16_t show_vty_sr_algorithm(struct vty *vty, struct tlv_header *tlvh) } /* Display Segment Routing SID/Label Range TLV information */ -static uint16_t show_vty_sr_range(struct vty *vty, struct tlv_header *tlvh) +static uint16_t show_vty_sr_range(struct vty *vty, struct tlv_header *tlvh, + json_object *json) { struct ri_sr_tlv_sid_label_range *range = (struct ri_sr_tlv_sid_label_range *)tlvh; check_tlv_size(RI_SR_TLV_LABEL_RANGE_SIZE, "SR Label Range"); - if (vty != NULL) { + if (json) { + tlvh_get_json_values(tlvh, json, + ntohs(range->header.type) == + RI_SR_TLV_SRGB_LABEL_RANGE + ? "SR Global Label Range TLV" + : "SR Local Label Range TLV"); + json_object_int_add(json, "rangeSize", + GET_RANGE_SIZE(ntohl(range->size))); + json_object_int_add(json, "rangeStartLabel", + GET_LABEL(ntohl(range->lower.value))); + } else if (vty != NULL) { vty_out(vty, " Segment Routing %s Range TLV:\n" " Range Size = %d\n" @@ -1525,13 +2021,19 @@ static uint16_t show_vty_sr_range(struct vty *vty, struct tlv_header *tlvh) } /* Display Segment Routing Maximum Stack Depth TLV information */ -static uint16_t show_vty_sr_msd(struct vty *vty, struct tlv_header *tlvh) +static uint16_t show_vty_sr_msd(struct vty *vty, struct tlv_header *tlvh, + json_object *json) { struct ri_sr_tlv_node_msd *msd = (struct ri_sr_tlv_node_msd *)tlvh; check_tlv_size(RI_SR_TLV_NODE_MSD_SIZE, "Node Maximum Stack Depth"); - if (vty != NULL) { + if (json) { + tlvh_get_json_values(tlvh, json, + "Node Maxomum Stack Depth TLV"); + json_object_int_add(json, "maximumStackDepth", + (int64_t)msd->value); + } else if (vty != NULL) { vty_out(vty, " Segment Routing MSD TLV:\n" " Node Maximum Stack Depth = %d\n", @@ -1545,6 +2047,317 @@ static uint16_t show_vty_sr_msd(struct vty *vty, struct tlv_header *tlvh) return TLV_SIZE(tlvh); } +static void show_vty_admin_groups(struct vty *vty, + struct admin_group *grp, + json_object *admngrps_json, + bool map_affinity) +{ + uint16_t indx = 0; + json_object *admngrp_json = NULL; + uint32_t admn_grp; + char *name = NULL; + + FOREACH_FLEX_ALGO_ADMIN_GROUP (grp, admn_grp) { + if (map_affinity) + name = affinity_map_name_get(admn_grp); + if (admngrps_json) { + if (!map_affinity) { + admngrp_json = json_object_new_int(admn_grp); + + } else if(name) { + admngrp_json = json_object_new_string(name); + } else { + admngrp_json = json_object_new_stringf( + "unknown(%u)", + admn_grp); + } + json_object_array_add(admngrps_json, admngrp_json); + } else if (vty != NULL) { + if (!(indx % 16)) + vty_out(vty, " [ "); + else + vty_out(vty, ", "); + + if (!map_affinity) { + vty_out(vty, "%u", admn_grp); + } else if (name) + vty_out(vty, "%s", name); + else + vty_out(vty, "unknown(%u)", admn_grp); + + if ((indx % 16) == 15) + vty_out(vty, " ]\n"); + } + indx ++; + } + + if (!admngrps_json && vty && (indx % 16)) + vty_out(vty, " ]\n"); +} + +static uint16_t show_vty_fad_exc_admngrp(struct vty *vty, + struct tlv_header *tlvh, + json_object *json) +{ + struct ri_fad_exclude_admingrp_subtlv *top = + (struct ri_fad_exclude_admingrp_subtlv *)tlvh; + json_object *admngrps_json = NULL; + struct admin_group grp = { 0 }; + + check_tlv_min_size(RI_FAD_EXC_ADMINGRP_SUBTLV_MIN_LEN, + "FAD Exclude Admin Groups"); + check_tlv_size_multiple_of(sizeof(uint32_t), + "FAD Exclude Admin Groups"); + + flex_algo_decode_admin_group(&grp, (uint8_t *)top->admin_groups, + ntohs(tlvh->length)); + if (json) { + tlvh_get_json_values(tlvh, json, "Exclude Admin Groups SubTLV"); + admngrps_json = json_object_new_array(); + json_object_object_add(json, "adminGroups", admngrps_json); + } else if (vty != NULL) { + vty_out(vty, " FAD Exclude Admin Groups: \n"); + } + + show_vty_admin_groups(vty, &grp, admngrps_json, true); + + return TLV_SIZE(tlvh); +} + +static uint16_t show_vty_fad_incany_admngrp(struct vty *vty, + struct tlv_header *tlvh, + json_object *json) +{ + struct ri_fad_include_any_admingrp_subtlv *top = + (struct ri_fad_include_any_admingrp_subtlv *)tlvh; + json_object *admngrps_json = NULL; + struct admin_group grp = { 0 }; + + check_tlv_min_size(RI_FAD_INCANY_ADMINGRP_SUBTLV_MIN_LEN, + "FAD Include Any Admin Groups"); + check_tlv_size_multiple_of(sizeof(uint32_t), + "FAD Include Any Admin Groups"); + + flex_algo_decode_admin_group(&grp, (uint8_t *)top->admin_groups, + ntohs(tlvh->length)); + if (json) { + tlvh_get_json_values(tlvh, json, "Include-Any Admin Groups SubTLV"); + admngrps_json = json_object_new_array(); + json_object_object_add(json, "adminGroups", admngrps_json); + } else if (vty != NULL) { + vty_out(vty, " FAD Include-Any Admin Groups: \n"); + } + + show_vty_admin_groups(vty, &grp, admngrps_json, true); + + return TLV_SIZE(tlvh); +} + +static uint16_t show_vty_fad_incall_admngrp(struct vty *vty, + struct tlv_header *tlvh, + json_object *json) +{ + struct ri_fad_include_all_admingrp_subtlv *top = + (struct ri_fad_include_all_admingrp_subtlv *)tlvh; + json_object *admngrps_json = NULL; + struct admin_group grp = { 0 }; + + check_tlv_min_size(RI_FAD_INCALL_ADMINGRP_SUBTLV_MIN_LEN, + "FAD Include All Admin Groups"); + check_tlv_size_multiple_of(sizeof(uint32_t), + "FAD Include All Admin Groups"); + + flex_algo_decode_admin_group(&grp, (uint8_t *)top->admin_groups, + ntohs(tlvh->length)); + if (json) { + tlvh_get_json_values(tlvh, json, "Include-All Admin Groups SubTLV"); + admngrps_json = json_object_new_array(); + json_object_object_add(json, "adminGroups", admngrps_json); + } else if (vty != NULL) { + vty_out(vty, " FAD Include-All Admin Groups: \n"); + } + + show_vty_admin_groups(vty, &grp, admngrps_json, true); + + return TLV_SIZE(tlvh); +} + +static uint16_t show_vty_fad_exc_srlg(struct vty *vty, struct tlv_header *tlvh, + json_object *json) +{ + struct ri_fad_exclude_srlg_subtlv *top = + (struct ri_fad_exclude_srlg_subtlv *)tlvh; + json_object *srlgs_json = NULL; + struct admin_group grp = { 0 }; + + check_tlv_min_size(RI_FAD_EXC_SRLG_SUBTLV_MIN_LEN, "FAD Exclude SRLGs"); + check_tlv_size_multiple_of(sizeof(uint32_t), "FAD Exclude SRLGs"); + + flex_algo_decode_admin_group(&grp, (uint8_t *)top->srlgs, + ntohs(tlvh->length)); + if (json) { + tlvh_get_json_values(tlvh, json, "Exclude SRLGs SubTLV"); + srlgs_json = json_object_new_array(); + json_object_object_add(json, "srlgs", srlgs_json); + } else if (vty != NULL) { + vty_out(vty, " FAD Exclude SRLGs: \n"); + } + + show_vty_admin_groups(vty, &grp, srlgs_json, false); + + return TLV_SIZE(tlvh); +} + +static uint16_t show_vty_fad_flags(struct vty *vty, struct tlv_header *tlvh, + json_object *json) +{ + struct ri_fad_flags_subtlv *top = (struct ri_fad_flags_subtlv *)tlvh; + uint16_t num_flags = ntohs(tlvh->length) / sizeof(top->flags[0]); + uint16_t indx; + json_object *flags_json = NULL; + json_object *flag_json = NULL; + + check_tlv_min_size(RI_FAD_FLAGS_SUBTLV_MIN_LEN, "FAD Flags"); + check_tlv_size_multiple_of(sizeof(uint8_t), "FAD Flags"); + + if (json) { + tlvh_get_json_values(tlvh, json, "Flexible-Algo Flags SubTLV"); + flags_json = json_object_new_array(); + json_object_object_add(json, "flags", flags_json); + for (indx = 0; indx < num_flags; indx++) { + flag_json = json_object_new_int64( + (int64_t)ntohl(top->flags[indx])); + json_object_array_add(flags_json, flag_json); + } + } else if (vty != NULL) { + vty_out(vty, " FAD Flags: \n"); + for (indx = 0; indx < num_flags; indx++) { + if (!(indx % 16)) + vty_out(vty, " [ 0x%02x", + ntohl(top->flags[indx])); + else if (!(indx % 15)) + vty_out(vty, ", 0x%02x ]\n", + ntohl(top->flags[indx])); + else + vty_out(vty, ", 0x%02x", + ntohl(top->flags[indx])); + } + if ((indx % 15)) + vty_out(vty, " ]\n"); + } else { + char list_str[1024] = {0}; + char disp_str[32]; + + zlog_debug(" FAD Flags:"); + for (indx = 0; indx < num_flags; indx++) { + snprintf(disp_str, sizeof(disp_str), "0x%02x ", + ntohl(top->flags[indx])); + strlcat(list_str, disp_str, sizeof(list_str)); + if (!(indx % 15)) { + zlog_debug(" %s", list_str); + list_str[0] = '\0'; + } + } + zlog_debug(" %s", list_str); + } + + return TLV_SIZE(tlvh); +} + +static uint16_t show_vty_fad_info(struct vty *vty, struct tlv_header *ri, + size_t buf_size, json_object *json) +{ + struct tlv_header *tlvh = ri; + uint16_t length = ntohs(tlvh->length); + uint16_t sum = 0; + struct ri_fad_tlv *fad_tlv = (struct ri_fad_tlv *)tlvh; + uint8_t *tlv_start = (uint8_t *)ri; + json_object *stlvs_json = NULL; + json_object *stlv_json = NULL; + + /* Verify that TLV length is valid against remaining buffer size */ + if (length > buf_size) { + vty_out(vty, " FAD TLV size %d exceeds buffer size. Abort!\n", + length); + return buf_size; + } + + check_tlv_min_size(RI_FAD_TLV_MIN_LEN, "Flexible Algorithm Definition"); + + if (json) { + tlvh_get_json_values(tlvh, json, + "Flexible Algorithm Defintion TLV"); + json_object_int_add(json, "algorithmId", + (int64_t)fad_tlv->algorithm_id); + json_object_int_add(json, "priority", + (int64_t)fad_tlv->priority); + json_object_string_add( + json, "metricType", + flex_algo_metric_type2str(fad_tlv->metric_type)); + json_object_string_add( + json, "caculationType", + flex_algo_calc_type2str(fad_tlv->calc_type)); + stlvs_json = json_object_new_array(); + json_object_object_add(json, "subTLVs", stlvs_json); + } else if (vty != NULL) { + vty_out(vty, + " Flexible Algorithm Defintion TLV: Length: %u\n" + " Algorithm-Identifier = %d\n" + " Priority = %d\n" + " Metric-Type = %s\n" + " Calculation-Type = %s\n", + ntohs(fad_tlv->header.length), fad_tlv->algorithm_id, + fad_tlv->priority, + flex_algo_metric_type2str(fad_tlv->metric_type), + flex_algo_calc_type2str(fad_tlv->calc_type)); + } else { + zlog_debug( + " Flexible Algorithm Defintion TLV: Algorithm-Identifier = %d", + fad_tlv->algorithm_id); + zlog_debug( + " Priority = %d, Metric-Type = %s, Calculation-Type = %s", + fad_tlv->priority, + flex_algo_metric_type2str(fad_tlv->metric_type), + flex_algo_calc_type2str(fad_tlv->calc_type)); + } + + tlv_start += RI_FAD_TLV_MIN_LEN + TLV_HDR_SIZE; + sum += RI_FAD_TLV_MIN_LEN; + for (tlvh = (struct tlv_header *)tlv_start; sum < length; + tlvh = TLV_HDR_NEXT(tlvh)) { + if (stlvs_json) { + stlv_json = json_object_new_object(); + json_object_array_add(stlvs_json, stlv_json); + } + + switch (ntohs(tlvh->type)) { + case RI_FAD_EXC_ADMINGRP_SUBTLV: + sum += show_vty_fad_exc_admngrp(vty, tlvh, stlv_json); + break; + case RI_FAD_INCANY_ADMINGRP_SUBTLV: + sum += show_vty_fad_incany_admngrp(vty, tlvh, + stlv_json); + break; + case RI_FAD_INCALL_ADMINGRP_SUBTLV: + sum += show_vty_fad_incall_admngrp(vty, tlvh, + stlv_json); + break; + case RI_FAD_FLAGS_SUBTLV: + sum += show_vty_fad_flags(vty, tlvh, stlv_json); + break; + case RI_FAD_EXC_SRLG_SUBTLV: + sum += show_vty_fad_exc_srlg(vty, tlvh, stlv_json); + break; + default: + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + stlv_json); + break; + } + } + + return TLV_SIZE(&fad_tlv->header); +} + static void ospf_router_info_show_info(struct vty *vty, struct json_object *json, struct ospf_lsa *lsa) @@ -1552,37 +2365,52 @@ static void ospf_router_info_show_info(struct vty *vty, struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh; uint16_t length = 0, sum = 0; + json_object *tlvs_json = NULL; + json_object *tlv_json = NULL; - if (json) - return; + if (json) { + tlvs_json = json_object_new_array(); + json_object_object_add(json, "tlvs", tlvs_json); + } /* Initialize TLV browsing */ length = lsa->size - OSPF_LSA_HEADER_SIZE; for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh; tlvh = TLV_HDR_NEXT(tlvh)) { + if (tlvs_json) { + tlv_json = json_object_new_object(); + json_object_array_add(tlvs_json, tlv_json); + } + switch (ntohs(tlvh->type)) { case RI_TLV_CAPABILITIES: - sum += show_vty_router_cap(vty, tlvh); + sum += show_vty_router_cap(vty, tlvh, tlv_json); break; case RI_TLV_PCE: tlvh++; sum += TLV_HDR_SIZE; - sum += show_vty_pce_info(vty, tlvh, length - sum); + sum += show_vty_pce_info(vty, tlvh, length - sum, + tlv_json); break; case RI_SR_TLV_SR_ALGORITHM: - sum += show_vty_sr_algorithm(vty, tlvh); + sum += show_vty_sr_algorithm(vty, tlvh, tlv_json); break; case RI_SR_TLV_SRGB_LABEL_RANGE: case RI_SR_TLV_SRLB_LABEL_RANGE: - sum += show_vty_sr_range(vty, tlvh); + sum += show_vty_sr_range(vty, tlvh, tlv_json); break; case RI_SR_TLV_NODE_MSD: - sum += show_vty_sr_msd(vty, tlvh); + sum += show_vty_sr_msd(vty, tlvh, tlv_json); + break; + case RI_FAD_TLV: + sum += show_vty_fad_info(vty, tlvh, length - sum, + tlv_json); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length); + sum += show_vty_unknown_tlv(vty, tlvh, length, + tlv_json); break; } } @@ -2282,31 +3110,39 @@ static int ospf_flex_algo_admin_group_update( const char *name, bool update_lsa) { struct affinity_map *map = NULL; - int found_ag; + int found_ag = 0; + uint32_t bitpos; if (!delete && !name) return CMD_ERR_INCOMPLETE; - map = affinity_map_get(name); + if (name) + map = affinity_map_get(name); if (name && !map) { zlog_err("Couldn't find any affinity by name '%s'", name); return CMD_WARNING_CONFIG_FAILED; } - found_ag = admin_group_get(admin_group, map->bit_position); + if (map) + found_ag = admin_group_get(admin_group, map->bit_position); if (!delete) { - if (!found_ag) { + if (map && !found_ag) { admin_group_set(admin_group, map->bit_position); /* Refresh RI LSA if already engaged */ update_lsa = true; } } else { - if (!found_ag) + if (!found_ag && name) return CMD_ERR_NO_MATCH; - admin_group_unset(admin_group, - map->bit_position); + if (!name) + FOREACH_FLEX_ALGO_ADMIN_GROUP(admin_group, bitpos) + admin_group_unset(admin_group, bitpos); + else if(map) + admin_group_unset(admin_group, + map->bit_position); + /* Refresh RI LSA if already engaged */ update_lsa = true; } @@ -2408,97 +3244,56 @@ DEFPY(flex_algo_incany_admngrp, flex_algo_incany_admngrp_cmd, &fad->admin_group_include_any, name, update_lsa); } -#if 0 DEFPY(flex_algo_exc_srlg, flex_algo_exc_srlg_cmd, - "flexible-algorithm (128-255)$id exclude-srlg (0-4294967295)$srlgval", + "[no$no] flexible-algorithm (128-255)$id exclude-srlg [(0-4294967295)$srlgval]", + NO_STR "Specify a Flexible Algorithm Definition\n" "Unique number assigned to the new Flexible Algorithm\n" - "Add a SRLG to the Exclude list\n" - "SRLG to be included\n") + "Add or remove a SRLG to or from the Exclude list\n" + "SRLG to be added or removed\n") { - uint32_t srlg; struct flex_algo *fad; - struct flex_algo_srlg *fsrlg; + int found_srlg; + uint32_t bitpos; + bool update_lsa = false; - bool new_fad = false; - bool new_srlg = false; if (!ospf_ri_enabled(vty)) return CMD_WARNING_CONFIG_FAILED; - srlg = (uint32_t)srlgval; - fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); - assert(fad); - if (new_fad) { + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); OspfRI.fad_info.num_fads++; - new_fad = true; + /* Refresh RI LSA if already engaged */ update_lsa = true; } - fsrlg = flex_algo_lookup_srlg(&fad->srlgs_exclude, srlg, true, - &new_srlg); - assert(fsrlg); - if (new_srlg) - update_lsa = true; - - /* Refresh/Re-originate RI LSA if already engaged */ - if (update_lsa) - ospf_router_info_schedule(REFRESH_THIS_LSA); - - return CMD_SUCCESS; -} - -DEFPY(no_flex_algo_exc_srlg, no_flex_algo_exc_srlg_cmd, - "no flexible-algorithm (128-255)$id exclude-srlg (0-4294967295)$srlgval", - NO_STR - "Specify a Flexible Algorithm Definition\n" - "Unique number assigned to the new Flexible Algorithm\n" - "Remove a specfic or all SRLG(s) from the Exclude list\n" - "SRLG to be removed\n") -{ - uint32_t srlg; - struct flex_algo *fad; - bool update_lsa = false; - - if (!ospf_ri_enabled(vty)) - return CMD_WARNING_CONFIG_FAILED; - - srlg = (uint32_t)srlgval; - - fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); - if (!fad) + if (no && !fad) return CMD_ERR_NO_MATCH; - flex_algo_delete_srlg(&fad->srlgs_exclude, srlg, &update_lsa); - - /* Refresh/Re-originate RI LSA if already engaged */ - if (update_lsa) - ospf_router_info_schedule(REFRESH_THIS_LSA); - - return CMD_SUCCESS; -} - -DEFPY(no_flex_algo_exc_srlg_all, no_flex_algo_exc_srlg_all_cmd, - "no flexible-algorithm (128-255)$id exclude-srlg", - NO_STR - "Specify a Flexible Algorithm Definition\n" - "Unique number assigned to the new Flexible Algorithm\n" - "Remove a specfic or all SRLG(s) from the Exclude list\n") -{ - struct flex_algo *fad; - bool update_lsa = false; - - if (!ospf_ri_enabled(vty)) - return CMD_WARNING_CONFIG_FAILED; - - fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); - if (!fad) - return CMD_ERR_NO_MATCH; + bitpos = (uint32_t) srlgval; + found_srlg = admin_group_get(&fad->srlgs_exclude, bitpos); + if (!no) { + if (!found_srlg) { + admin_group_set(&fad->srlgs_exclude, bitpos); + /* Refresh RI LSA if already engaged */ + update_lsa = true; + } + } else { + if (argc < 5) + FOREACH_FLEX_ALGO_SRLG(&fad->srlgs_exclude, bitpos) + admin_group_unset(&fad->srlgs_exclude, bitpos); + else { + if (!found_srlg) + return CMD_ERR_NO_MATCH; + + admin_group_unset(&fad->srlgs_exclude, bitpos); + } - if (flxalg_srlgs_count(&fad->srlgs_exclude)) { + /* Refresh RI LSA if already engaged */ update_lsa = true; - flex_algo_flush_srlgs(&fad->srlgs_exclude); } /* Refresh/Re-originate RI LSA if already engaged */ @@ -2507,44 +3302,54 @@ DEFPY(no_flex_algo_exc_srlg_all, no_flex_algo_exc_srlg_all_cmd, return CMD_SUCCESS; } -#endif DEFPY(flex_algo_prfx_metric, flex_algo_prfx_metric_cmd, - "flexible-algorithm (128-255)$id prefix-advertise-metric (0-4294967295)$prefmetric", + "[no$no] flexible-algorithm (128-255)$id advertise-prefix-metric [(0-4294967295)$prefmetric]", + NO_STR "Specify a Flexible Algorithm Definition\n" "Unique number assigned to the new Flexible Algorithm\n" - "Specify a default prefix advertise metric\n" - "Default prefix metric to be advertised\n") + "Advertise prefix metric TLV\n" + "Specify the metric to override all individual prefix metric with\n") { uint32_t metric; struct flex_algo *fad; bool update_lsa = false; - bool new_fad = false; if (!ospf_ri_enabled(vty)) return CMD_WARNING_CONFIG_FAILED; - metric = (uint32_t)prefmetric; - fad = flex_algo_lookup(OspfRI.fad_info.fads, (uint8_t)id); - assert(fad); - if (new_fad) { + if (!no && !fad) { + fad = flex_algo_alloc(OspfRI.fad_info.fads, (uint8_t)id, NULL); + assert(fad); OspfRI.fad_info.num_fads++; - new_fad = true; + /* Refresh RI LSA if already engaged */ update_lsa = true; } - if (!!FLEX_ALGO_PREFIX_METRIC_SET(fad) || - fad->prefix_adv_metric != metric) { - flex_algo_set_prefix_metric(fad, metric); - update_lsa = true; + if (no && !fad) + return CMD_ERR_NO_MATCH; + + if (!no) { + metric = prefmetric ? (uint32_t)prefmetric + : fad->prefix_adv_metric; + + if (!FLEX_ALGO_PREFIX_METRIC_SET(fad) || + fad->prefix_adv_metric != metric) { + flex_algo_set_prefix_metric(fad, metric); + update_lsa = true; + } + } else if (FLEX_ALGO_PREFIX_METRIC_SET(fad)) { + flex_algo_reset_prefix_metric(fad); + update_lsa = true; } - /* - * TODO: Refresh/Re-originate all EXT Prefix LSAs if already engaged. - if (update_lsa) - ospf_ext_update_all_prefix_fapms(); + /* + * Refresh/Re-originate the Router-Info LSA along with + * all the EXT Prefix LSAs if already engaged. */ + if (update_lsa) + ospf_router_info_schedule(REFRESH_THIS_LSA); return CMD_SUCCESS; } @@ -2556,7 +3361,7 @@ DEFUN(show_ip_ospf_router_info, show_ip_ospf_router_info_cmd, if (OspfRI.enabled) { vty_out(vty, "--- Router Information parameters ---\n"); - show_vty_router_cap(vty, &OspfRI.router_cap.header); + show_vty_router_cap(vty, &OspfRI.router_cap.header, NULL); } else { if (vty != NULL) vty_out(vty, @@ -2581,28 +3386,28 @@ DEFUN(show_ip_opsf_router_info_pce, show_ip_ospf_router_info_pce_cmd, vty_out(vty, "--- PCE parameters ---\n"); if (pce->pce_address.header.type != 0) - show_vty_pce_subtlv_address(vty, - &pce->pce_address.header); + show_vty_pce_subtlv_address( + vty, &pce->pce_address.header, NULL); if (pce->pce_scope.header.type != 0) - show_vty_pce_subtlv_path_scope(vty, - &pce->pce_scope.header); + show_vty_pce_subtlv_path_scope( + vty, &pce->pce_scope.header, NULL); for (ALL_LIST_ELEMENTS_RO(pce->pce_domain, node, domain)) { if (domain->header.type != 0) - show_vty_pce_subtlv_domain(vty, - &domain->header); + show_vty_pce_subtlv_domain(vty, &domain->header, + NULL); } for (ALL_LIST_ELEMENTS_RO(pce->pce_neighbor, node, neighbor)) { if (neighbor->header.type != 0) - show_vty_pce_subtlv_neighbor(vty, - &neighbor->header); + show_vty_pce_subtlv_neighbor( + vty, &neighbor->header, NULL); } if (pce->pce_cap_flag.header.type != 0) - show_vty_pce_subtlv_cap_flag(vty, - &pce->pce_cap_flag.header); + show_vty_pce_subtlv_cap_flag( + vty, &pce->pce_cap_flag.header, NULL); } else { vty_out(vty, " PCE info is disabled on this router\n"); @@ -2614,7 +3419,8 @@ DEFUN(show_ip_opsf_router_info_pce, show_ip_ospf_router_info_pce_cmd, static void show_vty_flxalg_info(struct vty *vty, struct flex_algo *fad) { uint32_t admin_grp; - // uint32_t srlg; + uint32_t srlg; + const char *name; vty_out(vty, " Flexible-Algorithm: %u\n", fad->algorithm); vty_out(vty, " Metric-Type: \t%s\n", @@ -2633,7 +3439,9 @@ static void show_vty_flxalg_info(struct vty *vty, struct flex_algo *fad) vty_out(vty, " Exclude-Admin-Groups: \n"); FOREACH_FLEX_ALGO_ADMIN_GROUP(&fad->admin_group_exclude_any, admin_grp) { - vty_out(vty, " \t - %u\n", admin_grp); + name = affinity_map_name_get(admin_grp); + vty_out(vty, " \t - %s(%u)\n", name ? name : "Unknown", + admin_grp); } } @@ -2641,7 +3449,9 @@ static void show_vty_flxalg_info(struct vty *vty, struct flex_algo *fad) vty_out(vty, " Include-Any-Admin-Groups: \n"); FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_any, admin_grp) { - vty_out(vty, " \t - %u\n", admin_grp); + name = affinity_map_name_get(admin_grp); + vty_out(vty, " \t - %s(%u)\n", name ? name : "Unknown", + admin_grp); } } @@ -2649,16 +3459,18 @@ static void show_vty_flxalg_info(struct vty *vty, struct flex_algo *fad) vty_out(vty, " Include-All-Admin-Groups: \n"); FOREACH_FLEX_ALGO_ADMIN_GROUP (&fad->admin_group_include_all, admin_grp) { - vty_out(vty, " \t - %u\n", admin_grp); + name = affinity_map_name_get(admin_grp); + vty_out(vty, " \t - %s(%u)\n", name ? name : "Unknown", + admin_grp); } } - // if (flxalg_srlgs_count(&fad->srlgs_exclude)) { - // vty_out(vty, " Exclude-SRLGs: \n"); - // FOREACH_FLEX_ALGO_SRLG (&fad->srlgs_exclude, srlg) { - // vty_out(vty, " \t - %u\n", srlg); - // } - // } + if (admin_group_size(&fad->srlgs_exclude)) { + vty_out(vty, " Exclude-SRLGs: \n"); + FOREACH_FLEX_ALGO_SRLG (&fad->srlgs_exclude, srlg) { + vty_out(vty, " \t - %u\n", srlg); + } + } } DEFPY(show_ip_opsf_router_info_flxalg, show_ip_ospf_router_info_flxalg_cmd, @@ -2666,7 +3478,7 @@ DEFPY(show_ip_opsf_router_info_flxalg, show_ip_ospf_router_info_flxalg_cmd, SHOW_STR IP_STR OSPF_STR "Router Information\n" "Flexible-Algorithm information\n" - "Unique identifier for the flexible algorithm\n") + "Unique identifier assigned to the Flexible-Algorithm\n") { struct flex_algo *fad; struct listnode *curr, *next; @@ -2724,9 +3536,7 @@ static void ospf_router_info_register_vty(void) install_element(OSPF_NODE, &flex_algo_exc_admngrp_cmd); install_element(OSPF_NODE, &flex_algo_incany_admngrp_cmd); install_element(OSPF_NODE, &flex_algo_incall_admngrp_cmd); - // install_element(OSPF_NODE, &flex_algo_exc_srlg_cmd); - // install_element(OSPF_NODE, &no_flex_algo_exc_srlg_cmd); - // install_element(OSPF_NODE, &no_flex_algo_exc_srlg_all_cmd); + install_element(OSPF_NODE, &flex_algo_exc_srlg_cmd); install_element(OSPF_NODE, &flex_algo_prfx_metric_cmd); return; diff --git a/ospfd/ospf_ri.h b/ospfd/ospf_ri.h index 5c521fdee2fc..f5f594dcca28 100644 --- a/ospfd/ospf_ri.h +++ b/ospfd/ospf_ri.h @@ -199,15 +199,89 @@ struct ospf_ri_sr_info { struct ri_sr_tlv_node_msd msd; }; +/* + * Flexible Algorithm Definition (FAD) TLV. + * Reference: draft-ietf-lsr-flex-algo section 5.2 + */ +#define RI_FAD_TLV 0x10 +struct ri_fad_tlv { + struct tlv_header header; /* Type = 16; Length = Variable. */ + uint8_t algorithm_id; /* Algorithm. 1 byte */ + uint8_t metric_type; /* Metric-Type. 1 Byte */ + uint8_t calc_type; /* Calculation Type */ + uint8_t priority; /* Priority */ + // struct list *sub_tlvs; /* Bunch of Sub-TLVs follows */ + struct tlv_list_head sub_tlvs; /* Bunch of Sub-TLVs follows */ +}; +#define RI_FAD_TLV_MIN_LEN 4 + +/* + * FAD Exclude AdminGroup Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 7.1 + */ +#define RI_FAD_EXC_ADMINGRP_SUBTLV 0x1 +#define RI_FAD_EXC_ADMINGRP_SUBTLV_MIN_LEN 4 +struct ri_fad_exclude_admingrp_subtlv { + struct tlv_header header; /* Type = 1; Length = Variable. */ + uint32_t admin_groups[0]; /* Admin-Groups as defined in RFC7308 */ +}; + +/* + * FAD Include-Any AdminGroup Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 7.2 + */ +#define RI_FAD_INCANY_ADMINGRP_SUBTLV 0x2 +#define RI_FAD_INCANY_ADMINGRP_SUBTLV_MIN_LEN 4 +struct ri_fad_include_any_admingrp_subtlv { + struct tlv_header header; /* Type = 2; Length = Variable. */ + uint32_t admin_groups[0]; /* Admin-Groups as defined in RFC7308 */ +}; + +/* + * FAD Include-All AdminGroup Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 7.3 + */ +#define RI_FAD_INCALL_ADMINGRP_SUBTLV 0x3 +#define RI_FAD_INCALL_ADMINGRP_SUBTLV_MIN_LEN 4 +struct ri_fad_include_all_admingrp_subtlv { + struct tlv_header header; /* Type = 3; Length = Variable. */ + uint32_t admin_groups[0]; /* Admin-Groups as defined in RFC7308 */ +}; + +/* + * FAD Flags Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 7.4 + */ +#define RI_FAD_FLAGS_SUBTLV 0x4 +#define RI_FAD_FLAGS_SUBTLV_MIN_LEN 4 +struct ri_fad_flags_subtlv { + struct tlv_header header; /* Type = 4; Length = Variable. */ + uint32_t flags[0]; /* Flags. Variable length. */ +}; + +/* + * FAD Exclude SRLG Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 7.5 + */ +#define RI_FAD_EXC_SRLG_SUBTLV 0x5 +#define RI_FAD_EXC_SRLG_SUBTLV_MIN_LEN 4 +struct ri_fad_exclude_srlg_subtlv { + struct tlv_header header; /* Type = 5; Length = Variable. */ + uint32_t srlgs[0]; /* SRLGs as defined in RFC4203 */ +}; + /* * Store Flexibe Algorithm Definition information - */ -#define MAX_NUM_FLEX_ALGO_DEFN 16 + */ +#define MAX_NUM_FLEX_ALGO_DEFN 16 struct ospf_ri_fad_info { - uint8_t num_fads; + uint8_t num_fads; /* Algorithms supported by the node */ struct flex_algos *fads; + + /* List of corresponding FAD TLVs */ + struct tlv_list_head ri_fad_tlvs; }; /* Store area information to flood LSA per area */ @@ -248,7 +322,7 @@ struct ospf_router_info { * Global variable to manage Opaque-LSA/Router Information on this node. * Note that all parameter values are stored in network byte order. */ - extern struct ospf_router_info OspfRI; +extern struct ospf_router_info OspfRI; /* Prototypes. */ extern int ospf_router_info_init(void); diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index 467cb0504d95..5c6bb1c5e002 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -125,7 +125,7 @@ static struct sr_node *sr_node_new(struct in_addr *rid) new = XCALLOC(MTYPE_OSPF_SR_PARAMS, sizeof(struct sr_node)); /* Default Algorithm, SRGB and MSD */ - for (int i = 0; i < ALGORITHM_COUNT; i++) + for (int i = 0; i < SR_ALGORITHM_COUNT; i++) new->algo[i] = SR_ALGORITHM_UNSET; new->srgb.range_size = 0; @@ -603,7 +603,7 @@ int ospf_sr_init(void) /* Initialize Algorithms, SRGB, SRLB and MSD TLVs */ /* Only Algorithm SPF is supported */ OspfSR.algo[0] = SR_ALGORITHM_SPF; - for (int i = 1; i < ALGORITHM_COUNT; i++) + for (int i = 1; i < SR_ALGORITHM_COUNT; i++) OspfSR.algo[i] = SR_ALGORITHM_UNSET; OspfSR.srgb.size = DEFAULT_SRGB_SIZE; @@ -1460,7 +1460,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa) int i; for (i = 0; i < ntohs(algo->header.length); i++) srn->algo[i] = algo->value[0]; - for (; i < ALGORITHM_COUNT; i++) + for (; i < SR_ALGORITHM_COUNT; i++) srn->algo[i] = SR_ALGORITHM_UNSET; } else { srn->algo[0] = SR_ALGORITHM_SPF; @@ -2735,13 +2735,13 @@ static void show_sr_node(struct vty *vty, struct json_object *json, srn->srlb.lower_bound); json_algo = json_object_new_array(); json_object_object_add(json_node, "algorithms", json_algo); - for (int i = 0; i < ALGORITHM_COUNT; i++) { + for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { if (srn->algo[i] == SR_ALGORITHM_UNSET) continue; json_obj = json_object_new_object(); - char tmp[2]; + char tmp[16]; - snprintf(tmp, sizeof(tmp), "%u", i); + snprintf(tmp, sizeof(tmp)-1, "%u", i); json_object_string_add(json_obj, tmp, srn->algo[i] == SR_ALGORITHM_SPF ? "SPF" @@ -2760,7 +2760,7 @@ static void show_sr_node(struct vty *vty, struct json_object *json, srn->srlb.lower_bound, upper); sbuf_push(&sbuf, 0, "\tAlgo.(s): %s", srn->algo[0] == SR_ALGORITHM_SPF ? "SPF" : "S-SPF"); - for (int i = 1; i < ALGORITHM_COUNT; i++) { + for (int i = 1; i < SR_ALGORITHM_COUNT; i++) { if (srn->algo[i] == SR_ALGORITHM_UNSET) continue; sbuf_push(&sbuf, 0, "/%s", diff --git a/ospfd/ospf_sr.h b/ospfd/ospf_sr.h index 9606bdcdcdd5..c0aba6a3837b 100644 --- a/ospfd/ospf_sr.h +++ b/ospfd/ospf_sr.h @@ -228,7 +228,7 @@ struct ospf_sr_db { /* Local SR info announced in Router Info LSA */ /* Algorithms supported by the node */ - uint8_t algo[ALGORITHM_COUNT]; + uint8_t algo[SR_ALGORITHM_COUNT]; /* * Segment Routing Global Block i.e. label range * Only one range supported in this code @@ -251,7 +251,7 @@ struct sr_node { /* 24-bit Opaque-ID field value according to RFC 7684 specification */ uint32_t instance; - uint8_t algo[ALGORITHM_COUNT]; /* Algorithms supported by the node */ + uint8_t algo[SR_ALGORITHM_COUNT]; /* Algorithms supported by the node */ struct sr_block srgb; /* Segment Routing Global Block */ struct sr_block srlb; /* Segment Routing Local Block */ uint8_t msd; /* Maximum SID Depth */ From 8fc6f5034c536cd2b8009cdde294a9c9fa1ae743 Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Thu, 10 Nov 2022 21:14:23 -0800 Subject: [PATCH 4/6] ospfd: Generate and parse EXT-PREFIX-LSA FAPM subTLVs and new EXT-IA-ASBR LSA along with EXT-IA-ASBR TLV and FAAM SubTLVs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds code to generate required FAPM SubTLVs under Extended-Prefix LSAs and new Ext-Inter-Area ASBR LSA along with Extended-Inter-Area ASBR TLV and FAAM SubTLVs, based on local Flex-Algo configurations. It also includes support to parse these new LSA and new TLVs/SubTLVs received from remote routers on-the-wire. The parsed result can be displayed using ’show ip ospf database opaque-area’. Signed-off-by: Pushpasis Sarkar --- ospfd/ospf_ext.c | 1057 ++++++++++++++++++++++++++++++++++++++++--- ospfd/ospf_ext.h | 71 +++ ospfd/ospf_memory.c | 16 +- ospfd/ospf_memory.h | 3 + ospfd/ospf_opaque.c | 8 + ospfd/ospf_opaque.h | 12 +- ospfd/ospf_ri.c | 5 +- ospfd/ospfd.c | 12 + ospfd/ospfd.h | 5 + 9 files changed, 1123 insertions(+), 66 deletions(-) diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index d82c2146c794..7bfe26150279 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -30,6 +30,7 @@ #include "sockunion.h" /* for inet_aton() */ #include "network.h" #include "if.h" +#include "flex_algo.h" #include "libospf.h" /* for ospf interface types */ #include "ospfd/ospfd.h" @@ -49,6 +50,8 @@ #include "ospfd/ospf_zebra.h" #include "ospfd/ospf_sr.h" #include "ospfd/ospf_ext.h" +#include "ospfd/ospf_opaque.h" +#include "ospfd/ospf_ri.h" #include "ospfd/ospf_errors.h" /* Following structure are internal use only. */ @@ -89,6 +92,15 @@ static int ospf_ext_link_lsa_update(struct ospf_lsa *lsa); static int ospf_ext_pref_lsa_update(struct ospf_lsa *lsa); static void ospf_ext_link_delete_adj_sid(struct ext_itf *exti); static void del_ext_info(void *val); +/* Extended Inter-Area ASBR Opaque LSA related callback functions */ +static void ospf_ext_ia_asbr_show_info(struct vty *vty, + struct json_object *json, + struct ospf_lsa *lsa); +static int ospf_ext_ia_asbr_lsa_originate(void *arg); +static struct ospf_lsa *ospf_ext_ia_asbr_lsa_refresh(struct ospf_lsa *lsa); +static void ospf_ext_ia_asbr_lsa_schedule(struct ospf_area *area, + enum lsa_opcode opcode); +static int ospf_ext_ia_asbr_lsa_update(struct ospf_lsa *lsa); /* * Extended Link/Prefix initialization @@ -154,6 +166,30 @@ int ospf_ext_init(void) return rc; } + zlog_info("EXT (%s): Register Extended Inter-Area ASBR Opaque LSA", + __func__); + rc = ospf_register_opaque_functab( + OspfEXT.scope, OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA, + NULL, /* new if handle by link */ + NULL, /* del if handle by link */ + NULL, /* ism change */ + NULL, /* nsm change */ + NULL, /* Write router config. */ + NULL, /* Write interface conf. */ + NULL, /* Write debug config. */ + ospf_ext_ia_asbr_show_info, /* Show LSA info */ + ospf_ext_ia_asbr_lsa_originate, /* Originate LSA */ + ospf_ext_ia_asbr_lsa_refresh, /* Refresh LSA */ + ospf_ext_ia_asbr_lsa_update, /* new_lsa_hook */ + NULL); /* del_lsa_hook */ + if (rc != 0) { + flog_warn( + EC_OSPF_OPAQUE_REGISTRATION, + "EXT (%s): Failed to register Extended Inter-Area ASBR LSA", + __func__); + return rc; + } + return rc; } @@ -174,6 +210,9 @@ void ospf_ext_term(void) ospf_delete_opaque_functab(OSPF_OPAQUE_AREA_LSA, OPAQUE_TYPE_EXTENDED_LINK_LSA); + ospf_delete_opaque_functab(OSPF_OPAQUE_AREA_LSA, + OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA); + list_delete(&OspfEXT.iflist); OspfEXT.scope = 0; OspfEXT.enabled = false; @@ -276,7 +315,64 @@ static struct ext_itf *lookup_ext_by_instance(struct ospf_lsa *lsa) * ---------------------------------------------------------------------- */ +static void flush_ext_prfx_fapm_subtlvs(struct ext_itf *exti) +{ + struct tlv *subtlv; + + FOREACH_TLV_IN_LIST (&exti->fapm_subtlvs, subtlv) { + tlv_list_del(&exti->fapm_subtlvs, subtlv); + XFREE(MTYPE_OSPF_EXT_PREFIX_FAPM_SUBTLV, subtlv); + } +} + /* Extended Prefix TLV - RFC7684 section 2.1 */ +static void set_ext_prefix_fapm(struct ext_itf *exti) +{ + struct flex_algo *fad; + struct listnode *curr, *next; + struct tlv *subtlv; + struct ext_subtlv_fapm *fapm; + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area: %pI4: Update FAPM SubTLVs for '%s' addr %pI4", + __func__, &exti->area->area_id, exti->ifp->name, + &exti->prefix.address); + + flush_ext_prfx_fapm_subtlvs(exti); + + if (OspfRI.fad_info.num_fads) { + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + if (!FLEX_ALGO_PREFIX_METRIC_SET(fad)) + continue; + + subtlv = + XCALLOC(MTYPE_OSPF_EXT_PREFIX_FAPM_SUBTLV, + sizeof(struct tlv) + + sizeof(struct ext_subtlv_fapm)); + assert(subtlv); + + fapm = (struct ext_subtlv_fapm *)&subtlv->hdr; + fapm->header.type = htons(EXT_SUBTLV_FAPM); + fapm->header.length = htons(EXT_SUBTLV_FAPM_LEN); + fapm->algorithm_id = fad->algorithm; + fapm->flags = 0; + fapm->metric = htonl(fad->prefix_adv_metric); + fapm->reserved = 0; + tlv_list_add_tail(&exti->fapm_subtlvs, subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area: %pI4, Itf: '%s' pref: %pI4/%u, add Flex-Algo %u, netric: %u", + __func__, &exti->area->area_id, + exti->ifp->name, &exti->prefix.address, + exti->prefix.pref_length, + fapm->algorithm_id, + ntohl(fapm->metric)); + } + } +} + static void set_ext_prefix(struct ext_itf *exti, uint8_t route_type, uint8_t flags, struct prefix_ipv4 p) { @@ -291,6 +387,14 @@ static void set_ext_prefix(struct ext_itf *exti, uint8_t route_type, exti->prefix.pref_length = p.prefixlen; exti->prefix.address = p.prefix; + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area: %pI4, Itf: '%s', Set EXT_PREFIX_TLV (type: %u, len: %u) for %pI4/%u", + __func__, &exti->area->area_id, exti->ifp->name, + ntohs(exti->prefix.header.type), + ntohs(exti->prefix.header.length), + &exti->prefix.address, exti->prefix.pref_length); + SET_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE); } @@ -454,7 +558,8 @@ static void ospf_extended_lsa_delete(struct ext_itf *exti) { /* Avoid deleting LSA if Extended is not enable */ - if (!OspfEXT.enabled) + if (!OspfEXT.enabled && + !(exti->stype == PREF_SID && OspfRI.fad_info.num_fads)) return; /* Process only Active Extended Prefix/Link LSA */ @@ -481,18 +586,10 @@ static void ospf_extended_lsa_delete(struct ext_itf *exti) ospf_sr_ext_itf_delete(exti); } -/* - * Update Extended prefix SID index for Loopback interface type - * - * @param ifname - Loopback interface name - * @param index - new value for the prefix SID of this interface - * @param p - prefix for this interface or NULL if Extended Prefix - * should be remove - * - * @return instance number if update is OK, 0 otherwise - */ -uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, - struct prefix_ipv4 *p, uint8_t flags) +static uint32_t ospf_ext_schedule_prefix(struct interface *ifp, + struct prefix_ipv4 *p, + bool set_pref_sid, uint32_t index, + uint8_t sid_flags) { int rc = 0; struct ext_itf *exti; @@ -505,12 +602,25 @@ uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, if (p != NULL) { osr_debug("EXT (%s): Schedule new prefix %pFX with index %u on interface %s", __func__, p, index, ifp->name); - /* Set first Extended Prefix then the Prefix SID information */ + /* Set first Extended Prefix TLV details */ set_ext_prefix(exti, OSPF_PATH_INTRA_AREA, EXT_TLV_PREF_NFLG, *p); - set_prefix_sid(exti, SR_ALGORITHM_SPF, index, SID_INDEX, flags); + + /* Then set the Prefix SID information (if any) */ + if (set_pref_sid) + set_prefix_sid(exti, SR_ALGORITHM_SPF, index, SID_INDEX, + sid_flags); + + /* Set the FAPM subTLVs (if any) */ + set_ext_prefix_fapm(exti); /* Try to Schedule LSA */ + + if (!OspfEXT.enabled && !tlv_list_count(&exti->fapm_subtlvs)) { + ospf_ext_pref_lsa_schedule(exti, FLUSH_THIS_LSA); + return 0; + } + if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) { if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) ospf_ext_pref_lsa_schedule(exti, @@ -530,6 +640,44 @@ uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, return SET_OPAQUE_LSID(exti->type, exti->instance); } +/* + * Update Extended prefix SID index for Loopback interface type + * + * @param ifname - Loopback interface name + * @param index - new value for the prefix SID of this interface + * @param p - prefix for this interface or NULL if Extended Prefix + * should be remove + * + * @return instance number if update is OK, 0 otherwise + */ +uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, + struct prefix_ipv4 *p, uint8_t flags) +{ + return ospf_ext_schedule_prefix(ifp, p, true, index, flags); +} + +void ospf_ext_update_all_prefix_fapms(void) +{ + struct listnode *node; + struct ospf_interface *oi; + struct ospf *top; + struct prefix_ipv4 p = {0}; + + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); + + if (!top) + return; + + for (ALL_LIST_ELEMENTS_RO(top->oiflist, node, oi)) { + p.prefix = oi->address->u.prefix4; + p.prefixlen = oi->address->prefixlen; + ospf_ext_schedule_prefix(oi->ifp, &p, false, 0, 0); + } + + /* Also update the Extended IA-ASBR Opaque LSA */ + ospf_ext_update_all_ia_asbr_lsas(top); +} + /** * Update Adjacecny-SID for Extended Link LSA * @@ -659,13 +807,122 @@ void ospf_ext_update_sr(bool enable) } else { /* Start by Removing Extended LSA */ for (ALL_LIST_ELEMENTS_RO(OspfEXT.iflist, node, exti)) - ospf_extended_lsa_delete(exti); + if (exti->stype != PREF_SID || + !OspfRI.fad_info.num_fads) + ospf_extended_lsa_delete(exti); + else + ospf_ext_lsa_schedule(exti, + REORIGINATE_THIS_LSA); /* And then disable Extended Link/Prefix */ OspfEXT.enabled = false; } } +/* + * Extended Inter-Area ASBR Opaque LSA + * Reference: draft-ietf-lsr-flex-algo section 10.1 + */ +void flush_ext_ia_asbr_faam_subtlvs(struct ospf_area *area) +{ + struct tlv *subtlv; + + FOREACH_TLV_IN_LIST (&area->eia_asbr_info->faam_subtlvs, subtlv) { + tlv_list_del(&area->eia_asbr_info->faam_subtlvs, subtlv); + XFREE(MTYPE_OSPF_EXT_IAASBR_FAAM_SUBTLV, subtlv); + } +} + +static void ospf_ext_update_ia_asbr_lsa(struct ospf_area *area) +{ + struct flex_algo *fad; + struct listnode *curr, *next; + struct tlv *subtlv; + struct ext_subtlv_faam *faam; + struct ospf *top; + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("EXT (%s): Area: %pI4: Update EIA-ASBR LSA", + __func__, &area->area_id); + + flush_ext_ia_asbr_faam_subtlvs(area); + + area->eia_asbr_info->ia_asbr_tlv.header.type = htons(EXT_TLV_IA_ASBR); + + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); + area->eia_asbr_info->ia_asbr_tlv.asbr_rtrid.s_addr = + top ? top->router_id.s_addr : 0; + + if (OspfRI.fad_info.num_fads) { + FOREACH_FLEX_ALGO_DEFN (OspfRI.fad_info.fads, curr, next, fad) { + if (!FLEX_ALGO_PREFIX_METRIC_SET(fad)) + continue; + + subtlv = + XCALLOC(MTYPE_OSPF_EXT_IAASBR_FAAM_SUBTLV, + sizeof(struct tlv) + + sizeof(struct ext_subtlv_faam)); + assert(subtlv); + + faam = (struct ext_subtlv_faam *)&subtlv->hdr; + faam->header.type = htons(EXT_SUBTLV_FAAM); + faam->header.length = htons(EXT_SUBTLV_FAAM_LEN); + faam->algorithm_id = fad->algorithm; + faam->metric = htonl(fad->prefix_adv_metric); + faam->reserved[0] = 0; + faam->reserved[1] = 0; + faam->reserved[2] = 0; + tlv_list_add_tail(&area->eia_asbr_info->faam_subtlvs, + subtlv); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area: %pI4: Added FAAM SubTLV (type: %u, length: %u, id: %u, metric: %u", + __func__, &area->area_id, + ntohs(faam->header.type), + ntohs(faam->header.length), + faam->algorithm_id, + ntohl(faam->metric)); + } + } + + SET_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ACTIVE); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("EXT (%s): Area: %pI4: Added %u FAAM SubTLVs", + __func__, &area->area_id, + (uint)tlv_list_count( + &area->eia_asbr_info->faam_subtlvs)); + + /* + * If there are no prefix-advertisement-metrics for this area, let's + * initiate a Flush of the EIA-ASBR LSA. + */ + if (!tlv_list_count(&area->eia_asbr_info->faam_subtlvs)) { + ospf_ext_ia_asbr_lsa_schedule(area, FLUSH_THIS_LSA); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area: %pI4: Flushing Ext Inter-Area ASBR LSA", + __func__, &area->area_id); + return; + } + + /* Re-originate or refresh the EIA ASBR LSA */ + if (CHECK_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ENGAGED)) + ospf_ext_ia_asbr_lsa_schedule(area, REFRESH_THIS_LSA); + else + ospf_ext_ia_asbr_lsa_schedule(area, REORIGINATE_THIS_LSA); +} + +void ospf_ext_update_all_ia_asbr_lsas(struct ospf *top) +{ + struct listnode *node, *nnode; + struct ospf_area *area; + + for (ALL_LIST_ELEMENTS(top->areas, node, nnode, area)) { + ospf_ext_update_ia_asbr_lsa(area); + } +} + /* * ----------------------------------------------------------------------- * Following are callback functions against generic Opaque-LSAs handling @@ -688,6 +945,7 @@ static int ospf_ext_link_new_if(struct interface *ifp) /* initialize new information and link back the interface */ new->ifp = ifp; new->flags = EXT_LPFLG_LSA_INACTIVE; + tlv_list_init(&new->fapm_subtlvs); listnode_add(OspfEXT.iflist, new); @@ -706,6 +964,9 @@ static int ospf_ext_link_del_if(struct interface *ifp) /* Flush LSA and remove Adjacency SID */ ospf_extended_lsa_delete(exti); + flush_ext_prfx_fapm_subtlvs(exti); + tlv_list_fini(&exti->fapm_subtlvs); + /* Dequeue listnode entry from the list. */ listnode_delete(OspfEXT.iflist, exti); @@ -958,7 +1219,7 @@ static int ospf_ext_pref_lsa_update(struct ospf_lsa *lsa) return 0; /* Check if Extended is enable */ - if (!OspfEXT.enabled) + if (!OspfEXT.enabled && !OspfRI.fad_info.num_fads) return 0; /* Call Segment Routing LSA update or deletion */ @@ -994,20 +1255,72 @@ static void build_tlv(struct stream *s, struct tlv_header *tlvh) /* Build an Extended Prefix Opaque LSA body for extended prefix TLV */ static void ospf_ext_pref_lsa_body_set(struct stream *s, struct ext_itf *exti) { + struct tlv *subtlv; + struct ext_subtlv_fapm *fapm_subtlv; + uint16_t tlv_size = 0; + struct tlv_header *tlvh, *subtlvh; /* Sanity check */ - if ((exti == NULL) || (exti->stype != PREF_SID)) + if ((exti == NULL) || + ((exti->stype != PREF_SID) && !tlv_list_count(&exti->fapm_subtlvs))) return; - /* Adjust Extended Prefix TLV size */ - TLV_LEN(exti->prefix) = htons(ntohs(TLV_LEN(exti->node_sid)) - + EXT_TLV_PREFIX_SIZE + TLV_HDR_SIZE); + if (!exti->prefix.header.type && OspfRI.enabled && + OspfRI.fad_info.num_fads) { + /* This could be becoz of a timing issue */ + ospf_ext_update_all_prefix_fapms(); + } + + /* Note the tlv header position in the stream buffer */ + tlvh = (struct tlv_header *)(STREAM_DATA(s) + stream_get_endp(s)); + tlv_size = EXT_TLV_PREFIX_SIZE; /* Build LSA body for an Extended Prefix TLV */ build_tlv_header(s, &exti->prefix.header); stream_put(s, TLV_DATA(&exti->prefix.header), EXT_TLV_PREFIX_SIZE); - /* Then add Prefix SID SubTLV */ - build_tlv(s, &exti->node_sid.header); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Adding Ext Prefix TLV (type: %u) for %pI4/%u", + __func__, ntohs(tlvh->type), &exti->prefix.address, + exti->prefix.pref_length); + + /* Add PREFIX_SID subTLV */ + if (OspfEXT.enabled && exti->stype == PREF_SID) { + subtlvh = (struct tlv_header *)(STREAM_DATA(s) + + stream_get_endp(s)); + tlv_size += ntohs(exti->node_sid.header.length) + TLV_HDR_SIZE; + build_tlv(s, &exti->node_sid.header); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Adding Ext Prefix SID SubTLV (type: %u, len: %u) sid: %u", + __func__, ntohs(subtlvh->type), + ntohs(subtlvh->length), + ntohl(exti->node_sid.value)); + } + + /* Add the FAPM sub-tlvs */ + FOREACH_TLV_IN_LIST (&exti->fapm_subtlvs, subtlv) { + subtlvh = (struct tlv_header *)(STREAM_DATA(s) + + stream_get_endp(s)); + fapm_subtlv = (struct ext_subtlv_fapm *)&subtlv->hdr; + tlv_size += ntohs(fapm_subtlv->header.length) + TLV_HDR_SIZE; + build_tlv(s, &fapm_subtlv->header); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Adding Ext Prefix FAPM SubTLV (type: %u, len: %u) algo: %u, metric: %u", + __func__, ntohs(subtlvh->type), + ntohs(subtlvh->length), + fapm_subtlv->algorithm_id, + ntohl(fapm_subtlv->metric)); + } + + /* Adjust Extended Prefix TLV size */ + tlvh->length = htons(tlv_size); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Generated %u bytes Ext-Prefix TLV(type: %u, len: %u)", + __func__, tlv_size, ntohs(tlvh->type), + ntohs(tlvh->length)); } /* Build an Extended Link Opaque LSA body for extended link TLV */ @@ -1292,9 +1605,9 @@ static int ospf_ext_pref_lsa_originate(void *arg) struct ext_itf *exti; int rc = -1; - if (!OspfEXT.enabled) { + if (!OspfEXT.enabled && !OspfRI.fad_info.num_fads) { zlog_info( - "EXT (%s): Segment Routing functionality is Disabled now", + "EXT (%s): Segment Routing and Flexible-Algorithm functionality is Disabled now", __func__); rc = 0; /* This is not an error case. */ return rc; @@ -1407,14 +1720,14 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa) struct ospf *top; struct ext_itf *exti; - if (!OspfEXT.enabled) { + if (!OspfEXT.enabled && !OspfRI.fad_info.num_fads) { /* * This LSA must have flushed before due to Extended Prefix * Opaque LSA status change. * It seems a slip among routers in the routing domain. */ zlog_info( - "EXT (%s): Segment Routing functionality is Disabled", + "EXT (%s): Segment Routing and Flexible-Algo functionality is Disabled", __func__); /* Flush it anyway. */ lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); @@ -1780,7 +2093,7 @@ static uint16_t show_vty_ext_link_lan_adj_sid(struct vty *vty, } static uint16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh, - size_t buf_size) + size_t buf_size, json_object *json) { if (TLV_SIZE(tlvh) > buf_size) { vty_out(vty, " TLV size %d exceeds buffer size. Abort!", @@ -1788,8 +2101,11 @@ static uint16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh, return buf_size; } - vty_out(vty, " Unknown TLV: [type(0x%x), length(0x%x)]\n", - ntohs(tlvh->type), ntohs(tlvh->length)); + if (json) + tlvh_get_json_values(tlvh, json, "Unknown"); + else + vty_out(vty, " Unknown TLV: [type(0x%x), length(0x%x)]\n", + ntohs(tlvh->type), ntohs(tlvh->length)); return TLV_SIZE(tlvh); } @@ -1834,7 +2150,8 @@ static uint16_t show_vty_link_info(struct vty *vty, struct tlv_header *ext, sum += show_vty_ext_link_rmt_itf_addr(vty, tlvh); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length - sum); + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + NULL); break; } } @@ -1863,7 +2180,8 @@ static void ospf_ext_link_show_info(struct vty *vty, struct json_object *json, sum += show_vty_link_info(vty, tlvh, length - sum); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length - sum); + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + NULL); break; } } @@ -1871,7 +2189,8 @@ static void ospf_ext_link_show_info(struct vty *vty, struct json_object *json, /* Prefix SID SubTLV */ static uint16_t show_vty_ext_pref_pref_sid(struct vty *vty, - struct tlv_header *tlvh) + struct tlv_header *tlvh, + json_object *json) { struct ext_subtlv_prefix_sid *top = (struct ext_subtlv_prefix_sid *)tlvh; @@ -1882,53 +2201,106 @@ static uint16_t show_vty_ext_pref_pref_sid(struct vty *vty, : SID_INDEX_SIZE(EXT_SUBTLV_PREFIX_SID_SIZE); check_tlv_size(tlv_size, "Prefix SID"); - vty_out(vty, - " Prefix SID Sub-TLV: Length %u\n\tAlgorithm: %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\t%s: %u\n", - ntohs(top->header.length), top->algorithm, top->flags, - top->mtid, - CHECK_FLAG(top->flags, EXT_SUBTLV_PREFIX_SID_VFLG) ? "Label" - : "Index", - CHECK_FLAG(top->flags, EXT_SUBTLV_PREFIX_SID_VFLG) - ? GET_LABEL(ntohl(top->value)) - : ntohl(top->value)); + if (json) { + tlvh_get_json_values(tlvh, json, "Prefix SID SubTLV"); + json_object_int_add(json, "algotithm", (int64_t)top->algorithm); + json_object_int_add(json, "flags", (int64_t)top->flags); + } else + vty_out(vty, + " Prefix SID Sub-TLV: Length %u\n\tAlgorithm: %u\n\tFlags: 0x%x\n\tMT-ID:0x%x\n\t%s: %u\n", + ntohs(top->header.length), top->algorithm, top->flags, + top->mtid, + CHECK_FLAG(top->flags, EXT_SUBTLV_PREFIX_SID_VFLG) + ? "Label" + : "Index", + CHECK_FLAG(top->flags, EXT_SUBTLV_PREFIX_SID_VFLG) + ? GET_LABEL(ntohl(top->value)) + : ntohl(top->value)); + + return TLV_SIZE(tlvh); +} + +/* Prefix SID SubTLV */ +static uint16_t show_vty_ext_pref_fapm(struct vty *vty, struct tlv_header *tlvh, + json_object *json) +{ + struct ext_subtlv_fapm *top = (struct ext_subtlv_fapm *)tlvh; + + check_tlv_size(EXT_SUBTLV_FAPM_LEN, "Flex-Algo Prefix-metric"); + + if (json) { + tlvh_get_json_values(tlvh, json, + "Flex-Algo Prefix Metric (FAPM) SubTLV"); + json_object_int_add(json, "algotithmId", + (int64_t)top->algorithm_id); + json_object_int_add(json, "flags", (int64_t)top->flags); + json_object_int_add(json, "metric", ntohl(top->metric)); + } else + vty_out(vty, + " Prefix FAPM Sub-TLV: Length %u\n\tAlgorithm: %u\n\tFlags: 0x%x\n\tMetric: %u\n", + ntohs(top->header.length), top->algorithm_id, + top->flags, ntohl(top->metric)); return TLV_SIZE(tlvh); } /* Extended Prefix SubTLVs */ static uint16_t show_vty_pref_info(struct vty *vty, struct tlv_header *ext, - size_t buf_size) + size_t buf_size, json_object *json) { struct ext_tlv_prefix *top = (struct ext_tlv_prefix *)ext; struct tlv_header *tlvh; uint16_t length = ntohs(top->header.length); uint16_t sum = 0; + json_object *stlvs_json = NULL; + json_object *stlv_json = NULL; /* Verify that TLV length is valid against remaining buffer size */ if (length > buf_size) { vty_out(vty, - " Extended Link TLV size %d exceeds buffer size. Abort!\n", + " Extended Prefix TLV size %d exceeds buffer size. Abort!\n", length); return buf_size; } - vty_out(vty, - " Extended Prefix TLV: Length %u\n\tRoute Type: %u\n" - "\tAddress Family: 0x%x\n\tFlags: 0x%x\n\tAddress: %pI4/%u\n", - ntohs(top->header.length), top->route_type, top->af, top->flags, - &top->address, top->pref_length); + if (json) { + tlvh_get_json_values(ext, json, "Extended Prefix TLV"); + json_object_string_addf(json, "prefixAddress", "%pI4", + &top->address); + json_object_int_add(json, "prefixLength", + (int64_t)top->pref_length); + json_object_int_add(json, "routeType", + (int64_t)top->route_type); + json_object_int_add(json, "addressFamily", (int64_t)top->af); + stlvs_json = json_object_new_array(); + json_object_object_add(json, "subTLVs", stlvs_json); + } else if (vty) + vty_out(vty, + " Extended Prefix TLV: Length %u\n\tRoute Type: %u\n" + "\tAddress Family: 0x%x\n\tFlags: 0x%x\n\tAddress: %pI4/%u\n", + ntohs(top->header.length), top->route_type, top->af, + top->flags, &top->address, top->pref_length); /* Skip Extended Prefix TLV and parse sub-TLVs */ length -= EXT_TLV_PREFIX_SIZE; tlvh = (struct tlv_header *)((char *)(ext) + TLV_HDR_SIZE + EXT_TLV_PREFIX_SIZE); for (; sum < length && tlvh; tlvh = TLV_HDR_NEXT(tlvh)) { + if (stlvs_json) { + stlv_json = json_object_new_object(); + json_object_array_add(stlvs_json, stlv_json); + } + switch (ntohs(tlvh->type)) { case EXT_SUBTLV_PREFIX_SID: - sum += show_vty_ext_pref_pref_sid(vty, tlvh); + sum += show_vty_ext_pref_pref_sid(vty, tlvh, stlv_json); + break; + case EXT_SUBTLV_FAPM: + sum += show_vty_ext_pref_fapm(vty, tlvh, stlv_json); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length - sum); + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + stlv_json); break; } } @@ -1943,22 +2315,597 @@ static void ospf_ext_pref_show_info(struct vty *vty, struct json_object *json, struct lsa_header *lsah = lsa->data; struct tlv_header *tlvh; uint16_t length = 0, sum = 0; + json_object *tlvs_json = NULL; + json_object *tlv_json = NULL; - if (json) - return; + if (json) { + tlvs_json = json_object_new_array(); + json_object_object_add(json, "tlvs", tlvs_json); + } /* Initialize TLV browsing */ length = lsa->size - OSPF_LSA_HEADER_SIZE; for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh; tlvh = TLV_HDR_NEXT(tlvh)) { + if (tlvs_json) { + tlv_json = json_object_new_object(); + json_object_array_add(tlvs_json, tlv_json); + } + switch (ntohs(tlvh->type)) { case EXT_TLV_PREFIX: - sum += show_vty_pref_info(vty, tlvh, length - sum); + sum += show_vty_pref_info(vty, tlvh, length - sum, + tlv_json); break; default: - sum += show_vty_unknown_tlv(vty, tlvh, length - sum); + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + tlv_json); break; } } } + +/* Prefix SID SubTLV */ +static uint16_t show_vty_ext_ia_asbr_faam(struct vty *vty, + struct tlv_header *tlvh, + json_object *json) +{ + struct ext_subtlv_faam *top = (struct ext_subtlv_faam *)tlvh; + + check_tlv_size(EXT_SUBTLV_FAAM_LEN, "FAAM SubTLV"); + + if (json) { + tlvh_get_json_values(tlvh, json, + "Flex-Algo ASBR Metric (FAAM) SubTLV"); + json_object_int_add(json, "algorithmId", + (int64_t)top->algorithm_id); + json_object_int_add(json, "metric", ntohl(top->metric)); + } else if (vty) { + vty_out(vty, + " Flex-Algo ASBR Metric Sub-TLV: Length %u\n\tAlgorithm: %u\n\tMetric:%u\n", + ntohs(top->header.length), top->algorithm_id, + ntohl(top->metric)); + } + + return TLV_SIZE(tlvh); +} + +/* Extended Inter-Area ASBR TLVs and SubTLVs */ +static uint16_t show_vty_eia_asbr_info(struct vty *vty, struct tlv_header *ext, + size_t buf_size, json_object *json) +{ + struct ext_tlv_ia_asbr *top = (struct ext_tlv_ia_asbr *)ext; + struct tlv_header *tlvh; + uint16_t length = ntohs(top->header.length); + uint16_t sum = 0; + uint8_t *tlv_start = (uint8_t *)ext; + json_object *stlvs_json = NULL; + json_object *stlv_json = NULL; + + /* Verify that TLV length is valid against remaining buffer size */ + if (length > buf_size) { + vty_out(vty, + " Extended Inter-Area ASBR TLV size %d exceeds buffer size. Abort!\n", + length); + return buf_size; + } + + if (json) { + tlvh_get_json_values(ext, json, "Extended Inter-Area ASBR TLV"); + json_object_string_addf(json, "asbrRouterId", "%pI4", + &top->asbr_rtrid); + stlvs_json = json_object_new_array(); + json_object_object_add(json, "subTLVs", stlvs_json); + } else if (vty) + vty_out(vty, + " Extended Inter-Area ASBR TLV: Length %u\n\tASBR-Router-Id: %pI4\n", + ntohs(top->header.length), &top->asbr_rtrid); + else + zlog_debug( + " Extended Inter-Area ASBR TLV: Length %u, ASBR-Router-Id: %pI4", + ntohs(top->header.length), &top->asbr_rtrid); + + /* Skip EIA-ASBR TLV and parse sub-TLVs */ + sum += EXT_TLV_IA_ASBR_LEN_MIN; + tlv_start += TLV_HDR_SIZE + EXT_TLV_IA_ASBR_LEN_MIN; + for (tlvh = (struct tlv_header *)tlv_start; sum < length && tlvh; + tlvh = TLV_HDR_NEXT(tlvh)) { + if (stlvs_json) { + stlv_json = json_object_new_object(); + json_object_array_add(stlvs_json, stlv_json); + } + + switch (ntohs(tlvh->type)) { + case EXT_SUBTLV_FAAM: + sum += show_vty_ext_ia_asbr_faam(vty, tlvh, stlv_json); + break; + default: + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + stlv_json); + break; + } + } + + return TLV_SIZE(ext); +} + +/* Extended Inter-Area ASBR LSA TLVs */ +static void ospf_ext_ia_asbr_show_info(struct vty *vty, + struct json_object *json, + struct ospf_lsa *lsa) +{ + struct lsa_header *lsah = lsa->data; + struct tlv_header *tlvh; + uint16_t length = 0, sum = 0; + json_object *tlvs_json = NULL; + json_object *tlv_json = NULL; + + if (json) { + tlvs_json = json_object_new_array(); + json_object_object_add(json, "tlvs", tlvs_json); + } + + /* Initialize TLV browsing */ + length = lsa->size - OSPF_LSA_HEADER_SIZE; + + for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh; + tlvh = TLV_HDR_NEXT(tlvh)) { + if (tlvs_json) { + tlv_json = json_object_new_object(); + json_object_array_add(tlvs_json, tlv_json); + } + + switch (ntohs(tlvh->type)) { + case EXT_TLV_IA_ASBR: + sum += show_vty_eia_asbr_info(vty, tlvh, length - sum, + tlv_json); + break; + default: + sum += show_vty_unknown_tlv(vty, tlvh, length - sum, + tlv_json); + break; + } + } +} + +/* Build an Extended IA-ASBR Opaque LSA body for extended IA-ASBR TLV */ +static void ospf_ext_ia_asbr_lsa_body_set(struct stream *s, + struct ospf_area *area) +{ + struct tlv *subtlv; + struct ext_subtlv_faam *faam_subtlv; + uint16_t tlv_size = 0; + struct tlv_header *tlvh; + + /* Note the tlv header position in the stream buffer */ + tlvh = (struct tlv_header *)(STREAM_DATA(s) + stream_get_endp(s)); + tlv_size = EXT_TLV_IA_ASBR_LEN_MIN; + + /* Build LSA body for an Extended IA-ASBR TLV */ + build_tlv_header(s, &area->eia_asbr_info->ia_asbr_tlv.header); + stream_put(s, TLV_DATA(&area->eia_asbr_info->ia_asbr_tlv.header), + EXT_TLV_IA_ASBR_LEN_MIN); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("EXT (%s): Adding Ext IA-ASBR TLV (type: %u)", + __func__, ntohs(tlvh->type)); + + /* Add the FAAM sub-tlvs */ + FOREACH_TLV_IN_LIST (&area->eia_asbr_info->faam_subtlvs, subtlv) { + faam_subtlv = (struct ext_subtlv_faam *)&subtlv->hdr; + tlv_size += ntohs(faam_subtlv->header.length) + TLV_HDR_SIZE; + build_tlv(s, &faam_subtlv->header); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Added FAAM subTLV (type: %u, length: %u)", + __func__, ntohs(faam_subtlv->header.type), + ntohs(faam_subtlv->header.length)); + } + + /* Adjust Extended IA-ASBR TLV size */ + tlvh->length = htons(tlv_size); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Added Ext IA-ASBR TLV (type: %u, length: %u)", + __func__, ntohs(tlvh->type), ntohs(tlvh->length)); +} + +/* Create new Extended IA-ASBR opaque-LSA for every extended prefix */ +static struct ospf_lsa *ospf_ext_ia_asbr_lsa_new(struct ospf_area *area) +{ + struct stream *s; + struct lsa_header *lsah; + struct ospf_lsa *new = NULL; + uint8_t options, lsa_type; + struct in_addr lsa_id; + struct in_addr router_id; + uint32_t tmp; + uint16_t length; + + /* Sanity Check */ + if (OspfEXT.scope == OSPF_OPAQUE_AS_LSA) + return NULL; + + /* Sanity check */ + if (!area->eia_asbr_info || + !tlv_list_count(&area->eia_asbr_info->faam_subtlvs)) { + zlog_debug( + "EXT (%s): No FAAM SubTLVs found for area %pI4, skip adding LSA body", + __func__, &area->area_id); + return NULL; + } + + /* Create a stream for LSA. */ + s = stream_new(OSPF_MAX_LSA_SIZE); + + /* Prepare LSA Header */ + lsah = (struct lsa_header *)STREAM_DATA(s); + + lsa_type = OspfEXT.scope; + + /* + * LSA ID is a variable number identifying different instances of + * Extended IA-ASBR Opaque LSA from the same router see RFC 7684 + */ + tmp = SET_OPAQUE_LSID(OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA, + area->ospf->instance); + lsa_id.s_addr = htonl(tmp); + + options = OSPF_OPTION_O; /* Don't forget this :-) */ + + /* Fix Options and Router ID depending of the flooding scope */ + options |= LSA_OPTIONS_GET(area); /* Get area default option */ + options |= LSA_OPTIONS_NSSA_GET(area); + router_id = area->ospf->router_id; + + /* Set opaque-LSA header fields. */ + lsa_header_set(s, options, lsa_type, lsa_id, router_id); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): LSA[Type%u:%pI4]: Create an Opaque-LSA Extended IA-ASBR Opaque LSA instance", + __func__, lsa_type, &lsa_id); + + /* Set opaque-LSA body fields. */ + ospf_ext_ia_asbr_lsa_body_set(s, area); + + /* Set length. */ + length = stream_get_endp(s); + lsah->length = htons(length); + + /* Now, create an OSPF LSA instance. */ + new = ospf_lsa_new_and_data(length); + new->vrf_id = area->ospf->vrf_id; + new->area = area; + SET_FLAG(new->flags, OSPF_LSA_SELF); + memcpy(new->data, lsah, length); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): LSA[Type%u:%pI4]: Final length of Opaque-LSA Extended IA-ASBR Opaque LSA: %d/%d", + __func__, lsa_type, &lsa_id, length, + ntohs(lsah->length)); + stream_free(s); + + return new; +} + +/* + * Process the origination of an Extended Prefix Opaque LSA + * for every extended prefix TLV + */ +static int ospf_ext_ia_asbr_lsa_originate1(struct ospf_area *area) +{ + struct ospf_lsa *new; + int rc = -1; + + /* Create new Opaque-LSA/Extended Prefix Opaque LSA instance. */ + new = ospf_ext_ia_asbr_lsa_new(area); + if (new == NULL) { + flog_warn(EC_OSPF_EXT_LSA_UNEXPECTED, + "EXT (%s): ospf_ext_ia_asbr_lsa_new() error", + __func__); + return rc; + } + + /* Install this LSA into LSDB. */ + if (ospf_lsa_install(area->ospf, NULL /*oi */, new) == NULL) { + flog_warn(EC_OSPF_LSA_INSTALL_FAILURE, + "EXT (%s): ospf_lsa_install() error", __func__); + ospf_lsa_unlock(&new); + return rc; + } + + /* + * Now this Extended Prefix Opaque LSA info parameter entry has + * associated LSA. + */ + SET_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ENGAGED); + + /* Update new LSA origination count. */ + area->ospf->lsa_originate_count++; + + /* Flood new LSA through area. */ + ospf_flood_through_area(area, NULL /*nbr */, new); + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): LSA[Type%u:%pI4]: Originate Opaque-LSA Extended IA-ASBR Opaque LSA: Area(%pI4)", + __func__, new->data->type, &new->data->id, + &area->area_id); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + ospf_lsa_header_dump(new->data); + + rc = 0; + + return rc; +} + +/* Trigger the origination of Extended IA-ASBR Opaque LSAs */ +static int ospf_ext_ia_asbr_lsa_originate(void *arg) +{ + struct ospf_area *area = (struct ospf_area *)arg; + + if (!OspfRI.fad_info.num_fads) { + zlog_info( + "EXT (%s): No Flexible-Algorithms has been configured so far.", + __func__); + return 0; /* This is not an error case. */ + } + + ospf_ext_update_ia_asbr_lsa(area); + if (!tlv_list_count(&area->eia_asbr_info->faam_subtlvs)) { + zlog_info( + "EXT (%s): No advertise-prefix-metric configured for any Flexible-Algorithms", + __func__); + return 0; /* This is not an error case. */ + } + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Start Originate IA-ASBR LSA for area %pI4", + __func__, &area->area_id); + + if (CHECK_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ENGAGED)) { + if (CHECK_FLAG(area->eia_asbr_info->flags, + EXT_LPFLG_LSA_FORCED_REFRESH)) { + flog_warn(EC_OSPF_EXT_LSA_UNEXPECTED, + "EXT (%s): Refresh instead of Originate", + __func__); + UNSET_FLAG(area->eia_asbr_info->flags, + EXT_LPFLG_LSA_FORCED_REFRESH); + ospf_ext_ia_asbr_lsa_schedule(area, REFRESH_THIS_LSA); + } + } + + /* Ok, let's try to originate an LSA */ + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Let's finally re-originate the LSA 11.0.0.%u for area %pI4", + __func__, area->ospf->instance, &area->area_id); + ospf_ext_ia_asbr_lsa_originate1(area); + + return 0; +} + +/* Refresh an Extended IA-ASBR Opaque LSA */ +static struct ospf_lsa *ospf_ext_ia_asbr_lsa_refresh(struct ospf_lsa *lsa) +{ + struct ospf_lsa *new = NULL; + struct ospf_area *area = lsa->area; + struct ospf *top; + + /* If the lsa's age reached to MaxAge, start flushing procedure. */ + if (!area) { + flog_warn(EC_OSPF_EXT_LSA_UNEXPECTED, + "EXT (%s): No Area found associated: Flush it!", + __func__); + /* Flush it anyway. */ + lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); + } + + /* If the lsa's age reached to MaxAge, start flushing procedure. */ + if (IS_LSA_MAXAGE(lsa)) { + if (area) + UNSET_FLAG(area->eia_asbr_info->flags, + EXT_LPFLG_LSA_ENGAGED); + ospf_opaque_lsa_flush_schedule(lsa); + return NULL; + } + + /* Create new Opaque-LSA/Extended IA-ASBR Opaque LSA instance. */ + new = ospf_ext_ia_asbr_lsa_new(area); + + if (new == NULL) { + flog_warn(EC_OSPF_EXT_LSA_UNEXPECTED, + "EXT (%s): ospf_ext_ia_asbr_lsa_new() error", + __func__); + return NULL; + } + new->data->ls_seqnum = lsa_seqnum_increment(lsa); + + /* + * Install this LSA into LSDB + * Given "lsa" will be freed in the next function + * As area could be NULL i.e. when using OPAQUE_LSA_AS, we prefer to use + * ospf_lookup() to get ospf instance + */ + top = area->ospf; + + if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) { + flog_warn(EC_OSPF_LSA_INSTALL_FAILURE, + "EXT (%s): ospf_lsa_install() error", __func__); + ospf_lsa_unlock(&new); + return NULL; + } + + /* Flood updated LSA through the IA-ASBR Area according to the RFC7684 + */ + ospf_flood_through_area(area, NULL /*nbr */, new); + + /* Debug logging. */ + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): LSA[Type%u:%pI4] Refresh Extended IA-ASBR LSA", + __func__, new->data->type, &new->data->id); + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + ospf_lsa_header_dump(new->data); + + return new; +} + +/* Schedule Extended IA-ASBR Opaque LSA origination/refreshment/flushing */ +static void ospf_ext_ia_asbr_lsa_schedule(struct ospf_area *area, + enum lsa_opcode opcode) +{ + struct ospf_lsa lsa; + struct lsa_header lsah; + struct ospf *top; + uint32_t tmp; + + memset(&lsa, 0, sizeof(lsa)); + memset(&lsah, 0, sizeof(lsah)); + + /* Sanity Check */ + + /* Check if the corresponding LSA is ready to be flooded */ + if (opcode != FLUSH_THIS_LSA && + !(CHECK_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ACTIVE))) + return; + + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug("EXT (%s): Schedule %s EIA-ASBR LSA for area %pI4", + __func__, + opcode == REORIGINATE_THIS_LSA + ? "Re-Originate" + : opcode == REFRESH_THIS_LSA + ? "Refresh" + : opcode == FLUSH_THIS_LSA + ? "Flush" + : "", + &area->area_id); + + /* Verify Area */ + if (area == NULL) { + if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) + zlog_debug( + "EXT (%s): Area is not yet set. Try to use Backbone Area", + __func__); + + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); + struct in_addr backbone = {.s_addr = INADDR_ANY}; + area = ospf_area_lookup_by_area_id(top, backbone); + if (area == NULL) { + flog_warn(EC_OSPF_EXT_LSA_UNEXPECTED, + "EXT (%s): Unable to set Area", __func__); + return; + } + } + /* Set LSA header information */ + lsa.area = area; + lsa.data = &lsah; + lsah.type = OSPF_OPAQUE_AREA_LSA; + tmp = SET_OPAQUE_LSID(OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA, + area->ospf->instance); + lsah.id.s_addr = htonl(tmp); + + switch (opcode) { + case REORIGINATE_THIS_LSA: + ospf_opaque_lsa_reoriginate_schedule( + (void *)area, OSPF_OPAQUE_AREA_LSA, + OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA); + break; + case REFRESH_THIS_LSA: + ospf_opaque_lsa_refresh_schedule(&lsa); + break; + case FLUSH_THIS_LSA: + UNSET_FLAG(area->eia_asbr_info->flags, EXT_LPFLG_LSA_ENGAGED); + ospf_opaque_lsa_flush_schedule(&lsa); + break; + } +} + +/* Update info from Extended Inter-Area ASBR LSA */ +static void ospf_ext_update_ia_asbr_info_from_lsa(struct ospf_lsa *lsa) +{ + // struct sr_node *srn; + struct tlv_header *tlvh; + struct lsa_header *lsah = (struct lsa_header *)lsa->data; + // struct sr_prefix *srp; + + int length; + + if (IS_DEBUG_OSPF(lsa, LSA)) + zlog_debug( + "EXT (%s): Process Extended Inter-Area LSA 11.0.0.%u from %pI4", + __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), + &lsah->adv_router); + + /* Initialize TLV browsing */ + length = lsa->size - OSPF_LSA_HEADER_SIZE; + for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh; + tlvh = TLV_HDR_NEXT(tlvh)) { + if (ntohs(tlvh->type) == EXT_TLV_IA_ASBR) { + /* Got Extended Inter-Area ASBR information */ + /* + * TODO: Parse the Extended Inter-Area ASBR TLV + * and it's sub-TLVs and update the DB (once we + * implement it) + */ + } + length -= TLV_SIZE(tlvh); + } +} + +/* Delete Segment Routing from Extended Prefix LSA */ +static void ospf_ext_delete_ia_asbr_info_for_lsa(struct ospf_lsa *lsa) +{ + // struct listnode *node; + // struct sr_prefix *srp; + // struct sr_node *srn; + struct lsa_header *lsah = (struct lsa_header *)lsa->data; + // uint32_t instance = ntohl(lsah->id.s_addr); + + if (IS_DEBUG_OSPF(lsa, LSA)) + zlog_debug( + "EXT (%s): Remove Extended Inter-Area ASBR LSA 11.0.0.%u from %pI4", + __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), + &lsah->adv_router); + + /* + * TODO: Remove the entry from the DB (once we implement it) + */ +} + +/* Callbacks to handle Extended Inter-Area ASBR LSA information */ +static int ospf_ext_ia_asbr_lsa_update(struct ospf_lsa *lsa) +{ + + /* Sanity Check */ + if (lsa == NULL) { + flog_warn(EC_OSPF_LSA_NULL, "EXT (%s): Abort! LSA is NULL", + __func__); + return -1; + } + + /* Process only Opaque LSA */ + if (lsa->data->type != OSPF_OPAQUE_AREA_LSA) + return 0; + + /* Process only Extended Prefix LSA */ + if (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)) != + OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA) + return 0; + + /* Check if it is not my LSA */ + if (IS_LSA_SELF(lsa)) + return 0; + + /* Call Segment Routing LSA update or deletion */ + if (!IS_LSA_MAXAGE(lsa)) + ospf_ext_update_ia_asbr_info_from_lsa(lsa); + else + ospf_ext_delete_ia_asbr_info_for_lsa(lsa); + + return 0; +} diff --git a/ospfd/ospf_ext.h b/ospfd/ospf_ext.h index 535e548b83f4..9aa8241488c6 100644 --- a/ospfd/ospf_ext.h +++ b/ospfd/ospf_ext.h @@ -106,6 +106,20 @@ struct ext_tlv_prefix { struct in_addr address; }; +/* + * Flexible Algorithm Prefix Metric Sub-TLV. + * Reference: draft-ietf-lsr-flex-algo section 9 + */ +#define EXT_SUBTLV_FAPM 0x3 +#define EXT_SUBTLV_FAPM_LEN 0x8 +struct ext_subtlv_fapm { + struct tlv_header header; /* Type = 3; Length = 8 bytes. */ + uint8_t algorithm_id; /* Algorithm. 1 byte */ + uint8_t flags; /* Flags. 1 byte */ + uint16_t reserved; /* Reserved. 2 bytes */ + uint32_t metric; /* Metric. 4 byte */ +}; + /* Extended Link TLV see RFC 7684 section 3.1 */ #define EXT_TLV_LINK 1 #define EXT_TLV_LINK_SIZE 12 @@ -125,6 +139,59 @@ struct ext_subtlv_rmt_itf_addr { struct in_addr value; }; +/* + * OSPF Extended Inter-Area ASBR Opaque LSA + * 24 16 8 0 + * +--------+--------+--------+--------+ --- + * | LS age |Options | 10 | A + * +--------+--------+--------+--------+ | Standard (Opaque) LSA header; + * | 11 | Instance | | + * +--------+--------+--------+--------+ | LSA Type 10 is used for Extended + * | Advertising router | | Inter-Area ASBR Opaque LSA + * +--------+--------+--------+--------+ | + * | LS sequence number | | Opaque Type 11 is used for Extended + * +--------+--------+--------+--------+ | Inter-Area ASBR Opaque LSA + * | LS checksum | Length | V + * +--------+--------+--------+--------+ --- + * | Type | Length | A + * +--------+--------+--------+--------+ | TLV part for Extended Inter-Area + * | | | ASBR Opaque LSA; + * ~ Values ... ~ | Values are structured as a set + * | | V of sub-TLVs. + * +--------+--------+--------+--------+ --- + */ + +/* + * OSPFv2 Extended Inter-Area ASBR TLV. + */ +#define EXT_TLV_IA_ASBR 0x1 +#define EXT_TLV_IA_ASBR_LEN_MIN 0x4 +struct ext_tlv_ia_asbr { + struct tlv_header header; + struct in_addr asbr_rtrid; +}; + +/* + * OSPFv2 Flexible Algorithm ASBR Metric SubTLV. + */ +#define EXT_SUBTLV_FAAM 0x1 +#define EXT_SUBTLV_FAAM_LEN 0x8 +struct ext_subtlv_faam { + struct tlv_header header; + uint8_t algorithm_id; /* Algorithm. 1 byte */ + uint8_t reserved[3]; /* Reserved. 3 byte */ + uint32_t metric; /* Metric. 4 byte */ +}; + +/* Extended Inter-Area ASBR information */ +struct ospf_ext_ia_asbr { + // struct in_addr asbr_rtrid; /* ASBR adverstising router-id */ + // uint32_t ext_ia_asbr_flags; /* Flags for managing EIA_ASBR LSAs */ + uint32_t flags; /* Flags to manage this EIA-ASBR Opaque LSA */ + struct ext_tlv_ia_asbr ia_asbr_tlv; /* EIA-ASBR TLV */ + struct tlv_list_head faam_subtlvs; /* FAAM sub-TLVs */ +}; + /* Internal structure to manage Extended Link/Prefix Opaque LSA */ struct ospf_ext_lp { bool enabled; @@ -163,6 +230,7 @@ struct ext_itf { /* extended link/prefix TLV information */ struct ext_tlv_prefix prefix; struct ext_subtlv_prefix_sid node_sid; + struct tlv_list_head fapm_subtlvs; struct ext_tlv_link link; struct ext_subtlv_adj_sid adj_sid[2]; struct ext_subtlv_lan_adj_sid lan_sid[2]; @@ -181,4 +249,7 @@ extern uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, struct prefix_ipv4 *p, uint8_t flags); +extern void flush_ext_ia_asbr_faam_subtlvs(struct ospf_area *area); +extern void ospf_ext_update_all_prefix_fapms(void); +extern void ospf_ext_update_all_ia_asbr_lsas(struct ospf *top); #endif /* _FRR_OSPF_EXT_PREF_H_ */ diff --git a/ospfd/ospf_memory.c b/ospfd/ospf_memory.c index ada5d64ee965..58eaae89a6bd 100644 --- a/ospfd/ospf_memory.c +++ b/ospfd/ospf_memory.c @@ -46,8 +46,16 @@ DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_RT_AGGR, "OSPF External Route Summarisation"); DEFINE_MTYPE(OSPFD, OSPF_P_SPACE, "OSPF TI-LFA P-Space"); DEFINE_MTYPE(OSPFD, OSPF_Q_SPACE, "OSPF TI-LFA Q-Space"); DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_TLV, "OSPF RI FAD TLV"); -DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV, "OSPF RI FAD Exclude AdminGroup SubTLV"); -DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV, "OSPF RI FAD Include-Any AdminGroup SubTLV"); -DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV, "OSPF RI FAD Include-All AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_ADMNGRP_SUBTLV, + "OSPF RI FAD Exclude AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV, + "OSPF RI FAD Include-Any AdminGroup SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV, + "OSPF RI FAD Include-All AdminGroup SubTLV"); DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_FLAGS_SUBTLV, "OSPF RI FAD Flags SubTLV"); -DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_SRLG_SUBTLV, "OSPF RI FAD Exclude SRLG SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_RI_FAD_EXC_SRLG_SUBTLV, + "OSPF RI FAD Exclude SRLG SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_EXT_PREFIX_FAPM_SUBTLV, "OSPF EXT Prefix FAPM SubTLV"); +DEFINE_MTYPE(OSPFD, OSPF_EXT_IAASBR_INFO, "OSPF EXT IA-ASBR LSA INFO"); +DEFINE_MTYPE(OSPFD, OSPF_EXT_IAASBR_FAAM_SUBTLV, + "OSPF EXT IA-ASBR FAAM SubTLV"); diff --git a/ospfd/ospf_memory.h b/ospfd/ospf_memory.h index 4ad1e92d6a4c..025b78f22961 100644 --- a/ospfd/ospf_memory.h +++ b/ospfd/ospf_memory.h @@ -50,5 +50,8 @@ DECLARE_MTYPE(OSPF_RI_FAD_INCANY_ADMNGRP_SUBTLV); DECLARE_MTYPE(OSPF_RI_FAD_INCALL_ADMNGRP_SUBTLV); DECLARE_MTYPE(OSPF_RI_FAD_FLAGS_SUBTLV); DECLARE_MTYPE(OSPF_RI_FAD_EXC_SRLG_SUBTLV); +DECLARE_MTYPE(OSPF_EXT_PREFIX_FAPM_SUBTLV); +DECLARE_MTYPE(OSPF_EXT_IAASBR_INFO); +DECLARE_MTYPE(OSPF_EXT_IAASBR_FAAM_SUBTLV); #endif /* _QUAGGA_OSPF_MEMORY_H */ diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 24a850c73738..c36bdca0a94b 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -229,6 +229,9 @@ static const char *ospf_opaque_type_name(uint8_t opaque_type) case OPAQUE_TYPE_EXTENDED_LINK_LSA: name = "Extended Link Opaque LSA"; break; + case OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA: + name = "Extended Inter-Area ASBR Opaque LSA"; + break; default: if (OPAQUE_TYPE_RANGE_UNASSIGNED(opaque_type)) name = "Unassigned"; @@ -1396,6 +1399,11 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0) struct opaque_info_per_type *oipt; int delay = 0; + if (IS_DEBUG_OSPF_EVENT) + zlog_debug( + "ospf_opaque_lsa_originate_schedule: Called for '%s'", + oi->ifp->name); + if ((top = oi_to_top(oi)) == NULL || (area = oi->area) == NULL) { if (IS_DEBUG_OSPF_EVENT) zlog_debug("%s: Invalid argument?", __func__); diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index ebe6999796e4..d2a252e3ca2e 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -47,7 +47,8 @@ #define OPAQUE_TYPE_INTER_AS_LSA 6 #define OPAQUE_TYPE_EXTENDED_PREFIX_LSA 7 #define OPAQUE_TYPE_EXTENDED_LINK_LSA 8 -#define OPAQUE_TYPE_MAX 8 +#define OPAQUE_TYPE_EXTENDED_INTER_AREA_ASBR_LSA 11 +#define OPAQUE_TYPE_MAX 11 /* Following types are proposed in internet-draft documents. */ #define OPAQUE_TYPE_8021_QOSPF 129 @@ -80,14 +81,13 @@ struct tlv_header { PREDECL_LIST(tlv_list); struct tlv { - struct tlv_list_item linkage; - struct tlv_header hdr; + struct tlv_list_item linkage; + struct tlv_header hdr; /* Body follows */ - uint8_t body[0]; + uint8_t body[0]; }; DECLARE_LIST(tlv_list, struct tlv, linkage); -#define FOREACH_TLV_IN_LIST(list, tlv) \ - frr_each_safe(tlv_list, list, tlv) +#define FOREACH_TLV_IN_LIST(list, tlv) frr_each_safe (tlv_list, list, tlv) #define TLV_HDR_SIZE (sizeof(struct tlv_header)) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index a4a6b2fadb21..080b924203a2 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -43,6 +43,7 @@ #include "ospfd/ospf_ase.h" #include "ospfd/ospf_zebra.h" #include "ospfd/ospf_sr.h" +#include "ospfd/ospf_ext.h" #include "ospfd/ospf_ri.h" #include "ospfd/ospf_errors.h" #ifndef VTYSH_EXTRACT_PL @@ -3348,8 +3349,10 @@ DEFPY(flex_algo_prfx_metric, flex_algo_prfx_metric_cmd, * Refresh/Re-originate the Router-Info LSA along with * all the EXT Prefix LSAs if already engaged. */ - if (update_lsa) + if (update_lsa) { + ospf_ext_update_all_prefix_fapms(); ospf_router_info_schedule(REFRESH_THIS_LSA); + } return CMD_SUCCESS; } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 4c4666db5295..536dee9d810d 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -47,6 +47,8 @@ #include "ospfd/ospf_ldp_sync.h" #include "ospfd/ospf_gr.h" #include "ospfd/ospf_apiserver.h" +#include "ospfd/ospf_sr.h" +#include "ospfd/ospf_ext.h" DEFINE_QOBJ_TYPE(ospf); @@ -955,6 +957,10 @@ struct ospf_area *ospf_area_new(struct ospf *ospf, struct in_addr area_id) if (area_id.s_addr == OSPF_AREA_BACKBONE) ospf->backbone = new; + new->eia_asbr_info = XCALLOC(MTYPE_OSPF_EXT_IAASBR_INFO, + sizeof(struct ospf_ext_ia_asbr)); + tlv_list_init(&new->eia_asbr_info->faam_subtlvs); + return new; } @@ -984,6 +990,12 @@ void ospf_area_lsdb_discard_delete(struct ospf_area *area) static void ospf_area_free(struct ospf_area *area) { + if (area->eia_asbr_info) { + flush_ext_ia_asbr_faam_subtlvs(area); + XFREE(MTYPE_OSPF_EXT_IAASBR_INFO, area->eia_asbr_info); + area->eia_asbr_info = NULL; + } + ospf_opaque_type10_lsa_term(area); /* Free LSDBs. */ diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index a61dd67b444a..d278036f64d8 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -501,6 +501,8 @@ struct p_space { struct p_spaces_item p_spaces_item; }; +struct ospf_ext_ia_asbr; + /* OSPF area structure. */ struct ospf_area { /* OSPF instance. */ @@ -635,6 +637,9 @@ struct ospf_area { uint32_t full_vls; /* Fully adjacent virtual neighbors. */ struct ospf_area_fr_info fr_info; /* Flood reduction info. */ + + /* Exntended Inter-Area ASBR Opaque Info */ + struct ospf_ext_ia_asbr *eia_asbr_info; }; /* OSPF config network structure. */ From 47df9e5a88f4ad3c6e5aadc3519a0e3bf7315c0b Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Fri, 15 Jul 2022 08:55:02 -0700 Subject: [PATCH 5/6] doc: Add documentation for Flexible-Algorithm support for OSPFv2 This commit adds documentation for Flexible-Algorithm support in OSPFv2 and related configuration and show commands. Signed-off-by: Pushpasis Sarkar --- doc/user/ospfd.rst | 208 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) diff --git a/doc/user/ospfd.rst b/doc/user/ospfd.rst index 2f88f245990e..e1a9c5595e28 100644 --- a/doc/user/ospfd.rst +++ b/doc/user/ospfd.rst @@ -1174,6 +1174,214 @@ TI-LFA requires a proper Segment Routing configuration. Note that so far only P2P interfaces are supported. +Flexible Algorithms (Flex-Algo) +=============================== + +This is a bare-minimum implementation of : :t:`draft-ietf-lsr-flex-algo`. Currently +`Shortest Path First` is the only algorithm supported, with `IGP-Metric` and +`Shortest-Path-First` are the only values supported for `metric-type` and +`calculation-type` respectively. In future support for more algorithms, +metric-types and calculation-types shall be added. + +Please note, since Flexible Algorithm Definitions (also referred to as FAD) +are advertised in Opaque LSAs (one ore more), capability to carry Opaque +Linkstate Information (in the form of Opaque LSAs) should be turned on using +``capability opaque`` and ``router-info area`` configration commands under +`router ospf` level. + +.. clicmd:: [no] flexible-algorithm (128-255) + + Add a new or remove an existing Flexible Algorithm Definition for the + current router to support. + + The add will result in the router advertsing the new flexible-algorithm + definition (with the specified algorithm-id) in all relevant types of + self-originated LSAs. By default, `calculation-type` and `metric-type` + for the new flexible-algorithm shall be set to `Shortest-Path-First` and + `IGP-Metric` respectively. + + Removing an existing Flexible Algorithm Definition will result in the + router removing all advertisements for the specified algorithm-id from all + the relevant types of self-originated LSAs. + +.. clicmd:: [no] flexible-algorithm (128-255) calculation-type (spf) + + Set (or reset) the `calculation-type` for the Flexible Algorithm Definition + specified by the algorithm-id. Currently `spf` (i.e. Shortest-Path-First) + only allowed value. Support for more metric-types shall be added in future. + + Resetting the `calculation-type` for the Flexible Algorithm Definition will + reset it to the default value of `spf`. + +.. clicmd:: [no] flexible-algorithm (128-255) metric-type (igp) + + Set the (or reset) `metric-type` for the Flexible Algorithm Definition + specified by the algorithm-id. Currently `igp-metric` is the only allowed + value. Support for more metric-types shall be added in future. + + Resetting the `metric-type` for the Flexible Algorithm Definition will + reset it to efault value of `igp-metric`. + +.. clicmd:: [no] flexible-algorithm (128-255) priority (0-4294967295) + + Set the (or reset) `priority` for the Flexible Algorithm Definition + specified by the algorithm-id. Default value of priority is 0. + + Resetting the `priority` for the Flexible Algorithm Definition will reset + it to default value 0. + +.. clicmd:: [no] flexible-algorithm (128-255) exclude-admin-group (0-4294967295) + + Add (or remove) the specified `admin-group` value to (or from) the list of + Exclude-Admin-Groups for the Flexible Algorithm Definition specified by the + algorithm-id. + + This will add (or remove) the admin-group to (or from) the list of + admin-groups advertised in the Exclude-Admin-Group Sub-TLV included in the + corresponding Flexible Algorithm Definition TLV (carried inside the + Router-Info external LSA). + +.. clicmd:: [no] flexible-algorithm (128-255) include-any-admin-group (0-4294967295) + + Add (or remove) the specified `admin-group` value to (or from) the list of + Include-Any-Admin-Groups for the Flexible Algorithm Definition specified by + the algorithm-id. + + This will add (or remove) the admin-group to (or from) the list of + admin-groups advertised in the Include-Any-Admin-Group Sub-TLV included in + the corresponding Flexible Algorithm Definition TLV (carried inside the + Router-Info external LSA). + +.. clicmd:: [no] flexible-algorithm (128-255) include-all-admin-group (0-4294967295) + + Add (or remove) the specified `admin-group` value to (or from) the list of + Include-All-Admin-Groups for the Flexible Algorithm Definition specified by + the algorithm-id. + + This will add (or remove) the admin-group to (or from) the list of + admin-groups advertised in the Include-All-Admin-Group Sub-TLV included in + the corresponding Flexible Algorithm Definition TLV (carried inside the + Router-Info external LSA). + +.. clicmd:: [no] flexible-algorithm (128-255) exclude-srlg (0-4294967295) + + Add (or remove) the specified `srlg` value to (or from) the list of + Exclude-SRLGs for the Flexible Algorithm Definition specified by the + algorithm-id. + + This will add (or remove) the admin-group to (or from) the list of + SRLGs advertised in the Exclude-SRLG Sub-TLV included in the + corresponding Flexible Algorithm Definition TLV (carried inside the + Router-Info external LSA). + +.. clicmd:: [no] flexible-algorithm (128-255) advertise-prefix-metric (0-4294967295) + + Set (or reset) the `advertise-prefix-metric` for the Flexible Algorithm + Definition specified by the algorithm-id. + + Setting the `advertise-prefix-metric` for the Flexible Algorithm + Definition will results in the router advertising the configured value + inside a Flexible-Algorithm Prefix-Metric(FAPM) Sub-TLV (carried inside + Extended Prefix TLV within a Extended Prefix Opaque LSA), as well as + inside a Flexible-Algorithm ASBR Metric(FAAM) Sub-TLV (to be carried in + the Extended Inter-Area ASBR TLV within a new Extended Inter-Area LSA). + By default no prefix metric is advertised. + + Resetting the `advertise-prefix-metric` for the Flexible Algorithm Definition + specified by the algorithm-id will remove advertisement of the previously + configured value from all the relevant Sub-TLVs, TLVs and LSAs. + +.. clicmd:: show ip ospf [vrf (vrf-name)] database opaque-area + + This existing command's output has been enhanced to display the new + Flexible-Algorithm definition LSAs, TLVs and Sub-TLVs. + + Following show command output shows the new Flexible Algoritms Definition + LSAs, TLVs and Sub-TLVs advertised. + + .. code-block:: frr + + frr# show ip ospf database opaque-area + + OSPF Router with ID (1.1.1.1) + + + Area-Local Opaque-LSA (Area 0.0.0.0) + + LS age: 524 + Options: 0x42 : *|O|-|-|-|-|E|- + LS Flags: 0x1 + LS Type: Area-Local Opaque-LSA + Link State ID: 4.0.0.0 (Area-Local Opaque-Type/ID) + Advertising Router: 1.1.1.1 + LS Seq Number: 8000000b + Checksum: 0x9b60 + Length: 80 + + Opaque-Type 4 (Router Information LSA) + Opaque-ID 0x0 + Opaque-Info: 60 octets of data + Router Capabilities: 0x10000000 + Flexible Algorithm Defintion TLV: Length: 48 + Algorithm-Identifier = 128 + Priority = 10 + Metric-Type = Invalid-Metric-Type + Calculation-Type = spf + FAD Exclude Admin Groups: + [ 30 ] + FAD Include Any Admin Groups: + [ 60, 70 ] + FAD Include All Admin Groups: + [ 20 ] + FAD Flags: + [ 10 ] + FAD Exclude SRLGs: + [ 10 ] + + LS age: 771 + Options: 0x42 : *|O|-|-|-|-|E|- + LS Flags: 0x6 + LS Type: Area-Local Opaque-LSA + Link State ID: 4.0.0.0 (Area-Local Opaque-Type/ID) + Advertising Router: 2.2.2.2 + LS Seq Number: 8000000b + Checksum: 0x4d9d + Length: 28 + + Opaque-Type 7 (Extended Prefix Opaque LSA) + Opaque-ID 0x1 + Opaque-Info: 24 octets of data + Extended Prefix TLV: Length 20 + Route Type: 1 + Address Family: 0x0 + Flags: 0x40 + Address: 1.1.1.1/32 + Prefix FAPM Sub-TLV: Length 8 + Algorithm: 128 + Flags: 0x0 + Metric: 100 + + LS age: 1383 + Options: 0x42 : *|O|-|-|-|-|E|- + LS Flags: 0x1 + LS Type: Area-Local Opaque-LSA + Link State ID: 11.0.0.0 (Area-Local Opaque-Type/ID) + Advertising Router: 1.1.1.1 + LS Seq Number: 8000000a + Checksum: 0xc826 + Length: 40 + + Opaque-Type 11 (Extended Inter-Area ASBR Opaque LSA) + Opaque-ID 0x0 + Opaque-Info: 20 octets of data + Extended Inter-Area ASBR TLV: Length 16 + ASBR-Router-Id: 1.1.1.1 + Flex-Algo ASBR Metric Sub-TLV: Length 8 + Algorithm: 128 + Metric:100 + + frr# + .. _debugging-ospf: Debugging OSPF From ca70189c72ec169a257ee0231a6e257146431f0d Mon Sep 17 00:00:00 2001 From: Pushpasis Sarkar Date: Mon, 22 Aug 2022 08:53:59 -0700 Subject: [PATCH 6/6] tests: Add Topotests for Flexible-Algorithm implementation in OSPFv2 This commit adds topotests for Flexible-Algorithm implementation in OSPFv2. Signed-off-by: Pushpasis Sarkar --- .../topotests/ospf_flexalgo_topo1/__init__.py | 0 .../ospf_flexalgo_topo1/rt1/ospfd.conf | 27 + .../ospf_flexalgo_topo1/rt1/ospfd_flxalg.conf | 40 + .../step1/show_ip_ospf_database_opaque.ref | 304 +++ .../rt1/step1/show_ip_ospf_flexalgo.ref | 17 + .../rt1/step1/show_ip_route.ref | 166 ++ .../step10/show_ip_ospf_database_opaque.ref | 305 +++ .../rt1/step10/show_ip_ospf_flexalgo.ref | 18 + .../step11/show_ip_ospf_database_opaque.ref | 296 +++ .../rt1/step11/show_ip_ospf_flexalgo.ref | 15 + .../step12/show_ip_ospf_database_opaque.ref | 305 +++ .../rt1/step12/show_ip_ospf_flexalgo.ref | 18 + .../step13/show_ip_ospf_database_opaque.ref | 296 +++ .../rt1/step13/show_ip_ospf_flexalgo.ref | 15 + .../step14/show_ip_ospf_database_opaque.ref | 239 +++ .../rt1/step14/show_ip_ospf_flexalgo.ref | 17 + .../step2/show_ip_ospf_database_opaque.ref | 314 ++++ .../show_ip_ospf_database_opaque_mismatch.ref | 79 + .../rt1/step2/show_ip_ospf_flexalgo.ref | 17 + .../rt1/step2/show_ip_route.ref | 166 ++ .../step4/show_ip_ospf_database_opaque.ref | 304 +++ .../rt1/step4/show_ip_ospf_flexalgo.ref | 17 + .../step5/show_ip_ospf_database_opaque.ref | 304 +++ .../rt1/step5/show_ip_ospf_flexalgo.ref | 17 + .../step6/show_ip_ospf_database_opaque.ref | 305 +++ .../rt1/step6/show_ip_ospf_flexalgo.ref | 18 + .../step7/show_ip_ospf_database_opaque.ref | 296 +++ .../rt1/step7/show_ip_ospf_flexalgo.ref | 15 + .../step8/show_ip_ospf_database_opaque.ref | 305 +++ .../rt1/step8/show_ip_ospf_flexalgo.ref | 18 + .../step9/show_ip_ospf_database_opaque.ref | 295 +++ .../rt1/step9/show_ip_ospf_flexalgo.ref | 14 + .../ospf_flexalgo_topo1/rt1/zebra.conf | 21 + .../ospf_flexalgo_topo1/rt2/ospfd.conf | 30 + .../ospf_flexalgo_topo1/rt2/ospfd_flxalg.conf | 35 + .../step1/show_ip_ospf_database_opaque.ref | 304 +++ .../rt2/step1/show_ip_ospf_flexalgo.ref | 1 + .../rt2/step1/show_ip_route.ref | 167 ++ .../step10/show_ip_ospf_database_opaque.ref | 305 +++ .../rt2/step10/show_ip_ospf_flexalgo.ref | 1 + .../step11/show_ip_ospf_database_opaque.ref | 296 +++ .../rt2/step11/show_ip_ospf_flexalgo.ref | 1 + .../step12/show_ip_ospf_database_opaque.ref | 305 +++ .../rt2/step12/show_ip_ospf_flexalgo.ref | 1 + .../step13/show_ip_ospf_database_opaque.ref | 296 +++ .../rt2/step13/show_ip_ospf_flexalgo.ref | 1 + .../step14/show_ip_ospf_database_opaque.ref | 239 +++ .../rt2/step14/show_ip_ospf_flexalgo.ref | 1 + .../step2/show_ip_ospf_database_opaque.ref | 314 ++++ .../show_ip_ospf_database_opaque_mismatch.ref | 79 + .../rt2/step2/show_ip_ospf_flexalgo.ref | 1 + .../rt2/step2/show_ip_route.ref | 168 ++ .../step4/show_ip_ospf_database_opaque.ref | 304 +++ .../rt2/step4/show_ip_ospf_flexalgo.ref | 1 + .../step5/show_ip_ospf_database_opaque.ref | 304 +++ .../rt2/step5/show_ip_ospf_flexalgo.ref | 1 + .../step6/show_ip_ospf_database_opaque.ref | 305 +++ .../rt2/step6/show_ip_ospf_flexalgo.ref | 1 + .../step7/show_ip_ospf_database_opaque.ref | 296 +++ .../rt2/step7/show_ip_ospf_flexalgo.ref | 1 + .../step8/show_ip_ospf_database_opaque.ref | 305 +++ .../rt2/step8/show_ip_ospf_flexalgo.ref | 1 + .../step9/show_ip_ospf_database_opaque.ref | 295 +++ .../rt2/step9/show_ip_ospf_flexalgo.ref | 1 + .../ospf_flexalgo_topo1/rt2/zebra.conf | 24 + .../ospf_flexalgo_topo1/rt3/ospfd.conf | 30 + .../ospf_flexalgo_topo1/rt3/ospfd_flxalg.conf | 35 + .../step1/show_ip_ospf_database_opaque.ref | 304 +++ .../rt3/step1/show_ip_ospf_flexalgo.ref | 1 + .../rt3/step1/show_ip_route.ref | 166 ++ .../step10/show_ip_ospf_database_opaque.ref | 305 +++ .../rt3/step10/show_ip_ospf_flexalgo.ref | 1 + .../step11/show_ip_ospf_database_opaque.ref | 296 +++ .../rt3/step11/show_ip_ospf_flexalgo.ref | 1 + .../step12/show_ip_ospf_database_opaque.ref | 305 +++ .../rt3/step12/show_ip_ospf_flexalgo.ref | 1 + .../step13/show_ip_ospf_database_opaque.ref | 296 +++ .../rt3/step13/show_ip_ospf_flexalgo.ref | 1 + .../step14/show_ip_ospf_database_opaque.ref | 239 +++ .../rt3/step14/show_ip_ospf_flexalgo.ref | 1 + .../step2/show_ip_ospf_database_opaque.ref | 314 ++++ .../show_ip_ospf_database_opaque_mismatch.ref | 79 + .../rt3/step2/show_ip_ospf_flexalgo.ref | 1 + .../rt3/step2/show_ip_route.ref | 166 ++ .../step4/show_ip_ospf_database_opaque.ref | 304 +++ .../rt3/step4/show_ip_ospf_flexalgo.ref | 1 + .../step5/show_ip_ospf_database_opaque.ref | 304 +++ .../rt3/step5/show_ip_ospf_flexalgo.ref | 1 + .../step6/show_ip_ospf_database_opaque.ref | 305 +++ .../rt3/step6/show_ip_ospf_flexalgo.ref | 1 + .../step7/show_ip_ospf_database_opaque.ref | 296 +++ .../rt3/step7/show_ip_ospf_flexalgo.ref | 1 + .../step8/show_ip_ospf_database_opaque.ref | 305 +++ .../rt3/step8/show_ip_ospf_flexalgo.ref | 1 + .../step9/show_ip_ospf_database_opaque.ref | 295 +++ .../rt3/step9/show_ip_ospf_flexalgo.ref | 1 + .../ospf_flexalgo_topo1/rt3/zebra.conf | 24 + .../ospf_flexalgo_topo1/rt4/ospfd.conf | 31 + .../ospf_flexalgo_topo1/rt4/ospfd_flxalg.conf | 41 + .../step1/show_ip_ospf_database_opaque.ref | 304 +++ .../rt4/step1/show_ip_ospf_flexalgo.ref | 17 + .../rt4/step1/show_ip_route.ref | 166 ++ .../step10/show_ip_ospf_database_opaque.ref | 305 +++ .../rt4/step10/show_ip_ospf_flexalgo.ref | 17 + .../step11/show_ip_ospf_database_opaque.ref | 296 +++ .../rt4/step11/show_ip_ospf_flexalgo.ref | 17 + .../step12/show_ip_ospf_database_opaque.ref | 305 +++ .../rt4/step12/show_ip_ospf_flexalgo.ref | 17 + .../step13/show_ip_ospf_database_opaque.ref | 296 +++ .../rt4/step13/show_ip_ospf_flexalgo.ref | 17 + .../step14/show_ip_ospf_database_opaque.ref | 239 +++ .../rt4/step14/show_ip_ospf_flexalgo.ref | 16 + .../step2/show_ip_ospf_database_opaque.ref | 314 ++++ .../show_ip_ospf_database_opaque_mismatch.ref | 79 + .../rt4/step2/show_ip_ospf_flexalgo.ref | 24 + .../rt4/step2/show_ip_route.ref | 166 ++ .../step4/show_ip_ospf_database_opaque.ref | 304 +++ .../rt4/step4/show_ip_ospf_flexalgo.ref | 17 + .../step5/show_ip_ospf_database_opaque.ref | 304 +++ .../rt4/step5/show_ip_ospf_flexalgo.ref | 17 + .../step6/show_ip_ospf_database_opaque.ref | 305 +++ .../rt4/step6/show_ip_ospf_flexalgo.ref | 17 + .../step7/show_ip_ospf_database_opaque.ref | 296 +++ .../rt4/step7/show_ip_ospf_flexalgo.ref | 17 + .../step8/show_ip_ospf_database_opaque.ref | 305 +++ .../rt4/step8/show_ip_ospf_flexalgo.ref | 17 + .../step9/show_ip_ospf_database_opaque.ref | 295 +++ .../rt4/step9/show_ip_ospf_flexalgo.ref | 17 + .../ospf_flexalgo_topo1/rt4/zebra.conf | 21 + .../test_ospf_flexalgo_topo1.py | 1663 +++++++++++++++++ 130 files changed, 19610 insertions(+) create mode 100644 tests/topotests/ospf_flexalgo_topo1/__init__.py create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/ospfd.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/ospfd_flxalg.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque_mismatch.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt1/zebra.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/ospfd.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/ospfd_flxalg.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque_mismatch.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt2/zebra.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/ospfd.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/ospfd_flxalg.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque_mismatch.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt3/zebra.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/ospfd.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/ospfd_flxalg.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque_mismatch.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_route.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_database_opaque.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_flexalgo.ref create mode 100644 tests/topotests/ospf_flexalgo_topo1/rt4/zebra.conf create mode 100644 tests/topotests/ospf_flexalgo_topo1/test_ospf_flexalgo_topo1.py diff --git a/tests/topotests/ospf_flexalgo_topo1/__init__.py b/tests/topotests/ospf_flexalgo_topo1/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd.conf b/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd.conf new file mode 100644 index 000000000000..6b4e640a2af9 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd.conf @@ -0,0 +1,27 @@ +password 1 +hostname rt1 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt1-1 + ip ospf area 0.0.0.0 +! +interface eth-rt1-2 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 1.1.1.1 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd_flxalg.conf b/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd_flxalg.conf new file mode 100644 index 000000000000..f774888786d0 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/ospfd_flxalg.conf @@ -0,0 +1,40 @@ +password 1 +hostname rt1 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +affinity-map red bit-position 0 +affinity-map green bit-position 100 +affinity-map blue bit-position 1000 +affinity-map yellow bit-position 200 +! +interface lo + ip ospf area 0.0.0.0 +! +interface eth-rt1-1 + ip ospf area 0.0.0.0 +! +interface eth-rt1-2 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 1.1.1.1 + capability opaque + router-info area 0.0.0.0 + flexible-algorithm 128 + flexible-algorithm 128 priority 10 + flexible-algorithm 128 exclude-admin-group red + flexible-algorithm 128 include-all-admin-group green + flexible-algorithm 128 include-any-admin-group green + flexible-algorithm 128 include-any-admin-group blue + flexible-algorithm 128 exclude-srlg 10 + flexible-algorithm 128 advertise-prefix-metric 100 + passive-interface lo +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..94cb641a705c --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..9930d482a630 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_route.ref new file mode 100644 index 000000000000..990d5c1e80d7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step1/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..965d3093aa15 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 324, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 304, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 292, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Include-All Admin Groups SubTLV", + "type": 3, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..f37784b18a5a --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step10/show_ip_ospf_flexalgo.ref @@ -0,0 +1,18 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + - blue(1000) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..935749aea7b4 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 192, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 172, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 160, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..99e97797d0c7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step11/show_ip_ospf_flexalgo.ref @@ -0,0 +1,15 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..934d807009d7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 216, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 196, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 184, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name": "Exclude SRLGs SubTLV", + "type": 5, + "length": 8, + "srlgs": [ + 10, + 40 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..1b95eea85c0d --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step12/show_ip_ospf_flexalgo.ref @@ -0,0 +1,18 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 + - 40 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..ba6483641806 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..6c9dc56c27c7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step13/show_ip_ospf_flexalgo.ref @@ -0,0 +1,15 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..83d5bde03ede --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_database_opaque.ref @@ -0,0 +1,239 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..1419dd13ab36 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step14/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..2bca6f1ba7bf --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque.ref @@ -0,0 +1,314 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 220, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 200, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 4, + "algorithmId": 129, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque_mismatch.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque_mismatch.ref new file mode 100644 index 000000000000..e841b1afa23c --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_database_opaque_mismatch.ref @@ -0,0 +1,79 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 56, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 32, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + }, + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "algotithmId": 129 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 52, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 28, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + }, + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 129 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..9930d482a630 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_route.ref new file mode 100644 index 000000000000..990d5c1e80d7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step2/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.20", + "afi":"ipv4", + "interfaceName":"eth-rt1-1", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.30", + "afi":"ipv4", + "interfaceName":"eth-rt1-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..f7e7c3e45bca --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 20, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..275f285ffbcb --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step4/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 20 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..9f40e5d71b48 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..40d8b458e893 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step5/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 128 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..0cc897057a59 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 236, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 216, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 204, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":28, + "adminGroups":[ + "red", + "yellow" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..261210469a15 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step6/show_ip_ospf_flexalgo.ref @@ -0,0 +1,18 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + - yellow(200) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..f5271d9af419 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..b7d8817e9398 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step7/show_ip_ospf_flexalgo.ref @@ -0,0 +1,15 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..febdbd59ec6a --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name": "Include-Any Admin Groups SubTLV", + "type": 2, + "length": 128, + "adminGroups": [ + "green", + "yellow", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..c2031ec7c22b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step8/show_ip_ospf_flexalgo.ref @@ -0,0 +1,18 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - yellow(200) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..3fce8c6c92a5 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_database_opaque.ref @@ -0,0 +1,295 @@ +{ + "routerId": "1.1.1.1", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 80, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 60, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 48, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..09083785eec8 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/step9/show_ip_ospf_flexalgo.ref @@ -0,0 +1,14 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 100 + Exclude-Admin-Groups: + - red(0) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt1/zebra.conf b/tests/topotests/ospf_flexalgo_topo1/rt1/zebra.conf new file mode 100644 index 000000000000..72224fac0d7a --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt1/zebra.conf @@ -0,0 +1,21 @@ +log file zebra.log +! +hostname rt1 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 1.1.1.1/32 +! +interface eth-rt1-1 + ip address 10.0.1.10/24 +! +interface eth-rt1-2 + ip address 10.0.2.10/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd.conf b/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd.conf new file mode 100644 index 000000000000..b74beffbc0a3 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd.conf @@ -0,0 +1,30 @@ +password 1 +hostname rt2 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt2-1 + ip ospf area 0.0.0.0 +! +interface eth-rt2-2 + ip ospf area 0.0.0.0 +! +interface eth-rt2-3 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 2.2.2.2 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd_flxalg.conf b/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd_flxalg.conf new file mode 100644 index 000000000000..ccb800581ba1 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/ospfd_flxalg.conf @@ -0,0 +1,35 @@ +password 1 +hostname rt2 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +affinity-map red bit-position 0 +affinity-map green bit-position 100 +affinity-map blue bit-position 1000 +affinity-map yellow bit-position 200 +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt2-1 + ip ospf area 0.0.0.0 +! +interface eth-rt2-2 + ip ospf area 0.0.0.0 +! +interface eth-rt2-3 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 2.2.2.2 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..64a90b636b1e --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_route.ref new file mode 100644 index 000000000000..956cde86b9d6 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step1/show_ip_route.ref @@ -0,0 +1,167 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "ip":"10.0.1.10", + "afi":"ipv4", + "interfaceName":"eth-rt2-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.40", + "afi":"ipv4", + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt2-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.10", + "afi":"ipv4", + "interfaceName":"eth-rt2-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + }, + { + "fib":true, + "ip":"10.0.4.40", + "afi":"ipv4", + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..4e7c6893fc2e --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 324, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 304, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 292, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Include-All Admin Groups SubTLV", + "type": 3, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step10/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..eb5bf14ffa16 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 192, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 172, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 160, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step11/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..faef93aaa73a --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 216, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 196, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 184, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name": "Exclude SRLGs SubTLV", + "type": 5, + "length": 8, + "srlgs": [ + 10, + 40 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step12/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..36987476d779 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step13/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..bb070bcb7533 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_database_opaque.ref @@ -0,0 +1,239 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step14/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..3a6ce2033fc6 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque.ref @@ -0,0 +1,314 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 220, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 200, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 4, + "algorithmId": 129, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque_mismatch.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque_mismatch.ref new file mode 100644 index 000000000000..d0b54440b833 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_database_opaque_mismatch.ref @@ -0,0 +1,79 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 56, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 32, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + }, + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "algotithmId": 129 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 52, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 28, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + }, + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 129 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_route.ref new file mode 100644 index 000000000000..8ce3f507425b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step2/show_ip_route.ref @@ -0,0 +1,168 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "ip":"10.0.1.10", + "afi":"ipv4", + "interfaceName":"eth-rt2-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.40", + "afi":"ipv4", + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceIndex":2, + "interfaceName":"eth-rt2-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.10", + "afi":"ipv4", + "interfaceName":"eth-rt2-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt2-3", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.30", + "afi":"ipv4", + "interfaceName":"eth-rt2-3", + "active":true + }, + { + "fib":true, + "ip":"10.0.4.40", + "afi":"ipv4", + "interfaceName":"eth-rt2-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..882ae46bf167 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 20, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step4/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..4b2e36d8968b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step5/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..4a789a6d4d11 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 236, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 216, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 204, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":28, + "adminGroups":[ + "red", + "yellow" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step6/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..64e0d5010dd2 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step7/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..a0c8c0a6f2bd --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name": "Include-Any Admin Groups SubTLV", + "type": 2, + "length": 128, + "adminGroups": [ + "green", + "yellow", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step8/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..4ec46e26a427 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_database_opaque.ref @@ -0,0 +1,295 @@ +{ + "routerId": "2.2.2.2", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 80, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 60, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 48, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/step9/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt2/zebra.conf b/tests/topotests/ospf_flexalgo_topo1/rt2/zebra.conf new file mode 100644 index 000000000000..b7da84ea7978 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt2/zebra.conf @@ -0,0 +1,24 @@ +log file zebra.log +! +hostname rt2 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 2.2.2.2/32 +! +interface eth-rt2-1 + ip address 10.0.1.20/24 +! +interface eth-rt2-2 + ip address 10.0.4.20/24 +! +interface eth-rt2-3 + ip address 10.0.3.20/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd.conf b/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd.conf new file mode 100644 index 000000000000..a53f0217fbfa --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd.conf @@ -0,0 +1,30 @@ +password 1 +hostname rt3 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt3-1 + ip ospf area 0.0.0.0 +! +interface eth-rt3-2 + ip ospf area 0.0.0.0 +! +interface eth-rt3-3 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 3.3.3.3 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd_flxalg.conf b/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd_flxalg.conf new file mode 100644 index 000000000000..53619943bc8f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/ospfd_flxalg.conf @@ -0,0 +1,35 @@ +password 1 +hostname rt3 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +affinity-map red bit-position 0 +affinity-map green bit-position 100 +affinity-map blue bit-position 1000 +affinity-map yellow bit-position 200 +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt3-1 + ip ospf area 0.0.0.0 +! +interface eth-rt3-2 + ip ospf area 0.0.0.0 +! +interface eth-rt3-3 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 3.3.3.3 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..9eac622c837e --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_route.ref new file mode 100644 index 000000000000..b84ab3826f0f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step1/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "ip":"10.0.2.10", + "afi":"ipv4", + "interfaceName":"eth-rt3-1", + "active":true + } + ] + } + ], + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.40", + "afi":"ipv4", + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.10", + "afi":"ipv4", + "interfaceName":"eth-rt3-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-1", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.40", + "afi":"ipv4", + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..bf206a77e47c --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 324, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 304, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 292, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Include-All Admin Groups SubTLV", + "type": 3, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step10/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..3a36343764ea --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 192, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 172, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 160, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step11/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..911e658c1b6c --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 216, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 196, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 184, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name": "Exclude SRLGs SubTLV", + "type": 5, + "length": 8, + "srlgs": [ + 10, + 40 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step12/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..e393e4db35ca --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step13/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..92ba0c4a5e99 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_database_opaque.ref @@ -0,0 +1,239 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step14/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..f95f4fbf3fd9 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque.ref @@ -0,0 +1,314 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 220, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 200, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 4, + "algorithmId": 129, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque_mismatch.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque_mismatch.ref new file mode 100644 index 000000000000..114cde4f5ad6 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_database_opaque_mismatch.ref @@ -0,0 +1,79 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 56, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 32, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + }, + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "algotithmId": 129 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 52, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 28, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + }, + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 129 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_route.ref new file mode 100644 index 000000000000..b84ab3826f0f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step2/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "ip":"10.0.2.10", + "afi":"ipv4", + "interfaceName":"eth-rt3-1", + "active":true + } + ] + } + ], + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "prefixLen":32, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.40", + "afi":"ipv4", + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "nexthops":[ + { + "fib":true, + "ip":"10.0.2.10", + "afi":"ipv4", + "interfaceName":"eth-rt3-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-1", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-3", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "prefixLen":24, + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.3.20", + "afi":"ipv4", + "interfaceName":"eth-rt3-3", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.40", + "afi":"ipv4", + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "prefixLen":24, + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt3-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..a3031a65bc76 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 20, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step4/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..5b22dd8bc166 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step5/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..d82ad938336f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 236, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 216, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 204, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":28, + "adminGroups":[ + "red", + "yellow" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step6/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..fa8135824e2f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step7/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..d8596cff0d89 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name": "Include-Any Admin Groups SubTLV", + "type": 2, + "length": 128, + "adminGroups": [ + "green", + "yellow", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step8/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..fe280b38f67a --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_database_opaque.ref @@ -0,0 +1,295 @@ +{ + "routerId": "3.3.3.3", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 80, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 60, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 48, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..204ef22e1611 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/step9/show_ip_ospf_flexalgo.ref @@ -0,0 +1 @@ + No Flexible-Algoritthms on this router diff --git a/tests/topotests/ospf_flexalgo_topo1/rt3/zebra.conf b/tests/topotests/ospf_flexalgo_topo1/rt3/zebra.conf new file mode 100644 index 000000000000..8e8bf470c5f1 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt3/zebra.conf @@ -0,0 +1,24 @@ +log file zebra.log +! +hostname rt3 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 3.3.3.3/32 +! +interface eth-rt3-1 + ip address 10.0.2.30/24 +! +interface eth-rt3-2 + ip address 10.0.5.30/24 +! +interface eth-rt3-3 + ip address 10.0.3.30/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd.conf b/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd.conf new file mode 100644 index 000000000000..ae9455887477 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd.conf @@ -0,0 +1,31 @@ +password 1 +hostname rt4 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +affinity-map red bit-position 0 +affinity-map green bit-position 100 +affinity-map blue bit-position 1000 +affinity-map yellow bit-position 200 +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt4-1 + ip ospf area 0.0.0.0 +! +interface eth-rt4-2 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 4.4.4.4 + capability opaque + router-info area 0.0.0.0 +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd_flxalg.conf b/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd_flxalg.conf new file mode 100644 index 000000000000..2e74766caf50 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/ospfd_flxalg.conf @@ -0,0 +1,41 @@ +password 1 +hostname rt4 +log file ospfd.log +log syslog debugging +! +debug ospf sr +! debug ospf te +! debug ospf event +! debug ospf lsa +debug ospf lsa generate +! debug ospf zebra +! +affinity-map red bit-position 0 +affinity-map green bit-position 100 +affinity-map blue bit-position 1000 +affinity-map yellow bit-position 200 +! +interface lo + ip ospf area 0.0.0.0 + ip ospf passive +! +interface eth-rt4-1 + ip ospf area 0.0.0.0 +! +interface eth-rt4-2 + ip ospf area 0.0.0.0 +! +router ospf + ospf router-id 4.4.4.4 + capability opaque + router-info area 0.0.0.0 + flexible-algorithm 128 + flexible-algorithm 128 priority 10 + flexible-algorithm 128 exclude-admin-group red + flexible-algorithm 128 include-all-admin-group green + flexible-algorithm 128 include-any-admin-group green + flexible-algorithm 128 include-any-admin-group blue + flexible-algorithm 128 exclude-srlg 10 + flexible-algorithm 128 advertise-prefix-metric 10 + passive-interface lo +! diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..554483b8f758 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..c34331e05b62 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_route.ref new file mode 100644 index 000000000000..fa213de304a5 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step1/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..394f070a7237 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 324, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 304, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 292, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Include-All Admin Groups SubTLV", + "type": 3, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step10/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..a0f8a42c6998 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 192, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 172, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 160, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step11/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..4a70b5a9ec38 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 216, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 196, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 184, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name": "Exclude SRLGs SubTLV", + "type": 5, + "length": 8, + "srlgs": [ + 10, + 40 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step12/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..204990ab755b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step13/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..365552abd8ca --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_database_opaque.ref @@ -0,0 +1,239 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..7952c8bb7730 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step14/show_ip_ospf_flexalgo.ref @@ -0,0 +1,16 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x00 + Advt-Prefix-Metric: N + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..3c77a8c93690 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque.ref @@ -0,0 +1,314 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 220, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 200, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 4, + "algorithmId": 129, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque_mismatch.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque_mismatch.ref new file mode 100644 index 000000000000..6904e63cc55b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_database_opaque_mismatch.ref @@ -0,0 +1,79 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 56, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 32, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + }, + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "algotithmId": 129 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 52, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 28, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + }, + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 129 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..d253f6e3ec5f --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_ospf_flexalgo.ref @@ -0,0 +1,24 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 + Flexible-Algorithm: 129 + Metric-Type: igp + Calculation-Type: spf + Priority: 128 + Flags: 0x00 + Advt-Prefix-Metric: N + \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_route.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_route.ref new file mode 100644 index 000000000000..fa213de304a5 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step2/show_ip_route.ref @@ -0,0 +1,166 @@ +{ + "1.1.1.1\/32":[ + { + "prefix":"1.1.1.1\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.4.20", + "afi":"ipv4", + "interfaceName":"eth-rt4-1", + "active":true + }, + { + "fib":true, + "ip":"10.0.5.30", + "afi":"ipv4", + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt4-1", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "directlyConnected":true, + "interfaceName":"eth-rt4-2", + "active":true + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..ab3034fdc19c --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 20, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step4/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..acba90ed80d7 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_database_opaque.ref @@ -0,0 +1,304 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 128, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2ae54ea1078e --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step5/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..3282d6e32e6e --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 236, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 216, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 204, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":28, + "adminGroups":[ + "red", + "yellow" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step6/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..2f7259bbf3a8 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_database_opaque.ref @@ -0,0 +1,296 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 204, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 184, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 172, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step7/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..2a3bcbd6d767 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_database_opaque.ref @@ -0,0 +1,305 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name": "Include-Any Admin Groups SubTLV", + "type": 2, + "length": 128, + "adminGroups": [ + "green", + "yellow", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step8/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_database_opaque.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_database_opaque.ref new file mode 100644 index 000000000000..9e9b565913a9 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_database_opaque.ref @@ -0,0 +1,295 @@ +{ + "routerId": "4.4.4.4", + "areaLocalOpaqueLsa": { + "areas": { + "0.0.0.0": [ + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 80, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 60, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 48, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "2.2.2.2", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "3.3.3.3", + "length": 28, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 8, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "4.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 212, + "opaqueType": "Router Information LSA", + "opaqueId": 0, + "opaqueDataLength": 192, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Router Capabilities TLV", + "type": 1, + "length": 4, + "capabilities": "0x10000000" + }, + { + "name": "Flexible Algorithm Defintion TLV", + "type": 16, + "length": 180, + "algorithmId": 128, + "priority": 10, + "metricType": "igp", + "caculationType": "spf", + "subTLVs": [ + { + "name":"Exclude Admin Groups SubTLV", + "type":1, + "length":4, + "adminGroups":[ + "red" + ] + }, + { + "name":"Include-Any Admin Groups SubTLV", + "type":2, + "length":128, + "adminGroups":[ + "green", + "blue" + ] + }, + { + "name":"Include-All Admin Groups SubTLV", + "type":3, + "length":16, + "adminGroups":[ + "green" + ] + }, + { + "name": "Flexible-Algo Flags SubTLV", + "type": 4, + "length": 4, + "flags": [ 2147483648 ] + }, + { + "name":"Exclude SRLGs SubTLV", + "type":5, + "length":4, + "srlgs":[ + 10 + ] + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "1.1.1.1", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "1.1.1.1", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "7.0.0.1", + "advertisingRouter": "4.4.4.4", + "length": 44, + "opaqueType": "Extended Prefix Opaque LSA", + "opaqueId": 1, + "opaqueDataLength": 24, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Prefix TLV", + "type": 1, + "length": 20, + "prefixAddress": "4.4.4.4", + "prefixLength": 32, + "routeType": 1, + "addressFamily": 0, + "subTLVs": [ + { + "name": "Flex-Algo Prefix Metric (FAPM) SubTLV", + "type": 3, + "length": 8, + "algotithmId": 128, + "flags": 0, + "metric": 10 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "1.1.1.1", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [ + { + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "1.1.1.1", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 100 + } + ] + } + ] + }, + { + "options": "*|O|-|-|-|-|E|-", + "lsaType": "Area-Local Opaque-LSA", + "linkStateId": "11.0.0.0", + "advertisingRouter": "4.4.4.4", + "length": 40, + "opaqueType": "Extended Inter-Area ASBR Opaque LSA", + "opaqueId": 0, + "opaqueDataLength": 20, + "opaqueDataLengthValid": true, + "tlvs": [{ + "name": "Extended Inter-Area ASBR TLV", + "type": 1, + "length": 16, + "asbrRouterId": "4.4.4.4", + "subTLVs": [ + { + "name": "Flex-Algo ASBR Metric (FAAM) SubTLV", + "type": 1, + "length": 8, + "algorithmId": 128, + "metric": 10 + } + ] + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_flexalgo.ref b/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_flexalgo.ref new file mode 100644 index 000000000000..2f1f20ed909b --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/step9/show_ip_ospf_flexalgo.ref @@ -0,0 +1,17 @@ +--- Flexible-Algorithm parameters --- + Flexible-Algorithm: 128 + Metric-Type: igp + Calculation-Type: spf + Priority: 10 + Flags: 0x80 + Advt-Prefix-Metric: Y + Prefix-Metric: 10 + Exclude-Admin-Groups: + - red(0) + Include-Any-Admin-Groups: + - green(100) + - blue(1000) + Include-All-Admin-Groups: + - green(100) + Exclude-SRLGs: + - 10 diff --git a/tests/topotests/ospf_flexalgo_topo1/rt4/zebra.conf b/tests/topotests/ospf_flexalgo_topo1/rt4/zebra.conf new file mode 100644 index 000000000000..d2e36cf4df74 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/rt4/zebra.conf @@ -0,0 +1,21 @@ +log file zebra.log +! +hostname rt4 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 4.4.4.4/32 +! +interface eth-rt4-1 + ip address 10.0.4.40/24 +! +interface eth-rt4-2 + ip address 10.0.5.40/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/ospf_flexalgo_topo1/test_ospf_flexalgo_topo1.py b/tests/topotests/ospf_flexalgo_topo1/test_ospf_flexalgo_topo1.py new file mode 100644 index 000000000000..472b89df7998 --- /dev/null +++ b/tests/topotests/ospf_flexalgo_topo1/test_ospf_flexalgo_topo1.py @@ -0,0 +1,1663 @@ +#!/usr/bin/python + +# +# Copyright (c) 2021 by VMware, Inc. ("VMware") +# Used Copyright (c) 2018 by Network Device Education Foundation, +# Inc. ("NetDEF") in this file. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +test_ospf_flexalgo_topo1.py: + + +---------+ + eth-rt1-1| |eth-rt1-2 + +----------+ 1.1.1.1 +-----------+ + | | RT1 | | + | | | | + | +---------+ | + 10.0.1.0/24| |10.0.2.0/24 + | | + eth-rt2-1| |eth-rt3-1 + +---------+ +---------+ + | | | | + | RT2 | 10.0.3.0/24 | RT3 | + | 2.2.2.2 +---------------------+ 3.3.3.3 | + | |eth-rt2-3 eth-rt3-3| | + +---------+ +---------+ + eth-rt2-2| |eth-rt3-2 + | | + 10.0.4.0/24| |10.0.5.0/24 + | +---------+ | + | | | | + | | RT4 | | + +----------+ 4.4.4.4 +-----------+ + eth-rt4-1| |eth-rt4-2 + +---------+ +""" + +import os +import sys +import pytest +import json +from functools import partial +from time import sleep + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger + +from lib.common_config import ( + start_topology, + write_test_footer, + step, + start_router, + apply_raw_config, +) + +# Required to instantiate the topology builder class. + +pytestmark = [pytest.mark.ospfd] + + +def build_topo(tgen): + "Build function" + + # + # Define FRR Routers + # + for router in ["rt1", "rt2", "rt3", "rt4"]: + tgen.add_router(router) + + # + # Define connections + # + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt1-1") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt2-1") + + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt1-2") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt3-1") + + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt2-2") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt4-1") + + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt3-2") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt4-2") + + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt2-3") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt3-3") + + +def setup_module(mod): + "Sets up the pytest environment" + tgen = Topogen(build_topo, mod.__name__) + tgen.start_topology() + + router_list = tgen.routers() + + # For all registered routers, load the zebra configuration file + for rname, router in router_list.items(): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + # TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname)) + TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd_flxalg.conf".format(rname)) + ) + + tgen.start_router() + + +def teardown_module(mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def print_cmd_result(rname, command): + print(get_topogen().gears[rname].vtysh_cmd(command, isjson=False)) + + +def router_compare_json_output(rname, command, reference, check_for_mismatch = False): + "Compare router JSON output" + + logger.info('Comparing router "%s" "%s" output', rname, command) + + tgen = get_topogen() + filename = "{}/{}/{}".format(CWD, rname, reference) + expected = json.loads(open(filename).read()) + + # Run test function until we get an result. Wait at most 60 seconds. + test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected) + if check_for_mismatch : + diff = None + for count in range(1,10): + _, diff = topotest.run_and_expect(test_func, None, count=5, wait=1) + if diff is not None: + # if there's some diff we have achieved the desired condition + break + # Else retry few more times + #if still there's no diff, then the desired condition failed + if diff is None: + assertmsg = '"{}" JSON output matches the not-to-be expected result'.format(rname) + logger.info('Not-to-be-Expected result:\n========\n{}\n=========='.format(expected)) + logger.info('Actual result:\n========\n{}\n========'.format(tgen.gears[rname].vtysh_cmd(command))) + assert False, assertmsg + else : + _, diff = topotest.run_and_expect(test_func, None, count=60, wait=1) + if diff is not None: + assertmsg = '"{}" JSON output mismatches the expected result, Diff:\n{}\n'.format(rname, diff) + logger.info('Expected result:\n========\n{}\n=========='.format(expected)) + logger.info('Actual result:\n========\n{}\n========'.format(tgen.gears[rname].vtysh_cmd(command))) + assert False, assertmsg + +def router_compare_text_output(rname, command, reference, check_for_mismatch = False): + "Compare router JSON output" + + logger.info('Comparing router "%s" "%s" output', rname, command) + + tgen = get_topogen() + filename = "{}/{}/{}".format(CWD, rname, reference) + expected = open(filename).read() + + # Run test function until we get an result. Wait at most 80 seconds. + test_func = partial( + topotest.router_output_cmp, tgen.gears[rname], command, expected + ) + if check_for_mismatch : + result = None + for count in range(1,10): + result, diff = topotest.run_and_expect(test_func, None, count=5, wait=1) + if result is not None: + # if there's some diff we have achieved the desired condition + break + # Else retry few more times + #if still there's no diff, then the desired condition failed + if result is None: + assertmsg = '"{}" Text output matches the not-to-be expected result:\n'.format(rname) + logger.info('Not-to-be-Expected result:\n========\n{}\n=========='.format(expected)) + logger.info('Actual result:\n========\n{}\n========'.format(tgen.gears[rname].vtysh_cmd(command))) + assert False, assertmsg + else : + result, diff = topotest.run_and_expect(test_func, "", count=3, wait=3.5) + if not result: + assertmsg = '"{}" Text output mismatches the expected result. Diff:\n {}\n'.format(rname, diff) + logger.info('Expected result:\n========\n{}\n=========='.format(expected)) + logger.info('Actual result:\n========\n{}\n========'.format(tgen.gears[rname].vtysh_cmd(command))) + assert False, assertmsg + +""" +Step 1 + +Test initial network convergence +""" +def test_rib_step1(request): + tgen = get_topogen() + tc_name = request.node.name + + step("Verify initial RIB") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_json_output( + rname, "show ip route ospf json", + "step1/show_ip_route.ref" + ) + + write_test_footer(tc_name) + + +def test_opaque_lsa_step1(request): + tgen = get_topogen() + + tc_name = request.node.name + step("Verify OSPF Opaque LSA advertisemenst for Flex-Algorithms") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + + +""" + Step 2 + + Action(s): + -Add another flexible-algo on rt4 with default configurations + + Expected changes: + -rt4 should advertise an additional FAD TLV in the RI-LSA with + following attributes and values + -- metric-type: igp + -- calculation-type: spf + -- priority: 0 + - rt4 should not advertise any additional FAPM or FAAM subTLVs + for algorithm 129. + + Action(s): + -Try deleting the flexible-algo on rt4 that was added in step 2 + + Expected changes: + -rt4 should remove Flex-Algo with id 129. + -rt2 MUST NOT advertise any FAD TLV in the RI-LSA or any + FAPM or FAAM subTLVs for algo 129. +""" +def test_flex_algo_default_add_step2(request): + tgen = get_topogen() + + tc_name = request.node.name + step("Add another flex-algo with defaults on rt4") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + raw_config = { + "rt4": { + "raw_config": [ + "router ospf", + "flexible-algorithm 129" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step2/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step2/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step2/show_ip_ospf_database_opaque_mismatch.ref", + check_for_mismatch=True + ) + + step("Try deleting flex-algo with algorithm Id 129 on rt4") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + raw_config = { + "rt4": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 129" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete Flex-Algo 129!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 3 + + Action(s): + -Try adding flexible-algo on rt2 with algo-id outside permitted + range + + Expected changes: + -rt2 should not allow configuration. + -rt2 MUST NOT advertise any FAD TLV in the RI-LSA or any + FAPM or FAAM subTLVs. +""" +def test_flex_algo_id_config_range_step3(request): + tgen = get_topogen() + + tc_name = request.node.name + step("Try adding flex-algo with invalid algorithm Id on rt2") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + raw_config = { + "rt2": { + "raw_config": [ + "router ospf", + "flexible-algorithm 127" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is False, "Testcase {} : Invalid configuration applied successfully!".format(tc_name) + + raw_config = { + "rt2": { + "raw_config": [ + "router ospf", + "flexible-algorithm 256" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is False, "Testcase {} : Invalid configuration applied successfully!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 4 + + Action(s): + -Modify the priority of flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with new priority. + -rt1 MUST advertise the FAD TLV for 128 with new value of priority. +""" +def test_flex_algo_modify_priority_step4(request): + tgen = get_topogen() + + tc_name = request.node.name + step("Try modifying priority of flex-algo with algorithm Id 128 on rt1 to 20") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 priority 20" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to modify priority of Flex-Algo 128 on rt1!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step4/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step4/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 5 + + Action(s): + -Delete the priority of flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with default priority of 0 + -rt1 MUST advertise the FAD TLV for 128 with new value of priority. + + Action(s): + -Restore the original priority of flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with with priority 10. + -rt1 MUST advertise the FAD TLV for 128 with new value of priority. +""" +def test_flex_algo_default_priority_metrictype_calctype_step5(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + step("Try deleting priority of flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 priority" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete priority of Flex-Algo 128 on rt1!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step5/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step5/show_ip_ospf_database_opaque.ref" + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + step("Try deleting metric-type of flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 metric-type" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete metric-type of Flex-Algo 128 on rt1!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step5/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step5/show_ip_ospf_database_opaque.ref" + + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + step("Try deleting calcultation-type of flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 calculation-type" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete calculation-type of Flex-Algo 128 on rt1!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step5/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step5/show_ip_ospf_database_opaque.ref" + + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + step("Try restoring priority of flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 priority 10" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to set priority of Flex-Algo 128 on rt1!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 6 + + Add and delete exclude-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_add_delete_excadmingrp_step6(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add an existing exclude-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should not update the Flex-Algo with any new exclude-admin-group. + -rt1 MUST NOT advertise the FAD TLV for 128 with any new exclude-admin-group + included in the Exclude-Admin-Groups SubTLV. + """ + + step("Try adding same again exclude admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-admin-group red" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add same exclude-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step6/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add a new exclude-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with new exclude-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with new exclude-admin-group + included in the Exclude-Admin-Groups SubTLV. + """ + step("Try adding new exclude admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-admin-group yellow" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add another exclude-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step6/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step6/show_ip_ospf_database_opaque.ref" + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete the newly added exclude-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove the new exclude-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the new exclude-admin-group + included in the Exclude-Admin-Groups SubTLV. + """ + step("Try deleting the new exclude admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 exclude-admin-group yellow" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete exclude-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step6/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step6/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + write_test_footer(tc_name) + +""" + Step 7 + + Add and delete exclude-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_delete_all_excadmingrp_step7(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete all exclude-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove all exclude-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the Exclude-Admin-Groups SubTLV. + """ + step("Try deleting all exclude admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 exclude-admin-group" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete all exclude-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step7/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step7/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add back the original exclude-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with corresponding exclude-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with original exclude-admin-group + included in the Exclude-Admin-Groups SubTLV. + """ + step("Try adding original exclude admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-admin-group red" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add exclude-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 8 + + Add and delete include-any-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_add_delete_incany_admingrp_step8(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add an existing include-any-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should not update the Flex-Algo with any new include-any-admin-group. + -rt1 MUST NOT advertise the FAD TLV for 128 with any new include-any-admin-group + included in the include-any-Admin-Groups SubTLV. + """ + + step("Try adding same again include-any admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-any-admin-group green" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add same include-any-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step8/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add a new include-any-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with new include-any-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with new include-any-admin-group + included in the include-any-Admin-Groups SubTLV. + """ + step("Try adding new include-any admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-any-admin-group yellow" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add another include-any-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step8/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step8/show_ip_ospf_database_opaque.ref" + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete the newly added include-any-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove the new include-any-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the new include-any-admin-group + included in the include-any-Admin-Groups SubTLV. + """ + step("Try deleting the new include-any admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 include-any-admin-group yellow" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete include-any-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step8/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step8/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + write_test_footer(tc_name) + +""" + Step 9 + + Add and delete include-all-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_delete_any_incany_admingrp_step9(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete all include-any-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove all include-any-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the include-any-Admin-Groups SubTLV. + """ + step("Try deleting all include-any admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 include-any-admin-group" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete all include-any-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step9/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step9/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add back the original include-any-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with corresponding include-any-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with original include-any-admin-group + included in the include-any-Admin-Groups SubTLV. + """ + step("Try adding original include-any admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-any-admin-group green", + "flexible-algorithm 128 include-any-admin-group blue", + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add include-any-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 10 + + Add and delete include-all-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_add_delete_incall_admingrp_step10(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add an existing include-all-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should not update the Flex-Algo with any new include-all-admin-group. + -rt1 MUST NOT advertise the FAD TLV for 128 with any new include-all-admin-group + included in the include-all-Admin-Groups SubTLV. + """ + + step("Try adding same again include-all admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-all-admin-group green" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add same include-all-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step10/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add a new include-all-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with new include-all-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with new include-all-admin-group + included in the include-all-Admin-Groups SubTLV. + """ + step("Try adding new include-all admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-all-admin-group blue" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add another include-all-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step10/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step10/show_ip_ospf_database_opaque.ref" + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete the newly added include-all-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove the new include-all-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the new include-all-admin-group + included in the include-all-Admin-Groups SubTLV. + """ + step("Try deleting the new include-all admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 include-all-admin-group blue" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete include-all-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step10/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step10/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + write_test_footer(tc_name) + +""" + Step 11 + + Add and delete include-all-admin-group to flexible-algo 128 on rt1 +""" +def test_flex_algo_delete_all_incall_admingrp_step11(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete all include-all-admin-group from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove all include-all-admin-group from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the include-all-Admin-Groups SubTLV. + """ + step("Try deleting all include-all admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 include-all-admin-group" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete all include-all-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step11/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step11/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add back the original include-all-admin-group to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with corresponding include-all-admin-group. + -rt1 MUST advertise the FAD TLV for 128 with original include-all-admin-group + included in the include-all-Admin-Groups SubTLV. + """ + step("Try adding original include-all admin-group for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 include-all-admin-group green" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add include-all-admin-group of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 12 + + Add and delete exclude-srlg to flexible-algo 128 on rt1 +""" +def test_flex_algo_add_delete_exc_srlg_step12(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add an existing exclude-srlg to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should not update the Flex-Algo with any new exclude-srlg. + -rt1 MUST NOT advertise the FAD TLV for 128 with any new exclude-srlg + included in the Exclude-SRLGs SubTLV. + """ + + step("Try adding same again exclude srlg for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-srlg 10" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add same exclude-srlg of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step12/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add a new exclude-srlg to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with new exclude-srlg. + -rt1 MUST advertise the FAD TLV for 128 with new exclude-srlg + included in the Exclude-SRLGs SubTLV. + """ + step("Try adding new exclude srlg for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-srlg 40" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add another exclude-srlg of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step12/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step12/show_ip_ospf_database_opaque.ref" + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete the newly added exclude-srlg from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove the new exclude-srlg from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the new exclude-srlg + included in the Exclude-SRLGs SubTLV. + """ + step("Try deleting the new exclude srlg for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 exclude-srlg 40" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete exclude-srlg of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step12/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step12/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + write_test_footer(tc_name) + +""" + Step 13 + + Add and delete exclude-srlg to flexible-algo 128 on rt1 +""" +def test_flex_algo_delete_all_exc_srlg_step13(request): + tgen = get_topogen() + + tc_name = request.node.name + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Delete all exclude-srlg from flexible-algo 128 on rt1 + + Expected changes: + -rt1 should remove all exclude-srlg from the Flex-Algo. + -rt1 MUST advertise the FAD TLV for 128 without the Exclude-SRLGs SubTLV. + """ + step("Try deleting all exclude srlg for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no flexible-algorithm 128 exclude-srlg" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete all exclude-srlg of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step13/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref", check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step13/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + """ + Action(s): + -Add back the original exclude-srlg to flexible-algo 128 on rt1 + + Expected changes: + -rt1 should update the Flex-Algo with corresponding exclude-srlg. + -rt1 MUST advertise the FAD TLV for 128 with original exclude-srlg + included in the Exclude-SRLGs SubTLV. + """ + step("Try adding original exclude srlg for flex-algo with algorithm Id 128 on rt1") + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 exclude-srlg 10" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to add exclude-srlg of Flex-Algo 128 on rt1 again!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +""" + Step 14 +""" +def test_flex_algo_delete_prefix_advt_metric_step14(request): + tgen = get_topogen() + + tc_name = request.node.name + + """ + Action(s): + -Delete the advertise-prefix-metric of flexible-algo 128 on rt4 + + Expected changes: + -rt4 should remove Ext-Prefix LSA and Ext-IASBR LSA for the Flex Algo 128. + """ + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + step("Try deleting advertise-prefix-metric of flex-algo with algorithm Id 128 on rt4") + # But set the LSA Maxage timer to a much shorter interval for verification + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "ospf maxage-delay 1", + ] + }, + "rt2": { + "raw_config": [ + "router ospf", + "ospf maxage-delay 1", + ] + }, + "rt3": { + "raw_config": [ + "router ospf", + "ospf maxage-delay 1", + ] + }, + "rt4": { + "raw_config": [ + "router ospf", + "ospf maxage-delay 1", + ] + } + } + result = apply_raw_config(tgen, raw_config) + + raw_config = { + "rt4": { + "raw_config": [ + "router ospf", + "ospf maxage-delay 1", + "no flexible-algorithm 128 advertise-prefix-metric" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to delete advertise-prefix-metric of Flex-Algo 128 on rt4!".format(tc_name) + + # LSA deletion will take upto few seconds. So let's wait for it. + topotest.sleep(2) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step14/show_ip_ospf_flexalgo.ref" + ) + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref", + check_for_mismatch=True + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step14/show_ip_ospf_database_opaque.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref", + check_for_mismatch=True + ) + + # Revert back the LSA Maxage timer to default + raw_config = { + "rt1": { + "raw_config": [ + "router ospf", + "no ospf maxage-delay", + ] + }, + "rt2": { + "raw_config": [ + "router ospf", + "no ospf maxage-delay", + ] + }, + "rt3": { + "raw_config": [ + "router ospf", + "no ospf maxage-delay", + ] + }, + "rt4": { + "raw_config": [ + "router ospf", + "no ospf maxage-delay", + ] + } + } + result = apply_raw_config(tgen, raw_config) + + """ + Action(s): + -Modify the advertise-prefix-metric of flexible-algo 128 on rt4 + + Expected changes: + -rt1 should update the Flex-Algo with new advertise-metric. + -rt1 MUST advertise the FAPM and FAAM (in a new Ext-IASBR LSA) + subTLVs for 128 with new value. + """ + step("Try restoring advertise-prefix-metric of flex-algo with algorithm Id 128 on rt4") + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + raw_config = { + "rt4": { + "raw_config": [ + "router ospf", + "flexible-algorithm 128 advertise-prefix-metric 10" + ] + } + } + + result = apply_raw_config(tgen, raw_config) + assert result is True, "Testcase {} : Failed to set advertise-prefix-metric of Flex-Algo 128 on rt4!".format(tc_name) + + for rname in ["rt1", "rt2", "rt3", "rt4"]: + router_compare_text_output( + rname, "show ip ospf router-info flexible-algorithms", + "step1/show_ip_ospf_flexalgo.ref" + ) + router_compare_json_output( + rname, "show ip ospf database opaque-area json", + "step1/show_ip_ospf_database_opaque.ref" + ) + + write_test_footer(tc_name) + +# Memory leak test template +def test_memory_leak(): + "Run the memory leak test and report results." + tgen = get_topogen() + if not tgen.is_memleak_enabled(): + pytest.skip("Memory leak test/report is disabled") + + tgen.report_memory_leaks() + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args))