summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_snmp_bgp4v2.c717
-rw-r--r--bgpd/bgp_snmp_bgp4v2.h5
-rw-r--r--bgpd/bgp_vty.c132
-rw-r--r--bgpd/bgp_vty.h16
-rw-r--r--ospf6d/ospf6_nssa.c48
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py118
6 files changed, 952 insertions, 84 deletions
diff --git a/bgpd/bgp_snmp_bgp4v2.c b/bgpd/bgp_snmp_bgp4v2.c
index 1be28e0b2d..9c91a30804 100644
--- a/bgpd/bgp_snmp_bgp4v2.c
+++ b/bgpd/bgp_snmp_bgp4v2.c
@@ -380,6 +380,397 @@ static uint8_t *bgpv2PeerErrorsTable(struct variable *v, oid name[],
return NULL;
}
+static uint8_t *bgpv2PeerEventTimesTable(struct variable *v, oid name[],
+ size_t *length, int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct peer *peer;
+ struct ipaddr addr = {};
+
+ if (smux_header_table(v, name, length, exact, var_len, write_method) ==
+ MATCH_FAILED)
+ return NULL;
+
+ peer = bgpv2PeerTable_lookup(v, name, length, exact, &addr);
+ if (!peer)
+ return NULL;
+
+ switch (v->magic) {
+ case BGP4V2_PEER_FSM_ESTABLISHED_TIME:
+ if (!peer->uptime)
+ return SNMP_INTEGER(0);
+ else
+ return SNMP_INTEGER(monotime(NULL) - peer->uptime);
+ case BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME:
+ if (!peer->update_time)
+ return SNMP_INTEGER(0);
+ else
+ return SNMP_INTEGER(monotime(NULL) - peer->update_time);
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+static struct bgp_path_info *
+bgp4v2PathAttrLookup(struct variable *v, oid name[], size_t *length,
+ struct bgp *bgp, struct prefix *addr, int exact)
+{
+ oid *offset;
+ int offsetlen;
+ struct bgp_path_info *path;
+ struct bgp_dest *dest;
+ union sockunion su;
+ unsigned int len;
+ struct ipaddr paddr = {};
+ size_t namelen = v ? v->namelen : BGP4V2_NLRI_ENTRY_OFFSET;
+ sa_family_t family = name[namelen - 1] == 4 ? AF_INET : AF_INET6;
+ afi_t afi = AFI_IP;
+ size_t afi_len = IN_ADDR_SIZE;
+
+ if (family == AF_INET6) {
+ afi = AFI_IP6;
+ afi_len = IN6_ADDR_SIZE;
+ }
+
+#define BGP_NLRI_ENTRY_OFFSET (afi_len + 1 + afi_len)
+
+ sockunion_init(&su);
+
+ if (exact) {
+ if (*length - v->namelen != BGP_NLRI_ENTRY_OFFSET)
+ return NULL;
+
+ /* Set OID offset for prefix */
+ offset = name + v->namelen;
+ if (family == AF_INET)
+ oid2in_addr(offset, afi_len, &addr->u.prefix4);
+ else
+ oid2in6_addr(offset, &addr->u.prefix6);
+ offset += afi_len;
+
+ /* Prefix length */
+ addr->prefixlen = *offset;
+ addr->family = family;
+ offset++;
+
+ /* Peer address */
+ su.sin.sin_family = family;
+ if (family == AF_INET)
+ oid2in_addr(offset, afi_len, &su.sin.sin_addr);
+ else
+ oid2in6_addr(offset, &su.sin6.sin6_addr);
+
+ /* Lookup node */
+ dest = bgp_node_lookup(bgp->rib[afi][SAFI_UNICAST], addr);
+ if (dest) {
+ for (path = bgp_dest_get_bgp_path_info(dest); path;
+ path = path->next)
+ if (sockunion_same(&path->peer->su, &su))
+ return path;
+
+ bgp_dest_unlock_node(dest);
+ }
+
+ return NULL;
+ }
+
+ offset = name + v->namelen;
+ offsetlen = *length - v->namelen;
+ len = offsetlen;
+
+ if (offsetlen == 0) {
+ dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]);
+ } else {
+ if (len > afi_len)
+ len = afi_len;
+
+ if (family == AF_INET)
+ oid2in_addr(offset, len, &addr->u.prefix4);
+ else
+ oid2in6_addr(offset, &addr->u.prefix6);
+
+ offset += afi_len;
+ offsetlen -= afi_len;
+
+ if (offsetlen > 0)
+ addr->prefixlen = *offset;
+ else
+ addr->prefixlen = len * 8;
+
+ dest = bgp_node_get(bgp->rib[afi][SAFI_UNICAST], addr);
+
+ offset++;
+ offsetlen--;
+ }
+
+ if (offsetlen > 0) {
+ len = offsetlen;
+ if (len > afi_len)
+ len = afi_len;
+
+ if (family == AF_INET)
+ oid2in_addr(offset, len, &paddr.ip._v4_addr);
+ else
+ oid2in6_addr(offset, &paddr.ip._v6_addr);
+ } else {
+ if (family == AF_INET)
+ memset(&paddr.ip._v4_addr, 0, afi_len);
+ else
+ memset(&paddr.ip._v6_addr, 0, afi_len);
+ }
+
+ if (!dest)
+ return NULL;
+
+ while ((dest = bgp_route_next(dest))) {
+ struct bgp_path_info *min = NULL;
+
+ for (path = bgp_dest_get_bgp_path_info(dest); path;
+ path = path->next) {
+ sa_family_t path_family =
+ sockunion_family(&path->peer->su);
+
+ if (path_family == AF_INET &&
+ IPV4_ADDR_CMP(&paddr.ip._v4_addr,
+ &path->peer->su.sin.sin_addr) < 0) {
+ if (!min ||
+ (min &&
+ IPV4_ADDR_CMP(
+ &path->peer->su.sin.sin_addr,
+ &min->peer->su.sin.sin_addr) < 0))
+ min = path;
+ } else if (path_family == AF_INET6 &&
+ IPV6_ADDR_CMP(
+ &paddr.ip._v6_addr,
+ &path->peer->su.sin6.sin6_addr) <
+ 0) {
+ if (!min ||
+ (min &&
+ IPV6_ADDR_CMP(
+ &path->peer->su.sin6.sin6_addr,
+ &min->peer->su.sin6.sin6_addr) <
+ 0))
+ min = path;
+ }
+ }
+
+ if (min) {
+ const struct prefix *rn_p = bgp_dest_get_prefix(dest);
+
+ *length = v->namelen + BGP_NLRI_ENTRY_OFFSET;
+
+ offset = name + v->namelen;
+
+ if (family == AF_INET)
+ oid_copy_in_addr(offset, &rn_p->u.prefix4);
+ else
+ oid_copy_in6_addr(offset, &rn_p->u.prefix6);
+
+ offset += afi_len;
+ *offset = rn_p->prefixlen;
+ offset++;
+
+ if (family == AF_INET) {
+ oid_copy_in_addr(offset,
+ &min->peer->su.sin.sin_addr);
+ addr->u.prefix4 = rn_p->u.prefix4;
+ } else {
+ oid_copy_in6_addr(
+ offset, &min->peer->su.sin6.sin6_addr);
+ addr->u.prefix6 = rn_p->u.prefix6;
+ }
+
+ addr->prefixlen = rn_p->prefixlen;
+
+ bgp_dest_unlock_node(dest);
+
+ return min;
+ }
+
+ if (family == AF_INET)
+ memset(&paddr.ip._v4_addr, 0, afi_len);
+ else
+ memset(&paddr.ip._v6_addr, 0, afi_len);
+ }
+
+ return NULL;
+}
+
+static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
+ size_t *length, int exact, size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct bgp *bgp;
+ struct bgp_path_info *path;
+ struct peer_af *paf = NULL;
+ struct prefix addr = {};
+ const struct prefix *prefix = NULL;
+ enum bgp_af_index index;
+
+ bgp = bgp_get_default();
+ if (!bgp)
+ return NULL;
+
+ if (smux_header_table(v, name, length, exact, var_len, write_method) ==
+ MATCH_FAILED)
+ return NULL;
+
+ path = bgp4v2PathAttrLookup(v, name, length, bgp, &addr, exact);
+ if (!path)
+ return NULL;
+
+ prefix = bgp_dest_get_prefix(path->net);
+
+ AF_FOREACH (index) {
+ paf = path->peer->peer_af_array[index];
+ if (paf)
+ break;
+ }
+
+ switch (v->magic) {
+ case BGP4V2_NLRI_INDEX:
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_AFI:
+ if (paf)
+ return SNMP_INTEGER(paf->afi);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_SAFI:
+ if (paf)
+ return SNMP_INTEGER(paf->safi);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_PREFIX_TYPE:
+ if (paf)
+ return SNMP_INTEGER(paf->afi);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_PREFIX:
+ if (prefix->family == AF_INET6)
+ return SNMP_IP6ADDRESS(prefix->u.prefix6);
+ else
+ return SNMP_IPADDRESS(prefix->u.prefix4);
+ case BGP4V2_NLRI_PREFIX_LEN:
+ return SNMP_INTEGER(prefix->prefixlen);
+ case BGP4V2_NLRI_BEST:
+ if (CHECK_FLAG(path->flags, BGP_PATH_SELECTED))
+ return SNMP_INTEGER(1);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_CALC_LOCAL_PREF:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ return SNMP_INTEGER(path->attr->local_pref);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_ORIGIN:
+ switch (path->attr->origin) {
+ case BGP_ORIGIN_IGP:
+ return SNMP_INTEGER(1);
+ case BGP_ORIGIN_EGP:
+ return SNMP_INTEGER(2);
+ case BGP_ORIGIN_INCOMPLETE:
+ return SNMP_INTEGER(3);
+ default:
+ return SNMP_INTEGER(0);
+ }
+ case BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE:
+ switch (path->attr->mp_nexthop_len) {
+ case BGP_ATTR_NHLEN_IPV4:
+ return SNMP_INTEGER(1);
+ case BGP_ATTR_NHLEN_IPV6_GLOBAL:
+ return SNMP_INTEGER(2);
+ case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
+ if (path->attr->mp_nexthop_prefer_global)
+ return SNMP_INTEGER(2);
+ else
+ return SNMP_INTEGER(4);
+ default:
+ return SNMP_INTEGER(1);
+ }
+ case BGP4V2_NLRI_NEXT_HOP_ADDR:
+ switch (path->attr->mp_nexthop_len) {
+ case BGP_ATTR_NHLEN_IPV4:
+ return SNMP_IPADDRESS(path->attr->mp_nexthop_global_in);
+ case BGP_ATTR_NHLEN_IPV6_GLOBAL:
+ return SNMP_IP6ADDRESS(path->attr->mp_nexthop_global);
+ case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
+ if (path->attr->mp_nexthop_prefer_global)
+ return SNMP_IP6ADDRESS(
+ path->attr->mp_nexthop_global);
+ else
+ return SNMP_IP6ADDRESS(
+ path->attr->mp_nexthop_local);
+ default:
+ return SNMP_IPADDRESS(path->attr->nexthop);
+ }
+ break;
+ case BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE:
+ case BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR:
+ /* Not properly defined in specification what should be here. */
+ break;
+ case BGP4V2_NLRI_LOCAL_PREF_PRESENT:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ return SNMP_INTEGER(1);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_LOCAL_PREF:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ return SNMP_INTEGER(path->attr->local_pref);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_MED_PRESENT:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)))
+ return SNMP_INTEGER(1);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_MED:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)))
+ return SNMP_INTEGER(path->attr->local_pref);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_ATOMIC_AGGREGATE:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))
+ return SNMP_INTEGER(1);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_AGGREGATOR_PRESENT:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)))
+ return SNMP_INTEGER(1);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_AGGREGATOR_AS:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)))
+ return SNMP_INTEGER(path->attr->aggregator_as);
+ else
+ return SNMP_INTEGER(0);
+ case BGP4V2_NLRI_AGGREGATOR_ADDR:
+ if (CHECK_FLAG(path->attr->flag,
+ ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)))
+ return SNMP_IPADDRESS(path->attr->aggregator_addr);
+ else
+ return SNMP_IPADDRESS(bgp_empty_addr);
+ case BGP4V2_NLRI_AS_PATH_CALC_LENGTH:
+ return SNMP_INTEGER(path->attr->aspath->segments->length);
+ case BGP4V2_NLRI_AS_PATH:
+ return aspath_snmp_pathseg(path->attr->aspath, var_len);
+ case BGP4V2_NLRI_PATH_ATTR_UNKNOWN:
+ *var_len = 0;
+ return NULL;
+ }
+ return NULL;
+}
+
static struct variable bgpv2_variables[] = {
/* bgp4V2PeerEntry */
{BGP4V2_PEER_INSTANCE,
@@ -671,6 +1062,332 @@ static struct variable bgpv2_variables[] = {
bgpv2PeerErrorsTable,
6,
{1, 3, 1, BGP4V2_PEER_LAST_ERROR_SENT_DATA, 2, 16}},
+ /* bgp4V2PeerEventTimesEntry */
+ {BGP4V2_PEER_FSM_ESTABLISHED_TIME,
+ ASN_UNSIGNED,
+ RONLY,
+ bgpv2PeerEventTimesTable,
+ 6,
+ {1, 4, 1, BGP4V2_PEER_FSM_ESTABLISHED_TIME, 1, 4}},
+ {BGP4V2_PEER_FSM_ESTABLISHED_TIME,
+ ASN_UNSIGNED,
+ RONLY,
+ bgpv2PeerEventTimesTable,
+ 6,
+ {1, 4, 1, BGP4V2_PEER_FSM_ESTABLISHED_TIME, 2, 16}},
+ {BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME,
+ ASN_UNSIGNED,
+ RONLY,
+ bgpv2PeerEventTimesTable,
+ 6,
+ {1, 4, 1, BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME, 1, 4}},
+ {BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME,
+ ASN_UNSIGNED,
+ RONLY,
+ bgpv2PeerEventTimesTable,
+ 6,
+ {1, 4, 1, BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME, 2, 16}},
+ /* bgp4V2NlriTable */
+ {BGP4V2_NLRI_INDEX,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_INDEX, 1, 4}},
+ {BGP4V2_NLRI_INDEX,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_INDEX, 2, 16}},
+ {BGP4V2_NLRI_AFI,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AFI, 1, 4}},
+ {BGP4V2_NLRI_AFI,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AFI, 2, 16}},
+ {BGP4V2_NLRI_SAFI,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_SAFI, 1, 4}},
+ {BGP4V2_NLRI_SAFI,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_SAFI, 2, 16}},
+ {BGP4V2_NLRI_PREFIX_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX_TYPE, 1, 4}},
+ {BGP4V2_NLRI_PREFIX_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX_TYPE, 2, 16}},
+ {BGP4V2_NLRI_PREFIX,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX, 1, 4}},
+ {BGP4V2_NLRI_PREFIX,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX, 2, 16}},
+ {BGP4V2_NLRI_PREFIX_LEN,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX_LEN, 1, 4}},
+ {BGP4V2_NLRI_PREFIX_LEN,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PREFIX_LEN, 2, 16}},
+ {BGP4V2_NLRI_BEST,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_BEST, 1, 4}},
+ {BGP4V2_NLRI_BEST,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_BEST, 2, 16}},
+ {BGP4V2_NLRI_CALC_LOCAL_PREF,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_CALC_LOCAL_PREF, 1, 4}},
+ {BGP4V2_NLRI_CALC_LOCAL_PREF,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_CALC_LOCAL_PREF, 2, 16}},
+ {BGP4V2_NLRI_ORIGIN,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_ORIGIN, 1, 4}},
+ {BGP4V2_NLRI_ORIGIN,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_ORIGIN, 2, 16}},
+ {BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE, 1, 4}},
+ {BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR_TYPE, 2, 16}},
+ {BGP4V2_NLRI_NEXT_HOP_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR, 1, 4}},
+ {BGP4V2_NLRI_NEXT_HOP_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_NEXT_HOP_ADDR, 2, 16}},
+ {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE, 1, 4}},
+ {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR_TYPE, 2, 16}},
+ {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR, 1, 4}},
+ {BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LINK_LOCAL_NEXT_HOP_ADDR, 2, 16}},
+ {BGP4V2_NLRI_LOCAL_PREF_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF_PRESENT, 1, 4}},
+ {BGP4V2_NLRI_LOCAL_PREF_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF_PRESENT, 2, 16}},
+ {BGP4V2_NLRI_LOCAL_PREF,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF, 1, 4}},
+ {BGP4V2_NLRI_LOCAL_PREF,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_LOCAL_PREF, 2, 16}},
+ {BGP4V2_NLRI_MED_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_MED_PRESENT, 1, 4}},
+ {BGP4V2_NLRI_MED_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_MED_PRESENT, 2, 16}},
+ {BGP4V2_NLRI_MED,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_MED, 1, 4}},
+ {BGP4V2_NLRI_MED,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_MED, 2, 16}},
+ {BGP4V2_NLRI_ATOMIC_AGGREGATE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_ATOMIC_AGGREGATE, 1, 4}},
+ {BGP4V2_NLRI_ATOMIC_AGGREGATE,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_ATOMIC_AGGREGATE, 2, 16}},
+ {BGP4V2_NLRI_AGGREGATOR_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_PRESENT, 1, 4}},
+ {BGP4V2_NLRI_AGGREGATOR_PRESENT,
+ ASN_INTEGER,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_PRESENT, 2, 16}},
+ {BGP4V2_NLRI_AGGREGATOR_AS,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_AS, 1, 4}},
+ {BGP4V2_NLRI_AGGREGATOR_AS,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_AS, 2, 16}},
+ {BGP4V2_NLRI_AGGREGATOR_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_ADDR, 1, 4}},
+ {BGP4V2_NLRI_AGGREGATOR_ADDR,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AGGREGATOR_ADDR, 2, 16}},
+ {BGP4V2_NLRI_AS_PATH_CALC_LENGTH,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH_CALC_LENGTH, 1, 4}},
+ {BGP4V2_NLRI_AS_PATH_CALC_LENGTH,
+ ASN_UNSIGNED,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH_CALC_LENGTH, 2, 16}},
+ {BGP4V2_NLRI_AS_PATH_STRING,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH_STRING, 1, 4}},
+ {BGP4V2_NLRI_AS_PATH_STRING,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH_STRING, 2, 16}},
+ {BGP4V2_NLRI_AS_PATH,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH, 1, 4}},
+ {BGP4V2_NLRI_AS_PATH,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_AS_PATH, 2, 16}},
+ {BGP4V2_NLRI_PATH_ATTR_UNKNOWN,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PATH_ATTR_UNKNOWN, 1, 4}},
+ {BGP4V2_NLRI_PATH_ATTR_UNKNOWN,
+ ASN_OCTET_STR,
+ RONLY,
+ bgp4v2PathAttrTable,
+ 6,
+ {1, 9, 1, BGP4V2_NLRI_PATH_ATTR_UNKNOWN, 2, 16}},
};
int bgp_snmp_bgp4v2_init(struct thread_master *tm)
diff --git a/bgpd/bgp_snmp_bgp4v2.h b/bgpd/bgp_snmp_bgp4v2.h
index 6980db9f8d..8b474c3887 100644
--- a/bgpd/bgp_snmp_bgp4v2.h
+++ b/bgpd/bgp_snmp_bgp4v2.h
@@ -61,7 +61,10 @@
#define BGP4V2_PEER_FSM_ESTABLISHED_TIME 1
#define BGP4V2_PEER_PEER_IN_UPDATES_ELAPSED_TIME 2
-/* bgp4V2NlriEntry */
+/* bgp4V2NlriEntry
+ * offset 1.3.6.1.3.5.1.1.9.1.x.(1|2).(4|16) = 13
+ */
+#define BGP4V2_NLRI_ENTRY_OFFSET 13
#define BGP4V2_NLRI_INDEX 1
#define BGP4V2_NLRI_AFI 2
#define BGP4V2_NLRI_SAFI 3
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index e51977f0f0..219362cd04 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -158,9 +158,7 @@ static struct peer_group *listen_range_exists(struct bgp *bgp,
struct prefix *range, int exact);
static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty,
- struct bgp *bgp,
- bool use_json,
- json_object *json);
+ struct bgp *bgp);
static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty,
enum show_type type,
@@ -11856,7 +11854,6 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p,
static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty,
struct peer *p,
- bool use_json,
json_object *json)
{
bool rbit = false;
@@ -11869,7 +11866,7 @@ static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty,
nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV);
}
- if (use_json) {
+ if (json) {
json_object_boolean_add(json, "rBit", rbit);
json_object_boolean_add(json, "nBit", nbit);
} else {
@@ -11880,12 +11877,11 @@ static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty,
static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,
struct peer *peer,
- bool use_json,
json_object *json)
{
const char *mode = "NotApplicable";
- if (!use_json)
+ if (!json)
vty_out(vty, "\n Remote GR Mode: ");
if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV)
@@ -11908,20 +11904,19 @@ static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty,
}
}
- if (use_json) {
+ if (json)
json_object_string_add(json, "remoteGrMode", mode);
- } else
+ else
vty_out(vty, mode, "\n");
}
static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty,
struct peer *p,
- bool use_json,
json_object *json)
{
const char *mode = "Invalid";
- if (!use_json)
+ if (!json)
vty_out(vty, " Local GR Mode: ");
if (bgp_peer_gr_mode_get(p) == PEER_HELPER)
@@ -11941,15 +11936,14 @@ static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty,
mode = "Invalid*";
}
- if (use_json) {
+ if (json)
json_object_string_add(json, "localGrMode", mode);
- } else {
+ else
vty_out(vty, mode, "\n");
- }
}
static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
- struct vty *vty, struct peer *peer, bool use_json, json_object *json)
+ struct vty *vty, struct peer *peer, json_object *json)
{
afi_t afi;
safi_t safi;
@@ -11966,7 +11960,7 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV))
continue;
- if (use_json) {
+ if (json) {
json_afi_safi = json_object_new_object();
json_endofrib_status = json_object_new_object();
json_timer = json_object_new_object();
@@ -11977,7 +11971,7 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
else
eor_flag = false;
- if (!use_json) {
+ if (!json) {
vty_out(vty, " %s:\n",
get_afi_safi_str(afi, safi, false));
@@ -11988,25 +11982,25 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
CHECK_FLAG(peer->af_cap[afi][safi],
PEER_CAP_RESTART_AF_PRESERVE_RCV)) {
- if (use_json) {
+ if (json) {
json_object_boolean_true_add(json_afi_safi,
"fBit");
} else
vty_out(vty, "True\n");
} else {
- if (use_json)
+ if (json)
json_object_boolean_false_add(json_afi_safi,
"fBit");
else
vty_out(vty, "False\n");
}
- if (!use_json)
+ if (!json)
vty_out(vty, " End-of-RIB sent: ");
if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_EOR_SEND)) {
- if (use_json) {
+ if (json) {
json_object_boolean_true_add(
json_endofrib_status, "endOfRibSend");
@@ -12019,7 +12013,7 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
PRINT_EOR(eor_flag);
}
} else {
- if (use_json) {
+ if (json) {
json_object_boolean_false_add(
json_endofrib_status, "endOfRibSend");
json_object_boolean_false_add(
@@ -12033,25 +12027,25 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
}
}
- if (!use_json)
+ if (!json)
vty_out(vty, " End-of-RIB received: ");
if (CHECK_FLAG(peer->af_sflags[afi][safi],
PEER_STATUS_EOR_RECEIVED)) {
- if (use_json)
+ if (json)
json_object_boolean_true_add(
json_endofrib_status, "endOfRibRecv");
else
vty_out(vty, "Yes\n");
} else {
- if (use_json)
+ if (json)
json_object_boolean_false_add(
json_endofrib_status, "endOfRibRecv");
else
vty_out(vty, "No\n");
}
- if (use_json) {
+ if (json) {
json_object_int_add(json_timer, "stalePathTimer",
peer->bgp->stalepath_time);
@@ -12111,7 +12105,7 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
peer->bgp->gr_info[afi][safi]
.t_select_deferral));
}
- if (use_json) {
+ if (json) {
json_object_object_add(json_afi_safi, "endOfRibStatus",
json_endofrib_status);
json_object_object_add(json_afi_safi, "timers",
@@ -12125,10 +12119,9 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,
struct peer *p,
- bool use_json,
json_object *json)
{
- if (use_json) {
+ if (json) {
json_object *json_timer = NULL;
json_timer = json_object_new_object();
@@ -12164,7 +12157,7 @@ static void bgp_show_neighbor_graceful_restart_time(struct vty *vty,
}
static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
- bool use_json, json_object *json)
+ json_object *json)
{
char dn_flag[2] = {0};
/* '*' + v6 address of neighbor */
@@ -12174,7 +12167,7 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
dn_flag[0] = '*';
if (p->conf_if) {
- if (use_json)
+ if (json)
json_object_string_addf(json, "neighborAddr", "%pSU",
&p->su);
else
@@ -12184,7 +12177,7 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag,
p->host);
- if (use_json)
+ if (json)
json_object_string_add(json, "neighborAddr",
neighborAddr);
else
@@ -12192,7 +12185,7 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
}
/* more gr info in new format */
- BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json);
+ BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json);
}
static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
@@ -14177,7 +14170,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
thread_timer_remain_second(p->t_gr_stale) *
1000);
/* more gr info in new format */
- BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json_grace);
+ BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace);
json_object_object_add(json_neigh, "gracefulRestartInfo",
json_grace);
} else {
@@ -14223,7 +14216,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
thread_timer_remain_second(p->t_gr_stale));
/* more gr info in new format */
- BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL);
+ BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL);
}
if (use_json) {
@@ -14696,20 +14689,14 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
enum show_type type,
union sockunion *su,
const char *conf_if, afi_t afi,
- bool use_json)
+ json_object *json)
{
struct listnode *node, *nnode;
struct peer *peer;
int find = 0;
safi_t safi = SAFI_UNICAST;
- json_object *json = NULL;
json_object *json_neighbor = NULL;
- if (use_json) {
- json = json_object_new_object();
- json_neighbor = json_object_new_object();
- }
-
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
@@ -14718,15 +14705,15 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
if ((peer->afc[afi][safi]) == 0)
continue;
+ if (json)
+ json_neighbor = json_object_new_object();
+
if (type == show_all) {
- bgp_show_peer_gr_status(vty, peer, use_json,
- json_neighbor);
+ bgp_show_peer_gr_status(vty, peer, json_neighbor);
- if (use_json) {
+ if (json)
json_object_object_add(json, peer->host,
json_neighbor);
- json_neighbor = NULL;
- }
} else if (type == show_peer) {
if (conf_if) {
@@ -14736,41 +14723,33 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
&& !strcmp(peer->hostname, conf_if))) {
find = 1;
bgp_show_peer_gr_status(vty, peer,
- use_json,
json_neighbor);
}
} else {
if (sockunion_same(&peer->su, su)) {
find = 1;
bgp_show_peer_gr_status(vty, peer,
- use_json,
json_neighbor);
}
}
- if (use_json && find)
+ if (json && find)
json_object_object_add(json, peer->host,
json_neighbor);
}
- if (find) {
- json_neighbor = NULL;
+ if (find)
break;
- }
}
if (type == show_peer && !find) {
- if (use_json)
+ if (json)
json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
else
vty_out(vty, "%% No such neighbor\n");
}
- if (use_json) {
- if (json_neighbor)
- json_object_free(json_neighbor);
- vty_json(vty, json);
- } else {
+
+ if (!json)
vty_out(vty, "\n");
- }
return CMD_SUCCESS;
}
@@ -14883,7 +14862,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty,
enum show_type type,
const char *ip_str,
- afi_t afi, bool use_json)
+ afi_t afi, json_object *json)
{
int ret;
@@ -14895,21 +14874,20 @@ static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty,
if (!bgp)
return;
- if (!use_json)
- bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json,
- NULL);
+ if (!json)
+ bgp_show_global_graceful_restart_mode_vty(vty, bgp);
if (ip_str) {
ret = str2sockunion(ip_str, &su);
if (ret < 0)
- bgp_show_neighbor_graceful_restart(
- vty, bgp, type, NULL, ip_str, afi, use_json);
+ bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL,
+ ip_str, afi, json);
else
bgp_show_neighbor_graceful_restart(vty, bgp, type, &su,
- NULL, afi, use_json);
+ NULL, afi, json);
} else
bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL,
- afi, use_json);
+ afi, json);
}
static void bgp_show_all_instances_neighbors_vty(struct vty *vty,
@@ -15229,9 +15207,7 @@ DEFUN (show_ip_bgp_lcommunity_info,
/* Graceful Restart */
static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty,
- struct bgp *bgp,
- bool use_json,
- json_object *json)
+ struct bgp *bgp)
{
@@ -15266,22 +15242,32 @@ static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty,
const char *ip_str,
afi_t afi, bool use_json)
{
+ json_object *json = NULL;
+
+ if (use_json)
+ json = json_object_new_object();
+
if ((afi == AFI_MAX) && (ip_str == NULL)) {
afi = AFI_IP;
while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) {
bgp_show_neighbor_graceful_restart_vty(
- vty, type, ip_str, afi, use_json);
+ vty, type, ip_str, afi, json);
afi++;
}
} else if (afi != AFI_MAX) {
bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi,
- use_json);
+ json);
} else {
+ if (json)
+ json_object_free(json);
return CMD_ERR_INCOMPLETE;
}
+ if (json)
+ vty_json(vty, json);
+
return CMD_SUCCESS;
}
/* Graceful Restart */
diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h
index 9526b50fb9..019789dff8 100644
--- a/bgpd/bgp_vty.h
+++ b/bgpd/bgp_vty.h
@@ -56,18 +56,14 @@ struct bgp;
"V AS LocalAS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n"
#define BGP_SHOW_SUMMARY_HEADER_FAILED "EstdCnt DropCnt ResetTime Reason\n"
-#define BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json) \
+#define BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json) \
do { \
- bgp_show_neighbor_graceful_restart_local_mode(vty, p, \
- use_json, json); \
- bgp_show_neighbor_graceful_restart_remote_mode( \
- vty, p, use_json, json); \
- bgp_show_neighnor_graceful_restart_flags(vty, p, use_json, \
- json); \
- bgp_show_neighbor_graceful_restart_time(vty, p, use_json, \
- json); \
+ bgp_show_neighbor_graceful_restart_local_mode(vty, p, json); \
+ bgp_show_neighbor_graceful_restart_remote_mode(vty, p, json); \
+ bgp_show_neighnor_graceful_restart_flags(vty, p, json); \
+ bgp_show_neighbor_graceful_restart_time(vty, p, json); \
bgp_show_neighbor_graceful_restart_capability_per_afi_safi( \
- vty, p, use_json, json); \
+ vty, p, json); \
} while (0)
#define VTY_BGP_GR_DEFINE_LOOP_VARIABLE \
diff --git a/ospf6d/ospf6_nssa.c b/ospf6d/ospf6_nssa.c
index f35c9df4a5..2921046837 100644
--- a/ospf6d/ospf6_nssa.c
+++ b/ospf6d/ospf6_nssa.c
@@ -1090,7 +1090,25 @@ static void ospf6_check_and_originate_type7_lsa(struct ospf6_area *area)
ospf6_nssa_lsa_originate(aggr->route, area, true);
}
}
+}
+
+static void ospf6_ase_lsa_refresh(struct ospf6 *o)
+{
+ struct ospf6_lsa *old;
+ for (struct ospf6_route *route = ospf6_route_head(o->external_table);
+ route; route = ospf6_route_next(route)) {
+ old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
+ route->path.origin.id, o->router_id,
+ o->lsdb);
+ if (old) {
+ THREAD_OFF(old->refresh);
+ thread_add_event(master, ospf6_lsa_refresh, old, 0,
+ &old->refresh);
+ } else {
+ ospf6_as_external_lsa_originate(route, o);
+ }
+ }
}
void ospf6_area_nssa_update(struct ospf6_area *area)
@@ -1134,6 +1152,36 @@ void ospf6_area_nssa_update(struct ospf6_area *area)
if (IS_OSPF6_DEBUG_NSSA)
zlog_debug("Normal area %s", area->name);
ospf6_nssa_flush_area(area);
+
+ /* Check if router is ABR */
+ if (ospf6_check_and_set_router_abr(area->ospf6)) {
+ if (IS_OSPF6_DEBUG_NSSA)
+ zlog_debug("Router is ABR area %s", area->name);
+ ospf6_schedule_abr_task(area->ospf6);
+ ospf6_ase_lsa_refresh(area->ospf6);
+ } else {
+ uint16_t type;
+ struct ospf6_lsa *lsa = NULL;
+
+ /*
+ * Refresh all type-5 LSAs so they get installed
+ * in the converted ares
+ */
+ if (IS_OSPF6_DEBUG_NSSA)
+ zlog_debug("Refresh type-5 LSAs, area %s",
+ area->name);
+
+ type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
+ for (ALL_LSDB_TYPED_ADVRTR(area->ospf6->lsdb, type,
+ area->ospf6->router_id,
+ lsa)) {
+ if (IS_OSPF6_DEBUG_NSSA)
+ ospf6_lsa_header_print(lsa);
+ THREAD_OFF(lsa->refresh);
+ thread_add_event(master, ospf6_lsa_refresh, lsa,
+ 0, &lsa->refresh);
+ }
+ }
}
}
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py
index 7b41c80ce3..35c28b8a07 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py
@@ -406,6 +406,124 @@ def test_ospfv3_nssa_tc26_p0(request):
write_test_footer(tc_name)
+def test_ospfv3_learning_tc15_p0(request):
+ """Verify OSPF can learn different types of LSA and processes them.
+
+ OSPF Learning : Edge learning different types of LSAs.
+ """
+ tc_name = request.node.name
+ write_test_header(tc_name)
+ tgen = get_topogen()
+
+ # Don't run this test if we have any failure.
+ if tgen.routers_have_failure():
+ check_router_status(tgen)
+
+ global topo
+ step("Bring up the base config as per the topology")
+ step("Configure area 1 as NSSA Area")
+
+ reset_config_on_routers(tgen)
+
+ step("Verify that Type 3 summary LSA is originated for the same Area 0")
+ ip = topo["routers"]["r1"]["links"]["r3-link0"]["ipv6"]
+ ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
+
+ input_dict = {
+ "r1": {
+ "static_routes": [
+ {
+ "network": ip_net,
+ "no_of_ip": 1,
+ "routeType": "Network",
+ "pathtype": "Inter-Area",
+ }
+ ]
+ }
+ }
+
+ dut = "r0"
+ result = verify_ospf6_rib(tgen, dut, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ protocol = "ospf6"
+ result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ input_dict = {
+ "r2": {
+ "static_routes": [
+ {"network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0"}
+ ]
+ }
+ }
+ result = create_static_routes(tgen, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ step("Redistribute static route in R2 ospf.")
+ dut = "r2"
+ red_static(dut)
+
+ step("Verify that Type 5 LSA is originated by R2.")
+ dut = "r0"
+ protocol = "ospf6"
+ result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ input_dict = {
+ "r1": {
+ "static_routes": [
+ {"network": NETWORK["ipv6"][0], "no_of_ip": 1, "routeType": "Network"}
+ ]
+ }
+ }
+
+ dut = "r1"
+ result = verify_ospf6_rib(tgen, dut, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ result = verify_ospf6_neighbor(tgen, topo)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ step("Change area 1 as non nssa area (on the fly changing area" " type on DUT).")
+
+ for rtr in ["r1", "r2", "r3"]:
+ input_dict = {
+ rtr: {
+ "ospf6": {"area": [{"id": "0.0.0.2", "type": "nssa", "delete": True}]}
+ }
+ }
+ result = create_router_ospf(tgen, topo, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("Verify that OSPF neighbours are reset after changing area type.")
+ step("Verify that ABR R2 originates type 5 LSA in area 1.")
+ step("Verify that R1 installs type 5 lsa in its database.")
+ step("Verify that route is calculated and installed in R1.")
+
+ input_dict = {
+ "r1": {
+ "static_routes": [
+ {"network": NETWORK["ipv6"][0], "no_of_ip": 1, "routeType": "Network"}
+ ]
+ }
+ }
+
+ dut = "r1"
+ result = verify_ospf6_rib(tgen, dut, input_dict)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ write_test_footer(tc_name)
+
+
# As per internal discussion, this script has to be removed as translator
# function is not supported, for more details kindly check this PR 2565570
def ospfv3_nssa_tc27_p0(request):