summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/control1
-rw-r--r--nhrpd/nhrp_interface.c3
-rw-r--r--ospf6d/ospf6_abr.c7
-rw-r--r--ospfd/ospf_abr.c418
-rw-r--r--ospfd/ospf_apiserver.c175
-rw-r--r--ospfd/ospf_ia.c113
-rw-r--r--ospfd/ospf_interface.c43
-rw-r--r--pimd/pim6_mld.c10
-rw-r--r--pimd/pim_addr.h2
-rw-r--r--pimd/pim_cmd_common.c139
-rw-r--r--pimd/pim_iface.c8
-rw-r--r--pimd/pim_nb_config.c21
-rw-r--r--pimd/pim_rp.c61
-rw-r--r--pimd/pim_vty.c6
-rw-r--r--tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py396
-rwxr-xr-xtests/topotests/conftest.py2
-rw-r--r--tests/topotests/lib/topogen.py2
-rwxr-xr-xtools/frrcommon.sh.in12
-rw-r--r--zebra/kernel_socket.c8
-rw-r--r--zebra/redistribute.c13
-rw-r--r--zebra/rib.h22
-rw-r--r--zebra/rt_netlink.c65
-rw-r--r--zebra/tc_netlink.c2
-rw-r--r--zebra/zapi_msg.c34
-rw-r--r--zebra/zebra_dplane.c5
-rw-r--r--zebra/zebra_mpls.c10
-rw-r--r--zebra/zebra_mpls.h17
-rw-r--r--zebra/zebra_rib.c1083
-rw-r--r--zebra/zebra_script.c19
29 files changed, 1717 insertions, 980 deletions
diff --git a/debian/control b/debian/control
index e8bf1a8ffa..06c16cc945 100644
--- a/debian/control
+++ b/debian/control
@@ -30,6 +30,7 @@ Build-Depends: bison,
python3-pytest <!nocheck>,
python3-sphinx,
texinfo (>= 4.7),
+ lua5.3 <pkg.frr.lua>,
liblua5.3-dev <pkg.frr.lua>
Standards-Version: 4.5.0.3
Homepage: https://www.frrouting.org/
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 1092ce13a1..4ac30a7d75 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -165,8 +165,7 @@ static void nhrp_interface_interface_notifier(struct notifier_block *n,
switch (cmd) {
case NOTIFY_INTERFACE_CHANGED:
- nhrp_interface_update_mtu(nifp->ifp, AFI_IP);
- nhrp_interface_update_source(nifp->ifp);
+ nhrp_interface_update_nbma(nifp->ifp, NULL);
break;
case NOTIFY_INTERFACE_ADDRESS_CHANGED:
nifp->nbma = nbmanifp->afi[AFI_IP].addr;
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 5af1139d9b..e9c42bb80c 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -488,7 +488,12 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
zlog_debug(
"Suppressed by range %pFX of area %s",
&range->prefix, route_area->name);
- ospf6_abr_delete_route(summary, summary_table, old);
+ /* The existing summary route could be a range, don't
+ * remove it in this case
+ */
+ if (summary && summary->type != OSPF6_DEST_TYPE_RANGE)
+ ospf6_abr_delete_route(summary, summary_table,
+ old);
return 0;
}
}
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index b7db1a6a83..4746b2fc66 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -366,9 +366,8 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area)
/* Router has Nt flag - always translate */
if (IS_ROUTER_LSA_NT(rlsa)) {
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_nssa_am_elected: router %pI4 asserts Nt",
- &lsa->data->id);
+ zlog_debug("%s: router %pI4 asserts Nt",
+ __func__, &lsa->data->id);
return 0;
}
@@ -380,9 +379,7 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area)
}
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_nssa_am_elected: best electable ABR is: %pI4",
- best);
+ zlog_debug("%s: best electable ABR is: %pI4", __func__, best);
if (best == NULL)
return 1;
@@ -408,14 +405,12 @@ void ospf_abr_nssa_check_status(struct ospf *ospf)
continue;
if (IS_DEBUG_OSPF(nssa, NSSA))
- zlog_debug(
- "ospf_abr_nssa_check_status: checking area %pI4",
- &area->area_id);
+ zlog_debug("%s: checking area %pI4", __func__,
+ &area->area_id);
if (!IS_OSPF_ABR(area->ospf)) {
if (IS_DEBUG_OSPF(nssa, NSSA))
- zlog_debug(
- "ospf_abr_nssa_check_status: not ABR");
+ zlog_debug("%s: not ABR", __func__);
area->NSSATranslatorState =
OSPF_NSSA_TRANSLATE_DISABLED;
} else {
@@ -424,8 +419,8 @@ void ospf_abr_nssa_check_status(struct ospf *ospf)
/* We never Translate Type-7 LSA. */
/* TODO: check previous state and flush? */
if (IS_DEBUG_OSPF(nssa, NSSA))
- zlog_debug(
- "ospf_abr_nssa_check_status: never translate");
+ zlog_debug("%s: never translate",
+ __func__);
area->NSSATranslatorState =
OSPF_NSSA_TRANSLATE_DISABLED;
break;
@@ -436,8 +431,8 @@ void ospf_abr_nssa_check_status(struct ospf *ospf)
* or let the nssa abr task take care of it?
*/
if (IS_DEBUG_OSPF(nssa, NSSA))
- zlog_debug(
- "ospf_abr_nssa_check_status: translate always");
+ zlog_debug("%s: translate always",
+ __func__);
area->NSSATranslatorState =
OSPF_NSSA_TRANSLATE_ENABLED;
break;
@@ -449,13 +444,14 @@ void ospf_abr_nssa_check_status(struct ospf *ospf)
OSPF_NSSA_TRANSLATE_ENABLED;
if (IS_DEBUG_OSPF(nssa, NSSA))
zlog_debug(
- "ospf_abr_nssa_check_status: elected translator");
+ "%s: elected translator",
+ __func__);
} else {
area->NSSATranslatorState =
OSPF_NSSA_TRANSLATE_DISABLED;
if (IS_DEBUG_OSPF(nssa, NSSA))
- zlog_debug(
- "ospf_abr_nssa_check_status: not elected");
+ zlog_debug("%s: not elected",
+ __func__);
}
break;
}
@@ -491,7 +487,7 @@ void ospf_check_abr_status(struct ospf *ospf)
uint8_t new_flags = ospf->flags;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_check_abr_status(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) {
if (listcount(area->oiflist)) {
@@ -510,14 +506,13 @@ void ospf_check_abr_status(struct ospf *ospf)
}
if (IS_DEBUG_OSPF_EVENT) {
- zlog_debug("ospf_check_abr_status(): looked through areas");
- zlog_debug("ospf_check_abr_status(): bb_configured: %d",
- bb_configured);
- zlog_debug("ospf_check_abr_status(): bb_act_attached: %d",
+ zlog_debug("%s: looked through areas", __func__);
+ zlog_debug("%s: bb_configured: %d", __func__, bb_configured);
+ zlog_debug("%s: bb_act_attached: %d", __func__,
bb_act_attached);
- zlog_debug("ospf_check_abr_status(): areas_configured: %d",
+ zlog_debug("%s: areas_configured: %d", __func__,
areas_configured);
- zlog_debug("ospf_check_abr_status(): areas_act_attached: %d",
+ zlog_debug("%s: areas_act_attached: %d", __func__,
areas_act_attached);
}
@@ -550,9 +545,8 @@ void ospf_check_abr_status(struct ospf *ospf)
if (new_flags != ospf->flags) {
ospf_spf_calculate_schedule(ospf, SPF_FLAG_ABR_STATUS_CHANGE);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_check_abr_status(): new router flags: %x",
- new_flags);
+ zlog_debug("%s: new router flags: %x", __func__,
+ new_flags);
ospf->flags = new_flags;
ospf_router_lsa_update(ospf);
}
@@ -563,37 +557,33 @@ static void ospf_abr_update_aggregate(struct ospf_area_range *range,
struct ospf_area *area)
{
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_update_aggregate(): Start");
+ zlog_debug("%s: Start", __func__);
if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
&& (range->cost != OSPF_STUB_MAX_METRIC_SUMMARY_COST)) {
range->cost = OSPF_STUB_MAX_METRIC_SUMMARY_COST;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_update_aggregate(): use summary max-metric 0x%08x",
- range->cost);
+ zlog_debug("%s: use summary max-metric 0x%08x",
+ __func__, range->cost);
} else if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_update_aggregate(): use configured cost %d",
- range->cost_config);
+ zlog_debug("%s: use configured cost %d", __func__,
+ range->cost_config);
range->cost = range->cost_config;
} else {
if (range->specifics == 0) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_update_aggregate(): use or->cost %d",
- or->cost);
+ zlog_debug("%s: use or->cost %d", __func__,
+ or->cost);
range->cost = or->cost; /* 1st time get 1st cost */
}
if (or->cost > range->cost) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_update_aggregate(): update to %d",
- or->cost);
+ zlog_debug("%s: update to %d", __func__,
+ or->cost);
range->cost = or->cost;
}
@@ -633,16 +623,14 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)
if (!CHECK_FLAG(lsa->data->options, OSPF_OPTION_NP)) {
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_translate_nssa(): LSA Id %pI4, P-bit off, NO Translation",
- &lsa->data->id);
+ zlog_debug("%s: LSA Id %pI4, P-bit off, NO Translation",
+ __func__, &lsa->data->id);
return 1;
}
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_translate_nssa(): LSA Id %pI4, TRANSLATING 7 to 5",
- &lsa->data->id);
+ zlog_debug("%s: LSA Id %pI4, TRANSLATING 7 to 5", __func__,
+ &lsa->data->id);
ext7 = (struct as_external_lsa *)(lsa->data);
p.prefix = lsa->data->id;
@@ -651,8 +639,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)
if (ext7->e[0].fwd_addr.s_addr == OSPF_DEFAULT_DESTINATION) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): LSA Id %pI4, Forward address is 0, NO Translation",
- &lsa->data->id);
+ "%s: LSA Id %pI4, Forward address is 0, NO Translation",
+ __func__, &lsa->data->id);
return 1;
}
@@ -665,8 +653,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)
UNSET_FLAG(old->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): remove old translated LSA id %pI4",
- &old->data->id);
+ "%s: remove old translated LSA id %pI4",
+ __func__, &old->data->id);
}
/* if type-7 is removed and type-5 does not exist, do not
* originate */
@@ -676,16 +664,16 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)
if (old && CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): found old translated LSA Id %pI4, refreshing",
- &old->data->id);
+ "%s: found old translated LSA Id %pI4, refreshing",
+ __func__, &old->data->id);
/* refresh */
new = ospf_translated_nssa_refresh(area->ospf, lsa, old);
if (!new) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): could not refresh translated LSA Id %pI4",
- &old->data->id);
+ "%s: could not refresh translated LSA Id %pI4",
+ __func__, &old->data->id);
}
} else {
/* no existing external route for this LSA Id
@@ -696,8 +684,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)
== NULL) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_translate_nssa(): Could not translate Type-7 for %pI4 to Type-5",
- &lsa->data->id);
+ "%s: Could not translate Type-7 for %pI4 to Type-5",
+ __func__, &lsa->data->id);
return 1;
}
}
@@ -723,7 +711,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
uint32_t full_cost;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_network_to_area(): Start");
+ zlog_debug("%s: Start", __func__);
if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
full_cost = OSPF_STUB_MAX_METRIC_SUMMARY_COST;
@@ -734,28 +722,25 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
area->ospf->router_id);
if (old) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): old summary found");
+ zlog_debug("%s: old summary found", __func__);
sl = (struct summary_lsa *)old->data;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): old metric: %d, new metric: %d",
- GET_METRIC(sl->metric), cost);
+ zlog_debug("%s: old metric: %d, new metric: %d",
+ __func__, GET_METRIC(sl->metric), cost);
if ((GET_METRIC(sl->metric) == full_cost)
&& ((old->flags & OSPF_LSA_IN_MAXAGE) == 0)) {
/* unchanged. simply reapprove it */
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): old summary approved");
+ zlog_debug("%s: old summary approved",
+ __func__);
SET_FLAG(old->flags, OSPF_LSA_APPROVED);
} else {
/* LSA is changed, refresh it */
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): refreshing summary");
+ zlog_debug("%s: refreshing summary", __func__);
set_metric(old, full_cost);
lsa = ospf_lsa_refresh(area->ospf, old);
@@ -772,8 +757,7 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
}
} else {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): creating new summary");
+ zlog_debug("%s: creating new summary", __func__);
lsa = ospf_summary_lsa_originate(p, full_cost, area);
/* This will flood through area. */
@@ -787,12 +771,12 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
SET_FLAG(lsa->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): flooding new version of summary");
+ zlog_debug("%s: flooding new version of summary",
+ __func__);
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_network_to_area(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static int ospf_abr_nexthops_belong_to_area(struct ospf_route * or,
@@ -866,16 +850,15 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p,
struct listnode *node;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_network(): Start");
+ zlog_debug("%s: Start", __func__);
or_area = ospf_area_lookup_by_area_id(ospf, or->u.std.area_id);
assert(or_area);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id))
continue;
@@ -886,16 +869,16 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p,
if (!ospf_abr_should_accept(p, area)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): prefix %pFX was denied by import-list",
- p);
+ "%s: prefix %pFX was denied by import-list",
+ __func__, p);
continue;
}
if (!ospf_abr_plist_in_check(area, or, p)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): prefix %pFX was denied by prefix-list",
- p);
+ "%s: prefix %pFX was denied by prefix-list",
+ __func__, p);
continue;
}
@@ -903,16 +886,16 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p,
&& area->no_summary) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): area %pI4 is stub and no_summary",
- &area->area_id);
+ "%s: area %pI4 is stub and no_summary",
+ __func__, &area->area_id);
continue;
}
if (or->path_type == OSPF_PATH_INTER_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): this is inter-area route to %pFX",
- p);
+ "%s: this is inter-area route to %pFX",
+ __func__, p);
if (!OSPF_IS_AREA_BACKBONE(area))
ospf_abr_announce_network_to_area(p, or->cost,
@@ -922,8 +905,8 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p,
if (or->path_type == OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_network(): this is intra-area route to %pFX",
- p);
+ "%s: this is intra-area route to %pFX",
+ __func__, p);
if ((range = ospf_area_range_match(or_area, p))
&& !ospf_area_is_transit(area))
ospf_abr_update_aggregate(range, or, area);
@@ -971,7 +954,7 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf)
struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_process_nssa_translates(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (!area->NSSATranslatorState)
@@ -981,16 +964,15 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf)
continue; /* skip if not Nssa Area */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_process_nssa_translates(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s(): looking at area %pI4", __func__,
+ &area->area_id);
LSDB_LOOP (NSSA_LSDB(area), rn, lsa)
ospf_abr_translate_nssa(area, lsa);
}
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_process_nssa_translates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_process_network_rt(struct ospf *ospf,
@@ -1001,7 +983,7 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
struct route_node *rn;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_process_network_rt(): Start");
+ zlog_debug("%s: Start", __func__);
for (rn = route_top(rt); rn; rn = route_next(rn)) {
if ((or = rn->info) == NULL)
@@ -1011,33 +993,35 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
or->u.std.area_id))) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): area %pI4 no longer exists",
- &or->u.std.area_id);
+ "%s: area %pI4 no longer exists", __func__,
+ &or->u.std.area_id);
continue;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_process_network_rt(): this is a route to %pFX",
- &rn->p);
+ zlog_debug("%s: this is a route to %pFX", __func__,
+ &rn->p);
if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): this is an External router, skipping");
+ "%s: this is an External router, skipping",
+ __func__);
continue;
}
if (or->cost >= OSPF_LS_INFINITY) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): this route's cost is infinity, skipping");
+ "%s: this route's cost is infinity, skipping",
+ __func__);
continue;
}
if (or->type == OSPF_DESTINATION_DISCARD) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): this is a discard entry, skipping");
+ "%s: this is a discard entry, skipping",
+ __func__);
continue;
}
@@ -1047,8 +1031,8 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
ospf, (struct prefix_ipv4 *)&rn->p,
or)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_process_network_rt(): denied by export-list");
+ zlog_debug("%s: denied by export-list",
+ __func__);
continue;
}
@@ -1058,8 +1042,8 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
area, or,
(struct prefix_ipv4 *)&rn->p)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_process_network_rt(): denied by prefix-list");
+ zlog_debug("%s: denied by prefix-list",
+ __func__);
continue;
}
@@ -1067,7 +1051,8 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
&& !OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): this route is not backbone one, skipping");
+ "%s: this route is not backbone one, skipping",
+ __func__);
continue;
}
@@ -1079,18 +1064,19 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
or->path_type != OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): ALT ABR: No BB connection, skip not intra-area routes");
+ "%s: ALT ABR: No BB connection, skip not intra-area routes",
+ __func__);
continue;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_process_network_rt(): announcing");
+ zlog_debug("%s: announcing", __func__);
ospf_abr_announce_network(ospf, (struct prefix_ipv4 *)&rn->p,
or);
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_process_network_rt(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
@@ -1100,31 +1086,28 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
struct summary_lsa *slsa = NULL;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_rtr_to_area(): Start");
+ zlog_debug("%s: Start", __func__);
old = ospf_lsa_lookup_by_prefix(area->lsdb, OSPF_ASBR_SUMMARY_LSA, p,
area->ospf->router_id);
if (old) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_rtr_to_area(): old summary found");
+ zlog_debug("%s: old summary found", __func__);
slsa = (struct summary_lsa *)old->data;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_network_to_area(): old metric: %d, new metric: %d",
- GET_METRIC(slsa->metric), cost);
+ zlog_debug("%s: old metric: %d, new metric: %d",
+ __func__, GET_METRIC(slsa->metric), cost);
}
if (old && (GET_METRIC(slsa->metric) == cost)
&& ((old->flags & OSPF_LSA_IN_MAXAGE) == 0)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_rtr_to_area(): old summary approved");
+ zlog_debug("%s: old summary approved", __func__);
SET_FLAG(old->flags, OSPF_LSA_APPROVED);
} else {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_rtr_to_area(): 2.2");
+ zlog_debug("%s: 2.2", __func__);
if (old) {
set_metric(old, cost);
@@ -1140,8 +1123,8 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_rtr_to_area(): flooding new version of summary");
+ zlog_debug("%s: flooding new version of summary",
+ __func__);
/*
zlog_info ("ospf_abr_announce_rtr_to_area(): creating new
@@ -1153,7 +1136,7 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_rtr_to_area(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
@@ -1164,13 +1147,12 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p,
struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_rtr(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_rtr(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id))
continue;
@@ -1182,24 +1164,24 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p,
if (or->u.std.external_routing == OSPF_AREA_NSSA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_rtr(): do not generate LSA Type-4 %pI4 from NSSA",
- &p->prefix);
+ "%s: do not generate LSA Type-4 %pI4 from NSSA",
+ __func__, &p->prefix);
continue;
}
if (area->external_routing != OSPF_AREA_DEFAULT) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_rtr(): area %pI4 doesn't support external routing",
- &area->area_id);
+ "%s: area %pI4 doesn't support external routing",
+ __func__, &area->area_id);
continue;
}
if (or->path_type == OSPF_PATH_INTER_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_rtr(): this is inter-area route to %pI4",
- &p->prefix);
+ "%s: this is inter-area route to %pI4",
+ __func__, &p->prefix);
if (!OSPF_IS_AREA_BACKBONE(area))
ospf_abr_announce_rtr_to_area(p, or->cost,
area);
@@ -1208,14 +1190,14 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p,
if (or->path_type == OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_rtr(): this is intra-area route to %pI4",
- &p->prefix);
+ "%s: this is intra-area route to %pI4",
+ __func__, &p->prefix);
ospf_abr_announce_rtr_to_area(p, or->cost, area);
}
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_rtr(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_process_router_rt(struct ospf *ospf,
@@ -1226,7 +1208,7 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
struct list *l;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_process_router_rt(): Start");
+ zlog_debug("%s: Start", __func__);
for (rn = route_top(rt); rn; rn = route_next(rn)) {
struct listnode *node, *nnode;
@@ -1239,16 +1221,15 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
l = rn->info;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_process_router_rt(): this is a route to %pI4",
- &rn->p.u.prefix4);
+ zlog_debug("%s: this is a route to %pI4", __func__,
+ &rn->p.u.prefix4);
for (ALL_LIST_ELEMENTS(l, node, nnode, or)) {
if (!ospf_area_lookup_by_area_id(ospf,
or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_router_rt(): area %pI4 no longer exists",
+ "%s: area %pI4 no longer exists", __func__,
&or->u.std.area_id);
continue;
}
@@ -1257,7 +1238,8 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
if (!CHECK_FLAG(or->u.std.flags, ROUTER_LSA_EXTERNAL)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_router_rt(): This is not an ASBR, skipping");
+ "%s: This is not an ASBR, skipping",
+ __func__);
continue;
}
@@ -1273,7 +1255,8 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
if (or != best) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_router_rt(): This route is not the best among possible, skipping");
+ "%s: This route is not the best among possible, skipping",
+ __func__);
continue;
}
@@ -1283,14 +1266,16 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_router_rt(): This route is not a backbone one, skipping");
+ "%s: This route is not a backbone one, skipping",
+ __func__);
continue;
}
if (or->cost >= OSPF_LS_INFINITY) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_router_rt(): This route has LS_INFINITY metric, skipping");
+ "%s: This route has LS_INFINITY metric, skipping",
+ __func__);
continue;
}
@@ -1300,7 +1285,8 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
or->path_type != OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_process_network_rt(): ALT ABR: No BB connection, skip not intra-area routes");
+ "%s: ALT ABR: No BB connection, skip not intra-area routes",
+ __func__);
continue;
}
@@ -1310,7 +1296,7 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_process_router_rt(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void
@@ -1320,7 +1306,7 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */
struct route_node *rn;
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_unapprove_translates(): Start");
+ zlog_debug("%s: Start", __func__);
/* NSSA Translator is not checked, because it may have gone away,
and we would want to flush any residuals anyway */
@@ -1329,13 +1315,12 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */
if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) {
UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED);
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_unapprove_translates(): approved unset on link id %pI4",
- &lsa->data->id);
+ zlog_debug("%s: approved unset on link id %pI4",
+ __func__, &lsa->data->id);
}
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_unapprove_translates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_unapprove_summaries(struct ospf *ospf)
@@ -1346,19 +1331,18 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf)
struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_unapprove_summaries(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_unapprove_summaries(): considering area %pI4",
- &area->area_id);
+ zlog_debug("%s: considering area %pI4", __func__,
+ &area->area_id);
LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)
if (ospf_lsa_is_self_originated(ospf, lsa)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_unapprove_summaries(): approved unset on summary link id %pI4",
- &lsa->data->id);
+ "%s: approved unset on summary link id %pI4",
+ __func__, &lsa->data->id);
UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED);
}
@@ -1366,14 +1350,14 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf)
if (ospf_lsa_is_self_originated(ospf, lsa)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_unapprove_summaries(): approved unset on asbr-summary link id %pI4",
- &lsa->data->id);
+ "%s: approved unset on asbr-summary link id %pI4",
+ __func__, &lsa->data->id);
UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED);
}
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_unapprove_summaries(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_prepare_aggregates(struct ospf *ospf)
@@ -1384,7 +1368,7 @@ static void ospf_abr_prepare_aggregates(struct ospf *ospf)
struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_prepare_aggregates(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
for (rn = route_top(area->ranges); rn; rn = route_next(rn))
@@ -1395,7 +1379,7 @@ static void ospf_abr_prepare_aggregates(struct ospf *ospf)
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_prepare_aggregates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_announce_aggregates(struct ospf *ospf)
@@ -1407,13 +1391,12 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
struct listnode *node, *n;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_aggregates(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_aggregates(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
for (rn = route_top(area->ranges); rn; rn = route_next(rn))
if ((range = rn->info)) {
@@ -1421,7 +1404,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
OSPF_AREA_RANGE_ADVERTISE)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_aggregates(): discarding suppress-ranges");
+ "%s: discarding suppress-ranges",
+ __func__);
continue;
}
@@ -1430,9 +1414,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
p.prefixlen = range->masklen;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_aggregates(): this is range: %pFX",
- &p);
+ zlog_debug("%s: this is range: %pFX",
+ __func__, &p);
if (CHECK_FLAG(range->flags,
OSPF_AREA_RANGE_SUBSTITUTE)) {
@@ -1443,8 +1426,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
if (range->specifics) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_aggregates(): active range");
+ zlog_debug("%s: active range",
+ __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas,
n, ar)) {
@@ -1467,7 +1450,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
area)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_abr_announce_aggregates(): Skipping announcement of BB aggregate into a transit area");
+ "%s: Skipping announcement of BB aggregate into a transit area",
+ __func__);
continue;
}
ospf_abr_announce_network_to_area(
@@ -1480,7 +1464,7 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf)
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_aggregates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void
@@ -1493,16 +1477,15 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */
struct prefix_ipv4 p;
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_send_nssa_aggregates(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (!area->NSSATranslatorState)
continue;
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_send_nssa_aggregates(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
for (rn = route_top(area->ranges); rn; rn = route_next(rn)) {
if (rn->info == NULL)
@@ -1514,7 +1497,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */
OSPF_AREA_RANGE_ADVERTISE)) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
- "ospf_abr_send_nssa_aggregates(): discarding suppress-ranges");
+ "%s: discarding suppress-ranges",
+ __func__);
continue;
}
@@ -1523,9 +1507,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */
p.prefixlen = range->masklen;
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_send_nssa_aggregates(): this is range: %pFX",
- &p);
+ zlog_debug("%s: this is range: %pFX", __func__,
+ &p);
if (CHECK_FLAG(range->flags,
OSPF_AREA_RANGE_SUBSTITUTE)) {
@@ -1536,8 +1519,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */
if (range->specifics) {
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_send_nssa_aggregates(): active range");
+ zlog_debug("%s: active range",
+ __func__);
/* Fetch LSA-Type-7 from aggregate prefix, and
* then
@@ -1550,7 +1533,7 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */
} /* all areas */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_send_nssa_aggregates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_announce_stub_defaults(struct ospf *ospf)
@@ -1563,7 +1546,7 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf)
return;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_stub_defaults(): Start");
+ zlog_debug("%s: Start", __func__);
p.family = AF_INET;
p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
@@ -1571,9 +1554,8 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf)
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_stub_defaults(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
if ((area->external_routing != OSPF_AREA_STUB)
&& (area->external_routing != OSPF_AREA_NSSA))
@@ -1583,14 +1565,13 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf)
continue; /* Sanity Check */
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
- &area->area_id);
+ zlog_debug("%s: announcing 0.0.0.0/0 to area %pI4",
+ __func__, &area->area_id);
ospf_abr_announce_network_to_area(&p, area->default_cost, area);
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_announce_stub_defaults(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static int ospf_abr_remove_unapproved_translates_apply(struct ospf *ospf,
@@ -1598,9 +1579,8 @@ static int ospf_abr_remove_unapproved_translates_apply(struct ospf *ospf,
{
if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)
&& !CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) {
- zlog_info(
- "ospf_abr_remove_unapproved_translates(): removing unapproved translates, ID: %pI4",
- &lsa->data->id);
+ zlog_info("%s: removing unapproved translates, ID: %pI4",
+ __func__, &lsa->data->id);
/* FLUSH THROUGHOUT AS */
ospf_lsa_flush_as(ospf, lsa);
@@ -1618,13 +1598,13 @@ static void ospf_abr_remove_unapproved_translates(struct ospf *ospf)
/* All AREA PROCESS should have APPROVED necessary LSAs */
/* Remove any left over and not APPROVED */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_remove_unapproved_translates(): Start");
+ zlog_debug("%s: Start", __func__);
LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)
ospf_abr_remove_unapproved_translates_apply(ospf, lsa);
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_remove_unapproved_translates(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf)
@@ -1635,13 +1615,12 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf)
struct ospf_lsa *lsa;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_remove_unapproved_summaries(): Start");
+ zlog_debug("%s: Start", __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_remove_unapproved_summaries(): looking at area %pI4",
- &area->area_id);
+ zlog_debug("%s: looking at area %pI4", __func__,
+ &area->area_id);
LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)
if (ospf_lsa_is_self_originated(ospf, lsa))
@@ -1655,7 +1634,7 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf)
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_remove_unapproved_summaries(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_manage_discard_routes(struct ospf *ospf)
@@ -1725,17 +1704,17 @@ static void ospf_abr_nssa_task(struct ospf *ospf) /* called only if any_nssa */
/* Each area must confirm TranslatorRole */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): Start");
+ zlog_debug("%s: Start", __func__);
/* For all Global Entries flagged "local-translate", unset APPROVED */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): unapprove translates");
+ zlog_debug("%s: unapprove translates", __func__);
ospf_abr_unapprove_translates(ospf);
/* RESET all Ranges in every Area, same as summaries */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): NSSA initialize aggregates");
+ zlog_debug("%s: NSSA initialize aggregates", __func__);
ospf_abr_prepare_aggregates(ospf); /*TURNED OFF just for now */
/* For all NSSAs, Type-7s, translate to 5's, INSTALL/FLOOD, or
@@ -1743,7 +1722,7 @@ static void ospf_abr_nssa_task(struct ospf *ospf) /* called only if any_nssa */
* Install or Approve in Type-5 Global LSDB
*/
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): process translates");
+ zlog_debug("%s: process translates", __func__);
ospf_abr_process_nssa_translates(ospf);
/* Translate/Send any "ranged" aggregates, and also 5-Install and
@@ -1752,7 +1731,7 @@ static void ospf_abr_nssa_task(struct ospf *ospf) /* called only if any_nssa */
* Install/Flood/Approve
*/
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): send NSSA aggregates");
+ zlog_debug("%s: send NSSA aggregates", __func__);
ospf_abr_send_nssa_aggregates(ospf); /*TURNED OFF FOR NOW */
/* Send any NSSA defaults as Type-5
@@ -1764,14 +1743,13 @@ static void ospf_abr_nssa_task(struct ospf *ospf) /* called only if any_nssa */
/* Flush any unapproved previous translates from Global Data Base */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_abr_nssa_task(): remove unapproved translates");
+ zlog_debug("%s: remove unapproved translates", __func__);
ospf_abr_remove_unapproved_translates(ospf);
ospf_abr_manage_discard_routes(ospf); /* same as normal...discard */
if (IS_DEBUG_OSPF_NSSA)
- zlog_debug("ospf_abr_nssa_task(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
/* This is the function taking care about ABR stuff, i.e.
@@ -1782,49 +1760,49 @@ void ospf_abr_task(struct ospf *ospf)
return;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): Start");
+ zlog_debug("%s: Start", __func__);
if (ospf->new_table == NULL || ospf->new_rtrs == NULL) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_abr_task(): Routing tables are not yet ready");
+ zlog_debug("%s: Routing tables are not yet ready",
+ __func__);
return;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): unapprove summaries");
+ zlog_debug("%s: unapprove summaries", __func__);
ospf_abr_unapprove_summaries(ospf);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): prepare aggregates");
+ zlog_debug("%s: prepare aggregates", __func__);
ospf_abr_prepare_aggregates(ospf);
if (IS_OSPF_ABR(ospf)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): process network RT");
+ zlog_debug("%s: process network RT", __func__);
ospf_abr_process_network_rt(ospf, ospf->new_table);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): process router RT");
+ zlog_debug("%s: process router RT", __func__);
ospf_abr_process_router_rt(ospf, ospf->new_rtrs);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): announce aggregates");
+ zlog_debug("%s: announce aggregates", __func__);
ospf_abr_announce_aggregates(ospf);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): announce stub defaults");
+ zlog_debug("%s: announce stub defaults", __func__);
ospf_abr_announce_stub_defaults(ospf);
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): remove unapproved summaries");
+ zlog_debug("%s: remove unapproved summaries", __func__);
ospf_abr_remove_unapproved_summaries(ospf);
ospf_abr_manage_discard_routes(ospf);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_abr_task(): Stop");
+ zlog_debug("%s: Stop", __func__);
}
static void ospf_abr_task_timer(struct thread *thread)
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index b8567830b1..f5ed77dab5 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -378,7 +378,7 @@ void ospf_apiserver_read(struct thread *thread)
apiserv->t_sync_read = NULL;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u",
+ zlog_debug("API: %s: Peer: %pI4/%u", __func__,
&apiserv->peer_sync.sin_addr,
ntohs(apiserv->peer_sync.sin_port));
}
@@ -388,13 +388,13 @@ void ospf_apiserver_read(struct thread *thread)
apiserv->t_async_read = NULL;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("API: ospf_apiserver_read: Peer: %pI4/%u",
+ zlog_debug("API: %s: Peer: %pI4/%u", __func__,
&apiserv->peer_async.sin_addr,
ntohs(apiserv->peer_async.sin_port));
}
#endif /* USE_ASYNC_READ */
else {
- zlog_warn("ospf_apiserver_read: Unknown fd(%d)", fd);
+ zlog_warn("%s: Unknown fd(%d)", __func__, fd);
ospf_apiserver_free(apiserv);
return;
}
@@ -402,9 +402,8 @@ void ospf_apiserver_read(struct thread *thread)
/* Read message from fd. */
msg = msg_read(fd);
if (msg == NULL) {
- zlog_warn(
- "ospf_apiserver_read: read failed on fd=%d, closing connection",
- fd);
+ zlog_warn("%s: read failed on fd=%d, closing connection",
+ __func__, fd);
/* Perform cleanup. */
ospf_apiserver_free(apiserv);
@@ -438,20 +437,19 @@ void ospf_apiserver_sync_write(struct thread *thread)
/* Sanity check */
if (fd != apiserv->fd_sync) {
- zlog_warn("ospf_apiserver_sync_write: Unknown fd=%d", fd);
+ zlog_warn("%s: Unknown fd=%d", __func__, fd);
goto out;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("API: ospf_apiserver_sync_write: Peer: %pI4/%u",
+ zlog_debug("API: %s: Peer: %pI4/%u", __func__,
&apiserv->peer_sync.sin_addr,
ntohs(apiserv->peer_sync.sin_port));
/* Check whether there is really a message in the fifo. */
msg = msg_fifo_pop(apiserv->out_sync_fifo);
if (!msg) {
- zlog_warn(
- "API: ospf_apiserver_sync_write: No message in Sync-FIFO?");
+ zlog_warn("API: %s: No message in Sync-FIFO?", __func__);
return;
}
@@ -464,8 +462,7 @@ void ospf_apiserver_sync_write(struct thread *thread)
msg_free(msg);
if (rc < 0) {
- zlog_warn("ospf_apiserver_sync_write: write failed on fd=%d",
- fd);
+ zlog_warn("%s: write failed on fd=%d", __func__, fd);
goto out;
}
@@ -500,20 +497,19 @@ void ospf_apiserver_async_write(struct thread *thread)
/* Sanity check */
if (fd != apiserv->fd_async) {
- zlog_warn("ospf_apiserver_async_write: Unknown fd=%d", fd);
+ zlog_warn("%s: Unknown fd=%d", __func__, fd);
goto out;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("API: ospf_apiserver_async_write: Peer: %pI4/%u",
+ zlog_debug("API: %s: Peer: %pI4/%u", __func__,
&apiserv->peer_async.sin_addr,
ntohs(apiserv->peer_async.sin_port));
/* Check whether there is really a message in the fifo. */
msg = msg_fifo_pop(apiserv->out_async_fifo);
if (!msg) {
- zlog_warn(
- "API: ospf_apiserver_async_write: No message in Async-FIFO?");
+ zlog_warn("API: %s: No message in Async-FIFO?", __func__);
return;
}
@@ -526,8 +522,7 @@ void ospf_apiserver_async_write(struct thread *thread)
msg_free(msg);
if (rc < 0) {
- zlog_warn("ospf_apiserver_async_write: write failed on fd=%d",
- fd);
+ zlog_warn("%s: write failed on fd=%d", __func__, fd);
goto out;
}
@@ -575,8 +570,7 @@ int ospf_apiserver_serv_sock_family(unsigned short port, int family)
/* Listen socket under queue length 3. */
rc = listen(accept_sock, 3);
if (rc < 0) {
- zlog_warn("ospf_apiserver_serv_sock_family: listen: %s",
- safe_strerror(errno));
+ zlog_warn("%s: listen: %s", __func__, safe_strerror(errno));
close(accept_sock); /* Close socket */
return rc;
}
@@ -608,8 +602,7 @@ void ospf_apiserver_accept(struct thread *thread)
/* Accept connection for synchronous messages */
new_sync_sock = sockunion_accept(accept_sock, &su);
if (new_sync_sock < 0) {
- zlog_warn("ospf_apiserver_accept: accept: %s",
- safe_strerror(errno));
+ zlog_warn("%s: accept: %s", __func__, safe_strerror(errno));
return;
}
@@ -622,16 +615,15 @@ void ospf_apiserver_accept(struct thread *thread)
ret = getpeername(new_sync_sock, (struct sockaddr *)&peer_sync,
&peerlen);
if (ret < 0) {
- zlog_warn("ospf_apiserver_accept: getpeername: %s",
+ zlog_warn("%s: getpeername: %s", __func__,
safe_strerror(errno));
close(new_sync_sock);
return;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("API: ospf_apiserver_accept: New peer: %pI4/%u",
- &peer_sync.sin_addr,
- ntohs(peer_sync.sin_port));
+ zlog_debug("API: %s: New peer: %pI4/%u", __func__,
+ &peer_sync.sin_addr, ntohs(peer_sync.sin_port));
/* Create new socket for asynchronous messages. */
peer_async = peer_sync;
@@ -640,18 +632,16 @@ void ospf_apiserver_accept(struct thread *thread)
/* Check if remote port number to make reverse connection is valid one.
*/
if (ntohs(peer_async.sin_port) == ospf_apiserver_getport()) {
- zlog_warn(
- "API: ospf_apiserver_accept: Peer(%pI4/%u): Invalid async port number?",
- &peer_async.sin_addr,
- ntohs(peer_async.sin_port));
+ zlog_warn("API: %s: Peer(%pI4/%u): Invalid async port number?",
+ __func__, &peer_async.sin_addr,
+ ntohs(peer_async.sin_port));
close(new_sync_sock);
return;
}
new_async_sock = socket(AF_INET, SOCK_STREAM, 0);
if (new_async_sock < 0) {
- zlog_warn("ospf_apiserver_accept: socket: %s",
- safe_strerror(errno));
+ zlog_warn("%s: socket: %s", __func__, safe_strerror(errno));
close(new_sync_sock);
return;
}
@@ -660,8 +650,7 @@ void ospf_apiserver_accept(struct thread *thread)
sizeof(struct sockaddr_in));
if (ret < 0) {
- zlog_warn("ospf_apiserver_accept: connect: %s",
- safe_strerror(errno));
+ zlog_warn("%s: connect: %s", __func__, safe_strerror(errno));
close(new_sync_sock);
close(new_async_sock);
return;
@@ -672,8 +661,7 @@ void ospf_apiserver_accept(struct thread *thread)
/* Make the asynchronous channel write-only. */
ret = shutdown(new_async_sock, SHUT_RD);
if (ret < 0) {
- zlog_warn("ospf_apiserver_accept: shutdown: %s",
- safe_strerror(errno));
+ zlog_warn("%s: shutdown: %s", __func__, safe_strerror(errno));
close(new_sync_sock);
close(new_async_sock);
return;
@@ -734,7 +722,7 @@ static int ospf_apiserver_send_msg(struct ospf_apiserver *apiserv,
event = OSPF_APISERVER_ASYNC_WRITE;
break;
default:
- zlog_warn("ospf_apiserver_send_msg: Unknown message type %d",
+ zlog_warn("%s: Unknown message type %d", __func__,
msg->hdr.msgtype);
return -1;
}
@@ -759,7 +747,7 @@ int ospf_apiserver_send_reply(struct ospf_apiserver *apiserv, uint32_t seqnr,
int ret;
if (!msg) {
- zlog_warn("ospf_apiserver_send_reply: msg_new failed");
+ zlog_warn("%s: msg_new failed", __func__);
#ifdef NOTYET
/* Cannot allocate new message. What should we do? */
ospf_apiserver_free(apiserv);
@@ -815,7 +803,7 @@ int ospf_apiserver_handle_msg(struct ospf_apiserver *apiserv, struct msg *msg)
rc = ospf_apiserver_handle_sync_router_id(apiserv, msg);
break;
default:
- zlog_warn("ospf_apiserver_handle_msg: Unknown message type: %d",
+ zlog_warn("%s: Unknown message type: %d", __func__,
msg->hdr.msgtype);
rc = -1;
}
@@ -846,8 +834,7 @@ int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserv,
originator_func = ospf_apiserver_lsa11_originator;
break;
default:
- zlog_warn("ospf_apiserver_register_opaque_type: lsa_type(%d)",
- lsa_type);
+ zlog_warn("%s: lsa_type(%d)", __func__, lsa_type);
return OSPF_API_ILLEGALLSATYPE;
}
@@ -1018,8 +1005,8 @@ void ospf_apiserver_notify_ready_type9(struct ospf_apiserver *apiserv)
0, OSPF_OPAQUE_LINK_LSA, r->opaque_type,
oi->address->u.prefix4);
if (!msg) {
- zlog_warn(
- "apiserver_notify_ready_type9: msg_new failed");
+ zlog_warn("%s: msg_new failed",
+ __func__);
#ifdef NOTYET
/* Cannot allocate new message. What
* should we do? */
@@ -1067,8 +1054,8 @@ void ospf_apiserver_notify_ready_type10(struct ospf_apiserver *apiserv)
0, OSPF_OPAQUE_AREA_LSA, r->opaque_type,
area->area_id);
if (!msg) {
- zlog_warn(
- "apiserver_notify_ready_type10: msg_new failed");
+ zlog_warn("%s: msg_new failed",
+ __func__);
#ifdef NOTYET
/* Cannot allocate new message. What
* should we do? */
@@ -1110,8 +1097,7 @@ void ospf_apiserver_notify_ready_type11(struct ospf_apiserver *apiserv)
r->opaque_type, noarea_id);
if (!msg) {
- zlog_warn(
- "apiserver_notify_ready_type11: msg_new failed");
+ zlog_warn("%s: msg_new failed", __func__);
#ifdef NOTYET
/* Cannot allocate new message. What should we
* do? */
@@ -1234,8 +1220,7 @@ static int apiserver_sync_callback(struct ospf_lsa *lsa, void *p_arg,
MSG_LSA_UPDATE_NOTIFY, seqnum, ifaddr, area_id,
lsa->flags & OSPF_LSA_SELF, lsa->data);
if (!msg) {
- zlog_warn(
- "apiserver_sync_callback: new_msg_update failed");
+ zlog_warn("%s: new_msg_update failed", __func__);
#ifdef NOTYET
/* Cannot allocate new message. What should we do? */
/* ospf_apiserver_free (apiserv);*/ /* Do nothing
@@ -1534,7 +1519,7 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area,
/* Create a stream for internal opaque LSA */
if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) {
- zlog_warn("ospf_apiserver_opaque_lsa_new: stream_new failed");
+ zlog_warn("%s: stream_new failed", __func__);
return NULL;
}
@@ -1627,7 +1612,7 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
case OSPF_OPAQUE_LINK_LSA:
oi = ospf_apiserver_if_lookup_by_addr(omsg->ifaddr);
if (!oi) {
- zlog_warn("apiserver_originate: unknown interface %pI4",
+ zlog_warn("%s: unknown interface %pI4", __func__,
&omsg->ifaddr);
rc = OSPF_API_NOSUCHINTERFACE;
goto out;
@@ -1638,7 +1623,7 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
case OSPF_OPAQUE_AREA_LSA:
area = ospf_area_lookup_by_area_id(ospf, omsg->area_id);
if (!area) {
- zlog_warn("apiserver_originate: unknown area %pI4",
+ zlog_warn("%s: unknown area %pI4", __func__,
&omsg->area_id);
rc = OSPF_API_NOSUCHAREA;
goto out;
@@ -1650,9 +1635,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
break;
default:
/* We can only handle opaque types here */
- zlog_warn(
- "apiserver_originate: Cannot originate non-opaque LSA type %d",
- data->type);
+ zlog_warn("%s: Cannot originate non-opaque LSA type %d",
+ __func__, data->type);
rc = OSPF_API_ILLEGALLSATYPE;
goto out;
}
@@ -1663,9 +1647,8 @@ int ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
if (!apiserver_is_opaque_type_registered(apiserv, lsa_type,
opaque_type)) {
- zlog_warn(
- "apiserver_originate: LSA-type(%d)/Opaque-type(%d): Not registered",
- lsa_type, opaque_type);
+ zlog_warn("%s: LSA-type(%d)/Opaque-type(%d): Not registered",
+ __func__, lsa_type, opaque_type);
rc = OSPF_API_OPAQUETYPENOTREGISTERED;
goto out;
}
@@ -1785,9 +1768,8 @@ int ospf_apiserver_originate1(struct ospf_lsa *lsa, struct ospf_lsa *old)
*/
assert(!ospf_opaque_is_owned(old));
if (IS_LSA_MAX_SEQ(old)) {
- flog_warn(
- EC_OSPF_LSA_INSTALL_FAILURE,
- "ospf_apiserver_originate1: old LSA at maxseq");
+ flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+ "%s: old LSA at maxseq", __func__);
return -1;
}
lsa->data->ls_seqnum = lsa_seqnum_increment(old);
@@ -1869,9 +1851,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
apiserv = lookup_apiserver_by_lsa(lsa);
if (!apiserv) {
- zlog_warn(
- "ospf_apiserver_lsa_refresher: LSA[%s]: No apiserver?",
- dump_lsa_key(lsa));
+ zlog_warn("%s: LSA[%s]: No apiserver?", __func__,
+ dump_lsa_key(lsa));
lsa->data->ls_age =
htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
goto out;
@@ -1889,8 +1870,7 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
new = ospf_apiserver_opaque_lsa_new(lsa->area, lsa->oi,
lsa->data);
if (!new) {
- zlog_warn(
- "ospf_apiserver_lsa_refresher: Cannot create a new LSA?");
+ zlog_warn("%s: Cannot create a new LSA?", __func__);
goto out;
}
} else {
@@ -1908,9 +1888,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
/* Install LSA into LSDB. */
if (ospf_lsa_install(ospf, new->oi, new) == NULL) {
- flog_warn(
- EC_OSPF_LSA_INSTALL_FAILURE,
- "ospf_apiserver_lsa_refresher: ospf_lsa_install failed");
+ flog_warn(EC_OSPF_LSA_INSTALL_FAILURE,
+ "%s: ospf_lsa_install failed", __func__);
ospf_lsa_unlock(&new);
goto out;
}
@@ -1962,7 +1941,7 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
case OSPF_OPAQUE_AREA_LSA:
area = ospf_area_lookup_by_area_id(ospf, dmsg->area_id);
if (!area) {
- zlog_warn("ospf_apiserver_lsa_delete: unknown area %pI4",
+ zlog_warn("%s: unknown area %pI4", __func__,
&dmsg->area_id);
rc = OSPF_API_NOSUCHAREA;
goto out;
@@ -1973,9 +1952,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
area = NULL;
break;
default:
- zlog_warn(
- "ospf_apiserver_lsa_delete: Cannot delete non-opaque LSA type %d",
- dmsg->lsa_type);
+ zlog_warn("%s: Cannot delete non-opaque LSA type %d", __func__,
+ dmsg->lsa_type);
rc = OSPF_API_ILLEGALLSATYPE;
goto out;
}
@@ -1986,9 +1964,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
if (!apiserver_is_opaque_type_registered(apiserv, lsa_type,
opaque_type)) {
- zlog_warn(
- "ospf_apiserver_lsa_delete: LSA-type(%d)/Opaque-type(%d): Not registered",
- lsa_type, opaque_type);
+ zlog_warn("%s: LSA-type(%d)/Opaque-type(%d): Not registered",
+ __func__, lsa_type, opaque_type);
rc = OSPF_API_OPAQUETYPENOTREGISTERED;
goto out;
}
@@ -2004,9 +1981,8 @@ int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
*/
old = ospf_lsa_lookup(ospf, area, dmsg->lsa_type, id, ospf->router_id);
if (!old) {
- zlog_warn(
- "ospf_apiserver_lsa_delete: LSA[Type%d:%pI4] not in LSDB",
- dmsg->lsa_type, &id);
+ zlog_warn("%s: LSA[Type%d:%pI4] not in LSDB", __func__,
+ dmsg->lsa_type, &id);
rc = OSPF_API_NOSUCHLSA;
goto out;
}
@@ -2114,7 +2090,7 @@ int ospf_apiserver_new_if(struct interface *ifp)
if (ifp->name[0] == '\0') {
/* interface has empty name */
- zlog_warn("ospf_apiserver_new_if: interface has no name?");
+ zlog_warn("%s: interface has no name?", __func__);
return 0;
}
@@ -2125,7 +2101,7 @@ int ospf_apiserver_new_if(struct interface *ifp)
if (ifp->name[0] == '\0') {
/* interface has empty name */
- zlog_warn("ospf_apiserver_new_if: interface has no name?");
+ zlog_warn("%s: interface has no name?", __func__);
return 0;
}
@@ -2134,9 +2110,8 @@ int ospf_apiserver_new_if(struct interface *ifp)
if (!oi) {
/* This interface is known to Zebra but not to OSPF daemon yet.
*/
- zlog_warn(
- "ospf_apiserver_new_if: interface %s not known to OSPFd?",
- ifp->name);
+ zlog_warn("%s: interface %s not known to OSPFd?", __func__,
+ ifp->name);
return 0;
}
@@ -2154,9 +2129,8 @@ int ospf_apiserver_del_if(struct interface *ifp)
struct ospf_interface *oi;
/* zlog_warn for debugging */
- zlog_warn("ospf_apiserver_del_if");
- zlog_warn("ifp name=%s status=%d index=%d", ifp->name, ifp->status,
- ifp->ifindex);
+ zlog_warn("%s ifp name=%s status=%d index=%d", __func__, ifp->name,
+ ifp->status, ifp->ifindex);
oi = ospf_apiserver_if_lookup_by_ifp(ifp);
@@ -2179,20 +2153,19 @@ void ospf_apiserver_ism_change(struct ospf_interface *oi, int old_state)
/* Tell clients about interface change */
/* zlog_warn for debugging */
- zlog_warn("ospf_apiserver_ism_change");
+ zlog_warn("%s", __func__);
if (listcount(apiserver_list) > 0) {
ospf_apiserver_clients_notify_ism_change(oi);
}
- zlog_warn("oi->ifp->name=%s", oi->ifp->name);
- zlog_warn("old_state=%d", old_state);
- zlog_warn("oi->state=%d", oi->state);
+ zlog_warn("%s oi->ifp->name=%s old_state=%d oi->state=%d", __func__,
+ oi->ifp->name, old_state, oi->state);
}
void ospf_apiserver_nsm_change(struct ospf_neighbor *nbr, int old_status)
{
/* Neighbor status changed, tell clients about it */
- zlog_warn("ospf_apiserver_nsm_change");
+ zlog_warn("%s", __func__);
if (listcount(apiserver_list) > 0) {
ospf_apiserver_clients_notify_nsm_change(nbr);
}
@@ -2300,7 +2273,8 @@ void ospf_apiserver_clients_notify_ready_type9(struct ospf_interface *oi)
oi->address->u.prefix4);
if (!msg) {
zlog_warn(
- "ospf_apiserver_clients_notify_ready_type9: new_msg_ready_notify failed");
+ "%s: new_msg_ready_notify failed",
+ __func__);
#ifdef NOTYET
/* Cannot allocate new message. What
* should we do? */
@@ -2344,7 +2318,8 @@ void ospf_apiserver_clients_notify_ready_type10(struct ospf_area *area)
area->area_id);
if (!msg) {
zlog_warn(
- "ospf_apiserver_clients_notify_ready_type10: new_msg_ready_nofity failed");
+ "%s: new_msg_ready_nofity failed",
+ __func__);
#ifdef NOTYET
/* Cannot allocate new message. What
* should we do? */
@@ -2390,7 +2365,8 @@ void ospf_apiserver_clients_notify_ready_type11(struct ospf *top)
id_null);
if (!msg) {
zlog_warn(
- "ospf_apiserver_clients_notify_ready_type11: new_msg_ready_notify failed");
+ "%s: new_msg_ready_notify failed",
+ __func__);
#ifdef NOTYET
/* Cannot allocate new message. What
* should we do? */
@@ -2449,8 +2425,7 @@ void ospf_apiserver_clients_notify_ism_change(struct ospf_interface *oi)
msg = new_msg_ism_change(0, ifaddr, area_id, oi->state);
if (!msg) {
- zlog_warn(
- "apiserver_clients_notify_ism_change: msg_new failed");
+ zlog_warn("%s: msg_new failed", __func__);
return;
}
@@ -2473,8 +2448,7 @@ void ospf_apiserver_clients_notify_nsm_change(struct ospf_neighbor *nbr)
msg = new_msg_nsm_change(0, ifaddr, nbraddr, nbr->router_id,
nbr->state);
if (!msg) {
- zlog_warn(
- "apiserver_clients_notify_nsm_change: msg_new failed");
+ zlog_warn("%s: msg_new failed", __func__);
return;
}
@@ -2509,8 +2483,7 @@ static int apiserver_clients_lsa_change_notify(uint8_t msgtype,
ifaddr, area_id,
lsa->flags & OSPF_LSA_SELF, lsa->data);
if (!msg) {
- zlog_warn(
- "apiserver_clients_lsa_change_notify: msg_new failed");
+ zlog_warn("%s: msg_new failed", __func__);
return -1;
}
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index f805899b81..f9869a6733 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -75,9 +75,7 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
struct ospf_route * or ;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_network_route(): processing summary route to %pFX",
- p);
+ zlog_debug("%s: processing summary route to %pFX", __func__, p);
/* Find a route to the same dest */
if ((rn1 = route_node_lookup(rt, (struct prefix *)p))) {
@@ -88,7 +86,8 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
if ((or = rn1->info)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_ia_network_route(): Found a route to the same network");
+ "%s: Found a route to the same network",
+ __func__);
/* Check the existing route. */
if ((res = ospf_route_cmp(ospf, new_or, or)) < 0) {
/* New route is better, so replace old one. */
@@ -112,9 +111,7 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
} /*if (rn1)*/
else { /* no route */
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_network_route(): add new route to %pFX",
- p);
+ zlog_debug("%s: add new route to %pFX", __func__, p);
ospf_route_add(rt, p, new_or, abr_or);
}
}
@@ -129,7 +126,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
int ret;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_ia_router_route(): considering %pFX", p);
+ zlog_debug("%s: considering %pFX", __func__, p);
/* Find a route to the same dest */
rn = route_node_get(rtrs, (struct prefix *)p);
@@ -150,7 +147,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
if (or) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_ia_router_route(): a route to the same ABR through the same area exists");
+ "%s: a route to the same ABR through the same area exists",
+ __func__);
/* New route is better */
if ((ret = ospf_route_cmp(ospf, new_or, or)) < 0) {
listnode_delete(rn->info, or);
@@ -160,8 +158,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
/* Routes are the same */
else if (ret == 0) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_router_route(): merging the new route");
+ zlog_debug("%s: merging the new route",
+ __func__);
ospf_route_copy_nexthops(or, abr_or->paths);
ospf_route_free(new_or);
@@ -170,8 +168,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
/* New route is worse */
else {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_router_route(): skipping the new route");
+ zlog_debug("%s: skipping the new route",
+ __func__);
ospf_route_free(new_or);
return;
}
@@ -180,7 +178,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
ospf_route_copy_nexthops(new_or, abr_or->paths);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_ia_router_route(): adding the new route");
+ zlog_debug("%s: adding the new route", __func__);
listnode_add(rn->info, new_or);
}
@@ -202,8 +200,7 @@ static int process_summary_lsa(struct ospf_area *area, struct route_table *rt,
sl = (struct summary_lsa *)lsa->data;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("process_summary_lsa(): LS ID: %pI4",
- &sl->header.id);
+ zlog_debug("%s: LS ID: %pI4", __func__, &sl->header.id);
metric = GET_METRIC(sl->metric);
@@ -311,8 +308,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
if (abr_or == NULL) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_network_route(): can't find a route to the ABR");
+ zlog_debug("%s: can't find a route to the ABR",
+ __func__);
return;
}
@@ -326,8 +323,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
installed
backbone paths */
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_network_route(): Allowing Shortcut ABR to add new route");
+ zlog_debug("%s: Allowing Shortcut ABR to add new route",
+ __func__);
new_or = ospf_route_new();
new_or->type = OSPF_DESTINATION_NETWORK;
new_or->id = lsa->header.id;
@@ -352,8 +349,7 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
if (or->path_type != OSPF_PATH_INTRA_AREA &&
or->path_type != OSPF_PATH_INTER_AREA) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_network_route(): ERR: path type is wrong");
+ zlog_debug("%s: ERR: path type is wrong", __func__);
return;
}
@@ -364,37 +360,39 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_update_network_route(): Shortcut: this intra-area path is not backbone");
+ "%s: Shortcut: this intra-area path is not backbone",
+ __func__);
return;
}
} else /* Not Shortcut ABR */
{
if (!OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_network_route(): route is not BB-associated");
+ zlog_debug("%s: route is not BB-associated",
+ __func__);
return; /* We can update only BB routes */
}
}
if (or->cost < cost) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_network_route(): new route is worse");
+ zlog_debug("%s: new route is worse", __func__);
return;
}
if (or->cost == cost) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_update_network_route(): new route is same distance, adding nexthops");
+ "%s: new route is same distance, adding nexthops",
+ __func__);
ospf_route_copy_nexthops(or, abr_or->paths);
}
if (or->cost > cost) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_update_network_route(): new route is better, overriding nexthops");
+ "%s: new route is better, overriding nexthops",
+ __func__);
ospf_route_subst_nexthops(or, abr_or->paths);
or->cost = cost;
@@ -431,8 +429,8 @@ static void ospf_update_router_route(struct ospf *ospf,
if (abr_or == NULL) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_update_router_route(): can't find a route to the ABR");
+ zlog_debug("%s: can't find a route to the ABR",
+ __func__);
return;
}
@@ -481,8 +479,8 @@ static void ospf_update_router_route(struct ospf *ospf,
if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_upd_router_route(): the remote router is not an ASBR");
+ zlog_debug("%s: the remote router is not an ASBR",
+ __func__);
return;
}
@@ -524,28 +522,24 @@ static int process_transit_summary_lsa(struct ospf_area *area,
sl = (struct summary_lsa *)lsa->data;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("process_transit_summaries(): LS ID: %pI4",
- &lsa->data->id);
+ zlog_debug("%s: LS ID: %pI4", __func__, &lsa->data->id);
metric = GET_METRIC(sl->metric);
if (metric == OSPF_LS_INFINITY) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "process_transit_summaries(): metric is infinity, skip");
+ zlog_debug("%s: metric is infinity, skip", __func__);
return 0;
}
if (IS_LSA_MAXAGE(lsa)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "process_transit_summaries(): This LSA is too old");
+ zlog_debug("%s: This LSA is too old", __func__);
return 0;
}
if (ospf_lsa_is_self_originated(area->ospf, lsa)) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "process_transit_summaries(): This LSA is mine, skip");
+ zlog_debug("%s: This LSA is mine, skip", __func__);
return 0;
}
@@ -586,20 +580,19 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_ia_routing():start");
+ zlog_debug("%s:start", __func__);
if (IS_OSPF_ABR(ospf)) {
switch (ospf->abr_type) {
case OSPF_ABR_STAND:
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_ia_routing():Standard ABR");
+ zlog_debug("%s:Standard ABR", __func__);
if ((area = ospf->backbone)) {
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug(
- "ospf_ia_routing():backbone area found");
- zlog_debug(
- "ospf_ia_routing():examining summaries");
+ "%s:backbone area found, examining summaries",
+ __func__);
}
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
@@ -611,23 +604,22 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL(
area, rt, rtrs);
} else if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_routing():backbone area NOT found");
+ zlog_debug("%s:backbone area NOT found",
+ __func__);
break;
case OSPF_ABR_IBM:
case OSPF_ABR_CISCO:
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_routing():Alternative Cisco/IBM ABR");
+ zlog_debug("%s:Alternative Cisco/IBM ABR",
+ __func__);
area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */
if (area && ospf_act_bb_connection(ospf)) {
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug(
- "ospf_ia_routing(): backbone area found");
- zlog_debug(
- "ospf_ia_routing(): examining BB summaries");
+ "%s: backbone area found, examining BB summaries",
+ __func__);
}
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
@@ -642,7 +634,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
*/
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_ia_routing(): Active BB connection not found");
+ "%s: Active BB connection not found",
+ __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node,
area))
OSPF_EXAMINE_SUMMARIES_ALL(area, rt,
@@ -651,17 +644,15 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
break;
case OSPF_ABR_SHORTCUT:
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_routing():Alternative Shortcut");
+ zlog_debug("%s:Alternative Shortcut", __func__);
area = ospf->backbone; /* Find the BB */
/* If we have an active BB connection */
if (area && ospf_act_bb_connection(ospf)) {
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug(
- "ospf_ia_routing(): backbone area found");
- zlog_debug(
- "ospf_ia_routing(): examining BB summaries");
+ "%s: backbone area found, examining BB summaries",
+ __func__);
}
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
}
@@ -683,8 +674,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
}
} else {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_ia_routing():not ABR, considering all areas");
+ zlog_debug("%s:not ABR, considering all areas",
+ __func__);
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 2a758d5583..646d318362 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -909,18 +909,19 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
struct prefix_ipv4 *p;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_vl_new()(%s): Start", ospf_get_name(ospf));
+ zlog_debug("%s: (%s): Start", __func__, ospf_get_name(ospf));
if (vlink_count == OSPF_VL_MAX_COUNT) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_vl_new(): Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links");
+ "%s: Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links",
+ __func__);
+
return NULL;
}
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
- ospf->vrf_id);
+ zlog_debug("%s: creating pseudo zebra interface vrf id %u",
+ __func__, ospf->vrf_id);
snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
vi = if_get_by_name(ifname, ospf->vrf_id, ospf->name);
@@ -944,7 +945,9 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
if (voi == NULL) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_vl_new(): Alarm: OSPF int structure is not created");
+ "%s: Alarm: OSPF int structure is not created",
+ __func__);
+
return NULL;
}
voi->connected = co;
@@ -954,17 +957,15 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
vlink_count++;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_vl_new(): Created name: %s", ifname);
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_vl_new(): set if->name to %s", vi->name);
+ zlog_debug("%s: Created name: %s set if->name to %s", __func__,
+ ifname, vi->name);
area_id.s_addr = INADDR_ANY;
area = ospf_area_get(ospf, area_id);
voi->area = area;
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_vl_new(): set associated area to the backbone");
+ zlog_debug("%s: set associated area to the backbone", __func__);
/* Add pseudo neighbor. */
ospf_nbr_self_reset(voi, voi->ospf->router_id);
@@ -972,7 +973,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
ospf_area_add_if(voi->area, voi);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("ospf_vl_new(): Stop");
+ zlog_debug("%s: Stop", __func__);
return voi;
}
@@ -1167,10 +1168,8 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
struct ospf_interface *oi;
if (IS_DEBUG_OSPF_EVENT) {
- zlog_debug("ospf_vl_up_check(): Start");
- zlog_debug("ospf_vl_up_check(): Router ID is %pI4",
- &rid);
- zlog_debug("ospf_vl_up_check(): Area is %pI4",
+ zlog_debug("%s: Start", __func__);
+ zlog_debug("%s: Router ID is %pI4 Area is %pI4", __func__, &rid,
&area->area_id);
}
@@ -1189,13 +1188,13 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
SET_FLAG(vl_data->flags, OSPF_VL_FLAG_APPROVED);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "ospf_vl_up_check(): this VL matched");
+ zlog_debug("%s: this VL matched", __func__);
if (oi->state == ISM_Down) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
- "ospf_vl_up_check(): VL is down, waking it up");
+ "%s: VL is down, waking it up",
+ __func__);
SET_FLAG(oi->ifp->flags, IFF_UP);
OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp);
}
@@ -1203,13 +1202,15 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
if (ospf_vl_set_params(area, vl_data, v)) {
if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
zlog_debug(
- "ospf_vl_up_check: VL cost change, scheduling router lsa refresh");
+ "%s: VL cost change, scheduling router lsa refresh",
+ __func__);
if (ospf->backbone)
ospf_router_lsa_update_area(
ospf->backbone);
else if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
zlog_debug(
- "ospf_vl_up_check: VL cost change, no backbone!");
+ "%s: VL cost change, no backbone!",
+ __func__);
}
}
}
diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c
index c5c98d8024..60602ee04a 100644
--- a/pimd/pim6_mld.c
+++ b/pimd/pim6_mld.c
@@ -2246,8 +2246,16 @@ void gm_ifp_update(struct interface *ifp)
return;
}
- if (!pim_ifp->mld)
+ /*
+ * If ipv6 mld is not enabled on interface, do not start mld activites.
+ */
+ if (!pim_ifp->gm_enable)
+ return;
+
+ if (!pim_ifp->mld) {
+ changed = true;
gm_start(ifp);
+ }
gm_ifp = pim_ifp->mld;
if (IPV6_ADDR_CMP(&pim_ifp->ll_lowest, &gm_ifp->cur_ll_lowest))
diff --git a/pimd/pim_addr.h b/pimd/pim_addr.h
index 2f2ff24675..defe4070cf 100644
--- a/pimd/pim_addr.h
+++ b/pimd/pim_addr.h
@@ -38,6 +38,7 @@ typedef struct in_addr pim_addr;
#define PIM_AF_DBG "pim"
#define PIM_MROUTE_DBG "mroute"
#define PIMREG "pimreg"
+#define GM "IGMP"
#define PIM_ADDR_FUNCNAME(name) ipv4_##name
@@ -64,6 +65,7 @@ typedef struct in6_addr pim_addr;
#define PIM_AF_DBG "pimv6"
#define PIM_MROUTE_DBG "mroute6"
#define PIMREG "pim6reg"
+#define GM "MLD"
#define PIM_ADDR_FUNCNAME(name) ipv6_##name
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 1d3f5f430a..3092d1d3f5 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -888,6 +888,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
{
struct pim_upstream *up;
time_t now = pim_time_monotonic_sec();
+ struct ttable *tt = NULL;
+ char *table = NULL;
json_object *json_group = NULL;
json_object *json_row = NULL;
@@ -895,8 +897,15 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
if (!json) {
vty_out(vty, "\n");
- vty_out(vty,
- "Source Group RpfIface RpfAddress RibNextHop Metric Pref\n");
+
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "Source|Group|RpfIface|RpfAddress|RibNextHop|Metric|Pref");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
}
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
@@ -944,8 +953,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
json_object_object_add(json_group, src_str, json_row);
} else {
- vty_out(vty,
- "%-15pPAs %-15pPAs %-16s %-15pPA %-15pPAs %6d %4d\n",
+ ttable_add_row(
+ tt, "%pPAs|%pPAs|%s|%pPA|%pPAs|%d|%d",
&up->sg.src, &up->sg.grp, rpf_ifname,
&rpf->rpf_addr,
&rpf->source_nexthop.mrib_nexthop_addr,
@@ -953,14 +962,27 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
rpf->source_nexthop.mrib_metric_preference);
}
}
+ /* Dump the generated table. */
+ if (!json) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
{
struct interface *ifp;
+ struct ttable *tt = NULL;
+ char *table = NULL;
- vty_out(vty,
- "Interface Address Neighbor Secondary \n");
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt, "Interface|Address|Neighbor|Secondary");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
FOR_ALL_INTERFACES (pim->vrf, ifp) {
struct pim_interface *pim_ifp;
@@ -988,12 +1010,16 @@ void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list,
prefix_node, p))
- vty_out(vty,
- "%-16s %-15pPAs %-15pPAs %-15pFX\n",
- ifp->name, &ifaddr, &neigh->source_addr,
- p);
+ ttable_add_row(tt, "%s|%pPAs|%pPAs|%pFX",
+ ifp->name, &ifaddr,
+ &neigh->source_addr, p);
}
}
+ /* Dump the generated table. */
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
}
void pim_show_state(struct pim_instance *pim, struct vty *vty,
@@ -1317,15 +1343,24 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
pim_sgaddr *sg, json_object *json)
{
struct pim_upstream *up;
+ struct ttable *tt = NULL;
+ char *table = NULL;
time_t now;
json_object *json_group = NULL;
json_object *json_row = NULL;
now = pim_time_monotonic_sec();
- if (!json)
- vty_out(vty,
- "Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt\n");
+ if (!json) {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "Iif|Source|Group|State|Uptime|JoinTimer|RSTimer|KATimer|RefCnt");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
char uptime[10];
@@ -1446,8 +1481,8 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
json_object_int_add(json_row, "sptBit", up->sptbit);
json_object_object_add(json_group, src_str, json_row);
} else {
- vty_out(vty,
- "%-16s%-15pPAs %-15pPAs %-11s %-8s %-9s %-9s %-9s %6d\n",
+ ttable_add_row(tt,
+ "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s|%d",
up->rpf.source_nexthop.interface
? up->rpf.source_nexthop.interface->name
: "Unknown",
@@ -1455,12 +1490,20 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
join_timer, rs_timer, ka_timer, up->ref_count);
}
}
+ /* Dump the generated table. */
+ if (!json) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
static void pim_show_join_desired_helper(struct pim_instance *pim,
struct vty *vty,
struct pim_upstream *up,
- json_object *json, bool uj)
+ json_object *json, bool uj,
+ struct ttable *tt)
{
json_object *json_group = NULL;
json_object *json_row = NULL;
@@ -1491,45 +1534,68 @@ static void pim_show_join_desired_helper(struct pim_instance *pim,
json_object_object_add(json_group, src_str, json_row);
} else {
- vty_out(vty, "%-15pPAs %-15pPAs %-6s\n", &up->sg.src,
- &up->sg.grp,
- pim_upstream_evaluate_join_desired(pim, up) ? "yes"
- : "no");
+ ttable_add_row(tt, "%pPAs|%pPAs|%s", &up->sg.src, &up->sg.grp,
+ pim_upstream_evaluate_join_desired(pim, up)
+ ? "yes"
+ : "no");
}
}
void pim_show_join_desired(struct pim_instance *pim, struct vty *vty, bool uj)
{
struct pim_upstream *up;
+ struct ttable *tt = NULL;
+ char *table = NULL;
json_object *json = NULL;
if (uj)
json = json_object_new_object();
- else
- vty_out(vty, "Source Group EvalJD\n");
+ else {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt, "Source|Group|EvalJD");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
/* scan all interfaces */
- pim_show_join_desired_helper(pim, vty, up, json, uj);
+ pim_show_join_desired_helper(pim, vty, up, json, uj, tt);
}
if (uj)
vty_json(vty, json);
+ else {
+ /* Dump the generated table. */
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
{
struct pim_upstream *up;
+ struct ttable *tt = NULL;
+ char *table = NULL;
json_object *json = NULL;
json_object *json_group = NULL;
json_object *json_row = NULL;
if (uj)
json = json_object_new_object();
- else
- vty_out(vty,
- "Source Group RpfIface RibNextHop RpfAddress \n");
+ else {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt,
+ "Source|Group|RpfIface|RibNextHop|RpfAddress");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
struct pim_rpf *rpf;
@@ -1571,16 +1637,22 @@ void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
&rpf->rpf_addr);
json_object_object_add(json_group, src_str, json_row);
} else {
- vty_out(vty,
- "%-15pPAs %-15pPAs %-16s %-15pPA %-15pPA\n",
- &up->sg.src, &up->sg.grp, rpf_ifname,
- &rpf->source_nexthop.mrib_nexthop_addr,
- &rpf->rpf_addr);
+ ttable_add_row(tt, "%pPAs|%pPAs|%s|%pPA|%pPA",
+ &up->sg.src, &up->sg.grp, rpf_ifname,
+ &rpf->source_nexthop.mrib_nexthop_addr,
+ &rpf->rpf_addr);
}
}
if (uj)
vty_json(vty, json);
+ else {
+ /* Dump the generated table. */
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,
@@ -3817,7 +3889,6 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
json_object *json,
- struct vty *vty,
struct ttable *tt)
{
json_object *json_group = NULL;
@@ -3885,10 +3956,10 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
/* Print PIM and IGMP route counts */
frr_each (rb_pim_oil, &pim->channel_oil_head, c_oil)
- show_mroute_count_per_channel_oil(c_oil, json, vty, tt);
+ show_mroute_count_per_channel_oil(c_oil, json, tt);
for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr))
- show_mroute_count_per_channel_oil(&sr->c_oil, json, vty, tt);
+ show_mroute_count_per_channel_oil(&sr->c_oil, json, tt);
/* Dump the generated table. */
if (!json) {
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 0fb5e8c6d9..e03e5a2630 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -115,7 +115,7 @@ static int pim_sec_addr_comp(const void *p1, const void *p2)
return 0;
}
-struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
+struct pim_interface *pim_if_new(struct interface *ifp, bool gm, bool pim,
bool ispimreg, bool is_vxlan_term)
{
struct pim_interface *pim_ifp;
@@ -154,9 +154,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
pim_ifp->pim_enable = pim;
pim_ifp->pim_passive_enable = false;
-#if PIM_IPV == 4
- pim_ifp->gm_enable = igmp;
-#endif
+ pim_ifp->gm_enable = gm;
pim_ifp->gm_join_list = NULL;
pim_ifp->pim_neighbor_list = NULL;
@@ -810,7 +808,7 @@ void pim_if_addr_add_all(struct interface *ifp)
ifp->name);
}
/*
- * PIM or IGMP is enabled on interface, and there is at least one
+ * PIM or IGMP/MLD is enabled on interface, and there is at least one
* address assigned, then try to create a vif_index.
*/
if (pim_ifp->mroute_vif_index < 0) {
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c
index 408e86b698..72b16a5f49 100644
--- a/pimd/pim_nb_config.c
+++ b/pimd/pim_nb_config.c
@@ -348,8 +348,7 @@ static bool is_pim_interface(const struct lyd_node *dnode)
return false;
}
-#if PIM_IPV == 4
-static int pim_cmd_igmp_start(struct interface *ifp)
+static int pim_cmd_gm_start(struct interface *ifp)
{
struct pim_interface *pim_ifp;
uint8_t need_startup = 0;
@@ -377,7 +376,6 @@ static int pim_cmd_igmp_start(struct interface *ifp)
return NB_OK;
}
-#endif /* PIM_IPV == 4 */
/*
* CLI reconfiguration affects the interface level (struct pim_interface).
@@ -2584,7 +2582,6 @@ int lib_interface_gmp_address_family_destroy(struct nb_cb_destroy_args *args)
int lib_interface_gmp_address_family_enable_modify(
struct nb_cb_modify_args *args)
{
-#if PIM_IPV == 4
struct interface *ifp;
bool gm_enable;
struct pim_interface *pim_ifp;
@@ -2600,9 +2597,10 @@ int lib_interface_gmp_address_family_enable_modify(
/* Limiting mcast interfaces to number of VIFs */
if (mcast_if_count == MAXVIFS) {
ifp_name = yang_dnode_get_string(if_dnode, "name");
- snprintf(args->errmsg, args->errmsg_len,
- "Max multicast interfaces(%d) Reached. Could not enable IGMP on interface %s",
- MAXVIFS, ifp_name);
+ snprintf(
+ args->errmsg, args->errmsg_len,
+ "Max multicast interfaces(%d) Reached. Could not enable %s on interface %s",
+ MAXVIFS, GM, ifp_name);
return NB_ERR_VALIDATION;
}
break;
@@ -2614,7 +2612,7 @@ int lib_interface_gmp_address_family_enable_modify(
gm_enable = yang_dnode_get_bool(args->dnode, NULL);
if (gm_enable)
- return pim_cmd_igmp_start(ifp);
+ return pim_cmd_gm_start(ifp);
else {
pim_ifp = ifp->info;
@@ -2626,15 +2624,16 @@ int lib_interface_gmp_address_family_enable_modify(
pim_if_membership_clear(ifp);
+#if PIM_IPV == 4
pim_if_addr_del_all_igmp(ifp);
+#else
+ gm_ifp_teardown(ifp);
+#endif
if (!pim_ifp->pim_enable)
pim_if_delete(ifp);
}
}
-#else
- /* TBD Depends on MLD data structure changes */
-#endif /* PIM_IPV == 4 */
return NB_OK;
}
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 783c9b97e7..1dce6b3562 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -51,6 +51,7 @@
#include "pim_bsm.h"
#include "pim_util.h"
#include "pim_ssm.h"
+#include "termtable.h"
/* Cleanup pim->rpf_hash each node data */
void pim_rp_list_hash_clean(void *data)
@@ -1166,14 +1167,25 @@ void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
struct rp_info *rp_info;
struct rp_info *prev_rp_info = NULL;
struct listnode *node;
+ struct ttable *tt = NULL;
+ char *table = NULL;
char source[7];
+ char grp[INET6_ADDRSTRLEN];
json_object *json_rp_rows = NULL;
json_object *json_row = NULL;
- if (!json)
- vty_out(vty,
- "RP address group/prefix-list OIF I am RP Source Group-Type\n");
+ if (!json) {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "RP address|group/prefix-list|OIF|I am RP|Source|Group-Type");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
+
for (ALL_LIST_ELEMENTS_RO(pim->rp_list, node, rp_info)) {
if (pim_rpf_addr_is_inaddr_any(&rp_info->rp))
continue;
@@ -1243,32 +1255,31 @@ void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
json_object_array_add(json_rp_rows, json_row);
} else {
- vty_out(vty, "%-15pPA ", &rp_info->rp.rpf_addr);
-
- if (rp_info->plist)
- vty_out(vty, "%-18s ", rp_info->plist);
- else
- vty_out(vty, "%-18pFX ", &rp_info->group);
-
- if (rp_info->rp.source_nexthop.interface)
- vty_out(vty, "%-16s ",
- rp_info->rp.source_nexthop
- .interface->name);
- else
- vty_out(vty, "%-16s ", "(Unknown)");
-
- if (rp_info->i_am_rp)
- vty_out(vty, "yes");
- else
- vty_out(vty, "no");
-
- vty_out(vty, "%14s", source);
- vty_out(vty, "%6s\n", group_type);
+ prefix2str(&rp_info->group, grp, sizeof(grp));
+ ttable_add_row(tt, "%pPA|%s|%s|%s|%s|%s",
+ &rp_info->rp.rpf_addr,
+ rp_info->plist
+ ? rp_info->plist
+ : grp,
+ rp_info->rp.source_nexthop.interface
+ ? rp_info->rp.source_nexthop
+ .interface->name
+ : "Unknown",
+ rp_info->i_am_rp
+ ? "yes"
+ : "no",
+ source, group_type);
}
prev_rp_info = rp_info;
}
- if (json) {
+ /* Dump the generated table. */
+ if (!json) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ } else {
if (prev_rp_info && json_rp_rows)
json_object_object_addf(json, json_rp_rows, "%pPA",
&prev_rp_info->rp.rpf_addr);
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index 3d5d68b1f4..cfbd436981 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -370,6 +370,12 @@ static int gm_config_write(struct vty *vty, int writes,
static int gm_config_write(struct vty *vty, int writes,
struct pim_interface *pim_ifp)
{
+ /* IF ipv6 mld */
+ if (pim_ifp->gm_enable) {
+ vty_out(vty, " ipv6 mld\n");
+ ++writes;
+ }
+
if (pim_ifp->mld_version != MLD_DEFAULT_VERSION)
vty_out(vty, " ipv6 mld version %d\n", pim_ifp->mld_version);
if (pim_ifp->gm_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL)
diff --git a/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py b/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py
index c8cdc7ec5c..4d7f436eac 100644
--- a/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py
+++ b/tests/topotests/bgp_default_originate/test_bgp_default_originate_2links.py
@@ -22,6 +22,7 @@
Following tests are covered.
1. Verify default-originate route with default static and network command
2. Verify default-originate route with aggregate summary command
+3. Verfiy default-originate behaviour in ecmp
"""
import os
import sys
@@ -48,7 +49,10 @@ from lib.bgp import (
from lib.common_config import (
verify_fib_routes,
step,
+ create_prefix_lists,
run_frr_cmd,
+ create_route_maps,
+ shutdown_bringup_interface,
get_frr_ipv6_linklocal,
start_topology,
apply_raw_config,
@@ -296,6 +300,78 @@ def verify_the_uptime(time_stamp_before, time_stamp_after, incremented=None):
return True
+def get_best_path_route_in_FIB(tgen, topo, dut, network):
+ """
+ API to verify the best route in FIB and return the ipv4 and ipv6 nexthop for the given route
+ command
+ =======
+ show ip route
+ show ipv6 route
+ params
+ ======
+ dut : device under test :
+ network ; route (ip) to which the best route to be retrieved
+ Returns
+ ========
+ on success : return dict with next hops for the best hop
+ on failure : return error message with boolean False
+ """
+ is_ipv4_best_path_found = False
+ is_ipv6_best_path_found = False
+ rnode = tgen.routers()[dut]
+ ipv4_show_bgp_json = run_frr_cmd(rnode, "sh ip bgp json ", isjson=True)
+ ipv6_show_bgp_json = run_frr_cmd(
+ rnode, "sh ip bgp ipv6 unicast json ", isjson=True
+ )
+ output_dict = {"ipv4": None, "ipv6": None}
+ ipv4_nxt_hop_count = len(ipv4_show_bgp_json["routes"][network["ipv4"]])
+ for index in range(ipv4_nxt_hop_count):
+ if "bestpath" in ipv4_show_bgp_json["routes"][network["ipv4"]][index].keys():
+ best_path_ip = ipv4_show_bgp_json["routes"][network["ipv4"]][index][
+ "nexthops"
+ ][0]["ip"]
+ output_dict["ipv4"] = best_path_ip
+ logger.info(
+ "[DUT [{}]] Best path for the route {} is {} ".format(
+ dut, network["ipv4"], best_path_ip
+ )
+ )
+ is_ipv4_best_path_found = True
+ else:
+ logger.error("ERROR....! No Best Path Found in BGP RIB.... FAILED")
+
+ ipv6_nxt_hop_count = len(ipv6_show_bgp_json["routes"][network["ipv6"]])
+ for index in range(ipv6_nxt_hop_count):
+ if "bestpath" in ipv6_show_bgp_json["routes"][network["ipv6"]][index].keys():
+ ip_add_count = len(
+ ipv6_show_bgp_json["routes"][network["ipv6"]][index]["nexthops"]
+ )
+ for i_index in range(ip_add_count):
+ if (
+ "global"
+ in ipv6_show_bgp_json["routes"][network["ipv6"]][index]["nexthops"][
+ i_index
+ ]["scope"]
+ ):
+ best_path_ip = ipv6_show_bgp_json["routes"][network["ipv6"]][index][
+ "nexthops"
+ ][i_index]["ip"]
+ output_dict["ipv6"] = best_path_ip
+ logger.info(
+ "[DUT [{}]] Best path for the route {} is {} ".format(
+ dut, network["ipv6"], best_path_ip
+ )
+ )
+
+ else:
+ logger.error("ERROR....! No Best Path Found in BGP RIB.... FAILED")
+ if is_ipv4_best_path_found:
+ return output_dict
+ else:
+ logger.error("ERROR...! Unable to find the Best Path in the RIB")
+ return False
+
+
#####################################################
#
# Testcases
@@ -1409,6 +1485,326 @@ def test_verify_bgp_default_originate_with_aggregate_summary_p1(request):
write_test_footer(tc_name)
+def test_verify_default_originate_with_2way_ecmp_p2(request):
+ """
+ Summary: "Verify default-originate route with 3 way ECMP and traffic "
+ """
+
+ tgen = get_topogen()
+ global BGP_CONVERGENCE
+ global DEFAULT_ROUTES
+ DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+
+ if BGP_CONVERGENCE != True:
+ pytest.skip("skipped because of BGP Convergence failure")
+ # test case name
+ tc_name = request.node.name
+ write_test_header(tc_name)
+ if tgen.routers_have_failure():
+ check_router_status(tgen)
+ reset_config_on_routers(tgen)
+
+ step("Populating next-hops details")
+ r1_r2_ipv4_neighbor_ips = []
+ r1_r2_ipv6_neighbor_ips = []
+ r1_link = None
+ for index in range(1, 3):
+ r1_link = "r1-link" + str(index)
+ r1_r2_ipv4_neighbor_ips.append(
+ topo["routers"]["r2"]["links"][r1_link]["ipv4"].split("/")[0]
+ )
+ r1_r2_ipv6_neighbor_ips.append(
+ topo["routers"]["r2"]["links"][r1_link]["ipv6"].split("/")[0]
+ )
+
+ step(
+ "Configure default-originate on R1 for all the neighbor of IPv4 and IPv6 peers "
+ )
+ local_as = get_dut_as_number(tgen, dut="r1")
+ for index in range(2):
+ raw_config = {
+ "r1": {
+ "raw_config": [
+ "router bgp {}".format(local_as),
+ "address-family ipv4 unicast",
+ "neighbor {} default-originate".format(
+ r1_r2_ipv4_neighbor_ips[index]
+ ),
+ "exit-address-family",
+ "address-family ipv6 unicast",
+ "neighbor {} default-originate ".format(
+ r1_r2_ipv6_neighbor_ips[index]
+ ),
+ "exit-address-family",
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step(
+ "After configuring default-originate command , verify default routes are advertised on R2 "
+ )
+
+ r2_link = None
+ for index in range(1, 3):
+ r2_link = "r2-link" + str(index)
+ ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+ interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+ ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+ DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ )
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("Ping R1 configure IPv4 and IPv6 loopback address from R2")
+ pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0]
+ router = tgen.gears["r2"]
+ output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
+ assert " 0% packet loss" in output, "Ping R1->R2 FAILED"
+ logger.info("Ping from R1 to R2 ... success")
+
+ step("Shuting up the active route")
+ network = {"ipv4": "0.0.0.0/0", "ipv6": "::/0"}
+ ipv_dict = get_best_path_route_in_FIB(tgen, topo, dut="r2", network=network)
+ dut_links = topo["routers"]["r1"]["links"]
+ active_interface = None
+ for key, values in dut_links.items():
+ ipv4_address = dut_links[key]["ipv4"].split("/")[0]
+ ipv6_address = dut_links[key]["ipv6"].split("/")[0]
+ if ipv_dict["ipv4"] == ipv4_address and ipv_dict["ipv6"] == ipv6_address:
+ active_interface = dut_links[key]["interface"]
+
+ logger.info(
+ "Shutting down the interface {} on router {} ".format(active_interface, "r1")
+ )
+ shutdown_bringup_interface(tgen, "r1", active_interface, False)
+
+ step("Verify the complete convergence to fail after shutting the interface")
+ result = verify_bgp_convergence(tgen, topo, expected=False)
+ assert (
+ result is not True
+ ), " Testcase {} : After shuting down the interface Convergence is expected to be Failed".format(
+ tc_name
+ )
+
+ step(
+ "Verify routes from active best path is not received from r1 after shuting the interface"
+ )
+ r2_link = None
+ for index in range(1, 3):
+ r2_link = "r2-link" + str(index)
+ ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+ interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+ ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+ DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+ if index == 1:
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ expected=False,
+ )
+ assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+ else:
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ )
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("Ping R1 configure IPv4 and IPv6 loopback address from R2")
+ pingaddr = topo["routers"]["r1"]["links"]["lo"]["ipv4"].split("/")[0]
+ router = tgen.gears["r2"]
+ output = router.run("ping -c 4 -w 4 {}".format(pingaddr))
+ assert " 0% packet loss" in output, "Ping R1->R2 FAILED"
+ logger.info("Ping from R1 to R2 ... success")
+
+ step("No Shuting up the active route")
+
+ shutdown_bringup_interface(tgen, "r1", active_interface, True)
+
+ step("Verify the complete convergence after bringup the interface")
+ result = verify_bgp_convergence(tgen, topo)
+ assert (
+ result is True
+ ), " Testcase {} : After bringing up the interface complete convergence is expected ".format(
+ tc_name
+ )
+
+ step("Verify all the routes are received from r1 after no shuting the interface")
+ r2_link = None
+ for index in range(1, 3):
+ r2_link = "r2-link" + str(index)
+ ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+ interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+ ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+ DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+ if index == 1:
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ )
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+ else:
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ )
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step(
+ "Configure IPv4 and IPv6 route-map with deny option on R2 to filter default route 0.0.0.0/0 and 0::0/0"
+ )
+ DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+ input_dict_3 = {
+ "r2": {
+ "prefix_lists": {
+ "ipv4": {
+ "Pv4": [
+ {
+ "seqid": "1",
+ "network": DEFAULT_ROUTES["ipv4"],
+ "action": "permit",
+ }
+ ]
+ },
+ "ipv6": {
+ "Pv6": [
+ {
+ "seqid": "1",
+ "network": DEFAULT_ROUTES["ipv6"],
+ "action": "permit",
+ }
+ ]
+ },
+ }
+ }
+ }
+ result = create_prefix_lists(tgen, input_dict_3)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ input_dict_3 = {
+ "r2": {
+ "route_maps": {
+ "RMv4": [
+ {
+ "action": "deny",
+ "seq_id": "1",
+ "match": {"ipv4": {"prefix_lists": "Pv4"}},
+ },
+ ],
+ "RMv6": [
+ {
+ "action": "deny",
+ "seq_id": "1",
+ "match": {"ipv6": {"prefix_lists": "Pv6"}},
+ },
+ ],
+ }
+ }
+ }
+ result = create_route_maps(tgen, input_dict_3)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
+
+ step("Apply route-map IN direction of R2 ( R2-R1) for IPv4 and IPv6 BGP neighbors")
+ r2_link = None
+ for index in range(1, 3):
+ r2_link = "r2-link" + str(index)
+ input_dict_4 = {
+ "r2": {
+ "bgp": {
+ "address_family": {
+ "ipv4": {
+ "unicast": {
+ "neighbor": {
+ "r1": {
+ "dest_link": {
+ r2_link: {
+ "route_maps": [
+ {"name": "RMv4", "direction": "in"}
+ ]
+ },
+ }
+ }
+ }
+ }
+ },
+ "ipv6": {
+ "unicast": {
+ "neighbor": {
+ "r1": {
+ "dest_link": {
+ r2_link: {
+ "route_maps": [
+ {"name": "RMv6", "direction": "in"}
+ ]
+ },
+ }
+ }
+ }
+ }
+ },
+ }
+ }
+ }
+ }
+ result = create_router_bgp(tgen, topo, input_dict_4)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("After applying the route-map the routes are not expected in RIB ")
+ r2_link = None
+ for index in range(1, 3):
+ r2_link = "r2-link" + str(index)
+ ipv4_nxt_hop = topo["routers"]["r1"]["links"][r2_link]["ipv4"].split("/")[0]
+ interface = topo["routers"]["r1"]["links"][r2_link]["interface"]
+ ipv6_link_local_nxt_hop = get_frr_ipv6_linklocal(tgen, "r1", intf=interface)
+ DEFAULT_ROUTE_NXT_HOP = {"ipv4": ipv4_nxt_hop, "ipv6": ipv6_link_local_nxt_hop}
+
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP,
+ expected=False,
+ )
+ assert result is not True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ write_test_footer(tc_name)
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py
index 120a3e82e4..f79ca71a64 100755
--- a/tests/topotests/conftest.py
+++ b/tests/topotests/conftest.py
@@ -363,7 +363,7 @@ def pytest_configure(config):
# Check environment now that we have config
if not diagnose_env(rundir):
- pytest.exit("environment has errors, please read the logs")
+ pytest.exit("environment has errors, please read the logs in %s" % rundir)
@pytest.fixture(autouse=True, scope="session")
diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py
index c51a187f28..04712eda87 100644
--- a/tests/topotests/lib/topogen.py
+++ b/tests/topotests/lib/topogen.py
@@ -1293,7 +1293,7 @@ def diagnose_env_linux(rundir):
)
continue
- logger.warning("could not find {} in {}".format(fname, frrdir))
+ logger.error("could not find {} in {}".format(fname, frrdir))
ret = False
else:
if fname != "zebra":
diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in
index 759d498379..b589ced965 100755
--- a/tools/frrcommon.sh.in
+++ b/tools/frrcommon.sh.in
@@ -272,7 +272,7 @@ all_start() {
}
all_stop() {
- local pids reversed
+ local pids reversed need_zebra
daemon_list enabled_daemons disabled_daemons
[ "$1" = "--reallyall" ] && enabled_daemons="$enabled_daemons $disabled_daemons"
@@ -282,13 +282,23 @@ all_stop() {
reversed="$dmninst $reversed"
done
+ # Stop zebra last, after trying to stop the other daemons
for dmninst in $reversed; do
+ if [ "$dmninst" = "zebra" ]; then
+ need_zebra="yes"
+ continue
+ fi
+
daemon_stop "$dmninst" "$1" &
pids="$pids $!"
done
for pid in $pids; do
wait $pid
done
+
+ if [ -n "$need_zebra" ]; then
+ daemon_stop "zebra"
+ fi
}
all_status() {
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index cb549339af..4c089ee194 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -1112,14 +1112,6 @@ void rtm_read(struct rt_msghdr *rtm)
} else
return;
- /*
- * CHANGE: delete the old prefix, we have no further information
- * to specify the route really
- */
- if (rtm->rtm_type == RTM_CHANGE)
- rib_delete(afi, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL,
- 0, zebra_flags, &p, NULL, NULL, 0, RT_TABLE_MAIN, 0,
- 0, true);
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
rib_add(afi, SAFI_UNICAST, VRF_DEFAULT, proto, 0, zebra_flags,
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 1a28f8ceec..4a8fe938ed 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -685,15 +685,10 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
zebra_del_import_table_entry(zvrf, rn, same);
}
- newre = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
- newre->type = ZEBRA_ROUTE_TABLE;
- newre->distance = zebra_import_table_distance[afi][re->table];
- newre->flags = re->flags;
- newre->metric = re->metric;
- newre->mtu = re->mtu;
- newre->table = zvrf->table_id;
- newre->uptime = monotime(NULL);
- newre->instance = re->table;
+ newre = zebra_rib_route_entry_new(
+ 0, ZEBRA_ROUTE_TABLE, re->table, re->flags, re->nhe_id,
+ zvrf->table_id, re->metric, re->mtu,
+ zebra_import_table_distance[afi][re->table], re->tag);
ng = nexthop_group_new();
copy_nexthops(&ng->nexthop, re->nhe->nhg.nexthop, NULL);
diff --git a/zebra/rib.h b/zebra/rib.h
index a40843e27f..dec5b2b8d6 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -178,15 +178,17 @@ struct route_entry {
/* meta-queue structure:
* sub-queue 0: nexthop group objects
* sub-queue 1: EVPN/VxLAN objects
- * sub-queue 2: connected
- * sub-queue 3: kernel
- * sub-queue 4: static
- * sub-queue 5: RIP, RIPng, OSPF, OSPF6, IS-IS, EIGRP, NHRP
- * sub-queue 6: iBGP, eBGP
- * sub-queue 7: any other origin (if any) typically those that
+ * sub-queue 2: Early Route Processing
+ * sub-queue 3: Early Label Processing
+ * sub-queue 4: connected
+ * sub-queue 5: kernel
+ * sub-queue 6: static
+ * sub-queue 7: RIP, RIPng, OSPF, OSPF6, IS-IS, EIGRP, NHRP
+ * sub-queue 8: iBGP, eBGP
+ * sub-queue 9: any other origin (if any) typically those that
* don't generate routes
*/
-#define MQ_SIZE 8
+#define MQ_SIZE 10
struct meta_queue {
struct list *subq[MQ_SIZE];
uint32_t size; /* sum of lengths of all subqueues */
@@ -342,6 +344,12 @@ extern void _route_entry_dump(const char *func, union prefixconstptr pp,
union prefixconstptr src_pp,
const struct route_entry *re);
+struct route_entry *
+zebra_rib_route_entry_new(vrf_id_t vrf_id, int type, uint8_t instance,
+ uint32_t flags, uint32_t nhe_id, uint32_t table_id,
+ uint32_t metric, uint32_t mtu, uint8_t distance,
+ route_tag_t tag);
+
#define ZEBRA_RIB_LOOKUP_ERROR -1
#define ZEBRA_RIB_FOUND_EXACT 0
#define ZEBRA_RIB_FOUND_NOGATE 1
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 0eab1fa850..e883033d59 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -937,44 +937,38 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
afi = AFI_IP6;
if (h->nlmsg_type == RTM_NEWROUTE) {
+ struct route_entry *re;
+ struct nexthop_group *ng = NULL;
+
+ re = zebra_rib_route_entry_new(vrf_id, proto, 0, flags, nhe_id,
+ table, metric, mtu, distance,
+ tag);
+ if (!nhe_id)
+ ng = nexthop_group_new();
if (!tb[RTA_MULTIPATH]) {
- struct nexthop nh = {0};
+ struct nexthop *nexthop, nh;
if (!nhe_id) {
nh = parse_nexthop_unicast(
ns_id, rtm, tb, bh_type, index, prefsrc,
gate, afi, vrf_id);
+
+ nexthop = nexthop_new();
+ *nexthop = nh;
+ nexthop_group_add_sorted(ng, nexthop);
}
- rib_add(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, &p,
- &src_p, &nh, nhe_id, table, metric, mtu,
- distance, tag, startup);
} else {
/* This is a multipath route */
- struct route_entry *re;
- struct nexthop_group *ng = NULL;
struct rtnexthop *rtnh =
(struct rtnexthop *)RTA_DATA(tb[RTA_MULTIPATH]);
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
- re->type = proto;
- re->distance = distance;
- re->flags = flags;
- re->metric = metric;
- re->mtu = mtu;
- re->vrf_id = vrf_id;
- re->table = table;
- re->uptime = monotime(NULL);
- re->tag = tag;
- re->nhe_id = nhe_id;
-
if (!nhe_id) {
uint8_t nhop_num;
/* Use temporary list of nexthops; parse
* message payload's nexthops.
*/
- ng = nexthop_group_new();
nhop_num =
parse_multipath_nexthops_unicast(
ns_id, ng, rtm, rtnh, tb,
@@ -989,23 +983,22 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
ng = NULL;
}
}
-
- if (nhe_id || ng)
- rib_add_multipath(afi, SAFI_UNICAST, &p,
- &src_p, re, ng, startup);
- else {
- /*
- * I really don't see how this is possible
- * but since we are testing for it let's
- * let the end user know why the route
- * that was just received was swallowed
- * up and forgotten
- */
- zlog_err(
- "%s: %pFX multipath RTM_NEWROUTE has a invalid nexthop group from the kernel",
- __func__, &p);
- XFREE(MTYPE_RE, re);
- }
+ }
+ if (nhe_id || ng)
+ rib_add_multipath(afi, SAFI_UNICAST, &p, &src_p, re, ng,
+ startup);
+ else {
+ /*
+ * I really don't see how this is possible
+ * but since we are testing for it let's
+ * let the end user know why the route
+ * that was just received was swallowed
+ * up and forgotten
+ */
+ zlog_err(
+ "%s: %pFX multipath RTM_NEWROUTE has a invalid nexthop group from the kernel",
+ __func__, &p);
+ XFREE(MTYPE_RE, re);
}
} else {
if (nhe_id) {
diff --git a/zebra/tc_netlink.c b/zebra/tc_netlink.c
index 89ce075454..4fb0241d1d 100644
--- a/zebra/tc_netlink.c
+++ b/zebra/tc_netlink.c
@@ -294,7 +294,7 @@ static ssize_t netlink_tclass_msg_encode(int cmd, struct zebra_dplane_ctx *ctx,
htb_opt.cbuffer = cbuffer;
tc_calc_rate_table(&htb_opt.rate, rtab, mtu);
- tc_calc_rate_table(&htb_opt.ceil, rtab, mtu);
+ tc_calc_rate_table(&htb_opt.ceil, ctab, mtu);
htb_opt.ceil.mpu = htb_opt.rate.mpu = 0;
htb_opt.ceil.overhead = htb_opt.rate.overhead = 0;
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index a578395ef8..761ba789b8 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2034,7 +2034,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
struct nhg_backup_info *bnhg = NULL;
int ret;
vrf_id_t vrf_id;
- struct nhg_hash_entry nhe;
+ struct nhg_hash_entry nhe, *n = NULL;
s = msg;
if (zapi_route_decode(s, &api) < 0) {
@@ -2052,17 +2052,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
(int)api.message, api.flags);
/* Allocate new route. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
- re->type = api.type;
- re->instance = api.instance;
- re->flags = api.flags;
- re->uptime = monotime(NULL);
- re->vrf_id = vrf_id;
-
- if (api.tableid)
- re->table = api.tableid;
- else
- re->table = zvrf->table_id;
+ re = zebra_rib_route_entry_new(
+ vrf_id, api.type, api.instance, api.flags, api.nhgid,
+ api.tableid ? api.tableid : zvrf->table_id, api.metric, api.mtu,
+ api.distance, api.tag);
if (!CHECK_FLAG(api.message, ZAPI_MESSAGE_NHG)
&& (!CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)
@@ -2087,9 +2080,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
&api.prefix);
}
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NHG))
- re->nhe_id = api.nhgid;
-
if (!re->nhe_id
&& (!zapi_read_nexthops(client, &api.prefix, api.nexthops,
api.flags, api.message, api.nexthop_num,
@@ -2105,15 +2095,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
return;
}
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_DISTANCE))
- re->distance = api.distance;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC))
- re->metric = api.metric;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_TAG))
- re->tag = api.tag;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_MTU))
- re->mtu = api.mtu;
-
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_OPAQUE)) {
re->opaque =
XMALLOC(MTYPE_RE_OPAQUE,
@@ -2161,9 +2142,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
zebra_nhe_init(&nhe, afi, ng->nexthop);
nhe.nhg.nexthop = ng->nexthop;
nhe.backup_info = bnhg;
+ n = zebra_nhe_copy(&nhe, 0);
}
- ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p,
- re, &nhe, false);
+ ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p, re, n,
+ false);
/*
* rib_add_multipath_nhe only fails in a couple spots
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 763c92ebb6..6a691a222f 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -2775,14 +2775,13 @@ int dplane_ctx_tc_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op)
{
int ret = EINVAL;
- struct zebra_vrf *zvrf = NULL;
struct zebra_ns *zns = NULL;
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
/* TODO: init traffic control qdisc */
- zns = zvrf ? zvrf->zns : zebra_ns_lookup(NS_DEFAULT);
+ zns = zebra_ns_lookup(NS_DEFAULT);
dplane_ctx_ns_init(ctx, zns, true);
@@ -3513,7 +3512,7 @@ dplane_route_update_internal(struct route_node *rn,
static enum zebra_dplane_result dplane_tc_update_internal(enum dplane_op_e op)
{
enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
- int ret = EINVAL;
+ int ret;
struct zebra_dplane_ctx *ctx = NULL;
/* Obtain context block */
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 3010a516b9..9756d9ba08 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -2747,9 +2747,9 @@ static bool ftn_update_nexthop(bool add_p, struct nexthop *nexthop,
return true;
}
-void mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
- struct prefix *prefix, uint8_t route_type,
- unsigned short route_instance)
+void zebra_mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ struct prefix *prefix, uint8_t route_type,
+ uint8_t route_instance)
{
struct route_table *table;
struct route_node *rn;
@@ -2882,8 +2882,8 @@ static bool ftn_update_znh(bool add_p, enum lsp_types_t type,
* There are several changes that need to be made, in several zebra
* data structures, so we want to do all the work required at once.
*/
-void mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
- const struct zapi_labels *zl)
+void zebra_mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
+ const struct zapi_labels *zl)
{
int i, counter, ret = 0;
char buf[NEXTHOP_STRLEN];
diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h
index a114f01339..cf247861f8 100644
--- a/zebra/zebra_mpls.h
+++ b/zebra/zebra_mpls.h
@@ -260,17 +260,30 @@ void zebra_mpls_print_fec(struct vty *vty, struct zebra_vrf *zvrf,
/*
* Handle zapi request to install/uninstall LSP and
* (optionally) FEC-To-NHLFE (FTN) bindings.
+ *
+ * mpls_zapi_labels_process -> Installs for future processing
+ * in the meta-q
+ * zebra_mpls_labels_process -> called by the meta-q
*/
void mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
const struct zapi_labels *zl);
+void zebra_mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
+ const struct zapi_labels *zl);
/*
* Uninstall all NHLFEs bound to a single FEC.
+ *
+ * mpls_ftn_uninstall -> Called to enqueue into early label processing
+ * via the metaq
+ * zebra_mpls_ftn_uninstall -> Called when we process the meta q
+ * for this item
*/
void mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
struct prefix *prefix, uint8_t route_type,
- unsigned short route_instance);
-
+ uint8_t route_instance);
+void zebra_mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ struct prefix *prefix, uint8_t route_type,
+ uint8_t route_instance);
/*
* Install/update a NHLFE for an LSP in the forwarding table. This may be
* a new LSP entry or a new NHLFE for an existing in-label or an update of
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 03bda8cc33..bd7e8bbbd0 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -81,6 +81,8 @@ DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason),
enum meta_queue_indexes {
META_QUEUE_NHG,
META_QUEUE_EVPN,
+ META_QUEUE_EARLY_ROUTE,
+ META_QUEUE_EARLY_LABEL,
META_QUEUE_CONNECTED,
META_QUEUE_KERNEL,
META_QUEUE_STATIC,
@@ -173,6 +175,29 @@ struct wq_evpn_wrapper {
#define WQ_EVPN_WRAPPER_TYPE_REM_MACIP 0x03
#define WQ_EVPN_WRAPPER_TYPE_REM_VTEP 0x04
+enum wq_label_types {
+ WQ_LABEL_FTN_UNINSTALL,
+ WQ_LABEL_LABELS_PROCESS,
+};
+
+struct wq_label_wrapper {
+ enum wq_label_types type;
+ vrf_id_t vrf_id;
+
+ struct prefix p;
+ enum lsp_types_t ltype;
+ uint8_t route_type;
+ uint8_t route_instance;
+
+ bool add_p;
+ struct zapi_labels zl;
+
+ int afi;
+};
+
+static void rib_addnode(struct route_node *rn, struct route_entry *re,
+ int process);
+
/* %pRN is already a printer for route_nodes that just prints the prefix */
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pZN" (struct route_node *)
@@ -185,6 +210,10 @@ static const char *subqueue2str(enum meta_queue_indexes index)
return "NHG Objects";
case META_QUEUE_EVPN:
return "EVPN/VxLan Objects";
+ case META_QUEUE_EARLY_ROUTE:
+ return "Early Route Processing";
+ case META_QUEUE_EARLY_LABEL:
+ return "Early Label Handling";
case META_QUEUE_CONNECTED:
return "Connected Routes";
case META_QUEUE_KERNEL:
@@ -2468,6 +2497,33 @@ static void process_subq_nhg(struct listnode *lnode)
XFREE(MTYPE_WQ_WRAPPER, w);
}
+static void process_subq_early_label(struct listnode *lnode)
+{
+ struct wq_label_wrapper *w = listgetdata(lnode);
+ struct zebra_vrf *zvrf;
+
+ if (!w)
+ return;
+
+ zvrf = vrf_info_lookup(w->vrf_id);
+ if (!zvrf) {
+ XFREE(MTYPE_WQ_WRAPPER, w);
+ return;
+ }
+
+ switch (w->type) {
+ case WQ_LABEL_FTN_UNINSTALL:
+ zebra_mpls_ftn_uninstall(zvrf, w->ltype, &w->p, w->route_type,
+ w->route_instance);
+ break;
+ case WQ_LABEL_LABELS_PROCESS:
+ zebra_mpls_zapi_labels_process(w->add_p, zvrf, &w->zl);
+ break;
+ }
+
+ XFREE(MTYPE_WQ_WRAPPER, w);
+}
+
static void process_subq_route(struct listnode *lnode, uint8_t qindex)
{
struct route_node *rnode = NULL;
@@ -2506,6 +2562,460 @@ static void process_subq_route(struct listnode *lnode, uint8_t qindex)
route_unlock_node(rnode);
}
+static void rib_re_nhg_free(struct route_entry *re)
+{
+ if (re->nhe && re->nhe_id) {
+ assert(re->nhe->id == re->nhe_id);
+ route_entry_update_nhe(re, NULL);
+ } else if (re->nhe && re->nhe->nhg.nexthop)
+ nexthops_free(re->nhe->nhg.nexthop);
+
+ nexthops_free(re->fib_ng.nexthop);
+}
+
+struct zebra_early_route {
+ afi_t afi;
+ safi_t safi;
+ struct prefix p;
+ struct prefix_ipv6 src_p;
+ bool src_p_provided;
+ struct route_entry *re;
+ struct nhg_hash_entry *re_nhe;
+ bool startup;
+ bool deletion;
+ bool fromkernel;
+};
+
+static void early_route_memory_free(struct zebra_early_route *ere)
+{
+ if (ere->re_nhe)
+ zebra_nhg_free(ere->re_nhe);
+
+ XFREE(MTYPE_RE, ere->re);
+ XFREE(MTYPE_WQ_WRAPPER, ere);
+}
+
+static void process_subq_early_route_add(struct zebra_early_route *ere)
+{
+ struct route_entry *re = ere->re;
+ struct route_table *table;
+ struct nhg_hash_entry *nhe = NULL;
+ struct route_node *rn;
+ struct route_entry *same = NULL, *first_same = NULL;
+ int same_count = 0;
+ rib_dest_t *dest;
+
+ /* Lookup table. */
+ table = zebra_vrf_get_table_with_table_id(ere->afi, ere->safi,
+ re->vrf_id, re->table);
+ if (!table) {
+ early_route_memory_free(ere);
+ return;
+ }
+
+ if (re->nhe_id > 0) {
+ nhe = zebra_nhg_lookup_id(re->nhe_id);
+
+ if (!nhe) {
+ /*
+ * We've received from the kernel a nexthop id
+ * that we don't have saved yet. More than likely
+ * it has not been processed and is on the
+ * queue to be processed. Let's stop what we
+ * are doing and cause the meta q to be processed
+ * storing this for later.
+ *
+ * This is being done this way because zebra
+ * runs with the assumption t
+ */
+ flog_err(
+ EC_ZEBRA_TABLE_LOOKUP_FAILED,
+ "Zebra failed to find the nexthop hash entry for id=%u in a route entry %pFX",
+ re->nhe_id, &ere->p);
+
+ early_route_memory_free(ere);
+ return;
+ }
+ } else {
+ /* Lookup nhe from route information */
+ nhe = zebra_nhg_rib_find_nhe(ere->re_nhe, ere->afi);
+ if (!nhe) {
+ char buf2[PREFIX_STRLEN] = "";
+
+ flog_err(
+ EC_ZEBRA_TABLE_LOOKUP_FAILED,
+ "Zebra failed to find or create a nexthop hash entry for %pFX%s%s",
+ &ere->p, ere->src_p_provided ? " from " : "",
+ ere->src_p_provided
+ ? prefix2str(&ere->src_p, buf2,
+ sizeof(buf2))
+ : "");
+
+ early_route_memory_free(ere);
+ return;
+ }
+ }
+
+ /*
+ * Attach the re to the nhe's nexthop group.
+ *
+ * TODO: This will need to change when we start getting IDs from upper
+ * level protocols, as the refcnt might be wrong, since it checks
+ * if old_id != new_id.
+ */
+ route_entry_update_nhe(re, nhe);
+
+ /* Make it sure prefixlen is applied to the prefix. */
+ apply_mask(&ere->p);
+ if (ere->src_p_provided)
+ apply_mask_ipv6(&ere->src_p);
+
+ /* Set default distance by route type. */
+ if (re->distance == 0)
+ re->distance = route_distance(re->type);
+
+ /* Lookup route node.*/
+ rn = srcdest_rnode_get(table, &ere->p,
+ ere->src_p_provided ? &ere->src_p : NULL);
+
+ /*
+ * If same type of route are installed, treat it as a implicit
+ * withdraw. If the user has specified the No route replace semantics
+ * for the install don't do a route replace.
+ */
+ RNODE_FOREACH_RE (rn, same) {
+ if (CHECK_FLAG(same->status, ROUTE_ENTRY_REMOVED)) {
+ same_count++;
+ continue;
+ }
+
+ /* Compare various route_entry properties */
+ if (rib_compare_routes(re, same)) {
+ same_count++;
+
+ if (first_same == NULL)
+ first_same = same;
+ }
+ }
+
+ same = first_same;
+
+ if (!ere->startup && (re->flags & ZEBRA_FLAG_SELFROUTE) &&
+ zrouter.asic_offloaded) {
+ if (!same) {
+ if (IS_ZEBRA_DEBUG_RIB)
+ zlog_debug(
+ "prefix: %pRN is a self route where we do not have an entry for it. Dropping this update, it's useless",
+ rn);
+ /*
+ * We are not on startup, this is a self route
+ * and we have asic offload. Which means
+ * we are getting a callback for a entry
+ * that was already deleted to the kernel
+ * but an earlier response was just handed
+ * back. Drop it on the floor
+ */
+ early_route_memory_free(ere);
+ return;
+ }
+ }
+
+ /* If this route is kernel/connected route, notify the dataplane. */
+ if (RIB_SYSTEM_ROUTE(re)) {
+ /* Notify dataplane */
+ dplane_sys_route_add(rn, re);
+ }
+
+ /* Link new re to node.*/
+ if (IS_ZEBRA_DEBUG_RIB) {
+ rnode_debug(
+ rn, re->vrf_id,
+ "Inserting route rn %p, re %p (%s) existing %p, same_count %d",
+ rn, re, zebra_route_string(re->type), same, same_count);
+
+ if (IS_ZEBRA_DEBUG_RIB_DETAILED)
+ route_entry_dump(
+ &ere->p,
+ ere->src_p_provided ? &ere->src_p : NULL, re);
+ }
+
+ SET_FLAG(re->status, ROUTE_ENTRY_CHANGED);
+ rib_addnode(rn, re, 1);
+
+ /* Free implicit route.*/
+ if (same)
+ rib_delnode(rn, same);
+
+ /* See if we can remove some RE entries that are queued for
+ * removal, but won't be considered in rib processing.
+ */
+ dest = rib_dest_from_rnode(rn);
+ RNODE_FOREACH_RE_SAFE (rn, re, same) {
+ if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED)) {
+ /* If the route was used earlier, must retain it. */
+ if (dest && re == dest->selected_fib)
+ continue;
+
+ if (IS_ZEBRA_DEBUG_RIB)
+ rnode_debug(rn, re->vrf_id,
+ "rn %p, removing unneeded re %p",
+ rn, re);
+
+ rib_unlink(rn, re);
+ }
+ }
+
+ route_unlock_node(rn);
+ if (ere->re_nhe)
+ zebra_nhg_free(ere->re_nhe);
+ XFREE(MTYPE_WQ_WRAPPER, ere);
+}
+
+static void process_subq_early_route_delete(struct zebra_early_route *ere)
+{
+ struct route_table *table;
+ struct route_node *rn;
+ struct route_entry *re;
+ struct route_entry *fib = NULL;
+ struct route_entry *same = NULL;
+ struct nexthop *rtnh;
+ char buf2[INET6_ADDRSTRLEN];
+ rib_dest_t *dest;
+
+ if (ere->src_p_provided)
+ assert(!ere->src_p.prefixlen || ere->afi == AFI_IP6);
+
+ /* Lookup table. */
+ table = zebra_vrf_lookup_table_with_table_id(
+ ere->afi, ere->safi, ere->re->vrf_id, ere->re->table);
+ if (!table) {
+ early_route_memory_free(ere);
+ return;
+ }
+
+ /* Apply mask. */
+ apply_mask(&ere->p);
+ if (ere->src_p_provided)
+ apply_mask_ipv6(&ere->src_p);
+
+ /* Lookup route node. */
+ rn = srcdest_rnode_lookup(table, &ere->p,
+ ere->src_p_provided ? &ere->src_p : NULL);
+ if (!rn) {
+ if (IS_ZEBRA_DEBUG_RIB) {
+ char src_buf[PREFIX_STRLEN];
+ struct vrf *vrf = vrf_lookup_by_id(ere->re->vrf_id);
+
+ if (ere->src_p_provided && ere->src_p.prefixlen)
+ prefix2str(&ere->src_p, src_buf,
+ sizeof(src_buf));
+ else
+ src_buf[0] = '\0';
+
+ zlog_debug("%s[%d]:%pRN%s%s doesn't exist in rib",
+ vrf->name, ere->re->table, rn,
+ (src_buf[0] != '\0') ? " from " : "",
+ src_buf);
+ }
+ early_route_memory_free(ere);
+ return;
+ }
+
+ dest = rib_dest_from_rnode(rn);
+ fib = dest->selected_fib;
+
+ struct nexthop *nh = NULL;
+
+ if (ere->re->nhe)
+ nh = ere->re->nhe->nhg.nexthop;
+
+ /* Lookup same type route. */
+ RNODE_FOREACH_RE (rn, re) {
+ if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
+ continue;
+
+ if (re->type != ere->re->type)
+ continue;
+ if (re->instance != ere->re->instance)
+ continue;
+ if (CHECK_FLAG(re->flags, ZEBRA_FLAG_RR_USE_DISTANCE) &&
+ ere->re->distance != re->distance)
+ continue;
+
+ if (re->type == ZEBRA_ROUTE_KERNEL &&
+ re->metric != ere->re->metric)
+ continue;
+ if (re->type == ZEBRA_ROUTE_CONNECT && (rtnh = nh) &&
+ rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) {
+ if (rtnh->ifindex != nh->ifindex)
+ continue;
+ same = re;
+ break;
+ }
+
+ /* Make sure that the route found has the same gateway. */
+ if (ere->re->nhe_id && re->nhe_id == ere->re->nhe_id) {
+ same = re;
+ break;
+ }
+
+ if (nh == NULL) {
+ same = re;
+ break;
+ }
+ for (ALL_NEXTHOPS(re->nhe->nhg, rtnh)) {
+ /*
+ * No guarantee all kernel send nh with labels
+ * on delete.
+ */
+ if (nexthop_same_no_labels(rtnh, nh)) {
+ same = re;
+ break;
+ }
+ }
+
+ if (same)
+ break;
+ }
+ /*
+ * If same type of route can't be found and this message is from
+ * kernel.
+ */
+ if (!same) {
+ /*
+ * In the past(HA!) we could get here because
+ * we were receiving a route delete from the
+ * kernel and we're not marking the proto
+ * as coming from it's appropriate originator.
+ * Now that we are properly noticing the fact
+ * that the kernel has deleted our route we
+ * are not going to get called in this path
+ * I am going to leave this here because
+ * this might still work this way on non-linux
+ * platforms as well as some weird state I have
+ * not properly thought of yet.
+ * If we can show that this code path is
+ * dead then we can remove it.
+ */
+ if (fib && CHECK_FLAG(ere->re->flags, ZEBRA_FLAG_SELFROUTE)) {
+ if (IS_ZEBRA_DEBUG_RIB) {
+ rnode_debug(
+ rn, ere->re->vrf_id,
+ "rn %p, re %p (%s) was deleted from kernel, adding",
+ rn, fib, zebra_route_string(fib->type));
+ }
+ if (zrouter.allow_delete ||
+ CHECK_FLAG(dest->flags, RIB_ROUTE_ANY_QUEUED)) {
+ UNSET_FLAG(fib->status, ROUTE_ENTRY_INSTALLED);
+ /* Unset flags. */
+ for (rtnh = fib->nhe->nhg.nexthop; rtnh;
+ rtnh = rtnh->next)
+ UNSET_FLAG(rtnh->flags,
+ NEXTHOP_FLAG_FIB);
+
+ /*
+ * This is a non FRR route
+ * as such we should mark
+ * it as deleted
+ */
+ dest->selected_fib = NULL;
+ } else {
+ /*
+ * This means someone else, other than Zebra,
+ * has deleted a Zebra router from the kernel.
+ * We will add it back
+ */
+ rib_install_kernel(rn, fib, NULL);
+ }
+ } else {
+ if (IS_ZEBRA_DEBUG_RIB) {
+ if (nh)
+ rnode_debug(
+ rn, ere->re->vrf_id,
+ "via %s ifindex %d type %d doesn't exist in rib",
+ inet_ntop(afi2family(ere->afi),
+ &nh->gate, buf2,
+ sizeof(buf2)),
+ nh->ifindex, ere->re->type);
+ else
+ rnode_debug(
+ rn, ere->re->vrf_id,
+ "type %d doesn't exist in rib",
+ ere->re->type);
+ }
+ route_unlock_node(rn);
+ early_route_memory_free(ere);
+ return;
+ }
+ }
+
+ if (same) {
+ struct nexthop *tmp_nh;
+
+ if (ere->fromkernel &&
+ CHECK_FLAG(ere->re->flags, ZEBRA_FLAG_SELFROUTE) &&
+ !zrouter.allow_delete) {
+ rib_install_kernel(rn, same, NULL);
+ route_unlock_node(rn);
+
+ early_route_memory_free(ere);
+ return;
+ }
+
+ /* Special handling for IPv4 or IPv6 routes sourced from
+ * EVPN - the nexthop (and associated MAC) need to be
+ * uninstalled if no more refs.
+ */
+ for (ALL_NEXTHOPS(re->nhe->nhg, tmp_nh)) {
+ struct ipaddr vtep_ip;
+
+ if (CHECK_FLAG(tmp_nh->flags, NEXTHOP_FLAG_EVPN)) {
+ memset(&vtep_ip, 0, sizeof(struct ipaddr));
+ if (ere->afi == AFI_IP) {
+ vtep_ip.ipa_type = IPADDR_V4;
+ memcpy(&(vtep_ip.ipaddr_v4),
+ &(tmp_nh->gate.ipv4),
+ sizeof(struct in_addr));
+ } else {
+ vtep_ip.ipa_type = IPADDR_V6;
+ memcpy(&(vtep_ip.ipaddr_v6),
+ &(tmp_nh->gate.ipv6),
+ sizeof(struct in6_addr));
+ }
+ zebra_rib_queue_evpn_route_del(
+ re->vrf_id, &vtep_ip, &ere->p);
+ }
+ }
+
+ /* Notify dplane if system route changes */
+ if (RIB_SYSTEM_ROUTE(re))
+ dplane_sys_route_del(rn, same);
+
+ rib_delnode(rn, same);
+ }
+
+ route_unlock_node(rn);
+
+ early_route_memory_free(ere);
+}
+
+/*
+ * When FRR receives a route we need to match the route up to
+ * nexthop groups. That we also may have just received
+ * place the data on this queue so that this work of finding
+ * the nexthop group entries for the route entry is always
+ * done after the nexthop group has had a chance to be processed
+ */
+static void process_subq_early_route(struct listnode *lnode)
+{
+ struct zebra_early_route *ere = listgetdata(lnode);
+
+ if (ere->deletion)
+ process_subq_early_route_delete(ere);
+ else
+ process_subq_early_route_add(ere);
+}
+
/*
* Examine the specified subqueue; process one entry and return 1 if
* there is a node, return 0 otherwise.
@@ -2525,6 +3035,12 @@ static unsigned int process_subq(struct list *subq,
case META_QUEUE_NHG:
process_subq_nhg(lnode);
break;
+ case META_QUEUE_EARLY_ROUTE:
+ process_subq_early_route(lnode);
+ break;
+ case META_QUEUE_EARLY_LABEL:
+ process_subq_early_label(lnode);
+ break;
case META_QUEUE_CONNECTED:
case META_QUEUE_KERNEL:
case META_QUEUE_STATIC:
@@ -2555,8 +3071,9 @@ static wq_item_status meta_queue_process(struct work_queue *dummy, void *data)
queue_len = dplane_get_in_queue_len();
if (queue_len > queue_limit) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- zlog_debug("rib queue: dplane queue len %u, limit %u, retrying",
- queue_len, queue_limit);
+ zlog_debug(
+ "rib queue: dplane queue len %u, limit %u, retrying",
+ queue_len, queue_limit);
/* Ensure that the meta-queue is actually enqueued */
if (work_queue_empty(zrouter.ribq))
@@ -2635,6 +3152,13 @@ static int rib_meta_queue_add(struct meta_queue *mq, void *data)
return 0;
}
+static int early_label_meta_queue_add(struct meta_queue *mq, void *data)
+{
+ listnode_add(mq->subq[META_QUEUE_EARLY_LABEL], data);
+ mq->size++;
+ return 0;
+}
+
static int rib_meta_queue_nhg_ctx_add(struct meta_queue *mq, void *data)
{
struct nhg_ctx *ctx = NULL;
@@ -2718,6 +3242,44 @@ static int mq_add_handler(void *data,
return mq_add_func(zrouter.mq, data);
}
+void mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ struct prefix *prefix, uint8_t route_type,
+ uint8_t route_instance)
+{
+ struct wq_label_wrapper *w;
+
+ w = XCALLOC(MTYPE_WQ_WRAPPER, sizeof(struct wq_label_wrapper));
+
+ w->type = WQ_LABEL_FTN_UNINSTALL;
+ w->vrf_id = zvrf->vrf->vrf_id;
+ w->p = *prefix;
+ w->ltype = type;
+ w->route_type = route_type;
+ w->route_instance = route_instance;
+
+ if (IS_ZEBRA_DEBUG_RIB_DETAILED)
+ zlog_debug("Early Label Handling for %pFX", prefix);
+
+ mq_add_handler(w, early_label_meta_queue_add);
+}
+
+void mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
+ const struct zapi_labels *zl)
+{
+ struct wq_label_wrapper *w;
+
+ w = XCALLOC(MTYPE_WQ_WRAPPER, sizeof(struct wq_label_wrapper));
+ w->type = WQ_LABEL_LABELS_PROCESS;
+ w->vrf_id = zvrf->vrf->vrf_id;
+ w->add_p = add_p;
+ w->zl = *zl;
+
+ if (IS_ZEBRA_DEBUG_RIB_DETAILED)
+ zlog_debug("Early Label Handling: Labels Process");
+
+ mq_add_handler(w, early_label_meta_queue_add);
+}
+
/* Add route_node to work queue and schedule processing */
int rib_queue_add(struct route_node *rn)
{
@@ -2958,7 +3520,6 @@ int zebra_rib_queue_evpn_rem_vtep_del(vrf_id_t vrf_id, vni_t vni,
return mq_add_handler(w, rib_meta_queue_evpn_add);
}
-
/* Create new meta queue.
A destructor function doesn't seem to be necessary here.
*/
@@ -3034,6 +3595,29 @@ static void nhg_meta_queue_free(struct meta_queue *mq, struct list *l,
}
}
+static void early_label_meta_queue_free(struct meta_queue *mq, struct list *l,
+ struct zebra_vrf *zvrf)
+{
+ struct wq_label_wrapper *w;
+ struct listnode *node, *nnode;
+
+ for (ALL_LIST_ELEMENTS(l, node, nnode, w)) {
+ if (zvrf && zvrf->vrf->vrf_id != w->vrf_id)
+ continue;
+
+ switch (w->type) {
+ case WQ_LABEL_FTN_UNINSTALL:
+ case WQ_LABEL_LABELS_PROCESS:
+ break;
+ }
+
+ node->data = NULL;
+ XFREE(MTYPE_WQ_WRAPPER, w);
+ list_delete_node(l, node);
+ mq->size--;
+ }
+}
+
static void rib_meta_queue_free(struct meta_queue *mq, struct list *l,
struct zebra_vrf *zvrf)
{
@@ -3053,6 +3637,22 @@ static void rib_meta_queue_free(struct meta_queue *mq, struct list *l,
}
}
+static void early_route_meta_queue_free(struct meta_queue *mq, struct list *l,
+ struct zebra_vrf *zvrf)
+{
+ struct zebra_early_route *zer;
+ struct listnode *node, *nnode;
+
+ for (ALL_LIST_ELEMENTS(l, node, nnode, zer)) {
+ if (zvrf && zer->re->vrf_id != zvrf->vrf->vrf_id)
+ continue;
+
+ XFREE(MTYPE_RE, zer);
+ node->data = NULL;
+ list_delete_node(l, node);
+ mq->size--;
+ }
+}
void meta_queue_free(struct meta_queue *mq, struct zebra_vrf *zvrf)
{
@@ -3067,6 +3667,12 @@ void meta_queue_free(struct meta_queue *mq, struct zebra_vrf *zvrf)
case META_QUEUE_EVPN:
evpn_meta_queue_free(mq, mq->subq[i], zvrf);
break;
+ case META_QUEUE_EARLY_ROUTE:
+ early_route_meta_queue_free(mq, mq->subq[i], zvrf);
+ break;
+ case META_QUEUE_EARLY_LABEL:
+ early_label_meta_queue_free(mq, mq->subq[i], zvrf);
+ break;
case META_QUEUE_CONNECTED:
case META_QUEUE_KERNEL:
case META_QUEUE_STATIC:
@@ -3210,17 +3816,6 @@ static void rib_addnode(struct route_node *rn,
rib_link(rn, re, process);
}
-static void rib_re_nhg_free(struct route_entry *re)
-{
- if (re->nhe && re->nhe_id) {
- assert(re->nhe->id == re->nhe_id);
- route_entry_update_nhe(re, NULL);
- } else if (re->nhe && re->nhe->nhg.nexthop)
- nexthops_free(re->nhe->nhg.nexthop);
-
- nexthops_free(re->fib_ng.nexthop);
-}
-
/*
* rib_unlink
*
@@ -3426,6 +4021,46 @@ void _route_entry_dump(const char *func, union prefixconstptr pp,
zlog_debug("%s: dump complete", straddr);
}
+static int rib_meta_queue_early_route_add(struct meta_queue *mq, void *data)
+{
+ struct zebra_early_route *ere = data;
+
+ listnode_add(mq->subq[META_QUEUE_EARLY_ROUTE], data);
+ mq->size++;
+
+ if (IS_ZEBRA_DEBUG_RIB_DETAILED)
+ zlog_debug(
+ "Route %pFX(%u) queued for processing into sub-queue %s",
+ &ere->p, ere->re->vrf_id,
+ subqueue2str(META_QUEUE_EARLY_ROUTE));
+
+ return 0;
+}
+
+struct route_entry *zebra_rib_route_entry_new(vrf_id_t vrf_id, int type,
+ uint8_t instance, uint32_t flags,
+ uint32_t nhe_id,
+ uint32_t table_id,
+ uint32_t metric, uint32_t mtu,
+ uint8_t distance, route_tag_t tag)
+{
+ struct route_entry *re;
+
+ re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
+ re->type = type;
+ re->instance = instance;
+ re->distance = distance;
+ re->flags = flags;
+ re->metric = metric;
+ re->mtu = mtu;
+ re->table = table_id;
+ re->vrf_id = vrf_id;
+ re->uptime = monotime(NULL);
+ re->tag = tag;
+ re->nhe_id = nhe_id;
+
+ return re;
+}
/*
* Internal route-add implementation; there are a couple of different public
* signatures. Callers in this path are responsible for the memory they
@@ -3441,162 +4076,25 @@ int rib_add_multipath_nhe(afi_t afi, safi_t safi, struct prefix *p,
struct prefix_ipv6 *src_p, struct route_entry *re,
struct nhg_hash_entry *re_nhe, bool startup)
{
- struct nhg_hash_entry *nhe = NULL;
- struct route_table *table;
- struct route_node *rn;
- struct route_entry *same = NULL, *first_same = NULL;
- int ret = 0;
- int same_count = 0;
- rib_dest_t *dest;
+ struct zebra_early_route *ere;
- if (!re || !re_nhe)
+ if (!re)
return -1;
assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
- /* Lookup table. */
- table = zebra_vrf_get_table_with_table_id(afi, safi, re->vrf_id,
- re->table);
- if (!table)
- return -1;
-
- if (re->nhe_id > 0) {
- nhe = zebra_nhg_lookup_id(re->nhe_id);
-
- if (!nhe) {
- flog_err(
- EC_ZEBRA_TABLE_LOOKUP_FAILED,
- "Zebra failed to find the nexthop hash entry for id=%u in a route entry",
- re->nhe_id);
-
- return -1;
- }
- } else {
- /* Lookup nhe from route information */
- nhe = zebra_nhg_rib_find_nhe(re_nhe, afi);
- if (!nhe) {
- char buf2[PREFIX_STRLEN] = "";
-
- flog_err(
- EC_ZEBRA_TABLE_LOOKUP_FAILED,
- "Zebra failed to find or create a nexthop hash entry for %pFX%s%s",
- p, src_p ? " from " : "",
- src_p ? prefix2str(src_p, buf2, sizeof(buf2))
- : "");
-
- return -1;
- }
- }
-
- /*
- * Attach the re to the nhe's nexthop group.
- *
- * TODO: This will need to change when we start getting IDs from upper
- * level protocols, as the refcnt might be wrong, since it checks
- * if old_id != new_id.
- */
- route_entry_update_nhe(re, nhe);
-
- /* Make it sure prefixlen is applied to the prefix. */
- apply_mask(p);
+ ere = XCALLOC(MTYPE_WQ_WRAPPER, sizeof(*ere));
+ ere->afi = afi;
+ ere->safi = safi;
+ ere->p = *p;
if (src_p)
- apply_mask_ipv6(src_p);
-
- /* Set default distance by route type. */
- if (re->distance == 0)
- re->distance = route_distance(re->type);
-
- /* Lookup route node.*/
- rn = srcdest_rnode_get(table, p, src_p);
-
- /*
- * If same type of route are installed, treat it as a implicit
- * withdraw. If the user has specified the No route replace semantics
- * for the install don't do a route replace.
- */
- RNODE_FOREACH_RE (rn, same) {
- if (CHECK_FLAG(same->status, ROUTE_ENTRY_REMOVED)) {
- same_count++;
- continue;
- }
-
- /* Compare various route_entry properties */
- if (rib_compare_routes(re, same)) {
- same_count++;
-
- if (first_same == NULL)
- first_same = same;
- }
- }
-
- same = first_same;
-
- if (!startup &&
- (re->flags & ZEBRA_FLAG_SELFROUTE) && zrouter.asic_offloaded) {
- if (!same) {
- if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug("prefix: %pRN is a self route where we do not have an entry for it. Dropping this update, it's useless", rn);
- /*
- * We are not on startup, this is a self route
- * and we have asic offload. Which means
- * we are getting a callback for a entry
- * that was already deleted to the kernel
- * but an earlier response was just handed
- * back. Drop it on the floor
- */
- rib_re_nhg_free(re);
-
- XFREE(MTYPE_RE, re);
- return ret;
- }
- }
-
- /* If this route is kernel/connected route, notify the dataplane. */
- if (RIB_SYSTEM_ROUTE(re)) {
- /* Notify dataplane */
- dplane_sys_route_add(rn, re);
- }
-
- /* Link new re to node.*/
- if (IS_ZEBRA_DEBUG_RIB) {
- rnode_debug(rn, re->vrf_id,
- "Inserting route rn %p, re %p (%s) existing %p, same_count %d",
- rn, re, zebra_route_string(re->type), same,
- same_count);
-
- if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- route_entry_dump(p, src_p, re);
- }
-
- SET_FLAG(re->status, ROUTE_ENTRY_CHANGED);
- rib_addnode(rn, re, 1);
-
- /* Free implicit route.*/
- if (same) {
- ret = 1;
- rib_delnode(rn, same);
- }
-
- /* See if we can remove some RE entries that are queued for
- * removal, but won't be considered in rib processing.
- */
- dest = rib_dest_from_rnode(rn);
- RNODE_FOREACH_RE_SAFE (rn, re, same) {
- if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED)) {
- /* If the route was used earlier, must retain it. */
- if (dest && re == dest->selected_fib)
- continue;
-
- if (IS_ZEBRA_DEBUG_RIB)
- rnode_debug(rn, re->vrf_id, "rn %p, removing unneeded re %p",
- rn, re);
+ ere->src_p = *src_p;
+ ere->src_p_provided = !!src_p;
+ ere->re = re;
+ ere->re_nhe = re_nhe;
+ ere->startup = startup;
- rib_unlink(rn, re);
- }
- }
-
- route_unlock_node(rn);
- return ret;
+ return mq_add_handler(ere, rib_meta_queue_early_route_add);
}
/*
@@ -3607,7 +4105,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
struct nexthop_group *ng, bool startup)
{
int ret;
- struct nhg_hash_entry nhe;
+ struct nhg_hash_entry nhe, *n;
if (!re)
return -1;
@@ -3625,10 +4123,8 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
else if (re->nhe_id > 0)
nhe.id = re->nhe_id;
- ret = rib_add_multipath_nhe(afi, safi, p, src_p, re, &nhe, startup);
-
- /* In this path, the callers expect memory to be freed. */
- nexthop_group_delete(&ng);
+ n = zebra_nhe_copy(&nhe, 0);
+ ret = rib_add_multipath_nhe(afi, safi, p, src_p, re, n, startup);
/* In error cases, free the route also */
if (ret < 0)
@@ -3643,212 +4139,32 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
uint32_t nhe_id, uint32_t table_id, uint32_t metric,
uint8_t distance, bool fromkernel)
{
- struct route_table *table;
- struct route_node *rn;
- struct route_entry *re;
- struct route_entry *fib = NULL;
- struct route_entry *same = NULL;
- struct nexthop *rtnh;
- char buf2[INET6_ADDRSTRLEN];
- rib_dest_t *dest;
-
- assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
-
- /* Lookup table. */
- table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf_id,
- table_id);
- if (!table)
- return;
-
- /* Apply mask. */
- apply_mask(p);
- if (src_p)
- apply_mask_ipv6(src_p);
-
- /* Lookup route node. */
- rn = srcdest_rnode_lookup(table, p, src_p);
- if (!rn) {
- if (IS_ZEBRA_DEBUG_RIB) {
- char src_buf[PREFIX_STRLEN];
- struct vrf *vrf = vrf_lookup_by_id(vrf_id);
-
- if (src_p && src_p->prefixlen)
- prefix2str(src_p, src_buf, sizeof(src_buf));
- else
- src_buf[0] = '\0';
-
- zlog_debug("%s[%d]:%pRN%s%s doesn't exist in rib",
- vrf->name, table_id, rn,
- (src_buf[0] != '\0') ? " from " : "",
- src_buf);
- }
- return;
- }
-
- dest = rib_dest_from_rnode(rn);
- fib = dest->selected_fib;
-
- /* Lookup same type route. */
- RNODE_FOREACH_RE (rn, re) {
- if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
- continue;
-
- if (re->type != type)
- continue;
- if (re->instance != instance)
- continue;
- if (CHECK_FLAG(re->flags, ZEBRA_FLAG_RR_USE_DISTANCE) &&
- distance != re->distance)
- continue;
-
- if (re->type == ZEBRA_ROUTE_KERNEL && re->metric != metric)
- continue;
- if (re->type == ZEBRA_ROUTE_CONNECT &&
- (rtnh = re->nhe->nhg.nexthop)
- && rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) {
- if (rtnh->ifindex != nh->ifindex)
- continue;
- same = re;
- break;
- }
-
- /* Make sure that the route found has the same gateway. */
- if (nhe_id && re->nhe_id == nhe_id) {
- same = re;
- break;
- }
-
- if (nh == NULL) {
- same = re;
- break;
- }
- for (ALL_NEXTHOPS(re->nhe->nhg, rtnh)) {
- /*
- * No guarantee all kernel send nh with labels
- * on delete.
- */
- if (nexthop_same_no_labels(rtnh, nh)) {
- same = re;
- break;
- }
- }
-
- if (same)
- break;
- }
- /* If same type of route can't be found and this message is from
- kernel. */
- if (!same) {
- /*
- * In the past(HA!) we could get here because
- * we were receiving a route delete from the
- * kernel and we're not marking the proto
- * as coming from it's appropriate originator.
- * Now that we are properly noticing the fact
- * that the kernel has deleted our route we
- * are not going to get called in this path
- * I am going to leave this here because
- * this might still work this way on non-linux
- * platforms as well as some weird state I have
- * not properly thought of yet.
- * If we can show that this code path is
- * dead then we can remove it.
- */
- if (fib && CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE)) {
- if (IS_ZEBRA_DEBUG_RIB) {
- rnode_debug(rn, vrf_id,
- "rn %p, re %p (%s) was deleted from kernel, adding",
- rn, fib,
- zebra_route_string(fib->type));
- }
- if (zrouter.allow_delete ||
- CHECK_FLAG(dest->flags, RIB_ROUTE_ANY_QUEUED)) {
- UNSET_FLAG(fib->status, ROUTE_ENTRY_INSTALLED);
- /* Unset flags. */
- for (rtnh = fib->nhe->nhg.nexthop; rtnh;
- rtnh = rtnh->next)
- UNSET_FLAG(rtnh->flags,
- NEXTHOP_FLAG_FIB);
-
- /*
- * This is a non FRR route
- * as such we should mark
- * it as deleted
- */
- dest->selected_fib = NULL;
- } else {
- /* This means someone else, other than Zebra,
- * has deleted
- * a Zebra router from the kernel. We will add
- * it back */
- rib_install_kernel(rn, fib, NULL);
- }
- } else {
- if (IS_ZEBRA_DEBUG_RIB) {
- if (nh)
- rnode_debug(
- rn, vrf_id,
- "via %s ifindex %d type %d doesn't exist in rib",
- inet_ntop(afi2family(afi),
- &nh->gate, buf2,
- sizeof(buf2)),
- nh->ifindex, type);
- else
- rnode_debug(
- rn, vrf_id,
- "type %d doesn't exist in rib",
- type);
- }
- route_unlock_node(rn);
- return;
- }
- }
-
- if (same) {
- struct nexthop *tmp_nh;
-
- if (fromkernel && CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE) &&
- !zrouter.allow_delete) {
- rib_install_kernel(rn, same, NULL);
- route_unlock_node(rn);
-
- return;
- }
-
- /* Special handling for IPv4 or IPv6 routes sourced from
- * EVPN - the nexthop (and associated MAC) need to be
- * uninstalled if no more refs.
- */
- for (ALL_NEXTHOPS(re->nhe->nhg, tmp_nh)) {
- struct ipaddr vtep_ip;
-
- if (CHECK_FLAG(tmp_nh->flags, NEXTHOP_FLAG_EVPN)) {
- memset(&vtep_ip, 0, sizeof(struct ipaddr));
- if (afi == AFI_IP) {
- vtep_ip.ipa_type = IPADDR_V4;
- memcpy(&(vtep_ip.ipaddr_v4),
- &(tmp_nh->gate.ipv4),
- sizeof(struct in_addr));
- } else {
- vtep_ip.ipa_type = IPADDR_V6;
- memcpy(&(vtep_ip.ipaddr_v6),
- &(tmp_nh->gate.ipv6),
- sizeof(struct in6_addr));
- }
- zebra_rib_queue_evpn_route_del(re->vrf_id,
- &vtep_ip, p);
- }
- }
+ struct zebra_early_route *ere;
+ struct route_entry *re = NULL;
+ struct nhg_hash_entry *nhe = NULL;
- /* Notify dplane if system route changes */
- if (RIB_SYSTEM_ROUTE(re))
- dplane_sys_route_del(rn, same);
+ re = zebra_rib_route_entry_new(vrf_id, type, instance, flags, nhe_id,
+ table_id, metric, 0, distance, 0);
- rib_delnode(rn, same);
+ if (nh) {
+ nhe = zebra_nhg_alloc();
+ nhe->nhg.nexthop = nexthop_dup(nh, NULL);
}
- route_unlock_node(rn);
- return;
+ ere = XCALLOC(MTYPE_WQ_WRAPPER, sizeof(*ere));
+ ere->afi = afi;
+ ere->safi = safi;
+ ere->p = *p;
+ if (src_p)
+ ere->src_p = *src_p;
+ ere->src_p_provided = !!src_p;
+ ere->re = re;
+ ere->re_nhe = nhe;
+ ere->startup = false;
+ ere->deletion = true;
+ ere->fromkernel = fromkernel;
+
+ mq_add_handler(ere, rib_meta_queue_early_route_add);
}
@@ -3859,36 +4175,23 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
uint8_t distance, route_tag_t tag, bool startup)
{
struct route_entry *re = NULL;
- struct nexthop *nexthop = NULL;
- struct nexthop_group *ng = NULL;
+ struct nexthop nexthop = {};
+ struct nexthop_group ng = {};
/* Allocate new route_entry structure. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
- re->type = type;
- re->instance = instance;
- re->distance = distance;
- re->flags = flags;
- re->metric = metric;
- re->mtu = mtu;
- re->table = table_id;
- re->vrf_id = vrf_id;
- re->uptime = monotime(NULL);
- re->tag = tag;
- re->nhe_id = nhe_id;
+ re = zebra_rib_route_entry_new(vrf_id, type, instance, flags, nhe_id,
+ table_id, metric, mtu, distance, tag);
/* If the owner of the route supplies a shared nexthop-group id,
* we'll use that. Otherwise, pass the nexthop along directly.
*/
if (!nhe_id) {
- ng = nexthop_group_new();
-
/* Add nexthop. */
- nexthop = nexthop_new();
- *nexthop = *nh;
- nexthop_group_add_sorted(ng, nexthop);
+ nexthop = *nh;
+ nexthop_group_add_sorted(&ng, &nexthop);
}
- return rib_add_multipath(afi, safi, p, src_p, re, ng, startup);
+ return rib_add_multipath(afi, safi, p, src_p, re, &ng, startup);
}
static const char *rib_update_event2str(enum rib_update_event event)
diff --git a/zebra/zebra_script.c b/zebra/zebra_script.c
index d247f87708..2e2f4159cd 100644
--- a/zebra/zebra_script.c
+++ b/zebra/zebra_script.c
@@ -329,14 +329,6 @@ void lua_pushzebra_dplane_ctx(lua_State *L, const struct zebra_dplane_ctx *ctx)
lua_setfield(L, -2, "ipset");
break;
}
- case DPLANE_OP_ADDR_INSTALL:
- case DPLANE_OP_ADDR_UNINSTALL:
- case DPLANE_OP_INTF_ADDR_ADD:
- case DPLANE_OP_INTF_ADDR_DEL:
- case DPLANE_OP_INTF_INSTALL:
- case DPLANE_OP_INTF_UPDATE:
- case DPLANE_OP_INTF_DELETE:
- break;
case DPLANE_OP_NEIGH_INSTALL:
case DPLANE_OP_NEIGH_UPDATE:
case DPLANE_OP_NEIGH_DELETE:
@@ -418,6 +410,17 @@ void lua_pushzebra_dplane_ctx(lua_State *L, const struct zebra_dplane_ctx *ctx)
}
lua_setfield(L, -2, "gre");
+ case DPLANE_OP_ADDR_INSTALL:
+ case DPLANE_OP_ADDR_UNINSTALL:
+ case DPLANE_OP_INTF_ADDR_ADD:
+ case DPLANE_OP_INTF_ADDR_DEL:
+ case DPLANE_OP_INTF_INSTALL:
+ case DPLANE_OP_INTF_UPDATE:
+ case DPLANE_OP_INTF_DELETE:
+ case DPLANE_OP_TC_INSTALL:
+ case DPLANE_OP_TC_UPDATE:
+ case DPLANE_OP_TC_DELETE:
+ /* Not currently handled */
case DPLANE_OP_INTF_NETCONFIG: /*NYI*/
case DPLANE_OP_NONE:
break;