if (p->hostname) {
if (use_json) {
- if (p->hostname)
- json_object_string_add(json_neigh, "hostname",
- p->hostname);
+ json_object_string_add(json_neigh, "hostname",
+ p->hostname);
if (p->domainname)
json_object_string_add(json_neigh, "domainname",
else
vty_out(vty, "Hostname: %s\n", p->hostname);
}
+ } else {
+ if (use_json)
+ json_object_string_add(json_neigh, "hostname",
+ "Unknown");
}
/* Peer-group */
p->shared_network ? "shared network"
: "non shared network");
}
+ } else {
+ if (use_json) {
+ json_object_string_add(json_neigh, "nexthop",
+ "Unknown");
+ json_object_string_add(json_neigh, "nexthopGlobal",
+ "Unknown");
+ json_object_string_add(json_neigh, "nexthopLocal",
+ "Unknown");
+ json_object_string_add(json_neigh, "bgpConnection",
+ "Unknown");
+ }
}
/* Timer information. */
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)
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);
+ }
+ }
}
}
/* PtoP link must have only 1 neighbor. */
if (ospf_nbr_count(oi, 0) > 1)
- flog_warn(EC_OSPF_PTP_NEIGHBOR,
- "Point-to-Point link has more than 1 neighobrs.");
+ flog_warn(
+ EC_OSPF_PTP_NEIGHBOR,
+ "Point-to-Point link on interface %s has more than 1 neighbor.",
+ oi->ifp->name);
return nbr;
}
return new;
}
-static void vertex_parent_free(void *p)
+static void vertex_parent_free(struct vertex_parent *p)
{
+ vertex_nexthop_free(p->local_nexthop);
+ vertex_nexthop_free(p->nexthop);
XFREE(MTYPE_OSPF_VERTEX_PARENT, p);
}
new->lsa = lsa->data;
new->children = list_new();
new->parents = list_new();
- new->parents->del = vertex_parent_free;
+ new->parents->del = (void (*)(void *))vertex_parent_free;
new->parents->cmp = vertex_parent_cmp;
new->lsa_p = lsa;
memcpy(copy, vertex, sizeof(struct vertex));
copy->parents = list_new();
- copy->parents->del = vertex_parent_free;
+ copy->parents->del = (void (*)(void *))vertex_parent_free;
copy->parents->cmp = vertex_parent_cmp;
copy->children = list_new();
/*
* Consider supplied next-hop for inclusion to the supplied list of
* equal-cost next-hops, adjust list as necessary.
+ *
+ * Returns vertex parent pointer if created otherwise `NULL` if it already
+ * exists.
*/
-static void ospf_spf_add_parent(struct vertex *v, struct vertex *w,
- struct vertex_nexthop *newhop,
- struct vertex_nexthop *newlhop,
- unsigned int distance)
+static struct vertex_parent *ospf_spf_add_parent(struct vertex *v,
+ struct vertex *w,
+ struct vertex_nexthop *newhop,
+ struct vertex_nexthop *newlhop,
+ unsigned int distance)
{
struct vertex_parent *vp, *wp;
struct listnode *node;
zlog_debug(
"%s: ... nexthop already on parent list, skipping add",
__func__);
- return;
+
+ return NULL;
}
}
newlhop);
listnode_add_sort(w->parents, vp);
- return;
+ return vp;
}
static int match_stub_prefix(struct lsa_header *lsa, struct in_addr v_link_addr,
memcpy(lnh, nh,
sizeof(struct vertex_nexthop));
- ospf_spf_add_parent(v, w, nh, lnh,
- distance);
+ if (ospf_spf_add_parent(v, w, nh, lnh,
+ distance) ==
+ NULL) {
+ vertex_nexthop_free(nh);
+ vertex_nexthop_free(lnh);
+ }
return 1;
} else
zlog_info(
memcpy(lnh, nh,
sizeof(struct vertex_nexthop));
- ospf_spf_add_parent(v, w, nh, lnh,
- distance);
+ if (ospf_spf_add_parent(v, w, nh, lnh,
+ distance) ==
+ NULL) {
+ vertex_nexthop_free(nh);
+ vertex_nexthop_free(lnh);
+ }
+
return 1;
} else
zlog_info(
lnh = vertex_nexthop_new();
memcpy(lnh, nh, sizeof(struct vertex_nexthop));
- ospf_spf_add_parent(v, w, nh, lnh, distance);
+ if (ospf_spf_add_parent(v, w, nh, lnh, distance) ==
+ NULL) {
+ vertex_nexthop_free(nh);
+ vertex_nexthop_free(lnh);
+ }
+
return 1;
}
} /* end V is the root */
sizeof(struct vertex_nexthop));
added = 1;
- ospf_spf_add_parent(v, w, nh, lnh,
- distance);
+ if (ospf_spf_add_parent(v, w, nh, lnh,
+ distance) ==
+ NULL) {
+ vertex_nexthop_free(nh);
+ vertex_nexthop_free(lnh);
+ }
}
/*
* Note lack of return is deliberate. See next
lnh = NULL;
}
- ospf_spf_add_parent(v, w, vp->nexthop, lnh, distance);
+ nh = vertex_nexthop_new();
+ *nh = *vp->nexthop;
+
+ if (ospf_spf_add_parent(v, w, nh, lnh, distance) == NULL) {
+ vertex_nexthop_free(nh);
+ vertex_nexthop_free(lnh);
+ }
}
return added;
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):