summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_bmp.c10
-rw-r--r--bgpd/bgp_evpn.c2
-rw-r--r--bgpd/bgp_evpn_vty.c33
-rw-r--r--bgpd/bgp_label.c2
-rw-r--r--bgpd/bgp_mac.c2
-rw-r--r--bgpd/bgp_mplsvpn.c4
-rw-r--r--bgpd/bgp_nht.c4
-rw-r--r--bgpd/bgp_open.c10
-rw-r--r--bgpd/bgp_route.c92
-rw-r--r--bgpd/bgp_route.h9
-rw-r--r--bgpd/bgp_routemap.c2
-rw-r--r--bgpd/bgp_rpki.c2
-rw-r--r--bgpd/bgp_updgrp_packet.c2
-rw-r--r--bgpd/bgp_zebra.c4
-rw-r--r--bgpd/rfapi/rfapi_import.c4
-rw-r--r--bgpd/rfapi/rfapi_rib.c2
-rw-r--r--bgpd/rfapi/rfapi_vty.c6
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c18
-rw-r--r--doc/developer/scripting.rst5
-rw-r--r--doc/developer/topotests.rst1
-rw-r--r--doc/developer/workflow.rst36
-rw-r--r--doc/user/bgp.rst2
-rw-r--r--doc/user/zebra.rst6
-rw-r--r--isisd/isis_mt.c14
-rw-r--r--isisd/isis_spf.c6
-rw-r--r--isisd/isis_sr.c2
-rw-r--r--isisd/isis_srv6.c2
-rw-r--r--isisd/isis_te.c4
-rw-r--r--lib/command.c4
-rw-r--r--lib/command.h4
-rw-r--r--lib/debug.c63
-rw-r--r--lib/debug.h49
-rw-r--r--lib/frrlua.c85
-rw-r--r--lib/frrlua.h3
-rw-r--r--lib/hash.c2
-rw-r--r--lib/libfrr.c3
-rw-r--r--lib/memory.c1
-rw-r--r--lib/memory.h1
-rw-r--r--lib/mgmt_be_client.c30
-rw-r--r--lib/mgmt_be_client.h5
-rw-r--r--lib/mgmt_fe_client.c30
-rw-r--r--lib/mgmt_fe_client.h5
-rw-r--r--lib/northbound.h2
-rw-r--r--lib/northbound_cli.c106
-rw-r--r--lib/northbound_sysrepo.c26
-rw-r--r--lib/termtable.c2
-rw-r--r--lib/termtable.h2
-rw-r--r--lib/vty.c26
-rw-r--r--lib/vty.h7
-rw-r--r--mgmtd/mgmt.c16
-rw-r--r--mgmtd/mgmt_be_adapter.c2
-rw-r--r--mgmtd/mgmt_vty.c42
-rw-r--r--nhrpd/nhrp_vty.c2
-rw-r--r--pathd/path_cli.c34
-rw-r--r--pathd/path_pcep.c7
-rw-r--r--pathd/path_pcep.h35
-rw-r--r--pathd/path_pcep_cli.c118
-rw-r--r--pathd/path_ted.c42
-rw-r--r--pathd/path_ted.h24
-rw-r--r--pathd/pathd.c18
-rw-r--r--pathd/pathd.h3
-rw-r--r--pbrd/pbr_debug.c55
-rw-r--r--pbrd/pbr_debug.h22
-rw-r--r--pbrd/pbr_vty.c27
-rw-r--r--pimd/pim6_mld.c4
-rw-r--r--pimd/pim_cmd_common.c36
-rw-r--r--pimd/pim_rp.c2
-rw-r--r--staticd/static_debug.c71
-rw-r--r--staticd/static_debug.h16
-rw-r--r--staticd/static_vty.c10
-rw-r--r--tests/bgpd/test_peer_attr.c2
-rw-r--r--tests/helpers/c/main.c2
-rw-r--r--tests/lib/cli/common_cli.c2
-rw-r--r--tests/lib/cli/test_cli.refout.in2
-rw-r--r--tests/lib/cli/test_commands.c2
-rw-r--r--tests/lib/northbound/test_oper_data.c2
-rw-r--r--tests/lib/test_grpc.cpp2
-rw-r--r--tests/lib/test_ttable.c36
-rw-r--r--tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_3.py137
-rw-r--r--tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py8
-rwxr-xr-xtests/topotests/conftest.py2
-rw-r--r--tests/topotests/example_munet/r1/frr.conf2
-rw-r--r--tests/topotests/example_munet/r2/frr.conf4
-rw-r--r--tests/topotests/example_munet/r3/frr.conf2
-rw-r--r--tests/topotests/example_munet/test_munet.py18
-rw-r--r--tests/topotests/isis_topo1/test_isis_topo1.py2
-rw-r--r--tests/topotests/kinds.yaml3
-rw-r--r--tests/topotests/lib/topogen.py6
-rw-r--r--tests/topotests/nhrp_redundancy/host/zebra.conf4
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_cache.json (renamed from tests/topotests/nhrp_redundancy/r4/nhrp_cache.json)16
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_cache_nhs1_down.json40
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_route.json (renamed from tests/topotests/nhrp_redundancy/r5/nhrp_route.json)18
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_route_nhs1_down.json49
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut.json (renamed from tests/topotests/nhrp_redundancy/r4/nhrp_route_shortcut.json)32
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut_nhs1_down.json96
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json5
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json9
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/nhrpd.conf (renamed from tests/topotests/nhrp_redundancy/r4/nhrpd.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/nhc1/zebra.conf16
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/nhrp_cache.json (renamed from tests/topotests/nhrp_redundancy/r5/nhrp_cache.json)16
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/nhrp_cache_nhs1_down.json40
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/nhrp_route.json (renamed from tests/topotests/nhrp_redundancy/r4/nhrp_route.json)18
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/nhrp_route_nhs1_down.json49
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/nhrpd.conf (renamed from tests/topotests/nhrp_redundancy/r5/nhrpd.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/nhc2/zebra.conf16
-rw-r--r--tests/topotests/nhrp_redundancy/nhs1/nhrp_cache.json (renamed from tests/topotests/nhrp_redundancy/r1/nhrp_cache.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs1/nhrp_route.json (renamed from tests/topotests/nhrp_redundancy/r3/nhrp_route.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs1/nhrpd.conf (renamed from tests/topotests/nhrp_redundancy/r2/nhrpd.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/nhs1/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/nhrp_cache.json (renamed from tests/topotests/nhrp_redundancy/r2/nhrp_cache.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/nhrp_cache_nhs1_down.json40
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/nhrp_route.json (renamed from tests/topotests/nhrp_redundancy/r1/nhrp_route.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/nhrp_route_nhs1_down.json48
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/nhrpd.conf (renamed from tests/topotests/nhrp_redundancy/r3/nhrpd.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/nhs2/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/nhrp_cache.json (renamed from tests/topotests/nhrp_redundancy/r3/nhrp_cache.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/nhrp_cache_nhs1_down.json40
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/nhrp_route.json (renamed from tests/topotests/nhrp_redundancy/r2/nhrp_route.json)12
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/nhrp_route_nhs1_down.json48
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/nhrpd.conf (renamed from tests/topotests/nhrp_redundancy/r1/nhrpd.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/nhs3/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/r1/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/r2/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/r3/zebra.conf12
-rw-r--r--tests/topotests/nhrp_redundancy/r4/zebra.conf16
-rw-r--r--tests/topotests/nhrp_redundancy/r5/zebra.conf16
-rw-r--r--tests/topotests/nhrp_redundancy/r7/zebra.conf4
-rw-r--r--tests/topotests/nhrp_redundancy/router/zebra.conf (renamed from tests/topotests/nhrp_redundancy/r6/zebra.conf)4
-rw-r--r--tests/topotests/nhrp_redundancy/test_nhrp_redundancy.dot38
-rw-r--r--tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py308
-rw-r--r--tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py2
-rw-r--r--tests/topotests/pytest.ini2
-rw-r--r--tests/topotests/route_scale/scale_test_common.py10
-rw-r--r--tests/topotests/zebra_multiple_connected/r1/ip_route_connected.json24
-rw-r--r--tests/topotests/zebra_multiple_connected/r1/ip_route_kernel.json24
-rw-r--r--tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py43
-rw-r--r--vrrpd/vrrp_debug.c88
-rw-r--r--vrrpd/vrrp_debug.h8
-rw-r--r--vrrpd/vrrp_vty.c14
-rw-r--r--vtysh/vtysh.c17
-rw-r--r--vtysh/vtysh.h2
-rw-r--r--vtysh/vtysh_config.c15
-rw-r--r--zebra/dplane_fpm_nl.c2
-rw-r--r--zebra/interface.c2
-rw-r--r--zebra/rib.h5
-rw-r--r--zebra/rt_netlink.c2
-rw-r--r--zebra/zebra_dplane.c15
-rw-r--r--zebra/zebra_mpls.c2
-rw-r--r--zebra/zebra_nhg.c48
-rw-r--r--zebra/zebra_nhg.h21
-rw-r--r--zebra/zebra_rib.c127
-rw-r--r--zebra/zebra_vty.c20
152 files changed, 1873 insertions, 1332 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c
index 43f8006e2d..44a4c0f00b 100644
--- a/bgpd/bgp_bmp.c
+++ b/bgpd/bgp_bmp.c
@@ -1221,7 +1221,7 @@ afibreak:
(safi == SAFI_MPLS_VPN))
prd = (struct prefix_rd *)bgp_dest_get_prefix(bmp->syncrdpos);
- bpi_num_labels = bgp_path_info_num_labels(bpi);
+ bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);
if (bpi && CHECK_FLAG(bpi->flags, BGP_PATH_SELECTED) &&
CHECK_FLAG(bmp->targets->afimon[afi][safi], BMP_MON_LOC_RIB)) {
@@ -1356,7 +1356,7 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)
break;
}
- bpi_num_labels = bgp_path_info_num_labels(bpi);
+ bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);
bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, &bqe->p, prd,
bpi ? bpi->attr : NULL, afi, safi,
@@ -1434,7 +1434,7 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
break;
}
- bpi_num_labels = bgp_path_info_num_labels(bpi);
+ bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);
bmp_monitor(bmp, peer, BMP_PEER_FLAG_L,
BMP_PEER_TYPE_GLOBAL_INSTANCE, &bqe->p, prd,
@@ -2743,7 +2743,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
- XFREE(MTYPE_TMP, out);
+ XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);
vty_out(vty, "\n %zu connected clients:\n",
@@ -2770,7 +2770,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
- XFREE(MTYPE_TMP, out);
+ XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);
vty_out(vty, "\n");
}
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index ef7b13f323..cb5c898315 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -3013,7 +3013,7 @@ bgp_create_evpn_bgp_path_info(struct bgp_path_info *parent_pi,
if (parent_pi->extra)
pi->extra->igpmetric = parent_pi->extra->igpmetric;
- if (bgp_path_info_num_labels(parent_pi))
+ if (BGP_PATH_INFO_NUM_LABELS(parent_pi))
pi->extra->labels = bgp_labels_intern(parent_pi->extra->labels);
bgp_path_info_add(dest, pi);
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index c28cdb4a65..0a5e6a773b 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -2561,7 +2561,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
/* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, dest, bgp_dest_get_prefix(dest),
- NULL, afi, safi, json, false);
+ NULL, afi, safi, json, false, true);
/* Display each path for this prefix. */
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
@@ -2663,7 +2663,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
/* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, dest, (struct prefix *)&p, NULL,
- afi, safi, json, false);
+ afi, safi, json, false, true);
evp = (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
@@ -2798,7 +2798,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
/* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, dest, bgp_dest_get_prefix(dest),
- prd, afi, safi, json, false);
+ prd, afi, safi, json, false, false);
if (json)
json_paths = json_object_new_array();
@@ -2905,9 +2905,10 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
}
/* Prefix and num paths displayed once per prefix. */
- route_vty_out_detail_header(
- vty, bgp, dest, bgp_dest_get_prefix(dest), prd,
- afi, safi, json_prefix, false);
+ route_vty_out_detail_header(vty, bgp, dest,
+ bgp_dest_get_prefix(dest),
+ prd, afi, safi, json_prefix,
+ false, false);
prefix_cnt++;
}
@@ -3042,9 +3043,10 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
p->prefixlen);
} else
/* Prefix and num paths displayed once per prefix. */
- route_vty_out_detail_header(
- vty, bgp, dest, p, (struct prefix_rd *)rd_destp,
- AFI_L2VPN, SAFI_EVPN, json_prefix, false);
+ route_vty_out_detail_header(vty, bgp, dest, p,
+ (struct prefix_rd *)rd_destp,
+ AFI_L2VPN, SAFI_EVPN,
+ json_prefix, false, false);
/* For EVPN, the prefix is displayed for each path (to
* fit in with code that already exists).
@@ -3197,11 +3199,14 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
/* Prefix and num paths displayed once per prefix. */
if (detail)
- route_vty_out_detail_header(
- vty, bgp, dest,
- bgp_dest_get_prefix(dest),
- (struct prefix_rd *)rd_destp, AFI_L2VPN,
- SAFI_EVPN, json_prefix, false);
+ route_vty_out_detail_header(vty, bgp, dest,
+ bgp_dest_get_prefix(
+ dest),
+ (struct prefix_rd *)
+ rd_destp,
+ AFI_L2VPN, SAFI_EVPN,
+ json_prefix, false,
+ false);
/* For EVPN, the prefix is displayed for each path (to
* fit in
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index ad40fef62c..af10111600 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -208,7 +208,7 @@ mpls_label_t bgp_adv_label(struct bgp_dest *dest, struct bgp_path_info *pi,
if (!dest || !pi || !to)
return MPLS_INVALID_LABEL;
- remote_label = bgp_path_info_num_labels(pi)
+ remote_label = BGP_PATH_INFO_NUM_LABELS(pi)
? pi->extra->labels->label[0]
: MPLS_INVALID_LABEL;
from = pi->peer;
diff --git a/bgpd/bgp_mac.c b/bgpd/bgp_mac.c
index bc44a212cd..86d6281ed1 100644
--- a/bgpd/bgp_mac.c
+++ b/bgpd/bgp_mac.c
@@ -169,7 +169,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
&& !dest_affected)
continue;
- num_labels = bgp_path_info_num_labels(pi);
+ num_labels = BGP_PATH_INFO_NUM_LABELS(pi);
label_pnt = num_labels ? &pi->extra->labels->label[0]
: NULL;
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 9de1c5f4c2..f7ca51e146 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -2322,7 +2322,7 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
}
num_labels = origin_local ? 0
- : bgp_path_info_num_labels(path_vpn);
+ : BGP_PATH_INFO_NUM_LABELS(path_vpn);
label_pnt = num_labels ? path_vpn->extra->labels->label : NULL;
}
@@ -4212,7 +4212,7 @@ void bgp_mplsvpn_nh_label_bind_register_local_label(struct bgp *bgp,
struct bgp_mplsvpn_nh_label_bind_cache_head *tree;
mpls_label_t label;
- label = bgp_path_info_num_labels(pi)
+ label = BGP_PATH_INFO_NUM_LABELS(pi)
? decode_label(&pi->extra->labels->label[0])
: MPLS_INVALID_LABEL;
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index f75df1e12d..0259da06dd 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -505,7 +505,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
return 1;
else if (safi == SAFI_UNICAST && pi &&
pi->sub_type == BGP_ROUTE_IMPORTED &&
- bgp_path_info_num_labels(pi) && !bnc->is_evpn_gwip_nexthop)
+ BGP_PATH_INFO_NUM_LABELS(pi) && !bnc->is_evpn_gwip_nexthop)
return bgp_isvalid_nexthop_for_l3vpn(bnc, pi);
else if (safi == SAFI_MPLS_VPN && pi &&
pi->sub_type != BGP_ROUTE_IMPORTED)
@@ -1310,7 +1310,7 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
if (safi == SAFI_UNICAST &&
path->sub_type == BGP_ROUTE_IMPORTED &&
- bgp_path_info_num_labels(path) &&
+ BGP_PATH_INFO_NUM_LABELS(path) &&
!(bre && bre->type == OVERLAY_INDEX_GATEWAY_IP)) {
bnc_is_valid_nexthop =
bgp_isvalid_nexthop_for_l3vpn(bnc, path)
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 945076709c..6451c7cf38 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -1374,7 +1374,7 @@ int bgp_open_option_parse(struct peer *peer, uint16_t length,
* Check that we can read the opt_type and fetch it
*/
if (STREAM_READABLE(s) < 1) {
- zlog_info("%s Option length error", peer->host);
+ zlog_err("%s Option length error", peer->host);
bgp_notify_send(peer->connection, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_MALFORMED_ATTR);
return -1;
@@ -1387,7 +1387,7 @@ int bgp_open_option_parse(struct peer *peer, uint16_t length,
*/
if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(peer)) {
if (STREAM_READABLE(s) < 2) {
- zlog_info("%s Option length error", peer->host);
+ zlog_err("%s Option length error", peer->host);
bgp_notify_send(peer->connection,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_MALFORMED_ATTR);
@@ -1397,7 +1397,7 @@ int bgp_open_option_parse(struct peer *peer, uint16_t length,
opt_length = stream_getw(s);
} else {
if (STREAM_READABLE(s) < 1) {
- zlog_info("%s Option length error", peer->host);
+ zlog_err("%s Option length error", peer->host);
bgp_notify_send(peer->connection,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_MALFORMED_ATTR);
@@ -1409,8 +1409,8 @@ int bgp_open_option_parse(struct peer *peer, uint16_t length,
/* Option length check. */
if (STREAM_READABLE(s) < opt_length) {
- zlog_info("%s Option length error (%d)", peer->host,
- opt_length);
+ zlog_err("%s Option length error (%d)", peer->host,
+ opt_length);
bgp_notify_send(peer->connection, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_MALFORMED_ATTR);
return -1;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index e76329fca6..8fcbcb5775 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -327,7 +327,7 @@ struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *pi)
bool bgp_path_info_has_valid_label(const struct bgp_path_info *path)
{
- if (!bgp_path_info_num_labels(path))
+ if (!BGP_PATH_INFO_NUM_LABELS(path))
return false;
return bgp_is_valid_label(&path->extra->labels->label[0]);
@@ -339,27 +339,13 @@ bool bgp_path_info_labels_same(const struct bgp_path_info *bpi,
uint8_t bpi_num_labels;
const mpls_label_t *bpi_label;
- bpi_num_labels = bgp_path_info_num_labels(bpi);
+ bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);
bpi_label = bpi_num_labels ? bpi->extra->labels->label : NULL;
return bgp_labels_same(bpi_label, bpi_num_labels,
(const mpls_label_t *)label, n);
}
-uint8_t bgp_path_info_num_labels(const struct bgp_path_info *pi)
-{
- if (!pi)
- return 0;
-
- if (!pi->extra)
- return 0;
-
- if (!pi->extra->labels)
- return 0;
-
- return pi->extra->labels->num_labels;
-}
-
/* Free bgp route information. */
void bgp_path_info_free_with_caller(const char *name,
struct bgp_path_info *path)
@@ -2252,7 +2238,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* off box as that the RT and RD created are localy
* significant and globaly useless.
*/
- if (safi == SAFI_MPLS_VPN && bgp_path_info_num_labels(pi) &&
+ if (safi == SAFI_MPLS_VPN && BGP_PATH_INFO_NUM_LABELS(pi) &&
pi->extra->labels->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK)
return false;
@@ -4797,22 +4783,21 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
false);
}
- if (peer->sort == BGP_PEER_EBGP) {
-
- /* rfc7999:
- * A BGP speaker receiving an announcement tagged with the
- * BLACKHOLE community SHOULD add the NO_ADVERTISE or
- * NO_EXPORT community as defined in RFC1997, or a
- * similar community, to prevent propagation of the
- * prefix outside the local AS. The community to prevent
- * propagation SHOULD be chosen according to the operator's
- * routing policy.
- */
- if (bgp_attr_get_community(&new_attr) &&
- community_include(bgp_attr_get_community(&new_attr),
- COMMUNITY_BLACKHOLE))
- bgp_attr_add_no_export_community(&new_attr);
+ /* rfc7999:
+ * A BGP speaker receiving an announcement tagged with the
+ * BLACKHOLE community SHOULD add the NO_ADVERTISE or
+ * NO_EXPORT community as defined in RFC1997, or a
+ * similar community, to prevent propagation of the
+ * prefix outside the local AS. The community to prevent
+ * propagation SHOULD be chosen according to the operator's
+ * routing policy.
+ */
+ if (bgp_attr_get_community(&new_attr) &&
+ community_include(bgp_attr_get_community(&new_attr),
+ COMMUNITY_BLACKHOLE))
+ bgp_attr_add_no_export_community(&new_attr);
+ if (peer->sort == BGP_PEER_EBGP) {
/* If we receive the graceful-shutdown community from an eBGP
* peer we must lower local-preference */
if (bgp_attr_get_community(&new_attr) &&
@@ -6861,7 +6846,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
bgp, p, pi);
}
} else {
- if (bgp_path_info_num_labels(pi))
+ if (BGP_PATH_INFO_NUM_LABELS(pi))
label = decode_label(
&pi->extra->labels->label[0]);
}
@@ -10540,7 +10525,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_nexthop_global = json_object_new_object();
}
- if (bgp_path_info_num_labels(path)) {
+ if (BGP_PATH_INFO_NUM_LABELS(path)) {
bgp_evpn_label2str(path->extra->labels->label,
path->extra->labels->num_labels, vni_buf,
sizeof(vni_buf));
@@ -11933,10 +11918,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
if (!use_json)
route_vty_out_detail_header(
vty, bgp, dest,
- bgp_dest_get_prefix(
- dest),
+ bgp_dest_get_prefix(dest),
prd, table->afi, safi,
- NULL, false);
+ NULL, false, false);
route_vty_out_detail(
vty, bgp, dest, dest_p, pi,
@@ -12009,10 +11993,12 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
prd = bgp_rd_from_dest(dest, safi);
- route_vty_out_detail_header(
- vty, bgp, dest,
- bgp_dest_get_prefix(dest), prd,
- table->afi, safi, json_paths, true);
+ route_vty_out_detail_header(vty, bgp, dest,
+ bgp_dest_get_prefix(
+ dest),
+ prd, table->afi,
+ safi, json_paths,
+ true, false);
vty_out(vty, "\"paths\": ");
json_detail_header_used = true;
@@ -12218,7 +12204,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct bgp_dest *dest, const struct prefix *p,
const struct prefix_rd *prd, afi_t afi,
safi_t safi, json_object *json,
- bool incremental_print)
+ bool incremental_print, bool local_table)
{
struct bgp_path_info *pi;
struct peer *peer;
@@ -12436,8 +12422,14 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
json_object_object_add(json, "advertisedTo",
json_adv_to);
} else {
- if (!json && first)
- vty_out(vty, " Not advertised to any peer");
+ if (!json && first) {
+ if (!local_table)
+ vty_out(vty,
+ " Not advertised to any peer");
+ else
+ vty_out(vty,
+ " Local BGP table not advertised");
+ }
vty_out(vty, "\n");
}
}
@@ -12476,10 +12468,10 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
}
if (header) {
- route_vty_out_detail_header(
- vty, bgp, bgp_node,
- bgp_dest_get_prefix(bgp_node), pfx_rd, AFI_IP,
- safi, json_header, false);
+ route_vty_out_detail_header(vty, bgp, bgp_node,
+ bgp_dest_get_prefix(bgp_node),
+ pfx_rd, AFI_IP, safi,
+ json_header, false, false);
header = 0;
}
(*display)++;
@@ -12949,7 +12941,7 @@ DEFUN (show_ip_bgp_l2vpn_evpn_statistics,
struct json_object *json_afi_safi = NULL, *json = NULL;
bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
- &bgp, false);
+ &bgp, uj);
if (!idx)
return CMD_WARNING;
@@ -12987,7 +12979,7 @@ DEFUN(show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd,
struct json_object *json_afi_safi = NULL, *json = NULL;
bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
- &bgp, false);
+ &bgp, uj);
if (!idx)
return CMD_WARNING;
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 5b433b5558..bc3ca4b2f8 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -561,6 +561,11 @@ struct bgp_aggregate {
/* path PREFIX (addpath rxid NUMBER) */
#define PATH_ADDPATH_STR_BUFFER PREFIX2STR_BUFFER + 32
+#define BGP_PATH_INFO_NUM_LABELS(pi) \
+ ((pi) && (pi)->extra && (pi)->extra->labels \
+ ? (pi)->extra->labels->num_labels \
+ : 0)
+
enum bgp_path_type {
BGP_PATH_SHOW_ALL,
BGP_PATH_SHOW_BESTPATH,
@@ -748,7 +753,6 @@ extern void bgp_path_info_delete(struct bgp_dest *dest,
extern struct bgp_path_info_extra *
bgp_path_info_extra_get(struct bgp_path_info *path);
extern bool bgp_path_info_has_valid_label(const struct bgp_path_info *path);
-extern uint8_t bgp_path_info_num_labels(const struct bgp_path_info *pi);
extern void bgp_path_info_set_flag(struct bgp_dest *dest,
struct bgp_path_info *path, uint32_t flag);
extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
@@ -899,7 +903,8 @@ extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
const struct prefix *p,
const struct prefix_rd *prd, afi_t afi,
safi_t safi, json_object *json,
- bool incremental_print);
+ bool incremental_print,
+ bool local_table);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct bgp_dest *bn, const struct prefix *p,
struct bgp_path_info *path, afi_t afi,
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 79c61e2ee2..d0b65a7426 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -1081,7 +1081,7 @@ route_match_vni(void *rule, const struct prefix *prefix, void *object)
return RMAP_NOOP;
for (label_cnt = 0; label_cnt < BGP_MAX_LABELS &&
- label_cnt < bgp_path_info_num_labels(path);
+ label_cnt < BGP_PATH_INFO_NUM_LABELS(path);
label_cnt++) {
if (vni == label2vni(&path->extra->labels->label[label_cnt]))
return RMAP_MATCH;
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 9db7b15296..f9cbf24031 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -666,7 +666,7 @@ static void revalidate_bgp_node(struct bgp_dest *bgp_dest, afi_t afi,
struct bgp_path_info *path =
bgp_dest_get_bgp_path_info(bgp_dest);
- num_labels = bgp_path_info_num_labels(path);
+ num_labels = BGP_PATH_INFO_NUM_LABELS(path);
label = num_labels ? path->extra->labels->label : NULL;
(void)bgp_update(ain->peer, bgp_dest_get_prefix(bgp_dest),
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 8cd851b9ac..bed00a6640 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -813,7 +813,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
label_pnt = &label;
num_labels = 1;
} else {
- num_labels = bgp_path_info_num_labels(path);
+ num_labels = BGP_PATH_INFO_NUM_LABELS(path);
label_pnt =
num_labels
? &path->extra->labels->label[0]
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 2d9100b895..6e2efabf8f 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1311,7 +1311,7 @@ static void bgp_zebra_announce_parse_nexthop(
api_nh->srte_color = bgp_attr_get_color(info->attr);
if (bgp_debug_zebra(&api->prefix)) {
- if (bgp_path_info_num_labels(mpinfo)) {
+ if (BGP_PATH_INFO_NUM_LABELS(mpinfo)) {
zlog_debug("%s: p=%pFX, bgp_is_valid_label: %d",
__func__, p,
bgp_is_valid_label(
@@ -1385,7 +1385,7 @@ static void bgp_zebra_announce_parse_nexthop(
mpinfo->peer->sort == BGP_PEER_CONFED))
*allow_recursion = true;
- num_labels = bgp_path_info_num_labels(mpinfo);
+ num_labels = BGP_PATH_INFO_NUM_LABELS(mpinfo);
labels = num_labels ? mpinfo->extra->labels->label : NULL;
if (num_labels && (is_evpn || bgp_is_valid_label(&labels[0]))) {
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 2afcb2f45c..44dfc88cf7 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -1272,7 +1272,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
/* label comes from MP_REACH_NLRI label */
vo->v.l2addr.label =
- bgp_path_info_num_labels(bpi)
+ BGP_PATH_INFO_NUM_LABELS(bpi)
? decode_label(&bpi->extra->labels->label[0])
: MPLS_INVALID_LABEL;
@@ -4167,7 +4167,7 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
BGP_PATH_REMOVED))
continue;
- if (bgp_path_info_num_labels(bpi))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi))
label = decode_label(
&bpi->extra->labels
->label[0]);
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index a0bdf4961f..53e416b2ee 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -692,7 +692,7 @@ static void rfapiRibBi2Ri(struct bgp_path_info *bpi, struct rfapi_info *ri,
/* label comes from MP_REACH_NLRI label */
vo->v.l2addr.label =
- bgp_path_info_num_labels(bpi)
+ BGP_PATH_INFO_NUM_LABELS(bpi)
? decode_label(&bpi->extra->labels->label[0])
: MPLS_INVALID_LABEL;
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index 9bfb6c4b45..8f1f509bbb 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -413,7 +413,7 @@ void rfapi_vty_out_vncinfo(struct vty *vty, const struct prefix *p,
XFREE(MTYPE_ECOMMUNITY_STR, s);
}
- if (bgp_path_info_num_labels(bpi)) {
+ if (BGP_PATH_INFO_NUM_LABELS(bpi)) {
if (bpi->extra->labels->label[0] == BGP_PREVENT_VRF_2_VRF_LEAK)
vty_out(vty, " label=VRF2VRF");
else
@@ -1052,7 +1052,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
snprintf(buf_un, sizeof(buf_un), "%s",
inet_ntop(pfx_vn.family, &pfx_vn.u.prefix, buf_ntop,
sizeof(buf_ntop)));
- if (bgp_path_info_num_labels(bpi)) {
+ if (BGP_PATH_INFO_NUM_LABELS(bpi)) {
uint32_t l = decode_label(&bpi->extra->labels->label[0]);
snprintf(buf_vn, sizeof(buf_vn), "Label: %d", l);
} else /* should never happen */
@@ -1161,7 +1161,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
}
}
}
- if (tun_type != BGP_ENCAP_TYPE_MPLS && bgp_path_info_num_labels(bpi)) {
+ if (tun_type != BGP_ENCAP_TYPE_MPLS && BGP_PATH_INFO_NUM_LABELS(bpi)) {
uint32_t l = decode_label(&bpi->extra->labels->label[0]);
if (!MPLS_LABEL_IS_NULL(l)) {
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 2bb7c1b161..e688638ed7 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -470,7 +470,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
if (bgp_attr_get_ecommunity(bpi->attr))
ecommunity_merge(new_ecom, bgp_attr_get_ecommunity(bpi->attr));
- if (bgp_path_info_num_labels(bpi))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi))
label = decode_label(&bpi->extra->labels->label[0]);
else
label = MPLS_INVALID_LABEL;
@@ -1704,7 +1704,7 @@ static void vnc_import_bgp_exterior_add_route_it(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels
->label[0]);
@@ -1878,7 +1878,7 @@ void vnc_import_bgp_exterior_del_route(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels
->label[0]);
@@ -2030,7 +2030,7 @@ void vnc_import_bgp_exterior_add_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels->label[0]);
else
@@ -2147,7 +2147,7 @@ void vnc_import_bgp_exterior_add_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi))
label = decode_label(
&bpi->extra->labels
->label[0]);
@@ -2174,7 +2174,7 @@ void vnc_import_bgp_exterior_add_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels
->label[0]);
@@ -2297,7 +2297,7 @@ void vnc_import_bgp_exterior_add_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels->label[0]);
else
@@ -2409,7 +2409,7 @@ void vnc_import_bgp_exterior_del_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi_interior))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi_interior))
label = decode_label(
&bpi_interior->extra->labels->label[0]);
else
@@ -2491,7 +2491,7 @@ void vnc_import_bgp_exterior_del_route_interior(
else
prd = NULL;
- if (bgp_path_info_num_labels(bpi))
+ if (BGP_PATH_INFO_NUM_LABELS(bpi))
label = decode_label(
&bpi->extra->labels->label[0]);
else
diff --git a/doc/developer/scripting.rst b/doc/developer/scripting.rst
index 7a43314490..f51130b1e3 100644
--- a/doc/developer/scripting.rst
+++ b/doc/developer/scripting.rst
@@ -523,6 +523,7 @@ object which contains methods corresponding to each of the ``zlog`` levels:
log.error("error")
log.notice("notice")
log.debug("debug")
+ log.trace("trace")
The log messages will show up in the daemon's log output.
@@ -579,14 +580,14 @@ accomplished with scripting.
RM_FAILURE, RM_NOMATCH, RM_MATCH, RM_MATCH_AND_CHANGE)
log.info("Evaluating route " .. prefix.network .. " from peer " .. peer.remote_id.string)
-
+
function on_match (prefix, attributes)
log.info("Match")
return {
attributes = RM_MATCH
}
end
-
+
function on_nomatch (prefix, attributes)
log.info("No match")
return {
diff --git a/doc/developer/topotests.rst b/doc/developer/topotests.rst
index 52c0361a02..72de7b3bc9 100644
--- a/doc/developer/topotests.rst
+++ b/doc/developer/topotests.rst
@@ -33,6 +33,7 @@ Installing Topotest Requirements
net-tools \
python3-pip \
iputils-ping \
+ iptables \
tshark \
valgrind
python3 -m pip install wheel
diff --git a/doc/developer/workflow.rst b/doc/developer/workflow.rst
index a6bdec1e5b..50bcb2976e 100644
--- a/doc/developer/workflow.rst
+++ b/doc/developer/workflow.rst
@@ -531,6 +531,42 @@ After Submitting Your Changes
community members.
- Your submission is done once it is merged to the master branch.
+Reverting the changes
+=====================
+
+When you revert a regular commit in Git, the process is straightforward - it
+undoes the changes introduced by that commit. However, reverting a merge commit
+is more complex. While it undoes the data changes brought in by the merge, it
+does not alter the repository's history or the merge's effect on it.
+
+Reverting a Merge Commit
+------------------------
+
+When you revert a merge commit, the following occurs:
+
+* The changes made by the merge are undone;
+* The merge itself remains in the history: it continues to be recognized as the point where two branches were joined;
+* Future merges will still treat this as the last shared state, regardless of the revert.
+
+Thus, a "revert" in Git undoes data changes, but it does not serve as a true "undo"
+for the historical effects of a commit.
+
+Reverting a Merge and Bisectability
+-----------------------------------
+
+Consider the implications of reverting a merge and then reverting that revert.
+This scenario complicates the debugging process, especially when using tools like
+git bisect. A reverted merge effectively consolidates all changes from the original
+merge into a single commit, but in reverse. This creates a challenge for debugging,
+as you lose the granularity of individual commits, making it difficult to identify
+the specific change causing an issue.
+
+Considerations
+--------------
+
+When reverting the changes, e.g. a full Pull Request, we SHOULD revert every commit
+individually, and not use git revert on merge commits.
+
Programming Languages, Tools and Libraries
==========================================
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index a569a9af28..aa62d274f0 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -2482,7 +2482,7 @@ is 4 octet long. The following format is used to define the community value.
``blackhole``
``blackhole`` represents well-known communities value ``BLACKHOLE``
``0xFFFF029A`` ``65535:666``. :rfc:`7999` documents sending prefixes to
- EBGP peers and upstream for the purpose of blackholing traffic.
+ peers and upstream for the purpose of blackholing traffic.
Prefixes tagged with the this community should normally not be
re-advertised from neighbors of the originating network. Upon receiving
``BLACKHOLE`` community from a BGP speaker, ``NO_ADVERTISE`` community
diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst
index 900d2fd343..b008eaf722 100644
--- a/doc/user/zebra.rst
+++ b/doc/user/zebra.rst
@@ -1637,7 +1637,11 @@ zebra Terminal Mode Commands
option as that nexthop groups are per namespace in linux.
If you specify singleton you would like to see the singleton
nexthop groups that do have an afi. [type] allows you to filter those
- only coming from a specific NHG type (protocol).
+ only coming from a specific NHG type (protocol). A nexthop group
+ that has `Initial Delay`, means that this nexthop group entry
+ was not installed because no-one was using it at that point and
+ Zebra can delay installing this route until it is used by something
+ else.
.. clicmd:: show <ip|ipv6> zebra route dump [<vrf> VRFNAME]
diff --git a/isisd/isis_mt.c b/isisd/isis_mt.c
index d04a24dc46..65ba395ffc 100644
--- a/isisd/isis_mt.c
+++ b/isisd/isis_mt.c
@@ -226,7 +226,8 @@ struct isis_area_mt_setting **area_mt_settings(struct isis_area *area,
count++;
if (count > size) {
- rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
+ rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
+ count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
@@ -341,7 +342,8 @@ circuit_mt_settings(struct isis_circuit *circuit, unsigned int *mt_count)
count++;
if (count > size) {
- rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
+ rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
+ count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
@@ -376,8 +378,8 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,
old_mt_count = adj->mt_count;
if (old_mt_count) {
- old_mt_set =
- XCALLOC(MTYPE_TMP, old_mt_count * sizeof(*old_mt_set));
+ old_mt_set = XCALLOC(MTYPE_MT_AREA_SETTING,
+ old_mt_count * sizeof(*old_mt_set));
memcpy(old_mt_set, adj->mt_set,
old_mt_count * sizeof(*old_mt_set));
}
@@ -436,7 +438,7 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,
changed = true;
if (old_mt_count)
- XFREE(MTYPE_TMP, old_mt_set);
+ XFREE(MTYPE_MT_AREA_SETTING, old_mt_set);
return changed;
}
@@ -464,7 +466,7 @@ static void mt_set_add(uint16_t **mt_set, unsigned int *size,
}
if (*index >= *size) {
- *mt_set = XREALLOC(MTYPE_TMP, *mt_set,
+ *mt_set = XREALLOC(MTYPE_MT_AREA_SETTING, *mt_set,
sizeof(**mt_set) * ((*index) + 1));
*size = (*index) + 1;
}
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 86302076f8..0f37ed012a 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -2337,7 +2337,7 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
if (json == NULL) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else
*json = ttable_json_with_json_text(
tt, "ssdsss",
@@ -3016,7 +3016,7 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else if (json) {
*json = ttable_json_with_json_text(
tt, prefix_sid ? "sdssdsdd" : "sdsss",
@@ -3458,7 +3458,7 @@ static void isis_print_frr_summary(struct vty *vty,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
diff --git a/isisd/isis_sr.c b/isisd/isis_sr.c
index f783038006..71e0f56e03 100644
--- a/isisd/isis_sr.c
+++ b/isisd/isis_sr.c
@@ -1064,7 +1064,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}
diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c
index b5974b1a62..2348bd043a 100644
--- a/isisd/isis_srv6.c
+++ b/isisd/isis_srv6.c
@@ -591,7 +591,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}
diff --git a/isisd/isis_te.c b/isisd/isis_te.c
index 545a516c27..c9af39ce5a 100644
--- a/isisd/isis_te.c
+++ b/isisd/isis_te.c
@@ -172,6 +172,10 @@ void isis_link_params_update_asla(struct isis_circuit *circuit,
struct isis_ext_subtlvs *ext = circuit->ext;
int i;
+ if (!ext)
+ /* no extended subTLVs - nothing to update */
+ return;
+
if (!HAS_LINK_PARAMS(ifp)) {
list_delete_all_node(ext->aslas);
return;
diff --git a/lib/command.c b/lib/command.c
index 51f2529e3e..ac8d60118e 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -17,6 +17,7 @@
#include <lib/version.h>
#include "command.h"
+#include "debug.h"
#include "frrstr.h"
#include "memory.h"
#include "log.h"
@@ -2463,8 +2464,7 @@ const char *host_config_get(void)
void cmd_show_lib_debugs(struct vty *vty)
{
route_map_show_debug(vty);
- mgmt_debug_be_client_show_debug(vty);
- mgmt_debug_fe_client_show_debug(vty);
+ debug_status_write(vty);
}
void install_default(enum node_type node)
diff --git a/lib/command.h b/lib/command.h
index cb105c656c..61d09973fd 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -84,14 +84,12 @@ enum node_type {
CONFIG_NODE, /* Config node. Default mode of config file. */
PREFIX_NODE, /* ip prefix-list node. */
PREFIX_IPV6_NODE, /* ipv6 prefix-list node. */
+ LIB_DEBUG_NODE, /* frrlib debug node. */
DEBUG_NODE, /* Debug node. */
VRF_DEBUG_NODE, /* Vrf Debug node. */
- NORTHBOUND_DEBUG_NODE, /* Northbound Debug node. */
DEBUG_VNC_NODE, /* Debug VNC node. */
RMAP_DEBUG_NODE, /* Route-map debug node */
RESOLVER_DEBUG_NODE, /* Resolver debug node */
- MGMT_BE_DEBUG_NODE, /* mgmtd backend-client debug node */
- MGMT_FE_DEBUG_NODE, /* mgmtd frontend-client debug node */
AAA_NODE, /* AAA node. */
EXTLOG_NODE, /* RFC5424 & co. extended syslog */
KEYCHAIN_NODE, /* Key-chain node. */
diff --git a/lib/debug.c b/lib/debug.c
index 757a47ab99..d25c32d428 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -9,42 +9,75 @@
#include "debug.h"
#include "command.h"
-static struct debug_cb_list_head cb_head;
+static struct debug_list_head debug_head;
-DECLARE_LIST(debug_cb_list, struct debug_callbacks, item);
+DECLARE_LIST(debug_list, struct debug, item);
/* All code in this section should be reentrant and MT-safe */
-DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
- NO_STR DEBUG_STR "Toggle all debugging output\n")
+DEFUN_NOSH (debug_all,
+ debug_all_cmd,
+ "[no] debug all",
+ NO_STR DEBUG_STR
+ "Toggle all debugging output\n")
{
- struct debug_callbacks *cb;
-
+ struct debug *debug;
bool set = !strmatch(argv[0]->text, "no");
uint32_t mode = DEBUG_NODE2MODE(vty->node);
- frr_each (debug_cb_list, &cb_head, cb)
- cb->debug_set_all(mode, set);
+ frr_each (debug_list, &debug_head, debug) {
+ DEBUG_MODE_SET(debug, mode, set);
+
+ /* If all modes have been turned off, don't preserve options. */
+ if (!DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
+ DEBUG_CLEAR(debug);
+ }
return CMD_SUCCESS;
}
/* ------------------------------------------------------------------------- */
-void debug_init(struct debug_callbacks *cb)
+void debug_status_write(struct vty *vty)
+{
+ struct debug *debug;
+
+ frr_each (debug_list, &debug_head, debug) {
+ if (DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
+ vty_out(vty, " %s debugging is on\n", debug->desc);
+ }
+}
+
+static int config_write_debug(struct vty *vty)
{
- static bool inited = false;
+ struct debug *debug;
- if (!inited) {
- inited = true;
- debug_cb_list_init(&cb_head);
+ frr_each (debug_list, &debug_head, debug) {
+ if (DEBUG_MODE_CHECK(debug, DEBUG_MODE_CONF))
+ vty_out(vty, "%s\n", debug->conf);
}
- debug_cb_list_add_head(&cb_head, cb);
+ return 0;
}
-void debug_init_cli(void)
+static struct cmd_node debug_node = {
+ .name = "debug",
+ .node = LIB_DEBUG_NODE,
+ .prompt = "",
+ .config_write = config_write_debug,
+};
+
+void debug_install(struct debug *debug)
{
+ debug_list_add_tail(&debug_head, debug);
+}
+
+void debug_init(void)
+{
+ debug_list_init(&debug_head);
+
+ install_node(&debug_node);
+
install_element(ENABLE_NODE, &debug_all_cmd);
install_element(CONFIG_NODE, &debug_all_cmd);
}
diff --git a/lib/debug.h b/lib/debug.h
index e9d8a31abd..eee314cff5 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -34,6 +34,7 @@ extern "C" {
#define DEBUG_OPT_NONE 0x00000000
+PREDECL_LIST(debug_list);
/*
* Debugging record.
*
@@ -63,37 +64,18 @@ extern "C" {
* manipulate the flags field in a multithreaded environment results in
* undefined behavior.
*
+ * conf
+ * The configuration string that will be written to the config file.
+ *
* desc
* Human-readable description of this debugging record.
*/
struct debug {
atomic_uint_fast32_t flags;
+ const char *conf;
const char *desc;
-};
-PREDECL_LIST(debug_cb_list);
-/*
- * Callback set for debugging code.
- *
- * debug_set_all
- * Function pointer to call when the user requests that all debugs have a
- * mode set.
- */
-struct debug_callbacks {
- /*
- * Linked list of Callbacks to call
- */
- struct debug_cb_list_item item;
-
- /*
- * flags
- * flags to set on debug flag fields
- *
- * set
- * true: set flags
- * false: unset flags
- */
- void (*debug_set_all)(uint32_t flags, bool set);
+ struct debug_list_item item;
};
/*
@@ -217,22 +199,19 @@ struct debug_callbacks {
#define DEBUGN(name, fmt, ...) DEBUG(notice, name, fmt, ##__VA_ARGS__)
#define DEBUGD(name, fmt, ...) DEBUG(debug, name, fmt, ##__VA_ARGS__)
+/* Show current debugging status. */
+void debug_status_write(struct vty *vty);
+
/*
- * Optional initializer for debugging. Highly recommended.
- *
- * This function installs common debugging commands and allows the caller to
- * specify callbacks to take when these commands are issued, allowing the
- * caller to respond to events such as a request to turn off all debugs.
- *
- * MT-Safe
+ * Register a debug item.
*/
-void debug_init(struct debug_callbacks *cb);
+void debug_install(struct debug *debug);
/*
- * Turn on the cli to turn on/off debugs.
- * Should only be called by libfrr
+ * Initialize debugging.
+ * Should only be called by libfrr.
*/
-void debug_init_cli(void);
+void debug_init(void);
#ifdef __cplusplus
}
diff --git a/lib/frrlua.c b/lib/frrlua.c
index 2cab1a5460..ef081e4bd0 100644
--- a/lib/frrlua.c
+++ b/lib/frrlua.c
@@ -323,7 +323,7 @@ void lua_pushnexthop_group(lua_State *L, const struct nexthop_group *ng)
{
lua_newtable(L);
struct nexthop *nexthop;
- int i = 0;
+ int i = 1;
for (ALL_NEXTHOPS_PTR(ng, nexthop)) {
lua_pushnexthop(L, nexthop);
@@ -382,6 +382,12 @@ static const char *frrlua_log_thunk(lua_State *L)
return lua_tostring(L, 1);
}
+static int frrlua_log_trace(lua_State *L)
+{
+ zlog_debug("%s", frrlua_stackdump(L));
+ return 0;
+}
+
static int frrlua_log_debug(lua_State *L)
{
zlog_debug("%s", frrlua_log_thunk(L));
@@ -413,11 +419,12 @@ static int frrlua_log_error(lua_State *L)
}
static const luaL_Reg log_funcs[] = {
- {"debug", frrlua_log_debug},
- {"info", frrlua_log_info},
- {"notice", frrlua_log_notice},
- {"warn", frrlua_log_warn},
- {"error", frrlua_log_error},
+ { "trace", frrlua_log_trace },
+ { "debug", frrlua_log_debug },
+ { "info", frrlua_log_info },
+ { "notice", frrlua_log_notice },
+ { "warn", frrlua_log_warn },
+ { "error", frrlua_log_error },
{},
};
@@ -432,6 +439,67 @@ void frrlua_export_logging(lua_State *L)
* Debugging.
*/
+void lua_table_dump(lua_State *L, int index, struct buffer *buf, int level)
+{
+ char tmpbuf[64] = {};
+
+ lua_pushnil(L);
+
+ while (lua_next(L, index) != 0) {
+ int key_type;
+ int value_type;
+
+ for (int i = 0; i < level; i++)
+ buffer_putstr(buf, " ");
+
+ key_type = lua_type(L, -2);
+ if (key_type == LUA_TSTRING) {
+ const char *key = lua_tostring(L, -2);
+
+ buffer_putstr(buf, key);
+ buffer_putstr(buf, ": ");
+ } else if (key_type == LUA_TNUMBER) {
+ snprintf(tmpbuf, sizeof(tmpbuf), "%g",
+ lua_tonumber(L, -2));
+ buffer_putstr(buf, tmpbuf);
+ buffer_putstr(buf, ": ");
+ }
+
+ value_type = lua_type(L, -1);
+ switch (value_type) {
+ case LUA_TSTRING:
+ snprintf(tmpbuf, sizeof(tmpbuf), "\"%s\"\n",
+ lua_tostring(L, -1));
+ buffer_putstr(buf, tmpbuf);
+ break;
+ case LUA_TBOOLEAN:
+ snprintf(tmpbuf, sizeof(tmpbuf), "%s\n",
+ lua_toboolean(L, -1) ? "true" : "false");
+ buffer_putstr(buf, tmpbuf);
+ break;
+ case LUA_TNUMBER:
+ snprintf(tmpbuf, sizeof(tmpbuf), "%g\n",
+ lua_tonumber(L, -1));
+ buffer_putstr(buf, tmpbuf);
+ break;
+ case LUA_TTABLE:
+ buffer_putstr(buf, "{\n");
+ lua_table_dump(L, lua_gettop(L), buf, level + 1);
+ for (int i = 0; i < level; i++)
+ buffer_putstr(buf, " ");
+ buffer_putstr(buf, "}\n");
+ break;
+ default:
+ snprintf(tmpbuf, sizeof(tmpbuf), "%s\n",
+ lua_typename(L, value_type));
+ buffer_putstr(buf, tmpbuf);
+ break;
+ }
+
+ lua_pop(L, 1);
+ }
+}
+
char *frrlua_stackdump(lua_State *L)
{
int top = lua_gettop(L);
@@ -458,6 +526,11 @@ char *frrlua_stackdump(lua_State *L)
lua_tonumber(L, i));
buffer_putstr(buf, tmpbuf);
break;
+ case LUA_TTABLE: /* tables */
+ buffer_putstr(buf, "{\n");
+ lua_table_dump(L, i, buf, 1);
+ buffer_putstr(buf, "}\n");
+ break;
default: /* other values */
snprintf(tmpbuf, sizeof(tmpbuf), "%s\n",
lua_typename(L, t));
diff --git a/lib/frrlua.h b/lib/frrlua.h
index dc0f4d9986..e407a4492f 100644
--- a/lib/frrlua.h
+++ b/lib/frrlua.h
@@ -181,6 +181,9 @@ int frrlua_table_get_integer(lua_State *L, const char *key);
*/
void frrlua_export_logging(lua_State *L);
+/* A helper fuction that dumps the Lua stack */
+void lua_table_dump(lua_State *L, int index, struct buffer *buf, int level);
+
/*
* Dump Lua stack to a string.
*
diff --git a/lib/hash.c b/lib/hash.c
index df56243985..edbfeec464 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -444,7 +444,7 @@ DEFUN_NOSH(show_hash_stats,
ttable_colseps(tt, 0, RIGHT, true, '|');
char *table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No named hash tables to display.\n");
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 10a9c5d5f2..0a575abac6 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -809,6 +809,7 @@ struct event_loop *frr_init(void)
vty_init(master, di->log_always);
lib_cmd_init();
+ debug_init();
frr_pthread_init();
#ifdef HAVE_SCRIPTING
@@ -825,8 +826,6 @@ struct event_loop *frr_init(void)
"%s: failed to initialize northbound database",
__func__);
- debug_init_cli();
-
return master;
}
diff --git a/lib/memory.c b/lib/memory.c
index 8fbe5c4093..ac39516edd 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -25,6 +25,7 @@ struct memgroup **mg_insert = &mg_first;
DEFINE_MGROUP(LIB, "libfrr");
DEFINE_MTYPE(LIB, TMP, "Temporary memory");
+DEFINE_MTYPE(LIB, TMP_TTABLE, "Temporary memory for TTABLE");
DEFINE_MTYPE(LIB, BITFIELD, "Bitfield memory");
static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)
diff --git a/lib/memory.h b/lib/memory.h
index 65b99a5fc9..8e8c61da04 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -138,6 +138,7 @@ struct memgroup {
DECLARE_MGROUP(LIB);
DECLARE_MTYPE(TMP);
+DECLARE_MTYPE(TMP_TTABLE);
extern void *qmalloc(struct memtype *mt, size_t size)
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 49879f3f53..f03006ad0e 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -116,6 +116,7 @@ struct mgmt_be_client {
frr_each_safe (mgmt_be_txns, &(client_ctx)->txn_head, (txn))
struct debug mgmt_dbg_be_client = {
+ .conf = "debug mgmt client backend",
.desc = "Management backend client operations"
};
@@ -1258,31 +1259,6 @@ DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
return CMD_SUCCESS;
}
-static int mgmt_debug_be_client_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&mgmt_dbg_be_client, DEBUG_MODE_CONF))
- vty_out(vty, "debug mgmt client backend\n");
-
- return 1;
-}
-
-void mgmt_debug_be_client_show_debug(struct vty *vty)
-{
- if (debug_check_be_client())
- vty_out(vty, "debug mgmt client backend\n");
-}
-
-static struct debug_callbacks mgmt_dbg_be_client_cbs = {
- .debug_set_all = mgmt_debug_client_be_set
-};
-
-static struct cmd_node mgmt_dbg_node = {
- .name = "debug mgmt client backend",
- .node = MGMT_BE_DEBUG_NODE,
- .prompt = "",
- .config_write = mgmt_debug_be_client_config_write,
-};
-
struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
struct mgmt_be_client_cbs *cbs,
uintptr_t user_data,
@@ -1328,8 +1304,8 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
void mgmt_be_client_lib_vty_init(void)
{
- debug_init(&mgmt_dbg_be_client_cbs);
- install_node(&mgmt_dbg_node);
+ debug_install(&mgmt_dbg_be_client);
+
install_element(ENABLE_NODE, &debug_mgmt_client_be_cmd);
install_element(CONFIG_NODE, &debug_mgmt_client_be_cmd);
}
diff --git a/lib/mgmt_be_client.h b/lib/mgmt_be_client.h
index 7ad0589bdb..6ed8c2a39f 100644
--- a/lib/mgmt_be_client.h
+++ b/lib/mgmt_be_client.h
@@ -122,11 +122,6 @@ mgmt_be_client_create(const char *name, struct mgmt_be_client_cbs *cbs,
extern void mgmt_be_client_lib_vty_init(void);
/*
- * Print enabled debugging commands.
- */
-extern void mgmt_debug_be_client_show_debug(struct vty *vty);
-
-/*
* [Un]-subscribe with MGMTD for one or more YANG subtree(s).
*
* client
diff --git a/lib/mgmt_fe_client.c b/lib/mgmt_fe_client.c
index 8cfb025f72..ced2f2e454 100644
--- a/lib/mgmt_fe_client.c
+++ b/lib/mgmt_fe_client.c
@@ -49,6 +49,7 @@ struct mgmt_fe_client {
frr_each_safe (mgmt_sessions, &(client)->sessions, (session))
struct debug mgmt_dbg_fe_client = {
+ .conf = "debug mgmt client frontend",
.desc = "Management frontend client operations"
};
@@ -805,31 +806,6 @@ DEFPY(debug_mgmt_client_fe, debug_mgmt_client_fe_cmd,
return CMD_SUCCESS;
}
-static int mgmt_debug_fe_client_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&mgmt_dbg_fe_client, DEBUG_MODE_CONF))
- vty_out(vty, "debug mgmt client frontend\n");
-
- return CMD_SUCCESS;
-}
-
-void mgmt_debug_fe_client_show_debug(struct vty *vty)
-{
- if (debug_check_fe_client())
- vty_out(vty, "debug mgmt client frontend\n");
-}
-
-static struct debug_callbacks mgmt_dbg_fe_client_cbs = {
- .debug_set_all = mgmt_debug_client_fe_set
-};
-
-static struct cmd_node mgmt_dbg_node = {
- .name = "debug mgmt client frontend",
- .node = MGMT_FE_DEBUG_NODE,
- .prompt = "",
- .config_write = mgmt_debug_fe_client_config_write,
-};
-
/*
* Initialize library and try connecting with MGMTD.
*/
@@ -870,8 +846,8 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
void mgmt_fe_client_lib_vty_init(void)
{
- debug_init(&mgmt_dbg_fe_client_cbs);
- install_node(&mgmt_dbg_node);
+ debug_install(&mgmt_dbg_fe_client);
+
install_element(ENABLE_NODE, &debug_mgmt_client_fe_cmd);
install_element(CONFIG_NODE, &debug_mgmt_client_fe_cmd);
}
diff --git a/lib/mgmt_fe_client.h b/lib/mgmt_fe_client.h
index 20c87044a5..2b5a25fa0d 100644
--- a/lib/mgmt_fe_client.h
+++ b/lib/mgmt_fe_client.h
@@ -179,11 +179,6 @@ mgmt_fe_client_create(const char *client_name, struct mgmt_fe_client_cbs *cbs,
extern void mgmt_fe_client_lib_vty_init(void);
/*
- * Print enabled debugging commands.
- */
-extern void mgmt_debug_fe_client_show_debug(struct vty *vty);
-
-/*
* Create a new Session for a Frontend Client connection.
*
* lib_hndl
diff --git a/lib/northbound.h b/lib/northbound.h
index 34d17a587c..da5f5be1ee 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -799,8 +799,6 @@ DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments),
(xpath, arguments));
DECLARE_HOOK(nb_notification_tree_send,
(const char *xpath, const struct lyd_node *tree), (xpath, tree));
-DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
-DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
/* Northbound debugging records */
extern struct debug nb_dbg_cbs_config;
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 4f962cda5c..f9794bee3c 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -22,13 +22,19 @@
#include "northbound_db.h"
#include "lib/northbound_cli_clippy.c"
-struct debug nb_dbg_cbs_config = {0, "Northbound callbacks: configuration"};
-struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
-struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"};
-struct debug nb_dbg_cbs_notify = {0, "Northbound callbacks: notifications"};
-struct debug nb_dbg_notif = {0, "Northbound notifications"};
-struct debug nb_dbg_events = {0, "Northbound events"};
-struct debug nb_dbg_libyang = {0, "libyang debugging"};
+struct debug nb_dbg_cbs_config = { 0, "debug northbound callbacks configuration",
+ "Northbound callbacks: configuration" };
+struct debug nb_dbg_cbs_state = { 0, "debug northbound callbacks state",
+ "Northbound callbacks: state" };
+struct debug nb_dbg_cbs_rpc = { 0, "debug northbound callbacks rpc",
+ "Northbound callbacks: RPCs" };
+struct debug nb_dbg_cbs_notify = { 0, "debug northbound callbacks notify",
+ "Northbound callbacks: notifications" };
+struct debug nb_dbg_notif = { 0, "debug northbound notifications",
+ "Northbound notifications" };
+struct debug nb_dbg_events = { 0, "debug northbound events",
+ "Northbound events" };
+struct debug nb_dbg_libyang = { 0, "debug northbound libyang", "libyang" };
struct nb_config *vty_shared_candidate_config;
static struct event_loop *master;
@@ -1380,7 +1386,7 @@ static int nb_cli_show_transactions(struct vty *vty)
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No configuration transactions to display.\n\n");
@@ -1661,7 +1667,7 @@ DEFPY (show_yang_module,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG modules to display.\n\n");
@@ -1771,7 +1777,7 @@ DEFPY (show_yang_module_translator,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG module translators to display.\n\n");
@@ -1842,37 +1848,6 @@ DEFPY (rollback_config,
}
/* Debug CLI commands. */
-static struct debug *nb_debugs[] = {
- &nb_dbg_cbs_config, &nb_dbg_cbs_state, &nb_dbg_cbs_rpc,
- &nb_dbg_cbs_notify, &nb_dbg_notif, &nb_dbg_events,
- &nb_dbg_libyang,
-};
-
-static const char *const nb_debugs_conflines[] = {
- "debug northbound callbacks configuration",
- "debug northbound callbacks state",
- "debug northbound callbacks rpc",
- "debug northbound callbacks notify",
- "debug northbound notifications",
- "debug northbound events",
- "debug northbound libyang",
-};
-
-DEFINE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
-
-static void nb_debug_set_all(uint32_t flags, bool set)
-{
- for (unsigned int i = 0; i < array_size(nb_debugs); i++) {
- DEBUG_FLAGS_SET(nb_debugs[i], flags, set);
-
- /* If all modes have been turned off, don't preserve options. */
- if (!DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_ALL))
- DEBUG_CLEAR(nb_debugs[i]);
- }
-
- hook_call(nb_client_debug_set_all, flags, set);
-}
-
DEFPY (debug_nb,
debug_nb_cmd,
"[no] debug northbound\
@@ -1895,8 +1870,13 @@ DEFPY (debug_nb,
"libyang debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
+ bool all = false;
+
+ /* no specific debug --> act on all of them */
+ if (strmatch(argv[argc - 1]->text, "northbound"))
+ all = true;
- if (cbs) {
+ if (cbs || all) {
bool none = (!cbs_cfg && !cbs_state && !cbs_rpc && !cbs_notify);
if (none || cbs_cfg)
@@ -1908,45 +1888,18 @@ DEFPY (debug_nb,
if (none || cbs_notify)
DEBUG_MODE_SET(&nb_dbg_cbs_notify, mode, !no);
}
- if (notifications)
+ if (notifications || all)
DEBUG_MODE_SET(&nb_dbg_notif, mode, !no);
- if (events)
+ if (events || all)
DEBUG_MODE_SET(&nb_dbg_events, mode, !no);
- if (libyang) {
+ if (libyang || all) {
DEBUG_MODE_SET(&nb_dbg_libyang, mode, !no);
yang_debugging_set(!no);
}
- /* no specific debug --> act on all of them */
- if (strmatch(argv[argc - 1]->text, "northbound")) {
- nb_debug_set_all(mode, !no);
- yang_debugging_set(!no);
- }
-
return CMD_SUCCESS;
}
-DEFINE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
-
-static int nb_debug_config_write(struct vty *vty)
-{
- for (unsigned int i = 0; i < array_size(nb_debugs); i++)
- if (DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_CONF))
- vty_out(vty, "%s\n", nb_debugs_conflines[i]);
-
- hook_call(nb_client_debug_config_write, vty);
-
- return 1;
-}
-
-static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all};
-static struct cmd_node nb_debug_node = {
- .name = "northbound debug",
- .node = NORTHBOUND_DEBUG_NODE,
- .prompt = "",
- .config_write = nb_debug_config_write,
-};
-
void nb_cli_install_default(int node)
{
_install_element(node, &show_config_candidate_section_cmd);
@@ -2007,9 +1960,14 @@ void nb_cli_init(struct event_loop *tm)
/* Initialize the shared candidate configuration. */
vty_shared_candidate_config = nb_config_new(NULL);
- debug_init(&nb_dbg_cbs);
+ debug_install(&nb_dbg_cbs_config);
+ debug_install(&nb_dbg_cbs_state);
+ debug_install(&nb_dbg_cbs_rpc);
+ debug_install(&nb_dbg_cbs_notify);
+ debug_install(&nb_dbg_notif);
+ debug_install(&nb_dbg_events);
+ debug_install(&nb_dbg_libyang);
- install_node(&nb_debug_node);
install_element(ENABLE_NODE, &debug_nb_cmd);
install_element(CONFIG_NODE, &debug_nb_cmd);
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index 0ec7610a9a..1f4d036cc2 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -19,7 +19,9 @@
#include <sysrepo/values.h>
#include <sysrepo/xpath.h>
-static struct debug nb_dbg_client_sysrepo = {0, "Northbound client: Sysrepo"};
+static struct debug nb_dbg_client_sysrepo = { 0,
+ "debug northbound client sysrepo",
+ "Northbound client: Sysrepo" };
static struct event_loop *master;
static sr_session_ctx_t *session;
@@ -553,29 +555,9 @@ DEFUN (debug_nb_sr,
return CMD_SUCCESS;
}
-static int frr_sr_debug_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_CONF))
- vty_out(vty, "debug northbound client sysrepo\n");
-
- return 0;
-}
-
-static int frr_sr_debug_set_all(uint32_t flags, bool set)
-{
- DEBUG_FLAGS_SET(&nb_dbg_client_sysrepo, flags, set);
-
- /* If all modes have been turned off, don't preserve options. */
- if (!DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_ALL))
- DEBUG_CLEAR(&nb_dbg_client_sysrepo);
-
- return 0;
-}
-
static void frr_sr_cli_init(void)
{
- hook_register(nb_client_debug_config_write, frr_sr_debug_config_write);
- hook_register(nb_client_debug_set_all, frr_sr_debug_set_all);
+ debug_install(&nb_dbg_client_sysrepo);
install_element(ENABLE_NODE, &debug_nb_sr_cmd);
install_element(CONFIG_NODE, &debug_nb_sr_cmd);
diff --git a/lib/termtable.c b/lib/termtable.c
index 88cc25bf68..ce19701389 100644
--- a/lib/termtable.c
+++ b/lib/termtable.c
@@ -363,7 +363,7 @@ char *ttable_dump(struct ttable *tt, const char *newline)
memcpy(&right[0], newline, nl_len);
/* allocate print buffer */
- buf = XCALLOC(MTYPE_TMP, width * (nlines + 1) + 1);
+ buf = XCALLOC(MTYPE_TMP_TTABLE, width * (nlines + 1) + 1);
pos = 0;
if (tt->style.border.top_on) {
diff --git a/lib/termtable.h b/lib/termtable.h
index 0782c82abd..d284c4f376 100644
--- a/lib/termtable.h
+++ b/lib/termtable.h
@@ -270,7 +270,7 @@ void ttable_rowseps(struct ttable *tt, unsigned int row,
*
* Caller must free this string after use with
*
- * XFREE (MTYPE_TMP, str);
+ * XFREE (MTYPE_TMP_TTABLE, str);
*
* @param tt the table to dump
* @param newline the desired newline sequence to use, null terminated.
diff --git a/lib/vty.c b/lib/vty.c
index 0a4a3d2b86..256a3bb3f5 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -345,8 +345,17 @@ int vty_out(struct vty *vty, const char *format, ...)
case VTY_SHELL_SERV:
case VTY_FILE:
default:
+ vty->vty_buf_size_accumulated += strlen(filtered);
/* print without crlf replacement */
buffer_put(vty->obuf, (uint8_t *)filtered, strlen(filtered));
+ /* For every chunk of memory, we invoke vtysh_flush where we
+ * put the data of collective vty->obuf Linked List items on the
+ * socket and free the vty->obuf data.
+ */
+ if (vty->vty_buf_size_accumulated >= VTY_MAX_INTERMEDIATE_FLUSH) {
+ vty->vty_buf_size_accumulated = 0;
+ vtysh_flush(vty);
+ }
break;
}
@@ -2118,6 +2127,8 @@ static void vtysh_accept(struct event *thread)
int client_len;
struct sockaddr_un client;
struct vty *vty;
+ int ret = 0;
+ uint32_t sndbufsize = VTY_SEND_BUF_MAX;
vty_event_serv(VTYSH_SERV, vtyserv);
@@ -2141,6 +2152,20 @@ static void vtysh_accept(struct event *thread)
close(sock);
return;
}
+
+ /*
+ * Increasing the SEND socket buffer size so that the socket can hold
+ * before sending it to VTY shell.
+ */
+ ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&sndbufsize,
+ sizeof(sndbufsize));
+ if (ret < 0) {
+ flog_err(EC_LIB_SOCKET,
+ "Cannot set socket %d send buffer size, %s", sock,
+ safe_strerror(errno));
+ close(sock);
+ return;
+ }
set_cloexec(sock);
#ifdef VTYSH_DEBUG
@@ -2227,6 +2252,7 @@ static int vtysh_flush(struct vty *vty)
vty_close(vty);
return -1;
case BUFFER_EMPTY:
+ vty->vty_buf_size_accumulated = 0;
break;
}
return 0;
diff --git a/lib/vty.h b/lib/vty.h
index c336a816cc..e511e8e79a 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -236,6 +236,7 @@ struct vty {
uintptr_t mgmt_req_pending_data;
bool mgmt_locked_candidate_ds;
bool mgmt_locked_running_ds;
+ uint64_t vty_buf_size_accumulated;
};
static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
@@ -338,6 +339,12 @@ struct vty_arg {
/* Vty read buffer size. */
#define VTY_READ_BUFSIZ 512
+/* Vty max send buffer size */
+#define VTY_SEND_BUF_MAX 16777216
+
+/* Vty flush intermediate size */
+#define VTY_MAX_INTERMEDIATE_FLUSH 131072
+
/* Directory separator. */
#ifndef DIRECTORY_SEP
#define DIRECTORY_SEP '/'
diff --git a/mgmtd/mgmt.c b/mgmtd/mgmt.c
index fe0357e7e4..cfadad4829 100644
--- a/mgmtd/mgmt.c
+++ b/mgmtd/mgmt.c
@@ -15,10 +15,14 @@
#include "mgmtd/mgmt_history.h"
#include "mgmtd/mgmt_memory.h"
-struct debug mgmt_debug_be = { .desc = "Management backend adapter" };
-struct debug mgmt_debug_ds = {.desc = "Management datastore"};
-struct debug mgmt_debug_fe = { .desc = "Management frontend adapter" };
-struct debug mgmt_debug_txn = {.desc = "Management transaction"};
+struct debug mgmt_debug_be = { .conf = "debug mgmt backend",
+ .desc = "Management backend adapter" };
+struct debug mgmt_debug_ds = { .conf = "debug mgmt datastore",
+ .desc = "Management datastore" };
+struct debug mgmt_debug_fe = { .conf = "debug mgmt frontend",
+ .desc = "Management frontend adapter" };
+struct debug mgmt_debug_txn = { .conf = "debug mgmt transaction",
+ .desc = "Management transaction" };
/* MGMTD process wide configuration. */
static struct mgmt_master mgmt_master;
@@ -39,6 +43,10 @@ void mgmt_master_init(struct event_loop *master, const int buffer_size)
void mgmt_init(void)
{
+ debug_install(&mgmt_debug_be);
+ debug_install(&mgmt_debug_ds);
+ debug_install(&mgmt_debug_fe);
+ debug_install(&mgmt_debug_txn);
/* Initialize datastores */
mgmt_ds_init(mm);
diff --git a/mgmtd/mgmt_be_adapter.c b/mgmtd/mgmt_be_adapter.c
index f1c5424d0a..93c9bcac44 100644
--- a/mgmtd/mgmt_be_adapter.c
+++ b/mgmtd/mgmt_be_adapter.c
@@ -249,6 +249,8 @@ static void mgmt_register_client_xpath(enum mgmt_be_client_id id,
{
struct mgmt_be_xpath_map **maps, *map;
+ maps = NULL;
+
switch (type) {
case MGMT_BE_XPATH_SUBSCR_TYPE_CFG:
maps = &be_cfg_xpath_map;
diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c
index 8ccb463577..876f703560 100644
--- a/mgmtd/mgmt_vty.c
+++ b/mgmtd/mgmt_vty.c
@@ -557,52 +557,11 @@ DEFPY(mgmt_rollback,
return CMD_SUCCESS;
}
-int config_write_mgmt_debug(struct vty *vty);
-static struct cmd_node debug_node = {
- .name = "mgmt debug",
- .node = DEBUG_NODE,
- .prompt = "",
- .config_write = config_write_mgmt_debug,
-};
-
-static int write_mgmt_debug_helper(struct vty *vty, bool config)
-{
- uint32_t mode = config ? DEBUG_MODE_CONF : DEBUG_MODE_ALL;
- bool be = DEBUG_MODE_CHECK(&mgmt_debug_be, mode);
- bool ds = DEBUG_MODE_CHECK(&mgmt_debug_ds, mode);
- bool fe = DEBUG_MODE_CHECK(&mgmt_debug_fe, mode);
- bool txn = DEBUG_MODE_CHECK(&mgmt_debug_txn, mode);
-
- if (!(be || ds || fe || txn))
- return 0;
-
- vty_out(vty, "debug mgmt");
- if (be)
- vty_out(vty, " backend");
- if (ds)
- vty_out(vty, " datastore");
- if (fe)
- vty_out(vty, " frontend");
- if (txn)
- vty_out(vty, " transaction");
-
- vty_out(vty, "\n");
-
- return 0;
-}
-
-int config_write_mgmt_debug(struct vty *vty)
-{
- return write_mgmt_debug_helper(vty, true);
-}
-
DEFPY_NOSH(show_debugging_mgmt, show_debugging_mgmt_cmd,
"show debugging [mgmt]", SHOW_STR DEBUG_STR "MGMT Information\n")
{
vty_out(vty, "MGMT debugging status:\n");
- write_mgmt_debug_helper(vty, false);
-
cmd_show_lib_debugs(vty);
return CMD_SUCCESS;
@@ -696,7 +655,6 @@ void mgmt_vty_init(void)
event_add_event(mm->master, mgmt_config_read_in, NULL, 0,
&mgmt_daemon_info->read_in);
- install_node(&debug_node);
install_node(&mgmtd_node);
install_element(VIEW_NODE, &show_mgmt_be_adapter_cmd);
diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index 22b6bdcec7..96ba4728bf 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -882,7 +882,7 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];
struct json_object *json = NULL;
- if (!ctx->count) {
+ if (!ctx->count && !ctx->json) {
vty_out(vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via",
"Identity");
}
diff --git a/pathd/path_cli.c b/pathd/path_cli.c
index e22931c13e..bf8a9ea028 100644
--- a/pathd/path_cli.c
+++ b/pathd/path_cli.c
@@ -131,7 +131,7 @@ DEFPY(show_srte_policy,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
@@ -1089,9 +1089,7 @@ DEFPY_NOSH(show_debugging_pathd, show_debugging_pathd_cmd,
vty_out(vty, "Path debugging status:\n");
cmd_show_lib_debugs(vty);
- /* nothing to do here */
- path_ted_show_debugging(vty);
- path_policy_show_debugging(vty);
+
return CMD_SUCCESS;
}
@@ -1101,10 +1099,8 @@ DEFPY(debug_path_policy, debug_path_policy_cmd, "[no] debug pathd policy",
"policy debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
- bool no_debug = no;
DEBUG_MODE_SET(&path_policy_debug, mode, !no);
- DEBUG_FLAGS_SET(&path_policy_debug, PATH_POLICY_DEBUG_BASIC, !no_debug);
return CMD_SUCCESS;
}
@@ -1307,33 +1303,9 @@ int config_write_segment_routing(struct vty *vty)
return 1;
}
-static int path_policy_cli_debug_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_CONF)) {
- if (DEBUG_FLAGS_CHECK(&path_policy_debug,
- PATH_POLICY_DEBUG_BASIC))
- vty_out(vty, "debug pathd policy\n");
- return 1;
- }
- return 0;
-}
-
-static int path_policy_cli_debug_set_all(uint32_t flags, bool set)
-{
- DEBUG_FLAGS_SET(&path_policy_debug, flags, set);
-
- /* If all modes have been turned off, don't preserve options. */
- if (!DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_ALL))
- DEBUG_CLEAR(&path_policy_debug);
-
- return 0;
-}
-
void path_cli_init(void)
{
- hook_register(nb_client_debug_config_write,
- path_policy_cli_debug_config_write);
- hook_register(nb_client_debug_set_all, path_policy_cli_debug_set_all);
+ debug_install(&path_policy_debug);
install_node(&segment_routing_node);
install_node(&sr_traffic_eng_node);
diff --git a/pathd/path_pcep.c b/pathd/path_pcep.c
index ec9d8adfc1..a0a53b0d84 100644
--- a/pathd/path_pcep.c
+++ b/pathd/path_pcep.c
@@ -31,7 +31,12 @@ DEFINE_MTYPE(PATHD, PCEP, "PCEP module");
/*
* Globals.
*/
-static struct pcep_glob pcep_glob_space = {.dbg = {0, "pathd module: pcep"}};
+static struct pcep_glob pcep_glob_space = {
+ .dbg_basic = { 0, "debug pathd pcep basic", "PCEP basic" },
+ .dbg_path = { 0, "debug pathd pcep path", "PCEP path" },
+ .dbg_msg = { 0, "debug pathd pcep message", "PCEP message" },
+ .dbg_lib = { 0, "debug pathd pcep pceplib", "PCEP lib" },
+};
struct pcep_glob *pcep_g = &pcep_glob_space;
/* Main Thread Even Handler */
diff --git a/pathd/path_pcep.h b/pathd/path_pcep.h
index d6dbcb5c08..a4f899df58 100644
--- a/pathd/path_pcep.h
+++ b/pathd/path_pcep.h
@@ -27,40 +27,22 @@ DECLARE_MTYPE(PCEP);
#define PCEP_DEBUG_MODE_PCEPLIB 0x08
#define PCEP_DEBUG_MODE_ALL 0x0F
#define PCEP_DEBUG(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC)) \
- DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGD(&pcep_g->dbg_basic, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PATH(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH)) \
- DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGD(&pcep_g->dbg_path, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PCEP(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP)) \
- DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGD(&pcep_g->dbg_msg, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PCEPLIB(priority, fmt, ...) \
do { \
switch (priority) { \
case LOG_DEBUG: \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
- PCEP_DEBUG_MODE_PCEPLIB)) \
- DEBUGD(&pcep_g->dbg, "pcep: " fmt, \
- ##__VA_ARGS__); \
+ DEBUGD(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_INFO: \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
- PCEP_DEBUG_MODE_PCEPLIB)) \
- DEBUGI(&pcep_g->dbg, "pcep: " fmt, \
- ##__VA_ARGS__); \
+ DEBUGI(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_NOTICE: \
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
- PCEP_DEBUG_MODE_PCEPLIB)) \
- DEBUGN(&pcep_g->dbg, "pcep: " fmt, \
- ##__VA_ARGS__); \
+ DEBUGN(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_WARNING: \
case LOG_ERR: \
@@ -294,7 +276,10 @@ struct path {
};
struct pcep_glob {
- struct debug dbg;
+ struct debug dbg_basic;
+ struct debug dbg_path;
+ struct debug dbg_msg;
+ struct debug dbg_lib;
struct event_loop *master;
struct frr_pthread *fpt;
uint8_t num_pce_opts_cli;
diff --git a/pathd/path_pcep_cli.c b/pathd/path_pcep_cli.c
index 47a811d144..8ceadb3e60 100644
--- a/pathd/path_pcep_cli.c
+++ b/pathd/path_pcep_cli.c
@@ -46,8 +46,6 @@
#define BUFFER_PCC_PCE_SIZE 1024
/* CLI Function declarations */
-static int pcep_cli_debug_config_write(struct vty *vty);
-static int pcep_cli_debug_set_all(uint32_t flags, bool set);
static int pcep_cli_pcep_config_write(struct vty *vty);
static int pcep_cli_pcc_config_write(struct vty *vty);
static int pcep_cli_pce_config_write(struct vty *vty);
@@ -110,10 +108,6 @@ static const char PCEP_VTYSH_ARG_DELEGATION_TIMEOUT[] = "delegation-timeout";
static const char PCEP_VTYSH_ARG_SR_DRAFT07[] = "sr-draft07";
static const char PCEP_VTYSH_ARG_PCE_INIT[] = "pce-initiated";
static const char PCEP_VTYSH_ARG_TCP_MD5[] = "tcp-md5-auth";
-static const char PCEP_VTYSH_ARG_BASIC[] = "basic";
-static const char PCEP_VTYSH_ARG_PATH[] = "path";
-static const char PCEP_VTYSH_ARG_MESSAGE[] = "message";
-static const char PCEP_VTYSH_ARG_PCEPLIB[] = "pceplib";
static const char PCEP_CLI_CAP_STATEFUL[] = " [Stateful PCE]";
static const char PCEP_CLI_CAP_INCL_DB_VER[] = " [Include DB version]";
static const char PCEP_CLI_CAP_LSP_TRIGGERED[] = " [LSP Triggered Resync]";
@@ -463,31 +457,19 @@ static void pcep_cli_remove_pce_connection(struct pce_opts *pce_opts)
* VTY command implementations
*/
-static int path_pcep_cli_debug(struct vty *vty, const char *debug_type, bool set)
+static int path_pcep_cli_debug(struct vty *vty, bool onoff, bool basic,
+ bool path, bool message, bool lib)
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
- /* Global Set */
- if (debug_type == NULL) {
- DEBUG_MODE_SET(&pcep_g->dbg, mode, set);
- DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_ALL, set);
- return CMD_SUCCESS;
- }
-
- DEBUG_MODE_SET(&pcep_g->dbg, mode, true);
-
- if (strcmp(debug_type, "basic") == 0)
- DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC, set);
- else if (strcmp(debug_type, "path") == 0)
- DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH, set);
- else if (strcmp(debug_type, "message") == 0)
- DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP, set);
- else if (strcmp(debug_type, "pceplib") == 0)
- DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB, set);
-
- /* Unset the pcep debug mode if there is no flag at least set*/
- if (!DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_ALL))
- DEBUG_MODE_SET(&pcep_g->dbg, mode, false);
+ if (basic)
+ DEBUG_MODE_SET(&pcep_g->dbg_basic, mode, onoff);
+ if (path)
+ DEBUG_MODE_SET(&pcep_g->dbg_path, mode, onoff);
+ if (message)
+ DEBUG_MODE_SET(&pcep_g->dbg_msg, mode, onoff);
+ if (lib)
+ DEBUG_MODE_SET(&pcep_g->dbg_lib, mode, onoff);
return CMD_SUCCESS;
}
@@ -1712,42 +1694,6 @@ static int path_pcep_cli_clear_srte_pcep_session(struct vty *vty,
* Config Write functions
*/
-int pcep_cli_debug_config_write(struct vty *vty)
-{
- char buff[128] = "";
-
- if (DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_CONF)) {
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC))
- csnprintfrr(buff, sizeof(buff), " %s",
- PCEP_VTYSH_ARG_BASIC);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH))
- csnprintfrr(buff, sizeof(buff), " %s",
- PCEP_VTYSH_ARG_PATH);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP))
- csnprintfrr(buff, sizeof(buff), " %s",
- PCEP_VTYSH_ARG_MESSAGE);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB))
- csnprintfrr(buff, sizeof(buff), " %s",
- PCEP_VTYSH_ARG_PCEPLIB);
- vty_out(vty, "debug pathd pcep%s\n", buff);
- buff[0] = 0;
- return 1;
- }
-
- return 0;
-}
-
-int pcep_cli_debug_set_all(uint32_t flags, bool set)
-{
- DEBUG_FLAGS_SET(&pcep_g->dbg, flags, set);
-
- /* If all modes have been turned off, don't preserve options. */
- if (!DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_ALL))
- DEBUG_CLEAR(&pcep_g->dbg);
-
- return 0;
-}
-
int pcep_cli_pcep_config_write(struct vty *vty)
{
vty_out(vty, " pcep\n");
@@ -2006,36 +1952,9 @@ int pcep_cli_pcep_pce_config_write(struct vty *vty)
* The param names are taken from the path_pcep_cli_clippy.c generated file.
*/
-DEFPY(show_debugging_pathd_pcep,
- show_debugging_pathd_pcep_cmd,
- "show debugging pathd-pcep",
- SHOW_STR
- "State of each debugging option\n"
- "pathd pcep module debugging\n")
-{
- vty_out(vty, "Pathd pcep debugging status:\n");
-
- if (DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_CONF)) {
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC))
- vty_out(vty, " Pathd pcep %s debugging is on\n",
- PCEP_VTYSH_ARG_BASIC);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH))
- vty_out(vty, " Pathd pcep %s debugging is on\n",
- PCEP_VTYSH_ARG_PATH);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP))
- vty_out(vty, " Pathd pcep %s debugging is on\n",
- PCEP_VTYSH_ARG_MESSAGE);
- if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB))
- vty_out(vty, " Pathd pcep %s debugging is on\n",
- PCEP_VTYSH_ARG_PCEPLIB);
- }
-
- return CMD_SUCCESS;
-}
-
DEFPY(pcep_cli_debug,
pcep_cli_debug_cmd,
- "[no] debug pathd pcep [<basic|path|message|pceplib>$debug_type]",
+ "[no] debug pathd pcep [{basic$basic|path$path|message$msg|pceplib$lib}]",
NO_STR DEBUG_STR
"pathd debugging\n"
"pcep module debugging\n"
@@ -2044,7 +1963,11 @@ DEFPY(pcep_cli_debug,
"pcep message debugging\n"
"pceplib debugging\n")
{
- return path_pcep_cli_debug(vty, debug_type, !no);
+ if (strmatch(argv[argc - 1]->text, "pcep"))
+ return path_pcep_cli_debug(vty, !no, true, true, true, true);
+ else
+ return path_pcep_cli_debug(vty, !no, !!basic, !!path, !!msg,
+ !!lib);
}
DEFPY(pcep_cli_show_srte_pcep_counters,
@@ -2372,9 +2295,11 @@ DEFPY(pcep_cli_clear_srte_pcep_session,
void pcep_cli_init(void)
{
hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
- hook_register(nb_client_debug_config_write,
- pcep_cli_debug_config_write);
- hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
+
+ debug_install(&pcep_g->dbg_basic);
+ debug_install(&pcep_g->dbg_path);
+ debug_install(&pcep_g->dbg_msg);
+ debug_install(&pcep_g->dbg_lib);
memset(&pce_connections_g, 0, sizeof(pce_connections_g));
@@ -2423,7 +2348,6 @@ void pcep_cli_init(void)
/* Top commands */
install_element(CONFIG_NODE, &pcep_cli_debug_cmd);
install_element(ENABLE_NODE, &pcep_cli_debug_cmd);
- install_element(ENABLE_NODE, &show_debugging_pathd_pcep_cmd);
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_counters_cmd);
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_pce_config_cmd);
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_pce_cmd);
diff --git a/pathd/path_ted.c b/pathd/path_ted.c
index df23f93127..0f8d3827ff 100644
--- a/pathd/path_ted.c
+++ b/pathd/path_ted.c
@@ -30,12 +30,11 @@ static uint32_t path_ted_stop_importing_igp(void);
static enum zclient_send_status path_ted_link_state_sync(void);
static void path_ted_timer_handler_sync(struct event *thread);
static void path_ted_timer_handler_refresh(struct event *thread);
-static int path_ted_cli_debug_config_write(struct vty *vty);
-static int path_ted_cli_debug_set_all(uint32_t flags, bool set);
extern struct zclient *zclient;
-struct ted_state ted_state_g = {};
+struct ted_state ted_state_g = { .dbg = { .conf = "debug pathd mpls-te",
+ .desc = "Pathd TED" } };
/*
* path_path_ted public API function implementations
@@ -335,10 +334,8 @@ DEFPY (debug_path_ted,
"ted debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
- bool no_debug = (no != NULL);
DEBUG_MODE_SET(&ted_state_g.dbg, mode, !no);
- DEBUG_FLAGS_SET(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC, !no_debug);
return CMD_SUCCESS;
}
@@ -466,37 +463,6 @@ DEFPY (show_pathd_ted_db,
return CMD_SUCCESS;
}
-/*
- * Config Write functions
- */
-
-int path_ted_cli_debug_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_CONF)) {
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC))
- vty_out(vty, "debug pathd mpls-te\n");
- return 1;
- }
- return 0;
-}
-
-void path_ted_show_debugging(struct vty *vty)
-{
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC))
- vty_out(vty, " Path TED debugging is on\n");
-}
-
-int path_ted_cli_debug_set_all(uint32_t flags, bool set)
-{
- DEBUG_FLAGS_SET(&ted_state_g.dbg, flags, set);
-
- /* If all modes have been turned off, don't preserve options. */
- if (!DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_ALL))
- DEBUG_CLEAR(&ted_state_g.dbg);
-
- return 0;
-}
-
/**
* Help fn to show ted related configuration
*
@@ -543,9 +509,7 @@ static void path_ted_register_vty(void)
install_element(CONFIG_NODE, &debug_path_ted_cmd);
install_element(ENABLE_NODE, &debug_path_ted_cmd);
- hook_register(nb_client_debug_config_write,
- path_ted_cli_debug_config_write);
- hook_register(nb_client_debug_set_all, path_ted_cli_debug_set_all);
+ debug_install(&ted_state_g.dbg);
}
/**
diff --git a/pathd/path_ted.h b/pathd/path_ted.h
index a1bc784b7f..7f3b3f590f 100644
--- a/pathd/path_ted.h
+++ b/pathd/path_ted.h
@@ -59,28 +59,17 @@ struct ted_state {
struct debug dbg;
};
/* Debug flags. */
-#define PATH_TED_DEBUG_BASIC 0x01
#define PATH_TED_DEBUG(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
- DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
#define PATH_TED_ERROR(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
- DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
+
#define PATH_TED_WARN(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
- DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
+
#define PATH_TED_INFO(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
- DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
- } while (0)
+ DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
/* TED management functions */
bool path_ted_is_initialized(void);
@@ -92,7 +81,6 @@ int path_ted_segment_list_refresh(void);
/* TED configuration functions */
uint32_t path_ted_config_write(struct vty *vty);
-void path_ted_show_debugging(struct vty *vty);
/* TED util functions */
/* clang-format off */
diff --git a/pathd/pathd.c b/pathd/pathd.c
index 9bb7dbae84..431fe4d1e3 100644
--- a/pathd/pathd.c
+++ b/pathd/pathd.c
@@ -33,15 +33,13 @@ DEFINE_HOOK(pathd_candidate_updated, (struct srte_candidate * candidate),
DEFINE_HOOK(pathd_candidate_removed, (struct srte_candidate * candidate),
(candidate));
-struct debug path_policy_debug;
+struct debug path_policy_debug = {
+ .conf = "debug pathd policy",
+ .desc = "Pathd policy",
+};
#define PATH_POLICY_DEBUG(fmt, ...) \
- do { \
- if (DEBUG_FLAGS_CHECK(&path_policy_debug, \
- PATH_POLICY_DEBUG_BASIC)) \
- DEBUGD(&path_policy_debug, "policy: " fmt, \
- ##__VA_ARGS__); \
- } while (0)
+ DEBUGD(&path_policy_debug, "policy: " fmt, ##__VA_ARGS__)
static void trigger_pathd_candidate_created(struct srte_candidate *candidate);
@@ -1281,12 +1279,6 @@ const char *srte_origin2str(enum srte_protocol_origin origin)
assert(!"Reached end of function we should never hit");
}
-void path_policy_show_debugging(struct vty *vty)
-{
- if (DEBUG_FLAGS_CHECK(&path_policy_debug, PATH_POLICY_DEBUG_BASIC))
- vty_out(vty, " Path policy debugging is on\n");
-}
-
void pathd_shutdown(void)
{
path_ted_teardown();
diff --git a/pathd/pathd.h b/pathd/pathd.h
index 73ad49226e..75e7eff920 100644
--- a/pathd/pathd.h
+++ b/pathd/pathd.h
@@ -32,8 +32,6 @@ enum srte_protocol_origin {
extern struct debug path_policy_debug;
-#define PATH_POLICY_DEBUG_BASIC 0x01
-
enum srte_policy_status {
SRTE_POLICY_STATUS_UNKNOWN = 0,
SRTE_POLICY_STATUS_DOWN = 1,
@@ -437,7 +435,6 @@ void srte_candidate_status_update(struct srte_candidate *candidate, int status);
void srte_candidate_unset_segment_list(const char *originator, bool force);
const char *srte_origin2str(enum srte_protocol_origin origin);
void pathd_shutdown(void);
-void path_policy_show_debugging(struct vty *vty);
/* path_cli.c */
void path_cli_init(void);
diff --git a/pbrd/pbr_debug.c b/pbrd/pbr_debug.c
index b30b54b7f0..6b0d1d5a81 100644
--- a/pbrd/pbr_debug.c
+++ b/pbrd/pbr_debug.c
@@ -13,53 +13,16 @@
#include "pbrd/pbr_debug_clippy.c"
#include "pbrd/pbr_debug.h"
-struct debug pbr_dbg_map = {0, "PBR map"};
-struct debug pbr_dbg_zebra = {0, "PBR Zebra communications"};
-struct debug pbr_dbg_nht = {0, "PBR nexthop tracking"};
-struct debug pbr_dbg_event = {0, "PBR events"};
-
-struct debug *pbr_debugs[] = {&pbr_dbg_map, &pbr_dbg_zebra, &pbr_dbg_nht,
- &pbr_dbg_event};
-
-const char *pbr_debugs_conflines[] = {
- "debug pbr map",
- "debug pbr zebra",
- "debug pbr nht",
- "debug pbr events",
-};
-
-void pbr_debug_set_all(uint32_t flags, bool set)
-{
- for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
- DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
-
- /* if all modes have been turned off, don't preserve options */
- if (!DEBUG_MODE_CHECK(pbr_debugs[i], DEBUG_MODE_ALL))
- DEBUG_CLEAR(pbr_debugs[i]);
- }
-}
-
-int pbr_debug_config_write_helper(struct vty *vty, bool config)
-{
- uint32_t mode = DEBUG_MODE_ALL;
-
- if (config)
- mode = DEBUG_MODE_CONF;
-
- for (unsigned int i = 0; i < array_size(pbr_debugs); i++)
- if (DEBUG_MODE_CHECK(pbr_debugs[i], mode))
- vty_out(vty, "%s\n", pbr_debugs_conflines[i]);
- return 0;
-}
-
-int pbr_debug_config_write(struct vty *vty)
-{
- return pbr_debug_config_write_helper(vty, true);
-}
-
-struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
+struct debug pbr_dbg_map = { 0, "debug pbr map", "PBR map" };
+struct debug pbr_dbg_zebra = { 0, "debug pbr zebra",
+ "PBR Zebra communications" };
+struct debug pbr_dbg_nht = { 0, "debug pbr nht", "PBR nexthop tracking" };
+struct debug pbr_dbg_event = { 0, "debug pbr events", "PBR events" };
void pbr_debug_init(void)
{
- debug_init(&pbr_dbg_cbs);
+ debug_install(&pbr_dbg_map);
+ debug_install(&pbr_dbg_zebra);
+ debug_install(&pbr_dbg_nht);
+ debug_install(&pbr_dbg_event);
}
diff --git a/pbrd/pbr_debug.h b/pbrd/pbr_debug.h
index 09109971d2..c1ffce99b8 100644
--- a/pbrd/pbr_debug.h
+++ b/pbrd/pbr_debug.h
@@ -35,26 +35,4 @@ void pbr_debug_init(void);
*/
void pbr_debug_set_all(uint32_t flags, bool set);
-/*
- * Config write helper.
- *
- * vty
- * Vty to write to
- *
- * config
- * Whether we are writing to show run or saving config file
- *
- * Returns:
- * 0 for convenience
- */
-int pbr_debug_config_write_helper(struct vty *vty, bool config);
-
-/*
- * Print PBR debugging configuration.
- *
- * vty
- * VTY to print debugging configuration to.
- */
-int pbr_debug_config_write(struct vty *vty);
-
#endif /* __PBR_DEBUG_H__ */
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index 64d88847c8..08fe56c7bb 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -1954,13 +1954,6 @@ DEFPY (show_pbr_interface,
/* PBR debugging CLI ------------------------------------------------------- */
-static struct cmd_node debug_node = {
- .name = "debug",
- .node = DEBUG_NODE,
- .prompt = "",
- .config_write = pbr_debug_config_write,
-};
-
DEFPY(debug_pbr,
debug_pbr_cmd,
"[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]",
@@ -1973,20 +1966,21 @@ DEFPY(debug_pbr,
"Events\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
+ bool all = false;
+
+ /* no specific debug --> act on all of them */
+ if (strmatch(argv[argc - 1]->text, "pbr"))
+ all = true;
- if (map)
+ if (map || all)
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
- if (zebra)
+ if (zebra || all)
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
- if (nht)
+ if (nht || all)
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
- if (events)
+ if (events || all)
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
- /* no specific debug --> act on all of them */
- if (strmatch(argv[argc - 1]->text, "pbr"))
- pbr_debug_set_all(mode, !no);
-
return CMD_SUCCESS;
}
@@ -1999,8 +1993,6 @@ DEFUN_NOSH(show_debugging_pbr,
{
vty_out(vty, "PBR debugging status:\n");
- pbr_debug_config_write_helper(vty, false);
-
cmd_show_lib_debugs(vty);
return CMD_SUCCESS;
@@ -2194,7 +2186,6 @@ void pbr_vty_init(void)
install_node(&pbr_map_node);
/* debug */
- install_node(&debug_node);
install_element(ENABLE_NODE, &debug_pbr_cmd);
install_element(CONFIG_NODE, &debug_pbr_cmd);
install_element(ENABLE_NODE, &show_debugging_pbr_cmd);
diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c
index a39d182990..8ccf42d729 100644
--- a/pimd/pim6_mld.c
+++ b/pimd/pim6_mld.c
@@ -2537,7 +2537,7 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname,
if (!js && !detail) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -3021,7 +3021,7 @@ static void gm_show_groups(struct vty *vty, struct vrf *vrf, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index d1368ff1ff..a87f5b6981 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -874,7 +874,7 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -926,7 +926,7 @@ void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@@ -1180,7 +1180,7 @@ void pim_show_state(struct pim_instance *pim, struct vty *vty,
#else
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
#endif
}
@@ -1413,7 +1413,7 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -1490,7 +1490,7 @@ void pim_show_join_desired(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -1569,7 +1569,7 @@ void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -1751,7 +1751,7 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -1831,7 +1831,7 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@@ -1974,7 +1974,7 @@ void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -2079,7 +2079,7 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -2262,7 +2262,7 @@ void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@@ -2734,7 +2734,7 @@ static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
return CMD_SUCCESS;
@@ -3214,7 +3214,7 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -3500,7 +3500,7 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -3939,7 +3939,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -4022,7 +4022,7 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@@ -5325,7 +5325,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
tt = NULL;
}
@@ -5379,7 +5379,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
if (!bsm_rpinfos_count(bsgrp->partial_bsrp_list) && !uj)
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 0f8940bb16..a2ddc82164 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -1272,7 +1272,7 @@ void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
} else {
if (prev_rp_info && json_rp_rows)
diff --git a/staticd/static_debug.c b/staticd/static_debug.c
index a65752c958..618ba91d12 100644
--- a/staticd/static_debug.c
+++ b/staticd/static_debug.c
@@ -19,68 +19,11 @@
*/
/* clang-format off */
-struct debug static_dbg_events = {0, "Staticd events"};
-struct debug static_dbg_route = {0, "Staticd route"};
-struct debug static_dbg_bfd = {0, "Staticd bfd"};
-
-struct debug *static_debug_arr[] = {
- &static_dbg_events,
- &static_dbg_route,
- &static_dbg_bfd
-};
-
-const char *static_debugs_conflines[] = {
- "debug static events",
- "debug static route",
- "debug static bfd"
-};
+struct debug static_dbg_events = {0, "debug static events", "Staticd events"};
+struct debug static_dbg_route = {0, "debug static route", "Staticd route"};
+struct debug static_dbg_bfd = {0, "debug static bfd", "Staticd bfd"};
/* clang-format on */
-
-/*
- * Set or unset all staticd debugs
- *
- * flags
- * The flags to set
- *
- * set
- * Whether to set or unset the specified flags
- */
-static void static_debug_set_all(uint32_t flags, bool set)
-{
- for (unsigned int i = 0; i < array_size(static_debug_arr); i++) {
- DEBUG_FLAGS_SET(static_debug_arr[i], flags, set);
-
- /* if all modes have been turned off, don't preserve options */
- if (!DEBUG_MODE_CHECK(static_debug_arr[i], DEBUG_MODE_ALL))
- DEBUG_CLEAR(static_debug_arr[i]);
- }
-}
-
-static int static_debug_config_write_helper(struct vty *vty, bool config)
-{
- uint32_t mode = DEBUG_MODE_ALL;
-
- if (config)
- mode = DEBUG_MODE_CONF;
-
- for (unsigned int i = 0; i < array_size(static_debug_arr); i++)
- if (DEBUG_MODE_CHECK(static_debug_arr[i], mode))
- vty_out(vty, "%s\n", static_debugs_conflines[i]);
-
- return 0;
-}
-
-int static_config_write_debug(struct vty *vty)
-{
- return static_debug_config_write_helper(vty, true);
-}
-
-int static_debug_status_write(struct vty *vty)
-{
- return static_debug_config_write_helper(vty, false);
-}
-
/*
* Set debugging status.
*
@@ -113,11 +56,9 @@ void static_debug_set(int vtynode, bool onoff, bool events, bool route,
* Debug lib initialization
*/
-struct debug_callbacks static_dbg_cbs = {
- .debug_set_all = static_debug_set_all
-};
-
void static_debug_init(void)
{
- debug_init(&static_dbg_cbs);
+ debug_install(&static_dbg_events);
+ debug_install(&static_dbg_route);
+ debug_install(&static_dbg_bfd);
}
diff --git a/staticd/static_debug.h b/staticd/static_debug.h
index c9100680f7..b990f7bcc9 100644
--- a/staticd/static_debug.h
+++ b/staticd/static_debug.h
@@ -29,22 +29,6 @@ extern struct debug static_dbg_bfd;
void static_debug_init(void);
/*
- * Print staticd debugging configuration.
- *
- * vty
- * VTY to print debugging configuration to.
- */
-int static_config_write_debug(struct vty *vty);
-
-/*
- * Print staticd debugging configuration, human readable form.
- *
- * vty
- * VTY to print debugging configuration to.
- */
-int static_debug_status_write(struct vty *vty);
-
-/*
* Set debugging status.
*
* vtynode
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index a18028ed08..07b8bc3d28 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -1639,26 +1639,16 @@ DEFUN_NOSH (show_debugging_static,
{
vty_out(vty, "Staticd debugging status\n");
- static_debug_status_write(vty);
-
cmd_show_lib_debugs(vty);
return CMD_SUCCESS;
}
-static struct cmd_node debug_node = {
- .name = "debug",
- .node = DEBUG_NODE,
- .prompt = "",
- .config_write = static_config_write_debug,
-};
-
#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
void static_vty_init(void)
{
#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
- install_node(&debug_node);
install_element(ENABLE_NODE, &debug_staticd_cmd);
install_element(CONFIG_NODE, &debug_staticd_cmd);
install_element(ENABLE_NODE, &show_debugging_static_cmd);
diff --git a/tests/bgpd/test_peer_attr.c b/tests/bgpd/test_peer_attr.c
index 767c41cfee..d5faa33ca8 100644
--- a/tests/bgpd/test_peer_attr.c
+++ b/tests/bgpd/test_peer_attr.c
@@ -5,6 +5,7 @@
*/
#include <zebra.h>
+#include "debug.h"
#include "memory.h"
#include "plist.h"
#include "printfrr.h"
@@ -1348,6 +1349,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
static void bgp_startup(void)
{
cmd_init(1);
+ debug_init();
zlog_aux_init("NONE: ", LOG_DEBUG);
zprivs_preinit(&bgpd_privs);
zprivs_init(&bgpd_privs);
diff --git a/tests/helpers/c/main.c b/tests/helpers/c/main.c
index fdda7f1e2a..9cb395bb1f 100644
--- a/tests/helpers/c/main.c
+++ b/tests/helpers/c/main.c
@@ -6,6 +6,7 @@
#include <sys/stat.h>
#include <lib/version.h>
+#include "debug.h"
#include "getopt.h"
#include "frrevent.h"
#include "vty.h"
@@ -141,6 +142,7 @@ int main(int argc, char **argv)
cmd_init(1);
vty_init(master, false);
lib_cmd_init();
+ debug_init();
nb_init(master, NULL, 0, false);
/* OSPF vty inits. */
diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c
index f9f584f450..6401971435 100644
--- a/tests/lib/cli/common_cli.c
+++ b/tests/lib/cli/common_cli.c
@@ -9,6 +9,7 @@
#include <zebra.h>
#include <sys/stat.h>
+#include "debug.h"
#include "frrevent.h"
#include "vty.h"
#include "command.h"
@@ -71,6 +72,7 @@ int main(int argc, char **argv)
vty_init(master, false);
lib_cmd_init();
+ debug_init();
for (yangcount = 0; test_yang_modules && test_yang_modules[yangcount];
yangcount++)
diff --git a/tests/lib/cli/test_cli.refout.in b/tests/lib/cli/test_cli.refout.in
index 84365810d5..222abcdade 100644
--- a/tests/lib/cli/test_cli.refout.in
+++ b/tests/lib/cli/test_cli.refout.in
@@ -409,7 +409,6 @@ domainname test.domain
!
!
!
-!
end
test# conf t
test(config)# hostname foohost
@@ -425,7 +424,6 @@ domainname test.domain
!
!
!
-!
end
foohost(config)#
end.
diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c
index ea84120fc1..0034c2af89 100644
--- a/tests/lib/cli/test_commands.c
+++ b/tests/lib/cli/test_commands.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include "debug.h"
#include "command.h"
#include "memory.h"
#include "vector.h"
@@ -195,6 +196,7 @@ static void test_init(void)
struct cmd_element *cmd;
cmd_init(1);
+ debug_init();
nb_init(master, NULL, 0, false);
install_node(&bgp_node);
diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c
index 321f158668..74a0dfe6cc 100644
--- a/tests/lib/northbound/test_oper_data.c
+++ b/tests/lib/northbound/test_oper_data.c
@@ -7,6 +7,7 @@
#include <zebra.h>
#include <sys/stat.h>
+#include "debug.h"
#include "frrevent.h"
#include "vty.h"
#include "command.h"
@@ -459,6 +460,7 @@ int main(int argc, char **argv)
cmd_hostname_set("test");
vty_init(master, false);
lib_cmd_init();
+ debug_init();
nb_init(master, modules, array_size(modules), false);
install_element(ENABLE_NODE, &test_rpc_cmd);
diff --git a/tests/lib/test_grpc.cpp b/tests/lib/test_grpc.cpp
index 202313603d..2f0282704e 100644
--- a/tests/lib/test_grpc.cpp
+++ b/tests/lib/test_grpc.cpp
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <zebra.h>
+#include "debug.h"
#include "filter.h"
#include "frr_pthread.h"
#include "libfrr.h"
@@ -79,6 +80,7 @@ static void static_startup(void)
// static struct option_chain *oc;
cmd_init(1);
+ debug_init();
zlog_aux_init("NONE: ", LOG_DEBUG);
zprivs_preinit(&static_privs);
diff --git a/tests/lib/test_ttable.c b/tests/lib/test_ttable.c
index 562ddf9d66..7ac0e3516b 100644
--- a/tests/lib/test_ttable.c
+++ b/tests/lib/test_ttable.c
@@ -20,7 +20,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* add new row with 1 column, assert that it is not added */
assert(ttable_add_row(tt, "%s", "Garbage") == NULL);
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* add new row, assert that it is added */
assert(ttable_add_row(tt, "%s|%s|%s", "a", "b", "c"));
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* add empty row, assert that it is added */
assert(ttable_add_row(tt, "||"));
@@ -44,7 +44,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 3);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* delete 1st row, assert that it is removed */
ttable_del_row(tt, 0);
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* delete last row, assert that it is removed */
ttable_del_row(tt, 0);
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* delete the remaining row, check dumping an empty table */
ttable_del_row(tt, 0);
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 0);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* add new row */
ttable_add_row(tt, "%s|%s||%s|%9d", "slick", "black", "triple", 1337);
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* add bigger row */
ttable_add_row(tt, "%s|%s||%s|%s",
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at beginning */
ttable_insert_row(tt, 0, "%s|%s||%d|%lf", "converting", "vegetarians",
@@ -95,7 +95,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 3);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at end */
ttable_insert_row(tt, tt->nrows - 1, "%s|%s||%d|%ld", "converting",
@@ -104,7 +104,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 4);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at middle */
ttable_insert_row(tt, 1, "%s|%s||%s|%ld", "she", "pioneer", "aki", 1l);
@@ -112,7 +112,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* set alignment */
ttable_align(tt, 0, 1, 2, 2, LEFT);
@@ -120,14 +120,14 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_align(tt, 0, 1, 5, 1, RIGHT);
assert(tt->ncols == 5);
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* set padding */
ttable_pad(tt, 0, 1, 1, 1, RIGHT, 2);
@@ -135,14 +135,14 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_pad(tt, 0, 0, 5, 4, LEFT, 2);
assert(tt->ncols == 5);
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* restyle */
tt->style.cell.border.bottom_on = false;
@@ -156,13 +156,13 @@ int main(int argc, char **argv)
ttable_rowseps(tt, 1, TOP, true, '-');
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* column separators for leftmost column */
ttable_colseps(tt, 0, RIGHT, true, '|');
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
/* delete table */
ttable_del(tt);
diff --git a/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_3.py b/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_3.py
index eca41e3b9e..73b2c19659 100644
--- a/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_3.py
+++ b/tests/topotests/bgp_default_originate/test_bgp_default_originate_topo1_3.py
@@ -16,6 +16,7 @@ import sys
import time
import pytest
from lib.topolog import logger
+import json
# pylint: disable=C0413
# Import topogen and topotest helpers
@@ -54,6 +55,7 @@ from lib.common_config import (
reset_config_on_routers,
create_static_routes,
check_router_status,
+ retry,
)
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
@@ -657,7 +659,7 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
)
step(
- " Configure default originate with route-map RMv4 and RMv6 for IPv4 and IPv6 bgp neighbors on R1 ( R1-R2) "
+ "Configure default originate with route-map RMv4 and RMv6 for IPv4 and IPv6 bgp neighbors on R1 ( R1-R2) "
)
local_as = get_dut_as_number(tgen, dut="r1")
default_originate_config = {
@@ -775,7 +777,7 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
tc_name, result
)
- step(" Configure default-originate on R3 for R3 to R2 IPv4 and IPv6 BGP neighbors ")
+ step("Configure default-originate on R3 for R3 to R2 IPv4 and IPv6 BGP neighbors ")
local_as = get_dut_as_number(tgen, dut="r3")
default_originate_config = {
"r3": {
@@ -831,7 +833,7 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
dut="r2",
routes=DEFAULT_ROUTES,
expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R1,
- expected=False,
+ expected=True,
)
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
@@ -890,7 +892,31 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
tc_name, result
)
- step(" BGP Daemon restart operation")
+ # Allow for verification of the table version
+ # as that restarting bgp on one router will cause
+ # r2's version number should go up as that r1
+ # is not directly connected to r2
+ # where?
+ @retry(retry_timeout=60)
+ def verify_version_upgrade(dut, version):
+ dut_new_ipv4_uni_json = json.loads(dut.vtysh_cmd("show bgp ipv4 uni json"))
+
+ logger.info(
+ "New version: {} comparing to old {}".format(
+ dut_new_ipv4_uni_json["tableVersion"], version
+ )
+ )
+ if version >= dut_new_ipv4_uni_json["tableVersion"]:
+ return False
+
+ return True
+
+ r2 = tgen.gears["r2"]
+
+ r2_bgp_ipv4_uni_json = json.loads(r2.vtysh_cmd("show bgp ipv4 uni json"))
+ curr_version = r2_bgp_ipv4_uni_json["tableVersion"]
+
+ step("BGP Daemon restart operation")
routers = ["r1", "r2"]
for dut in routers:
step(
@@ -898,41 +924,86 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
dut
)
)
+
kill_router_daemons(tgen, dut, ["bgpd"])
+ # Let's ensure that r2's version has upgraded and then
+ # let's check that the default route goes through
+ # r3's connection.
+ if dut == "r1":
+ step("Ensure that r2 prefers r3's default route at this point in time")
+ verify_version_upgrade(r2, curr_version)
+ # write code to ensure r1 neighbor is down
+ DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
+ result = verify_fib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R3,
+ expected=True,
+ )
+ assert (
+ result is True
+ ), "Testcase {} : Failed \n IBGP default route should be prefeered over EBGP \n Error: {}".format(
+ tc_name, result
+ )
+
+ result = verify_rib_default_route(
+ tgen,
+ topo,
+ dut="r2",
+ routes=DEFAULT_ROUTES,
+ expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R3,
+ expected=True,
+ )
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
start_router_daemons(tgen, dut, ["bgpd"])
- step("After restarting the BGP daomon Verify the default originate ")
- DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
- result = verify_fib_default_route(
- tgen,
- topo,
- dut="r2",
- routes=DEFAULT_ROUTES,
- expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R3,
- expected=False,
- )
- assert (
- result is not True
- ), "Testcase {} : Failed \n IBGP default route should be prefeered over EBGP \n Error: {}".format(
- tc_name, result
- )
+ if dut == "r2":
- result = verify_rib_default_route(
- tgen,
- topo,
- dut="r2",
- routes=DEFAULT_ROUTES,
- expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R3,
- expected=True,
- )
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result
- )
+ @retry(60)
+ def check_pfx_received_sent(dut):
+ output = json.loads(dut.vtysh_cmd("show bgp ipv4 uni summ json"))
+
+ logger.info(output)
+ if output["peerCount"] != 2:
+ logger.info(output["peerCount"])
+ logger.info("pc")
+ return False
+
+ if output["peers"]["192.168.1.1"]["state"] != "Established":
+ logger.info("Not Established 192.168.1.1")
+ return False
+
+ if output["peers"]["192.168.2.2"]["state"] != "Established":
+ logger.info("Not established 192.168.2.2")
+ return False
+ if output["peers"]["192.168.1.1"]["pfxRcd"] != 6:
+ logger.info("1.1 prxRcd")
+ return False
+
+ if output["peers"]["192.168.1.1"]["pfxSnt"] != 3:
+ logger.info("1.1 pfxsent")
+ return False
+
+ if output["peers"]["192.168.2.2"]["pfxRcd"] != 4:
+ logger.info("2.2 pfxRcd")
+ return False
+
+ if output["peers"]["192.168.2.2"]["pfxSnt"] != 9:
+ logger.info("2.2 pfxsnt")
+ return False
+
+ return True
+
+ check_pfx_received_sent(r2)
step(
"Verify the default route from R1 is is recieved both on RIB and FIB on R2"
)
-
DEFAULT_ROUTES = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"}
result = verify_fib_default_route(
tgen,
@@ -940,7 +1011,7 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
dut="r2",
routes=DEFAULT_ROUTES,
expected_nexthop=DEFAULT_ROUTE_NXT_HOP_R1,
- expected=False,
+ expected=True,
)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result
@@ -1003,7 +1074,7 @@ def test_verify_default_originate_after_BGP_and_FRR_restart_p2(request):
tc_name, result
)
- step(" Restarting FRR routers operation")
+ step("Restarting FRR routers operation")
"""
NOTE : Verify that iBGP default route is preffered over eBGP default route
"""
diff --git a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
index f7ac827e26..3932c29b98 100644
--- a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
+++ b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
@@ -140,7 +140,7 @@ def test_bgp_better_admin_won():
topotest.router_json_cmp, r3, "show ip route 40.0.0.0 json", expected
)
- _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"r3" route to 40.0.0.0 should have been lost'
assert result is None, assertmsg
@@ -155,7 +155,7 @@ def test_bgp_better_admin_won():
"show ip route 40.0.0.0 json",
expected,
)
- _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"r3" route to 40.0.0.0 did not come back'
assert result is None, assertmsg
@@ -196,7 +196,7 @@ def test_bgp_allow_as_in():
expected,
)
- _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"r1" 192.168.1.1/32 route should have arrived'
assert result is None, assertmsg
@@ -212,7 +212,7 @@ def test_bgp_allow_as_in():
expected,
)
- _, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"r2" 192.168.1.1/32 route should be gone'
assert result is None, assertmsg
diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py
index a2315138cc..be28b388ba 100755
--- a/tests/topotests/conftest.py
+++ b/tests/topotests/conftest.py
@@ -32,7 +32,7 @@ from lib import topolog, topotest
try:
# Used by munet native tests
- from munet.testing.fixtures import event_loop, unet # pylint: disable=all # noqa
+ from munet.testing.fixtures import unet # pylint: disable=all # noqa
@pytest.fixture(scope="module")
def rundir_module(pytestconfig):
diff --git a/tests/topotests/example_munet/r1/frr.conf b/tests/topotests/example_munet/r1/frr.conf
index 468bda5e01..692e4ceb47 100644
--- a/tests/topotests/example_munet/r1/frr.conf
+++ b/tests/topotests/example_munet/r1/frr.conf
@@ -4,4 +4,4 @@ service integrated-vtysh-config
interface eth0
ip address 10.0.1.1/24
-ip route 10.0.0.0/8 blackhole
+ip route 10.0.2.0/24 10.0.1.2
diff --git a/tests/topotests/example_munet/r2/frr.conf b/tests/topotests/example_munet/r2/frr.conf
index 77d9892485..da3f15b801 100644
--- a/tests/topotests/example_munet/r2/frr.conf
+++ b/tests/topotests/example_munet/r2/frr.conf
@@ -5,6 +5,4 @@ interface eth0
ip address 10.0.1.2/24
interface eth1
- ip address 10.0.2.2/24
-
-ip route 10.0.0.0/8 blackhole
+ ip address 10.0.2.2/24 \ No newline at end of file
diff --git a/tests/topotests/example_munet/r3/frr.conf b/tests/topotests/example_munet/r3/frr.conf
index e0839e6d8a..84527b34df 100644
--- a/tests/topotests/example_munet/r3/frr.conf
+++ b/tests/topotests/example_munet/r3/frr.conf
@@ -4,4 +4,4 @@ service integrated-vtysh-config
interface eth0
ip address 10.0.2.3/24
-ip route 10.0.0.0/8 blackhole
+ip route 10.0.1.0/24 10.0.2.2 \ No newline at end of file
diff --git a/tests/topotests/example_munet/test_munet.py b/tests/topotests/example_munet/test_munet.py
index 0d9599fa54..71052099c4 100644
--- a/tests/topotests/example_munet/test_munet.py
+++ b/tests/topotests/example_munet/test_munet.py
@@ -5,6 +5,22 @@
#
# Copyright (c) 2023, LabN Consulting, L.L.C.
#
+from munet.testing.util import retry
+
+
+@retry(retry_timeout=10)
+def wait_for_route(r, p):
+ o = r.cmd_raises(f"ip route show {p}")
+ assert p in o
+
+
async def test_native_test(unet):
- o = unet.hosts["r1"].cmd_nostatus("ip addr")
+ r1 = unet.hosts["r1"]
+ o = r1.cmd_nostatus("ip addr")
print(o)
+
+ wait_for_route(r1, "10.0.2.0/24")
+
+ r1.cmd_raises("ping -c1 10.0.1.2")
+ r1.cmd_raises("ping -c1 10.0.2.2")
+ r1.cmd_raises("ping -c1 10.0.2.3")
diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py
index a574f43d89..1cec2f16f0 100644
--- a/tests/topotests/isis_topo1/test_isis_topo1.py
+++ b/tests/topotests/isis_topo1/test_isis_topo1.py
@@ -623,7 +623,7 @@ def test_isis_hello_padding_during_adjacency_formation():
assert result is True, result
-@retry(retry_timeout=5)
+@retry(retry_timeout=10)
def check_last_iih_packet_for_padding(router, expect_padding):
logfilename = "{}/{}".format(router.gearlogdir, "isisd.log")
last_hello_packet_line = None
diff --git a/tests/topotests/kinds.yaml b/tests/topotests/kinds.yaml
index 5f4b61d4b7..20c819c79c 100644
--- a/tests/topotests/kinds.yaml
+++ b/tests/topotests/kinds.yaml
@@ -10,9 +10,10 @@ kinds:
/usr/lib/frr/frrinit.sh stop
volumes:
- "./%NAME%:/etc/frr"
+ - "%RUNDIR%/var.lib.frr:/var/lib/frr"
- "%RUNDIR%/var.log.frr:/var/log/frr"
- "%RUNDIR%/var.run.frr:/var/run/frr"
- - "%RUNDIR%/var.lib.frr:/var/lib/frr"
+ - "%RUNDIR%/var.tmp.frr:/var/tmp/frr"
cap-add:
- SYS_ADMIN
- AUDIT_WRITE
diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py
index f49e30ea5f..7941e5c1d2 100644
--- a/tests/topotests/lib/topogen.py
+++ b/tests/topotests/lib/topogen.py
@@ -832,10 +832,10 @@ class TopoRouter(TopoGear):
for daemon in self.RD:
# This will not work for all daemons
daemonstr = self.RD.get(daemon).rstrip("d")
- if daemonstr == "pim":
- grep_cmd = "grep 'ip {}' {}".format(daemonstr, source_path)
+ if daemonstr == "path":
+ grep_cmd = "grep 'candidate-path' {}".format(source_path)
else:
- grep_cmd = "grep 'router {}' {}".format(daemonstr, source_path)
+ grep_cmd = "grep -w '{}' {}".format(daemonstr, source_path)
result = self.run(grep_cmd, warn=False).strip()
if result:
self.load_config(daemon, "")
diff --git a/tests/topotests/nhrp_redundancy/host/zebra.conf b/tests/topotests/nhrp_redundancy/host/zebra.conf
new file mode 100644
index 0000000000..8bb7da0ad6
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/host/zebra.conf
@@ -0,0 +1,4 @@
+interface host-eth0
+ ip address 10.4.4.7/24
+!
+ip route 0.0.0.0/0 10.4.4.4
diff --git a/tests/topotests/nhrp_redundancy/r4/nhrp_cache.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_cache.json
index f87ebcf5fc..9e8a5c999d 100644
--- a/tests/topotests/nhrp_redundancy/r4/nhrp_cache.json
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_cache.json
@@ -4,9 +4,9 @@
},
"table": [
{
- "interface": "r4-gre0",
+ "interface": "nhc1-gre0",
"type": "nhs",
- "protocol": "176.16.1.2",
+ "protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
@@ -15,9 +15,9 @@
"identity": ""
},
{
- "interface": "r4-gre0",
+ "interface": "nhc1-gre0",
"type": "local",
- "protocol": "176.16.1.4",
+ "protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
@@ -26,9 +26,9 @@
"identity": "-"
},
{
- "interface": "r4-gre0",
+ "interface": "nhc1-gre0",
"type": "nhs",
- "protocol": "176.16.1.3",
+ "protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
@@ -37,9 +37,9 @@
"identity": ""
},
{
- "interface": "r4-gre0",
+ "interface": "nhc1-gre0",
"type": "nhs",
- "protocol": "176.16.1.1",
+ "protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"used": false,
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_cache_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_cache_nhs1_down.json
new file mode 100644
index 0000000000..5b91f3bcfb
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_cache_nhs1_down.json
@@ -0,0 +1,40 @@
+{
+ "attr": {
+ "entriesCount": 3
+ },
+ "table": [
+ {
+ "interface": "nhc1-gre0",
+ "type": "nhs",
+ "protocol": "172.16.1.2",
+ "nbma": "192.168.1.2",
+ "claimed_nbma": "192.168.1.2",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ },
+ {
+ "interface": "nhc1-gre0",
+ "type": "local",
+ "protocol": "172.16.1.4",
+ "nbma": "192.168.2.4",
+ "claimed_nbma": "192.168.2.4",
+ "used": false,
+ "timeout": false,
+ "auth": false,
+ "identity": "-"
+ },
+ {
+ "interface": "nhc1-gre0",
+ "type": "nhs",
+ "protocol": "172.16.1.3",
+ "nbma": "192.168.1.3",
+ "claimed_nbma": "192.168.1.3",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r5/nhrp_route.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route.json
index 1d1c16ffb8..083675651f 100644
--- a/tests/topotests/nhrp_redundancy/r5/nhrp_route.json
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route.json
@@ -1,7 +1,7 @@
{
- "176.16.1.1\/32": [
+ "172.16.1.1\/32": [
{
- "prefix": "176.16.1.1\/32",
+ "prefix": "172.16.1.1\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -16,15 +16,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r5-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.2\/32": [
+ "172.16.1.2\/32": [
{
- "prefix": "176.16.1.2\/32",
+ "prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -39,15 +39,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r5-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.3\/32": [
+ "172.16.1.3\/32": [
{
- "prefix": "176.16.1.3\/32",
+ "prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -62,7 +62,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r5-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_nhs1_down.json
new file mode 100644
index 0000000000..bfb468b0fb
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_nhs1_down.json
@@ -0,0 +1,49 @@
+{
+ "172.16.1.1\/32": null,
+ "172.16.1.2\/32": [
+ {
+ "prefix": "172.16.1.2\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.3\/32": [
+ {
+ "prefix": "172.16.1.3\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r4/nhrp_route_shortcut.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut.json
index f8efff2059..3a91f1baaa 100644
--- a/tests/topotests/nhrp_redundancy/r4/nhrp_route_shortcut.json
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut.json
@@ -1,7 +1,7 @@
{
- "5.5.5.5\/32": [
+ "10.5.5.0\/24": [
{
- "prefix": "5.5.5.5\/32",
+ "prefix": "10.5.5.0\/24",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -15,17 +15,17 @@
"nexthops": [
{
"fib": true,
- "ip": "176.16.1.5",
+ "ip": "172.16.1.5",
"afi": "ipv4",
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.1\/32": [
+ "172.16.1.1\/32": [
{
- "prefix": "176.16.1.1\/32",
+ "prefix": "172.16.1.1\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -40,15 +40,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.2\/32": [
+ "172.16.1.2\/32": [
{
- "prefix": "176.16.1.2\/32",
+ "prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -63,15 +63,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.3\/32": [
+ "172.16.1.3\/32": [
{
- "prefix": "176.16.1.3\/32",
+ "prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -86,15 +86,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
- "176.16.1.5\/32": [
+ "172.16.1.5\/32": [
{
- "prefix": "176.16.1.5\/32",
+ "prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -109,7 +109,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc1-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut_nhs1_down.json
new file mode 100644
index 0000000000..0f38feb6a8
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_route_shortcut_nhs1_down.json
@@ -0,0 +1,96 @@
+{
+ "10.5.5.0\/24": [
+ {
+ "prefix": "10.5.5.0\/24",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "ip": "172.16.1.5",
+ "afi": "ipv4",
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.1\/32": null,
+ "172.16.1.2\/32": [
+ {
+ "prefix": "172.16.1.2\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.3\/32": [
+ {
+ "prefix": "172.16.1.3\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.5\/32": [
+ {
+ "prefix": "172.16.1.5\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc1-gre0",
+ "active": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json
new file mode 100644
index 0000000000..78563cb902
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_absent.json
@@ -0,0 +1,5 @@
+{
+ "attr":{
+ "entriesCount":0
+ }
+}
diff --git a/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json
new file mode 100644
index 0000000000..4547c59c88
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrp_shortcut_present.json
@@ -0,0 +1,9 @@
+{
+ "table":[
+ {
+ "type":"dynamic",
+ "prefix":"10.5.5.0/24",
+ "via":"172.16.1.5"
+ }
+ ]
+}
diff --git a/tests/topotests/nhrp_redundancy/r4/nhrpd.conf b/tests/topotests/nhrp_redundancy/nhc1/nhrpd.conf
index 8a52f3386e..a0862f77ef 100644
--- a/tests/topotests/nhrp_redundancy/r4/nhrpd.conf
+++ b/tests/topotests/nhrp_redundancy/nhc1/nhrpd.conf
@@ -1,5 +1,5 @@
!debug nhrp all
-interface r4-gre0
+interface nhc1-gre0
ip nhrp holdtime 10
ip nhrp network-id 42
ip nhrp registration no-unique
@@ -7,5 +7,5 @@ interface r4-gre0
ip nhrp nhs dynamic nbma 192.168.1.2
ip nhrp nhs dynamic nbma 192.168.1.3
ip nhrp shortcut
- tunnel source r4-eth0
+ tunnel source nhc1-eth0
exit
diff --git a/tests/topotests/nhrp_redundancy/nhc1/zebra.conf b/tests/topotests/nhrp_redundancy/nhc1/zebra.conf
new file mode 100644
index 0000000000..07d9175418
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc1/zebra.conf
@@ -0,0 +1,16 @@
+ip forwarding
+interface nhc1-eth0
+ ip address 192.168.2.4/24
+!
+ip route 192.168.1.0/24 192.168.2.6
+interface nhc1-gre0
+ ip address 172.16.1.4/32
+ no link-detect
+ ipv6 nd suppress-ra
+!
+interface nhc1-eth1
+ ip address 10.4.4.4/24
+!
+ip route 0.0.0.0/0 172.16.1.1 50
+ip route 0.0.0.0/0 172.16.1.2 60
+ip route 0.0.0.0/0 172.16.1.3 70 \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r5/nhrp_cache.json b/tests/topotests/nhrp_redundancy/nhc2/nhrp_cache.json
index bc041c6014..8ee02a7cbf 100644
--- a/tests/topotests/nhrp_redundancy/r5/nhrp_cache.json
+++ b/tests/topotests/nhrp_redundancy/nhc2/nhrp_cache.json
@@ -4,9 +4,9 @@
},
"table": [
{
- "interface": "r5-gre0",
+ "interface": "nhc2-gre0",
"type": "nhs",
- "protocol": "176.16.1.2",
+ "protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
@@ -15,9 +15,9 @@
"identity": ""
},
{
- "interface": "r5-gre0",
+ "interface": "nhc2-gre0",
"type": "nhs",
- "protocol": "176.16.1.3",
+ "protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
@@ -26,9 +26,9 @@
"identity": ""
},
{
- "interface": "r5-gre0",
+ "interface": "nhc2-gre0",
"type": "nhs",
- "protocol": "176.16.1.1",
+ "protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"used": false,
@@ -37,9 +37,9 @@
"identity": ""
},
{
- "interface": "r5-gre0",
+ "interface": "nhc2-gre0",
"type": "local",
- "protocol": "176.16.1.5",
+ "protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
diff --git a/tests/topotests/nhrp_redundancy/nhc2/nhrp_cache_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhc2/nhrp_cache_nhs1_down.json
new file mode 100644
index 0000000000..bb1c483718
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc2/nhrp_cache_nhs1_down.json
@@ -0,0 +1,40 @@
+{
+ "attr": {
+ "entriesCount": 3
+ },
+ "table": [
+ {
+ "interface": "nhc2-gre0",
+ "type": "nhs",
+ "protocol": "172.16.1.2",
+ "nbma": "192.168.1.2",
+ "claimed_nbma": "192.168.1.2",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ },
+ {
+ "interface": "nhc2-gre0",
+ "type": "nhs",
+ "protocol": "172.16.1.3",
+ "nbma": "192.168.1.3",
+ "claimed_nbma": "192.168.1.3",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ },
+ {
+ "interface": "nhc2-gre0",
+ "type": "local",
+ "protocol": "172.16.1.5",
+ "nbma": "192.168.2.5",
+ "claimed_nbma": "192.168.2.5",
+ "used": false,
+ "timeout": false,
+ "auth": false,
+ "identity": "-"
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r4/nhrp_route.json b/tests/topotests/nhrp_redundancy/nhc2/nhrp_route.json
index 4f1faee7a7..a69c0caec3 100644
--- a/tests/topotests/nhrp_redundancy/r4/nhrp_route.json
+++ b/tests/topotests/nhrp_redundancy/nhc2/nhrp_route.json
@@ -1,7 +1,7 @@
{
- "176.16.1.1\/32": [
+ "172.16.1.1\/32": [
{
- "prefix": "176.16.1.1\/32",
+ "prefix": "172.16.1.1\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -16,15 +16,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc2-gre0",
"active": true
}
]
}
],
- "176.16.1.2\/32": [
+ "172.16.1.2\/32": [
{
- "prefix": "176.16.1.2\/32",
+ "prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -39,15 +39,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc2-gre0",
"active": true
}
]
}
],
- "176.16.1.3\/32": [
+ "172.16.1.3\/32": [
{
- "prefix": "176.16.1.3\/32",
+ "prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -62,7 +62,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r4-gre0",
+ "interfaceName": "nhc2-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/nhc2/nhrp_route_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhc2/nhrp_route_nhs1_down.json
new file mode 100644
index 0000000000..e2dd9dde23
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc2/nhrp_route_nhs1_down.json
@@ -0,0 +1,49 @@
+{
+ "172.16.1.1\/32": null,
+ "172.16.1.2\/32": [
+ {
+ "prefix": "172.16.1.2\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc2-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.3\/32": [
+ {
+ "prefix": "172.16.1.3\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhc2-gre0",
+ "active": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r5/nhrpd.conf b/tests/topotests/nhrp_redundancy/nhc2/nhrpd.conf
index 7241ed592d..16a6d87c27 100644
--- a/tests/topotests/nhrp_redundancy/r5/nhrpd.conf
+++ b/tests/topotests/nhrp_redundancy/nhc2/nhrpd.conf
@@ -1,5 +1,5 @@
!debug nhrp all
-interface r5-gre0
+interface nhc2-gre0
ip nhrp holdtime 10
ip nhrp network-id 42
ip nhrp nhs dynamic nbma 192.168.1.1
@@ -7,5 +7,5 @@ interface r5-gre0
ip nhrp nhs dynamic nbma 192.168.1.3
ip nhrp registration no-unique
ip nhrp shortcut
- tunnel source r5-eth0
+ tunnel source nhc2-eth0
exit
diff --git a/tests/topotests/nhrp_redundancy/nhc2/zebra.conf b/tests/topotests/nhrp_redundancy/nhc2/zebra.conf
new file mode 100644
index 0000000000..30ea6d4d1d
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhc2/zebra.conf
@@ -0,0 +1,16 @@
+ip forwarding
+interface nhc2-eth0
+ ip address 192.168.2.5/24
+!
+ip route 192.168.1.0/24 192.168.2.6
+interface nhc2-gre0
+ ip address 172.16.1.5/32
+ no link-detect
+ ipv6 nd suppress-ra
+!
+interface nhc2-eth1
+ ip address 10.5.5.5/24
+!
+ip route 0.0.0.0/0 172.16.1.1 50
+ip route 0.0.0.0/0 172.16.1.2 60
+ip route 0.0.0.0/0 172.16.1.3 70
diff --git a/tests/topotests/nhrp_redundancy/r1/nhrp_cache.json b/tests/topotests/nhrp_redundancy/nhs1/nhrp_cache.json
index a94dd9fecf..11d41d1b83 100644
--- a/tests/topotests/nhrp_redundancy/r1/nhrp_cache.json
+++ b/tests/topotests/nhrp_redundancy/nhs1/nhrp_cache.json
@@ -4,9 +4,9 @@
},
"table": [
{
- "interface": "r1-gre0",
+ "interface": "nhs1-gre0",
"type": "dynamic",
- "protocol": "176.16.1.4",
+ "protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
@@ -15,9 +15,9 @@
"identity": ""
},
{
- "interface": "r1-gre0",
+ "interface": "nhs1-gre0",
"type": "local",
- "protocol": "176.16.1.1",
+ "protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"used": false,
@@ -26,9 +26,9 @@
"identity": "-"
},
{
- "interface": "r1-gre0",
+ "interface": "nhs1-gre0",
"type": "dynamic",
- "protocol": "176.16.1.5",
+ "protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
diff --git a/tests/topotests/nhrp_redundancy/r3/nhrp_route.json b/tests/topotests/nhrp_redundancy/nhs1/nhrp_route.json
index 3d548c08fd..2574b1a5d2 100644
--- a/tests/topotests/nhrp_redundancy/r3/nhrp_route.json
+++ b/tests/topotests/nhrp_redundancy/nhs1/nhrp_route.json
@@ -1,7 +1,7 @@
{
- "176.16.1.4\/32": [
+ "172.16.1.4\/32": [
{
- "prefix": "176.16.1.4\/32",
+ "prefix": "172.16.1.4\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -16,15 +16,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r3-gre0",
+ "interfaceName": "nhs1-gre0",
"active": true
}
]
}
],
- "176.16.1.5\/32": [
+ "172.16.1.5\/32": [
{
- "prefix": "176.16.1.5\/32",
+ "prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -39,7 +39,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r3-gre0",
+ "interfaceName": "nhs1-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/r2/nhrpd.conf b/tests/topotests/nhrp_redundancy/nhs1/nhrpd.conf
index 4d63f07d1f..c0c8c28f94 100644
--- a/tests/topotests/nhrp_redundancy/r2/nhrpd.conf
+++ b/tests/topotests/nhrp_redundancy/nhs1/nhrpd.conf
@@ -1,9 +1,9 @@
!debug nhrp all
nhrp nflog-group 1
-interface r2-gre0
+interface nhs1-gre0
ip nhrp holdtime 10
ip nhrp network-id 42
ip nhrp registration no-unique
ip nhrp redirect
- tunnel source r2-eth0
+ tunnel source nhs1-eth0
exit
diff --git a/tests/topotests/nhrp_redundancy/nhs1/zebra.conf b/tests/topotests/nhrp_redundancy/nhs1/zebra.conf
new file mode 100644
index 0000000000..718e01b991
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs1/zebra.conf
@@ -0,0 +1,12 @@
+ip forwarding
+interface nhs1-eth0
+ ip address 192.168.1.1/24
+!
+ip route 192.168.2.0/24 192.168.1.6
+interface nhs1-gre0
+ ip address 172.16.1.1/32
+ no link-detect
+ ipv6 nd suppress-ra
+!
+ip route 10.4.4.0/24 172.16.1.4
+ip route 10.5.5.0/24 172.16.1.5
diff --git a/tests/topotests/nhrp_redundancy/r2/nhrp_cache.json b/tests/topotests/nhrp_redundancy/nhs2/nhrp_cache.json
index 91557a1918..6343c4deb9 100644
--- a/tests/topotests/nhrp_redundancy/r2/nhrp_cache.json
+++ b/tests/topotests/nhrp_redundancy/nhs2/nhrp_cache.json
@@ -4,9 +4,9 @@
},
"table": [
{
- "interface": "r2-gre0",
+ "interface": "nhs2-gre0",
"type": "local",
- "protocol": "176.16.1.2",
+ "protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
@@ -15,9 +15,9 @@
"identity": "-"
},
{
- "interface": "r2-gre0",
+ "interface": "nhs2-gre0",
"type": "dynamic",
- "protocol": "176.16.1.4",
+ "protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
@@ -26,9 +26,9 @@
"identity": ""
},
{
- "interface": "r2-gre0",
+ "interface": "nhs2-gre0",
"type": "dynamic",
- "protocol": "176.16.1.5",
+ "protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
diff --git a/tests/topotests/nhrp_redundancy/nhs2/nhrp_cache_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhs2/nhrp_cache_nhs1_down.json
new file mode 100644
index 0000000000..6343c4deb9
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs2/nhrp_cache_nhs1_down.json
@@ -0,0 +1,40 @@
+{
+ "attr": {
+ "entriesCount": 3
+ },
+ "table": [
+ {
+ "interface": "nhs2-gre0",
+ "type": "local",
+ "protocol": "172.16.1.2",
+ "nbma": "192.168.1.2",
+ "claimed_nbma": "192.168.1.2",
+ "used": false,
+ "timeout": false,
+ "auth": false,
+ "identity": "-"
+ },
+ {
+ "interface": "nhs2-gre0",
+ "type": "dynamic",
+ "protocol": "172.16.1.4",
+ "nbma": "192.168.2.4",
+ "claimed_nbma": "192.168.2.4",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ },
+ {
+ "interface": "nhs2-gre0",
+ "type": "dynamic",
+ "protocol": "172.16.1.5",
+ "nbma": "192.168.2.5",
+ "claimed_nbma": "192.168.2.5",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r1/nhrp_route.json b/tests/topotests/nhrp_redundancy/nhs2/nhrp_route.json
index b5f3e29e74..0ad37fc319 100644
--- a/tests/topotests/nhrp_redundancy/r1/nhrp_route.json
+++ b/tests/topotests/nhrp_redundancy/nhs2/nhrp_route.json
@@ -1,7 +1,7 @@
{
- "176.16.1.4\/32": [
+ "172.16.1.4\/32": [
{
- "prefix": "176.16.1.4\/32",
+ "prefix": "172.16.1.4\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -16,15 +16,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r1-gre0",
+ "interfaceName": "nhs2-gre0",
"active": true
}
]
}
],
- "176.16.1.5\/32": [
+ "172.16.1.5\/32": [
{
- "prefix": "176.16.1.5\/32",
+ "prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -39,7 +39,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r1-gre0",
+ "interfaceName": "nhs2-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/nhs2/nhrp_route_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhs2/nhrp_route_nhs1_down.json
new file mode 100644
index 0000000000..0ad37fc319
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs2/nhrp_route_nhs1_down.json
@@ -0,0 +1,48 @@
+{
+ "172.16.1.4\/32": [
+ {
+ "prefix": "172.16.1.4\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhs2-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.5\/32": [
+ {
+ "prefix": "172.16.1.5\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhs2-gre0",
+ "active": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r3/nhrpd.conf b/tests/topotests/nhrp_redundancy/nhs2/nhrpd.conf
index 87cc2161f8..df86d2798e 100644
--- a/tests/topotests/nhrp_redundancy/r3/nhrpd.conf
+++ b/tests/topotests/nhrp_redundancy/nhs2/nhrpd.conf
@@ -1,9 +1,9 @@
!debug nhrp all
nhrp nflog-group 1
-interface r3-gre0
+interface nhs2-gre0
ip nhrp holdtime 10
ip nhrp network-id 42
ip nhrp registration no-unique
ip nhrp redirect
- tunnel source r3-eth0
+ tunnel source nhs2-eth0
exit
diff --git a/tests/topotests/nhrp_redundancy/nhs2/zebra.conf b/tests/topotests/nhrp_redundancy/nhs2/zebra.conf
new file mode 100644
index 0000000000..6001bf21c0
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs2/zebra.conf
@@ -0,0 +1,12 @@
+ip forwarding
+interface nhs2-eth0
+ ip address 192.168.1.2/24
+!
+ip route 192.168.2.0/24 192.168.1.6
+interface nhs2-gre0
+ ip address 172.16.1.2/32
+ no link-detect
+ ipv6 nd suppress-ra
+!
+ip route 10.4.4.0/24 172.16.1.4
+ip route 10.5.5.0/24 172.16.1.5
diff --git a/tests/topotests/nhrp_redundancy/r3/nhrp_cache.json b/tests/topotests/nhrp_redundancy/nhs3/nhrp_cache.json
index ef3ab690bc..d911de348b 100644
--- a/tests/topotests/nhrp_redundancy/r3/nhrp_cache.json
+++ b/tests/topotests/nhrp_redundancy/nhs3/nhrp_cache.json
@@ -4,9 +4,9 @@
},
"table": [
{
- "interface": "r3-gre0",
+ "interface": "nhs3-gre0",
"type": "dynamic",
- "protocol": "176.16.1.4",
+ "protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
@@ -15,9 +15,9 @@
"identity": ""
},
{
- "interface": "r3-gre0",
+ "interface": "nhs3-gre0",
"type": "local",
- "protocol": "176.16.1.3",
+ "protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
@@ -26,9 +26,9 @@
"identity": "-"
},
{
- "interface": "r3-gre0",
+ "interface": "nhs3-gre0",
"type": "dynamic",
- "protocol": "176.16.1.5",
+ "protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
diff --git a/tests/topotests/nhrp_redundancy/nhs3/nhrp_cache_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhs3/nhrp_cache_nhs1_down.json
new file mode 100644
index 0000000000..d911de348b
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs3/nhrp_cache_nhs1_down.json
@@ -0,0 +1,40 @@
+{
+ "attr": {
+ "entriesCount": 3
+ },
+ "table": [
+ {
+ "interface": "nhs3-gre0",
+ "type": "dynamic",
+ "protocol": "172.16.1.4",
+ "nbma": "192.168.2.4",
+ "claimed_nbma": "192.168.2.4",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ },
+ {
+ "interface": "nhs3-gre0",
+ "type": "local",
+ "protocol": "172.16.1.3",
+ "nbma": "192.168.1.3",
+ "claimed_nbma": "192.168.1.3",
+ "used": false,
+ "timeout": false,
+ "auth": false,
+ "identity": "-"
+ },
+ {
+ "interface": "nhs3-gre0",
+ "type": "dynamic",
+ "protocol": "172.16.1.5",
+ "nbma": "192.168.2.5",
+ "claimed_nbma": "192.168.2.5",
+ "used": false,
+ "timeout": true,
+ "auth": false,
+ "identity": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r2/nhrp_route.json b/tests/topotests/nhrp_redundancy/nhs3/nhrp_route.json
index f1fa6e54c1..29a4f8f11b 100644
--- a/tests/topotests/nhrp_redundancy/r2/nhrp_route.json
+++ b/tests/topotests/nhrp_redundancy/nhs3/nhrp_route.json
@@ -1,7 +1,7 @@
{
- "176.16.1.4\/32": [
+ "172.16.1.4\/32": [
{
- "prefix": "176.16.1.4\/32",
+ "prefix": "172.16.1.4\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -16,15 +16,15 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r2-gre0",
+ "interfaceName": "nhs3-gre0",
"active": true
}
]
}
],
- "176.16.1.5\/32": [
+ "172.16.1.5\/32": [
{
- "prefix": "176.16.1.5\/32",
+ "prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
@@ -39,7 +39,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "r2-gre0",
+ "interfaceName": "nhs3-gre0",
"active": true
}
]
diff --git a/tests/topotests/nhrp_redundancy/nhs3/nhrp_route_nhs1_down.json b/tests/topotests/nhrp_redundancy/nhs3/nhrp_route_nhs1_down.json
new file mode 100644
index 0000000000..29a4f8f11b
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs3/nhrp_route_nhs1_down.json
@@ -0,0 +1,48 @@
+{
+ "172.16.1.4\/32": [
+ {
+ "prefix": "172.16.1.4\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhs3-gre0",
+ "active": true
+ }
+ ]
+ }
+ ],
+ "172.16.1.5\/32": [
+ {
+ "prefix": "172.16.1.5\/32",
+ "protocol": "nhrp",
+ "vrfId": 0,
+ "vrfName": "default",
+ "selected": true,
+ "destSelected": true,
+ "distance": 10,
+ "metric": 0,
+ "installed": true,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "fib": true,
+ "directlyConnected": true,
+ "interfaceName": "nhs3-gre0",
+ "active": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r1/nhrpd.conf b/tests/topotests/nhrp_redundancy/nhs3/nhrpd.conf
index ad48ce3769..e7c3504f65 100644
--- a/tests/topotests/nhrp_redundancy/r1/nhrpd.conf
+++ b/tests/topotests/nhrp_redundancy/nhs3/nhrpd.conf
@@ -1,9 +1,9 @@
!debug nhrp all
nhrp nflog-group 1
-interface r1-gre0
+interface nhs3-gre0
ip nhrp holdtime 10
ip nhrp network-id 42
ip nhrp registration no-unique
ip nhrp redirect
- tunnel source r1-eth0
+ tunnel source nhs3-eth0
exit
diff --git a/tests/topotests/nhrp_redundancy/nhs3/zebra.conf b/tests/topotests/nhrp_redundancy/nhs3/zebra.conf
new file mode 100644
index 0000000000..7c15438817
--- /dev/null
+++ b/tests/topotests/nhrp_redundancy/nhs3/zebra.conf
@@ -0,0 +1,12 @@
+ip forwarding
+interface nhs3-eth0
+ ip address 192.168.1.3/24
+!
+ip route 192.168.2.0/24 192.168.1.6
+interface nhs3-gre0
+ ip address 172.16.1.3/32
+ no link-detect
+ ipv6 nd suppress-ra
+!
+ip route 10.4.4.0/24 172.16.1.4
+ip route 10.5.5.0/24 172.16.1.5 \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r1/zebra.conf b/tests/topotests/nhrp_redundancy/r1/zebra.conf
deleted file mode 100644
index 0f11563f57..0000000000
--- a/tests/topotests/nhrp_redundancy/r1/zebra.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-ip forwarding
-interface r1-eth0
- ip address 192.168.1.1/24
-!
-ip route 192.168.2.0/24 192.168.1.6
-interface r1-gre0
- ip address 176.16.1.1/32
- no link-detect
- ipv6 nd suppress-ra
-!
-ip route 4.4.4.0/24 176.16.1.4
-ip route 5.5.5.0/24 176.16.1.5
diff --git a/tests/topotests/nhrp_redundancy/r2/zebra.conf b/tests/topotests/nhrp_redundancy/r2/zebra.conf
deleted file mode 100644
index 1a9c4ff915..0000000000
--- a/tests/topotests/nhrp_redundancy/r2/zebra.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-ip forwarding
-interface r2-eth0
- ip address 192.168.1.2/24
-!
-ip route 192.168.2.0/24 192.168.1.6
-interface r2-gre0
- ip address 176.16.1.2/32
- no link-detect
- ipv6 nd suppress-ra
-!
-ip route 4.4.4.0/24 176.16.1.4
-ip route 5.5.5.0/24 176.16.1.5
diff --git a/tests/topotests/nhrp_redundancy/r3/zebra.conf b/tests/topotests/nhrp_redundancy/r3/zebra.conf
deleted file mode 100644
index 980cfbcaab..0000000000
--- a/tests/topotests/nhrp_redundancy/r3/zebra.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-ip forwarding
-interface r3-eth0
- ip address 192.168.1.3/24
-!
-ip route 192.168.2.0/24 192.168.1.6
-interface r3-gre0
- ip address 176.16.1.3/32
- no link-detect
- ipv6 nd suppress-ra
-!
-ip route 4.4.4.0/24 176.16.1.4
-ip route 5.5.5.0/24 176.16.1.5 \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r4/zebra.conf b/tests/topotests/nhrp_redundancy/r4/zebra.conf
deleted file mode 100644
index e4a9a6f80f..0000000000
--- a/tests/topotests/nhrp_redundancy/r4/zebra.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-ip forwarding
-interface r4-eth0
- ip address 192.168.2.4/24
-!
-ip route 192.168.1.0/24 192.168.2.6
-interface r4-gre0
- ip address 176.16.1.4/32
- no link-detect
- ipv6 nd suppress-ra
-!
-interface r4-eth1
- ip address 4.4.4.4/24
-!
-ip route 0.0.0.0/0 176.16.1.1 50
-ip route 0.0.0.0/0 176.16.1.2 60
-ip route 0.0.0.0/0 176.16.1.3 70 \ No newline at end of file
diff --git a/tests/topotests/nhrp_redundancy/r5/zebra.conf b/tests/topotests/nhrp_redundancy/r5/zebra.conf
deleted file mode 100644
index 9b1e1c0646..0000000000
--- a/tests/topotests/nhrp_redundancy/r5/zebra.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-ip forwarding
-interface r5-eth0
- ip address 192.168.2.5/24
-!
-ip route 192.168.1.0/24 192.168.2.6
-interface r5-gre0
- ip address 176.16.1.5/32
- no link-detect
- ipv6 nd suppress-ra
-!
-interface r5-eth1
- ip address 5.5.5.5/24
-!
-ip route 0.0.0.0/0 176.16.1.1 50
-ip route 0.0.0.0/0 176.16.1.2 60
-ip route 0.0.0.0/0 176.16.1.3 70
diff --git a/tests/topotests/nhrp_redundancy/r7/zebra.conf b/tests/topotests/nhrp_redundancy/r7/zebra.conf
deleted file mode 100644
index 5747b40956..0000000000
--- a/tests/topotests/nhrp_redundancy/r7/zebra.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-interface r7-eth0
- ip address 4.4.4.7/24
-!
-ip route 0.0.0.0/0 4.4.4.4
diff --git a/tests/topotests/nhrp_redundancy/r6/zebra.conf b/tests/topotests/nhrp_redundancy/router/zebra.conf
index 63a37cd5bf..c0eb19ca40 100644
--- a/tests/topotests/nhrp_redundancy/r6/zebra.conf
+++ b/tests/topotests/nhrp_redundancy/router/zebra.conf
@@ -1,7 +1,7 @@
ip forwarding
-interface r6-eth0
+interface router-eth0
ip address 192.168.1.6/24
!
-interface r6-eth1
+interface router-eth1
ip address 192.168.2.6/24
exit
diff --git a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.dot b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.dot
index c169436db0..e94e1d0734 100644
--- a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.dot
+++ b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.dot
@@ -16,43 +16,43 @@ graph template {
label="nhrp-topo-redundant-nhs";
# Routers
- r1 [
+ nhs1 [
shape=doubleoctagon,
label="NHS 1",
fillcolor="#f08080",
style=filled,
];
- r2 [
+ nhs2 [
shape=doubleoctagon
label="NHS 2",
fillcolor="#f08080",
style=filled,
];
- r3 [
+ nhs3 [
shape=doubleoctagon
label="NHS 3",
fillcolor="#f08080",
style=filled,
];
- r4 [
+ nhc1 [
shape=doubleoctagon
label="NHC 1",
fillcolor="#f08080",
style=filled,
];
- r5 [
+ nhc2 [
shape=doubleoctagon
label="NHC 2",
fillcolor="#f08080",
style=filled,
];
- r6 [
+ router [
shape=doubleoctagon
label="router",
fillcolor="#f08080",
style=filled,
];
- r7 [
+ host [
shape=doubleoctagon
label="host",
fillcolor="#f08080",
@@ -74,30 +74,30 @@ graph template {
];
sw3 [
shape=oval,
- label="sw3\n4.4.4.0/24",
+ label="sw3\n10.4.4.0/24",
fillcolor="#d0e0d0",
style=filled,
];
sw4 [
shape=oval,
- label="sw4\n5.5.5.0/24",
+ label="sw4\n10.5.5.0/24",
fillcolor="#d0e0d0",
style=filled,
];
# Connections
- r1 -- sw1 [label="eth0"];
- r2 -- sw1 [label="eth0"];
- r3 -- sw1 [label="eth0"];
- r6 -- sw1 [label="eth0"];
+ nhs1 -- sw1 [label="eth0"];
+ nhs2 -- sw1 [label="eth0"];
+ nhs3 -- sw1 [label="eth0"];
+ router -- sw1 [label="eth0"];
- r4 -- sw2 [label="eth0"];
- r5 -- sw2 [label="eth0"];
- r6 -- sw2 [label="eth1"];
+ nhc1 -- sw2 [label="eth0"];
+ nhc2 -- sw2 [label="eth0"];
+ router -- sw2 [label="eth1"];
- r4 -- sw3 [label="eth1"];
- r7 -- sw3 [label="eth0"];
+ nhc1 -- sw3 [label="eth1"];
+ host -- sw3 [label="eth0"];
- r5 -- sw4 [label="eth1"];
+ nhc2 -- sw4 [label="eth1"];
}
diff --git a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
index ffd9abc9d4..06777aaa23 100644
--- a/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
+++ b/tests/topotests/nhrp_redundancy/test_nhrp_redundancy.py
@@ -56,11 +56,11 @@ TOPOLOGY = """
+------------+ | +-------+----+ +------+-----+ |
| | | | | | | |
| | +--------+ | | | |
-| Host |.7 | | NHC 1 | | NHC 2 +-----+5.5.5.0/24
+| Host |.7 | | NHC 1 | | NHC 2 +-----+10.5.5.0/24
| +---------+ | | | | |
+------------+ | +------------+ +------------+ |
| |
- 4.4.4.0/24
+ 10.4.4.0/24
"""
# Save the Current Working Directory to find configuration files.
@@ -76,30 +76,26 @@ def build_topo(tgen):
"Build function"
# Create 7 routers
- for routern in range(1, 8):
- tgen.add_router("r{}".format(routern))
+ for rname in ["nhs1", "nhs2", "nhs3", "nhc1", "nhc2", "router", "host"]:
+ tgen.add_router(rname)
- # Interconnect routers 1, 2, 3, 6
switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r6"])
+ switch.add_link(tgen.gears["nhs1"])
+ switch.add_link(tgen.gears["nhs2"])
+ switch.add_link(tgen.gears["nhs3"])
+ switch.add_link(tgen.gears["router"])
- # Interconnect routers 4, 5, 6
switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r4"])
- switch.add_link(tgen.gears["r5"])
- switch.add_link(tgen.gears["r6"])
+ switch.add_link(tgen.gears["nhc1"])
+ switch.add_link(tgen.gears["nhc2"])
+ switch.add_link(tgen.gears["router"])
- # Connect router 4, 7
switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r4"])
- switch.add_link(tgen.gears["r7"])
+ switch.add_link(tgen.gears["nhc1"])
+ switch.add_link(tgen.gears["host"])
- # Connect router 5
switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r5"])
+ switch.add_link(tgen.gears["nhc2"])
def _populate_iface():
@@ -110,7 +106,7 @@ def _populate_iface():
"echo 0 > /proc/sys/net/ipv4/ip_forward_use_pmtu",
"echo 1 > /proc/sys/net/ipv6/conf/{0}-eth0/disable_ipv6",
"echo 1 > /proc/sys/net/ipv6/conf/{0}-gre0/disable_ipv6",
- "iptables -A FORWARD -i {0}-gre0 -o {0}-gre0 -m hashlimit --hashlimit-upto 4/minute --hashlimit-burst 1 --hashlimit-mode srcip,dstip --hashlimit-srcmask 24 --hashlimit-dstmask 24 --hashlimit-name loglimit-0 -j NFLOG --nflog-group 1 --nflog-range 128",
+ "iptables -A FORWARD -i {0}-gre0 -o {0}-gre0 -m hashlimit --hashlimit-upto 4/minute --hashlimit-burst 1 --hashlimit-mode srcip,dstip --hashlimit-srcmask 24 --hashlimit-dstmask 24 --hashlimit-name loglimit-0 -j NFLOG --nflog-group 1 --nflog-size 128",
]
cmds_tot = [
@@ -122,40 +118,37 @@ def _populate_iface():
]
for cmd in cmds_tot_hub:
- # Router 1
- input = cmd.format("r1", "1")
+ input = cmd.format("nhs1", "1")
logger.info("input: " + input)
- output = tgen.net["r1"].cmd(input)
+ output = tgen.net["nhs1"].cmd(input)
logger.info("output: " + output)
- # Router 2
- input = cmd.format("r2", "2")
+ input = cmd.format("nhs2", "2")
logger.info("input: " + input)
- output = tgen.net["r2"].cmd(input)
+ output = tgen.net["nhs2"].cmd(input)
logger.info("output: " + output)
- # Router 3
- input = cmd.format("r3", "3")
+ input = cmd.format("nhs3", "3")
logger.info("input: " + input)
- output = tgen.net["r3"].cmd(input)
+ output = tgen.net["nhs3"].cmd(input)
logger.info("output: " + output)
for cmd in cmds_tot:
- input = cmd.format("r4", "4")
+ input = cmd.format("nhc1", "4")
logger.info("input: " + input)
- output = tgen.net["r4"].cmd(input)
+ output = tgen.net["nhc1"].cmd(input)
logger.info("output: " + output)
- input = cmd.format("r5", "5")
+ input = cmd.format("nhc2", "5")
logger.info("input: " + input)
- output = tgen.net["r5"].cmd(input)
+ output = tgen.net["nhc2"].cmd(input)
logger.info("output: " + output)
def _verify_iptables():
tgen = get_topogen()
# Verify iptables is installed. Required for shortcuts
- rc, _, _ = tgen.net["r1"].cmd_status("iptables")
+ rc, _, _ = tgen.net["nhs1"].cmd_status("iptables")
return False if rc == 127 else True
@@ -178,7 +171,7 @@ def setup_module(mod):
TopoRouter.RD_ZEBRA,
os.path.join(CWD, "{}/zebra.conf".format(rname)),
)
- if rname in ("r1", "r2", "r3", "r4", "r5"):
+ if rname in ("nhs1", "nhs2", "nhs3", "nhc1", "nhc2"):
router.load_config(
TopoRouter.RD_NHRP, os.path.join(CWD, "{}/nhrpd.conf".format(rname))
)
@@ -202,17 +195,15 @@ def test_protocols_convergence():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- logger.info("Checking NHRP cache and IPv4 routes for convergence")
+ logger.info("Checking NHRP cache for convergence")
router_list = tgen.routers()
# Check NHRP cache on servers and clients
- for _, router in router_list.items():
-
- json_file = "{}/{}/nhrp_cache.json".format(CWD, router.name)
- if not os.path.isfile(json_file):
- logger.info("skipping file {}".format(json_file))
+ for rname, router in router_list.items():
+ if "nh" not in rname:
continue
+ json_file = "{}/{}/nhrp_cache.json".format(CWD, router.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, router, "show ip nhrp cache json", expected
@@ -226,13 +217,12 @@ def test_protocols_convergence():
assert result is None, assertmsg
# Check NHRP IPV4 routes on servers and clients
+ logger.info("Checking IPv4 routes for convergence")
for rname, router in router_list.items():
-
- json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
- if not os.path.isfile(json_file):
- logger.info("skipping file {}".format(json_file))
+ if "nh" not in rname:
continue
+ json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected
@@ -246,53 +236,53 @@ def test_protocols_convergence():
assert result is None, assertmsg
# Test connectivity from 1 NHRP server to all clients
- pingrouter = tgen.gears["r1"]
- logger.info("Check Ping IPv4 from R1 to R4 = 176.16.1.4)")
- output = pingrouter.run("ping 176.16.1.4 -f -c 1000")
+ nhs1 = tgen.gears["nhs1"]
+ logger.info("Check Ping IPv4 from nhs1 to nhc1 = 172.16.1.4)")
+ output = nhs1.run("ping 172.16.1.4 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R1 to R4 should be ok"
+ assertmsg = "expected ping IPv4 from nhs1 to nhc1 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R1 to R4 OK")
+ logger.info("Check Ping IPv4 from nhs1 to nhc1 OK")
- logger.info("Check Ping IPv4 from R1 to R5 = 176.16.1.5)")
- output = pingrouter.run("ping 176.16.1.5 -f -c 1000")
+ logger.info("Check Ping IPv4 from nhs1 to nhc2 = 172.16.1.5)")
+ output = nhs1.run("ping 172.16.1.5 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R1 to R5 should be ok"
+ assertmsg = "expected ping IPv4 from nhs1 to nhc2 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R1 to R5 OK")
+ logger.info("Check Ping IPv4 from nhs1 to nhc2 OK")
# Test connectivity from 1 NHRP client to all servers
- pingrouter = tgen.gears["r4"]
- logger.info("Check Ping IPv4 from R4 to R1 = 176.16.1.1)")
- output = pingrouter.run("ping 176.16.1.1 -f -c 1000")
+ nhc1 = tgen.gears["nhc1"]
+ logger.info("Check Ping IPv4 from nhc1 to nhs1 = 172.16.1.1)")
+ output = nhc1.run("ping 172.16.1.1 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R4 to R1 should be ok"
+ assertmsg = "expected ping IPv4 from nhc1 to nhs1 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R4 to R1 OK")
+ logger.info("Check Ping IPv4 from nhc1 to nhs1 OK")
- logger.info("Check Ping IPv4 from R4 to R2 = 176.16.1.2)")
- output = pingrouter.run("ping 176.16.1.2 -f -c 1000")
+ logger.info("Check Ping IPv4 from nhc1 to nhs2 = 172.16.1.2)")
+ output = nhc1.run("ping 172.16.1.2 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R4 to R2 should be ok"
+ assertmsg = "expected ping IPv4 from nhc1 to nhs2 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R4 to R2 OK")
+ logger.info("Check Ping IPv4 from nhc1 to nhs2 OK")
- logger.info("Check Ping IPv4 from R4 to R3 = 176.16.1.3)")
- output = pingrouter.run("ping 176.16.1.3 -f -c 1000")
+ logger.info("Check Ping IPv4 from nhc1 to nhs3 = 172.16.1.3)")
+ output = nhc1.run("ping 172.16.1.3 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R4 to R3 should be ok"
+ assertmsg = "expected ping IPv4 from nhc1 to nhs3 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R4 to R3 OK")
+ logger.info("Check Ping IPv4 from nhc1 to nhs3 OK")
@retry(retry_timeout=30, initial_wait=5)
@@ -301,22 +291,21 @@ def verify_shortcut_path():
Verifying that traffic flows through shortcut path
"""
tgen = get_topogen()
- pingrouter = tgen.gears["r7"]
- logger.info("Check Ping IPv4 from R7 to R5 = 5.5.5.5")
+ host = tgen.gears["host"]
+ logger.info("Check Ping IPv4 from host to nhc2 = 10.5.5.5")
- output = pingrouter.run("ping 5.5.5.5 -f -c 1000")
+ output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R7 to R5 should be ok"
+ assertmsg = "expected ping IPv4 from host to nhc2 should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R7 to R5 OK")
+ logger.info("Check Ping IPv4 from host to nhc2 OK")
def test_redundancy_shortcut():
"""
Assert that if shortcut created and then NHS goes down, there is no traffic disruption
- Stop traffic and verify next time traffic started, shortcut is initiated by backup NHS
"""
tgen = get_topogen()
if tgen.routers_have_failure():
@@ -327,84 +316,207 @@ def test_redundancy_shortcut():
logger.info("Testing NHRP shortcuts with redundant servers")
- # Verify R4 nhrp routes before shortcut creation
- router = tgen.gears["r4"]
- json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
+ # Verify nhc1 nhrp routes before shortcut creation
+ nhc1 = tgen.gears["nhc1"]
+ json_file = "{}/{}/nhrp_route.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read())
test_func = partial(
- topotest.router_json_cmp, router, "show ip route nhrp json", expected
+ topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
- output = router.vtysh_cmd("show ip route nhrp")
+ output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output)
- assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
# Initiate shortcut by pinging between clients
- pingrouter = tgen.gears["r7"]
- logger.info("Check Ping IPv4 from R7 to R5 via shortcut = 5.5.5.5")
+ host = tgen.gears["host"]
+ logger.info("Check Ping IPv4 from host to nhc2 via shortcut = 10.5.5.5")
- output = pingrouter.run("ping 5.5.5.5 -f -c 1000")
+ output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R7 to R5 via shortcut should be ok"
+ assertmsg = "expected ping IPv4 from host to nhc2 via shortcut should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R7 to R5 via shortcut OK")
+ logger.info("Check Ping IPv4 from host to nhc2 via shortcut OK")
# Now check that NHRP shortcut route installed
- json_file = "{}/{}/nhrp_route_shortcut.json".format(CWD, router.name)
+ json_file = "{}/{}/nhrp_route_shortcut.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read())
test_func = partial(
- topotest.router_json_cmp, router, "show ip route nhrp json", expected
+ topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = nhc1.vtysh_cmd("show ip route nhrp")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+ assert result is None, assertmsg
+
+ json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+ assert result is None, assertmsg
+
+ # check the shortcut disappears because of no traffic
+ json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
- output = router.vtysh_cmd("show ip route nhrp")
+ output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
- assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
+
+def test_redundancy_shortcut_backup():
+ """
+ Stop traffic and verify next time traffic started, shortcut is initiated by backup NHS
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ if not _verify_iptables():
+ pytest.skip("iptables not installed")
+
+ nhc1 = tgen.gears["nhc1"]
+ router_list = tgen.routers()
+
# Bring down primary GRE interface and verify shortcut is not disturbed
- logger.info("Bringing down R1, primary NHRP server.")
- shutdown_bringup_interface(tgen, "r1", "r1-gre0", False)
+ logger.info("Bringing down nhs1, primary NHRP server.")
+ shutdown_bringup_interface(tgen, "nhs1", "nhs1-gre0", False)
+
+ # Check NHRP cache on servers and clients
+ for rname, router in router_list.items():
+ if "nh" not in rname:
+ continue
+ if "nhs1" in rname:
+ continue
+
+ json_file = "{}/{}/nhrp_cache_nhs1_down.json".format(CWD, router.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip nhrp cache json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = router.vtysh_cmd("show ip nhrp cache")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assert result is None, assertmsg
+
+ # Check NHRP IPV4 routes on servers and clients
+ logger.info("Checking IPv4 routes for convergence")
+ for rname, router in router_list.items():
+ if "nh" not in rname:
+ continue
+ if "nhs1" in rname:
+ continue
+
+ json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, router.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip route nhrp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = router.vtysh_cmd("show ip route nhrp")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assert result is None, assertmsg
# Verify shortcut is still active
- pingrouter = tgen.gears["r7"]
- logger.info("Check Ping IPv4 from R7 to R5 via shortcut = 5.5.5.5")
+ host = tgen.gears["host"]
+ logger.info("Check Ping IPv4 from host to nhc2 via shortcut = 10.5.5.5")
- output = pingrouter.run("ping 5.5.5.5 -f -c 1000")
+ output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output)
if "1000 packets transmitted, 1000 received" not in output:
- assertmsg = "expected ping IPv4 from R7 to R5 via shortcut should be ok"
+ assertmsg = "expected ping IPv4 from host to nhc2 via shortcut should be ok"
assert 0, assertmsg
else:
- logger.info("Check Ping IPv4 from R7 to R5 via shortcut OK")
+ logger.info("Check Ping IPv4 from host to nhc2 via shortcut OK")
+
+ # Verify shortcut is present in routing table
+ json_file = "{}/{}/nhrp_route_shortcut_nhs1_down.json".format(CWD, nhc1.name)
+ assertmsg = "No nhrp_route file found"
+ assert os.path.isfile(json_file), assertmsg
+
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = nhc1.vtysh_cmd("show ip route nhrp")
+ logger.info(output)
+
+ json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = nhc1.vtysh_cmd("show ip nhrp shortcut")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+ assert result is None, assertmsg
# Now verify shortcut is purged with lack of traffic
- json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
+ json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read())
test_func = partial(
- topotest.router_json_cmp, router, "show ip route nhrp json", expected
+ topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+
+ output = nhc1.vtysh_cmd("show ip route nhrp")
+ logger.info(output)
+
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
+ assert result is None, assertmsg
+
+ json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
- output = router.vtysh_cmd("show ip route nhrp")
+ output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
- assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
diff --git a/tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py b/tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py
index eae8806a59..718445f01f 100644
--- a/tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py
+++ b/tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py
@@ -234,7 +234,7 @@ def test_ospf_json():
"show ip ospf vrf {0}-ospf-cust1 json".format(rname),
expected,
)
- _, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+ _, diff = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(rname)
assert diff is None, assertmsg
diff --git a/tests/topotests/pytest.ini b/tests/topotests/pytest.ini
index db806fed39..9f33917c6b 100644
--- a/tests/topotests/pytest.ini
+++ b/tests/topotests/pytest.ini
@@ -1,6 +1,8 @@
# Skip pytests example directory
[pytest]
+asyncio_mode = auto
+
# NEEDS_EXABGP_4_2_11_FRR
# asyncio_mode = auto
diff --git a/tests/topotests/route_scale/scale_test_common.py b/tests/topotests/route_scale/scale_test_common.py
index 4b19bebe67..bb95c66031 100644
--- a/tests/topotests/route_scale/scale_test_common.py
+++ b/tests/topotests/route_scale/scale_test_common.py
@@ -119,7 +119,11 @@ def run_one_setup(r1, s):
count = d["rib"]
break
- logger.info("Testing {} routes X {} ecmp".format(count, s["ecmp"]))
+ logger.info(
+ "Testing {} routes X {} ecmp, waiting {} retries {}".format(
+ count, s["ecmp"], wait, retries
+ )
+ )
r1.vtysh_cmd(
"sharp install route 1.0.0.0 \
@@ -193,8 +197,8 @@ def route_install_helper(iter):
[2, "two"],
[4, "four"],
[8, "eight"],
- [16, "sixteen", 10, 40],
- [32, "thirtytwo", 10, 40],
+ [16, "sixteen", 10, 80],
+ [32, "thirtytwo", 10, 80],
]
# Build up a list of dicts with params for each step of the test;
diff --git a/tests/topotests/zebra_multiple_connected/r1/ip_route_connected.json b/tests/topotests/zebra_multiple_connected/r1/ip_route_connected.json
new file mode 100644
index 0000000000..db03ce84a6
--- /dev/null
+++ b/tests/topotests/zebra_multiple_connected/r1/ip_route_connected.json
@@ -0,0 +1,24 @@
+{
+ "192.168.44.0/24":[
+ {
+ "prefix":"192.168.44.0/24",
+ "prefixLen":24,
+ "protocol":"connected",
+ "vrfName":"default",
+ "selected":true,
+ "destSelected":true,
+ "distance":0,
+ "metric":0,
+ "installed":true,
+ "table":254,
+ "nexthops":[
+ {
+ "fib":true,
+ "directlyConnected":true,
+ "interfaceName":"r1-eth1",
+ "active":true
+ }
+ ]
+ }
+ ]
+}
diff --git a/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel.json b/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel.json
new file mode 100644
index 0000000000..22465cb477
--- /dev/null
+++ b/tests/topotests/zebra_multiple_connected/r1/ip_route_kernel.json
@@ -0,0 +1,24 @@
+{
+ "4.5.6.7/32":[
+ {
+ "prefix":"4.5.6.7/32",
+ "prefixLen":32,
+ "protocol":"kernel",
+ "vrfName":"default",
+ "selected":true,
+ "destSelected":true,
+ "distance":0,
+ "metric":0,
+ "installed":true,
+ "table":254,
+ "nexthops":[
+ {
+ "fib":true,
+ "directlyConnected":true,
+ "interfaceName":"r1-eth1",
+ "active":true
+ }
+ ]
+ }
+ ]
+}
diff --git a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py
index dc47527c74..7dbeb6f1cc 100644
--- a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py
+++ b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py
@@ -19,6 +19,9 @@ import sys
import pytest
import json
from functools import partial
+from lib.topolog import logger
+
+pytestmark = pytest.mark.random_order(disabled=True)
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
@@ -159,6 +162,46 @@ def test_zebra_noprefix_connected():
assert result, "Connected Route should not have been added"
+def test_zebra_noprefix_connected_add():
+ "Test that a noprefixroute created with a manual route works as expected, this is for NetworkManager"
+
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ router = tgen.gears["r1"]
+ router.run("ip route add 192.168.44.0/24 dev r1-eth1")
+
+ connected = "{}/{}/ip_route_connected.json".format(CWD, router.name)
+ expected = json.loads(open(connected).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip route 192.168.44.0/24 json", expected
+ )
+ result, _ = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assert result, "Connected Route should have been added\n{}".format(_)
+
+
+def test_zebra_kernel_route_add():
+ "Test that a random kernel route is properly handled as expected"
+
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ router = tgen.gears["r1"]
+ router.run("ip route add 4.5.6.7/32 dev r1-eth1")
+
+ kernel = "{}/{}/ip_route_kernel.json".format(CWD, router.name)
+ expected = json.loads(open(kernel).read())
+
+ test_func = partial(
+ topotest.router_json_cmp, router, "show ip route 4.5.6.7/32 json", expected
+ )
+ result, _ = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assert result, "Connected Route should have been added\n{}".format(_)
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
diff --git a/vrrpd/vrrp_debug.c b/vrrpd/vrrp_debug.c
index a772b3b5c5..fd0edcfc77 100644
--- a/vrrpd/vrrp_debug.c
+++ b/vrrpd/vrrp_debug.c
@@ -13,79 +13,15 @@
#include "vrrp_debug.h"
/* clang-format off */
-struct debug vrrp_dbg_arp = {0, "VRRP ARP"};
-struct debug vrrp_dbg_auto = {0, "VRRP autoconfiguration events"};
-struct debug vrrp_dbg_ndisc = {0, "VRRP Neighbor Discovery"};
-struct debug vrrp_dbg_pkt = {0, "VRRP packets"};
-struct debug vrrp_dbg_proto = {0, "VRRP protocol events"};
-struct debug vrrp_dbg_sock = {0, "VRRP sockets"};
-struct debug vrrp_dbg_zebra = {0, "VRRP Zebra events"};
-
-struct debug *vrrp_debugs[] = {
- &vrrp_dbg_arp,
- &vrrp_dbg_auto,
- &vrrp_dbg_ndisc,
- &vrrp_dbg_pkt,
- &vrrp_dbg_proto,
- &vrrp_dbg_sock,
- &vrrp_dbg_zebra
-};
-
-const char *vrrp_debugs_conflines[] = {
- "debug vrrp arp",
- "debug vrrp autoconfigure",
- "debug vrrp ndisc",
- "debug vrrp packets",
- "debug vrrp protocol",
- "debug vrrp sockets",
- "debug vrrp zebra",
-};
+struct debug vrrp_dbg_arp = {0, "debug vrrp arp", "VRRP ARP"};
+struct debug vrrp_dbg_auto = {0, "debug vrrp autoconfigure", "VRRP autoconfiguration events"};
+struct debug vrrp_dbg_ndisc = {0, "debug vrrp ndisc", "VRRP Neighbor Discovery"};
+struct debug vrrp_dbg_pkt = {0, "debug vrrp packets", "VRRP packets"};
+struct debug vrrp_dbg_proto = {0, "debug vrrp protocol", "VRRP protocol events"};
+struct debug vrrp_dbg_sock = {0, "debug vrrp sockets", "VRRP sockets"};
+struct debug vrrp_dbg_zebra = {0, "debug vrrp zebra", "VRRP Zebra events"};
/* clang-format on */
-/*
- * Set or unset flags on all debugs for vrrpd.
- *
- * flags
- * The flags to set
- *
- * set
- * Whether to set or unset the specified flags
- */
-static void vrrp_debug_set_all(uint32_t flags, bool set)
-{
- for (unsigned int i = 0; i < array_size(vrrp_debugs); i++) {
- DEBUG_FLAGS_SET(vrrp_debugs[i], flags, set);
-
- /* if all modes have been turned off, don't preserve options */
- if (!DEBUG_MODE_CHECK(vrrp_debugs[i], DEBUG_MODE_ALL))
- DEBUG_CLEAR(vrrp_debugs[i]);
- }
-}
-
-static int vrrp_debug_config_write_helper(struct vty *vty, bool config)
-{
- uint32_t mode = DEBUG_MODE_ALL;
-
- if (config)
- mode = DEBUG_MODE_CONF;
-
- for (unsigned int i = 0; i < array_size(vrrp_debugs); i++)
- if (DEBUG_MODE_CHECK(vrrp_debugs[i], mode))
- vty_out(vty, "%s\n", vrrp_debugs_conflines[i]);
-
- return 0;
-}
-
-int vrrp_config_write_debug(struct vty *vty)
-{
- return vrrp_debug_config_write_helper(vty, true);
-}
-
-int vrrp_debug_status_write(struct vty *vty)
-{
- return vrrp_debug_config_write_helper(vty, false);
-}
-
void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode,
bool onoff, bool proto, bool autoconf, bool pkt, bool sock,
bool ndisc, bool arp, bool zebra)
@@ -110,9 +46,13 @@ void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode,
/* ------------------------------------------------------------------------- */
-struct debug_callbacks vrrp_dbg_cbs = {.debug_set_all = vrrp_debug_set_all};
-
void vrrp_debug_init(void)
{
- debug_init(&vrrp_dbg_cbs);
+ debug_install(&vrrp_dbg_arp);
+ debug_install(&vrrp_dbg_auto);
+ debug_install(&vrrp_dbg_ndisc);
+ debug_install(&vrrp_dbg_pkt);
+ debug_install(&vrrp_dbg_proto);
+ debug_install(&vrrp_dbg_sock);
+ debug_install(&vrrp_dbg_zebra);
}
diff --git a/vrrpd/vrrp_debug.h b/vrrpd/vrrp_debug.h
index c1421ebbaa..c8b4c897f0 100644
--- a/vrrpd/vrrp_debug.h
+++ b/vrrpd/vrrp_debug.h
@@ -28,14 +28,6 @@ extern struct debug vrrp_dbg_zebra;
void vrrp_debug_init(void);
/*
- * Print VRRP debugging configuration.
- *
- * vty
- * VTY to print debugging configuration to.
- */
-int vrrp_config_write_debug(struct vty *vty);
-
-/*
* Print VRRP debugging configuration, human readable form.
*
* vty
diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c
index fd6cbc8b67..59794d9297 100644
--- a/vrrpd/vrrp_vty.c
+++ b/vrrpd/vrrp_vty.c
@@ -590,7 +590,7 @@ static void vrrp_show(struct vty *vty, struct vrrp_vrouter *vr)
char *table = ttable_dump(tt, "\n");
vty_out(vty, "\n%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@@ -695,7 +695,7 @@ DEFPY_YANG(vrrp_vrid_show_summary,
char *table = ttable_dump(tt, "\n");
vty_out(vty, "\n%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
list_delete(&ll);
@@ -738,8 +738,6 @@ DEFUN_NOSH (show_debugging_vrrp,
{
vty_out(vty, "VRRP debugging status:\n");
- vrrp_debug_status_write(vty);
-
cmd_show_lib_debugs(vty);
return CMD_SUCCESS;
@@ -747,13 +745,6 @@ DEFUN_NOSH (show_debugging_vrrp,
/* clang-format on */
-static struct cmd_node debug_node = {
- .name = "debug",
- .node = DEBUG_NODE,
- .prompt = "",
- .config_write = vrrp_config_write_debug,
-};
-
static struct cmd_node vrrp_node = {
.name = "vrrp",
.node = VRRP_NODE,
@@ -763,7 +754,6 @@ static struct cmd_node vrrp_node = {
void vrrp_vty_init(void)
{
- install_node(&debug_node);
install_node(&vrrp_node);
vrf_cmd_init(NULL);
if_cmd_init_default();
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index c43e1909e3..2d80feef6c 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -4639,6 +4639,7 @@ static int vtysh_connect(struct vtysh_client *vclient)
struct sockaddr_un addr;
struct stat s_stat;
const char *path;
+ uint32_t rcvbufsize = VTYSH_RCV_BUF_MAX;
if (!vclient->path[0])
snprintf(vclient->path, sizeof(vclient->path), "%s/%s.vty",
@@ -4688,6 +4689,22 @@ static int vtysh_connect(struct vtysh_client *vclient)
close(sock);
return -1;
}
+
+ /*
+ * Increasing the RECEIVE socket buffer size so that the socket can hold
+ * after receving from other process.
+ */
+ ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbufsize,
+ sizeof(rcvbufsize));
+ if (ret < 0) {
+#ifdef DEBUG
+ fprintf(stderr, "Cannot set socket %d rcv buffer size, %s\n",
+ sock, safe_strerror(errno));
+#endif /* DEBUG */
+ close(sock);
+ return -1;
+ }
+
vclient->fd = sock;
return 0;
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index b1d57aa3c2..3c532b99a8 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -36,6 +36,8 @@ extern struct event_loop *master;
#define VTYSH_PIM6D 0x100000
#define VTYSH_MGMTD 0x200000
+#define VTYSH_RCV_BUF_MAX 16777216
+
#define VTYSH_WAS_ACTIVE (-2)
/* commands in REALLYALL are crucial to correct vtysh operation */
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 8f7cd84818..6536e1b376 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -453,10 +453,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(FORWARDING_NODE, line);
else if (strncmp(line, "debug vrf", strlen("debug vrf")) == 0)
config = config_get(VRF_DEBUG_NODE, line);
- else if (strncmp(line, "debug northbound",
- strlen("debug northbound"))
- == 0)
- config = config_get(NORTHBOUND_DEBUG_NODE, line);
else if (strncmp(line, "debug route-map",
strlen("debug route-map"))
== 0)
@@ -464,12 +460,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
else if (strncmp(line, "debug resolver",
strlen("debug resolver")) == 0)
config = config_get(RESOLVER_DEBUG_NODE, line);
- else if (strncmp(line, "debug mgmt client frontend",
- strlen("debug mgmt client frontend")) == 0)
- config = config_get(MGMT_FE_DEBUG_NODE, line);
- else if (strncmp(line, "debug mgmt client backend",
- strlen("debug mgmt client backend")) == 0)
- config = config_get(MGMT_BE_DEBUG_NODE, line);
else if (strncmp(line, "debug", strlen("debug")) == 0)
config = config_get(DEBUG_NODE, line);
else if (strncmp(line, "password", strlen("password")) == 0
@@ -537,9 +527,8 @@ void vtysh_config_parse_line(void *arg, const char *line)
(I) == ACCESS_IPV6_NODE || (I) == ACCESS_MAC_NODE || \
(I) == PREFIX_IPV6_NODE || (I) == FORWARDING_NODE || \
(I) == DEBUG_NODE || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE || \
- (I) == NORTHBOUND_DEBUG_NODE || (I) == RMAP_DEBUG_NODE || \
- (I) == RESOLVER_DEBUG_NODE || (I) == MPLS_NODE || \
- (I) == KEYCHAIN_KEY_NODE)
+ (I) == RMAP_DEBUG_NODE || (I) == RESOLVER_DEBUG_NODE || \
+ (I) == MPLS_NODE || (I) == KEYCHAIN_KEY_NODE)
static void configvec_dump(vector vec, bool nested)
{
diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c
index 09080aa616..eb968bcd37 100644
--- a/zebra/dplane_fpm_nl.c
+++ b/zebra/dplane_fpm_nl.c
@@ -381,7 +381,7 @@ DEFPY(fpm_show_status,
out = ttable_dump(table, "\n");
vty_out(vty, "%s\n", out);
- XFREE(MTYPE_TMP, out);
+ XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(table);
}
diff --git a/zebra/interface.c b/zebra/interface.c
index 03b710e1a0..d146004781 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1058,6 +1058,8 @@ void if_down(struct interface *ifp)
/* Delete all neighbor addresses learnt through IPv6 RA */
if_down_del_nbr_connected(ifp);
+
+ rib_update_handle_vrf_all(RIB_UPDATE_INTERFACE_DOWN, ZEBRA_ROUTE_KERNEL);
}
void if_refresh(struct interface *ifp)
diff --git a/zebra/rib.h b/zebra/rib.h
index 84ea766c47..cd6efbfb36 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -326,6 +326,7 @@ typedef struct rib_tables_iter_t_ {
/* Events/reasons triggering a RIB update. */
enum rib_update_event {
+ RIB_UPDATE_INTERFACE_DOWN,
RIB_UPDATE_KERNEL,
RIB_UPDATE_RMAP_CHANGE,
RIB_UPDATE_OTHER,
@@ -395,7 +396,7 @@ extern int rib_add_multipath_nhe(afi_t afi, safi_t safi, struct prefix *p,
extern void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
unsigned short instance, uint32_t flags,
- struct prefix *p, struct prefix_ipv6 *src_p,
+ const struct prefix *p, const struct prefix_ipv6 *src_p,
const struct nexthop *nh, uint32_t nhe_id,
uint32_t table_id, uint32_t metric, uint8_t distance,
bool fromkernel);
@@ -477,6 +478,8 @@ extern uint8_t route_distance(int type);
extern void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq,
bool rt_delete);
+extern void rib_update_handle_vrf_all(enum rib_update_event event, int rtype);
+
/*
* rib_find_rn_from_ctx
*
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index c22145be69..ddcb83cd8c 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -799,8 +799,6 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
return 0;
if (rtm->rtm_protocol == RTPROT_REDIRECT)
return 0;
- if (rtm->rtm_protocol == RTPROT_KERNEL)
- return 0;
selfroute = is_selfroute(rtm->rtm_protocol);
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 1cee1ebb93..0851666510 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -4503,8 +4503,21 @@ dplane_nexthop_update_internal(struct nhg_hash_entry *nhe, enum dplane_op_e op)
ctx = dplane_ctx_alloc();
ret = dplane_ctx_nexthop_init(ctx, op, nhe);
- if (ret == AOK)
+ if (ret == AOK) {
+ if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL)) {
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED);
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_REINSTALL);
+ SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+
+ dplane_ctx_free(&ctx);
+ atomic_fetch_add_explicit(&zdplane_info.dg_nexthops_in,
+ 1, memory_order_relaxed);
+
+ return ZEBRA_DPLANE_REQUEST_SUCCESS;
+ }
+
ret = dplane_update_enqueue(ctx);
+ }
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_nexthops_in, 1,
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index d1c9cd54af..086150fb04 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -3794,7 +3794,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
if (tt->nrows > 1) {
char *table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 27b7f6340b..637eabde8d 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -356,18 +356,23 @@ void zebra_nhe_init(struct nhg_hash_entry *nhe, afi_t afi,
*/
if (nh && (nh->next == NULL)) {
switch (nh->type) {
- case NEXTHOP_TYPE_IFINDEX:
- case NEXTHOP_TYPE_BLACKHOLE:
/*
* This switch case handles setting the afi different
- * for ipv4/v6 routes. Ifindex/blackhole nexthop
+ * for ipv4/v6 routes. Ifindex nexthop
* objects cannot be ambiguous, they must be Address
- * Family specific. If we get here, we will either use
- * the AF of the route, or the one we got passed from
- * here from the kernel.
+ * Family specific as that the kernel relies on these
+ * for some reason. blackholes can be v6 because the
+ * v4 kernel infrastructure allows the usage of v6
+ * blackholes in this case. if we get here, we will
+ * either use the AF of the route, or the one we got
+ * passed from here from the kernel.
*/
+ case NEXTHOP_TYPE_IFINDEX:
nhe->afi = afi;
break;
+ case NEXTHOP_TYPE_BLACKHOLE:
+ nhe->afi = AFI_IP6;
+ break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4:
nhe->afi = AFI_IP;
@@ -414,6 +419,14 @@ struct nhg_hash_entry *zebra_nhe_copy(const struct nhg_hash_entry *orig,
if (orig->backup_info)
nhe->backup_info = nhg_backup_copy(orig->backup_info);
+ /*
+ * This is a special case, Zebra needs to track
+ * whether or not this flag was set on a initial
+ * unresolved NHG
+ */
+ if (CHECK_FLAG(orig->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL))
+ SET_FLAG(nhe->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL);
+
return nhe;
}
@@ -1154,7 +1167,7 @@ static void zebra_nhg_handle_install(struct nhg_hash_entry *nhe, bool install)
"%s nh id %u (flags 0x%x) associated dependent NHG %pNG install",
__func__, nhe->id, nhe->flags,
rb_node_dep->nhe);
- zebra_nhg_install_kernel(rb_node_dep->nhe);
+ zebra_nhg_install_kernel(rb_node_dep->nhe, true);
}
}
}
@@ -1173,7 +1186,7 @@ static void zebra_nhg_handle_kernel_state_change(struct nhg_hash_entry *nhe,
(is_delete ? "deleted" : "updated"), nhe);
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
- zebra_nhg_install_kernel(nhe);
+ zebra_nhg_install_kernel(nhe, ZEBRA_ROUTE_MAX);
} else
zebra_nhg_handle_uninstall(nhe);
}
@@ -3144,7 +3157,7 @@ uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,
return zebra_nhg_nhe2grp_internal(grp, 0, nhe, nhe, max_num);
}
-void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
+void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe, uint8_t type)
{
struct nhg_connected *rb_node_dep = NULL;
@@ -3157,9 +3170,16 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
nhe);
}
+ if ((type != ZEBRA_ROUTE_CONNECT && type != ZEBRA_ROUTE_LOCAL &&
+ type != ZEBRA_ROUTE_KERNEL) &&
+ CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL)) {
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL);
+ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+ }
+
/* Make sure all depends are installed/queued */
frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
- zebra_nhg_install_kernel(rb_node_dep->nhe);
+ zebra_nhg_install_kernel(rb_node_dep->nhe, type);
}
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID) &&
@@ -3183,9 +3203,6 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
nhe);
break;
case ZEBRA_DPLANE_REQUEST_SUCCESS:
- flog_err(EC_ZEBRA_DP_INVALID_RC,
- "DPlane returned an invalid result code for attempt of installation of %pNG into the kernel",
- nhe);
break;
}
}
@@ -3511,7 +3528,7 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type,
zebra_nhg_set_valid_if_active(new);
- zebra_nhg_install_kernel(new);
+ zebra_nhg_install_kernel(new, ZEBRA_ROUTE_MAX);
if (old) {
/*
@@ -3747,7 +3764,8 @@ void zebra_interface_nhg_reinstall(struct interface *ifp)
"%s install nhe %pNG nh type %u flags 0x%x",
__func__, rb_node_dep->nhe, nh->type,
rb_node_dep->nhe->flags);
- zebra_nhg_install_kernel(rb_node_dep->nhe);
+ zebra_nhg_install_kernel(rb_node_dep->nhe,
+ ZEBRA_ROUTE_MAX);
/* Don't need to modify dependents if installed */
if (CHECK_FLAG(rb_node_dep->nhe->flags,
diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h
index 3bb697aa75..712c1057a1 100644
--- a/zebra/zebra_nhg.h
+++ b/zebra/zebra_nhg.h
@@ -152,6 +152,25 @@ struct nhg_hash_entry {
* when installation is successful.
*/
#define NEXTHOP_GROUP_REINSTALL (1 << 8)
+
+/*
+ * Connected routes and kernel routes received
+ * from the kernel or created by Zebra do no
+ * need to be installed. For connected, this
+ * is because the routes are in the local table
+ * but not imported and we create an amalgram
+ * route for it. For kernel routes if the route
+ * is an pre-nhg route, there is no nexthop associated
+ * with it and we should not create it until it
+ * is used by something else.
+ * The reason for this is because is that this just
+ * fills up the DPlane's nexthop slots when there
+ * are a bunch of interfaces or pre-existing routes
+ * As such let's not initially install it ( but
+ * pretend it was successful ) and if another route
+ * chooses this NHG then we can install it then.
+ */
+#define NEXTHOP_GROUP_INITIAL_DELAY_INSTALL (1 << 9)
};
/* Upper 4 bits of the NHG are reserved for indicating the NHG type */
@@ -364,7 +383,7 @@ extern uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,
int size);
/* Dataplane install/uninstall */
-extern void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe);
+extern void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe, uint8_t type);
extern void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe);
extern void zebra_interface_nhg_reinstall(struct interface *ifp);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 59190e9dd3..d53b27a387 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -688,7 +688,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,
/*
* Install the resolved nexthop object first.
*/
- zebra_nhg_install_kernel(re->nhe);
+ zebra_nhg_install_kernel(re->nhe, re->type);
/*
* If this is a replace to a new RE let the originator of the RE
@@ -1619,6 +1619,10 @@ static bool rib_compare_routes(const struct route_entry *re1,
* v6 link-locals, and we also support multiple addresses in the same
* subnet on a single interface.
*/
+ if (re1->type == ZEBRA_ROUTE_CONNECT &&
+ (re1->nhe->nhg.nexthop->ifindex == re2->nhe->nhg.nexthop->ifindex))
+ return true;
+
if (re1->type != ZEBRA_ROUTE_CONNECT && re1->type != ZEBRA_ROUTE_LOCAL)
return true;
@@ -2863,10 +2867,11 @@ static void process_subq_early_route_add(struct zebra_early_route *ere)
/* 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);
+ rnode_debug(rn, re->vrf_id,
+ "Inserting route rn %p, re %p (%s/%s/%s) existing %p, same_count %d",
+ rn, re, zebra_route_string(re->type),
+ afi2str(ere->afi), safi2str(ere->safi), same,
+ same_count);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
route_entry_dump(
@@ -4370,19 +4375,55 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
return -1;
/* We either need nexthop(s) or an existing nexthop id */
- if (ng == NULL && re->nhe_id == 0)
+ if (ng == NULL && re->nhe_id == 0) {
+ zebra_rib_route_entry_free(re);
return -1;
+ }
/*
* Use a temporary nhe to convey info to the common/main api.
*/
zebra_nhe_init(&nhe, afi, (ng ? ng->nexthop : NULL));
- if (ng)
+ if (ng) {
nhe.nhg.nexthop = ng->nexthop;
- else if (re->nhe_id > 0)
+
+ if (re->type == ZEBRA_ROUTE_CONNECT ||
+ re->type == ZEBRA_ROUTE_LOCAL ||
+ re->type == ZEBRA_ROUTE_KERNEL)
+ SET_FLAG(nhe.flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL);
+ } else if (re->nhe_id > 0)
nhe.id = re->nhe_id;
n = zebra_nhe_copy(&nhe, 0);
+
+ if (re->type == ZEBRA_ROUTE_KERNEL) {
+ struct interface *ifp;
+ struct connected *connected;
+
+ if (p->family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6)) {
+ zebra_nhg_free(n);
+ zebra_rib_route_entry_free(re);
+ return -1;
+ }
+
+ ifp = if_lookup_prefix(p, re->vrf_id);
+ if (ifp) {
+ connected = connected_lookup_prefix(ifp, p);
+
+ if (connected && !CHECK_FLAG(connected->flags,
+ ZEBRA_IFA_NOPREFIXROUTE)) {
+ zebra_nhg_free(n);
+ zebra_rib_route_entry_free(re);
+ return -1;
+ }
+
+ if (ng && ng->nexthop &&
+ ifp->ifindex == ng->nexthop->ifindex)
+ re->type = ZEBRA_ROUTE_CONNECT;
+ }
+ }
+
ret = rib_add_multipath_nhe(afi, safi, p, src_p, re, n, startup);
/* In error cases, free the route also */
@@ -4393,8 +4434,8 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
}
void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
- unsigned short instance, uint32_t flags, struct prefix *p,
- struct prefix_ipv6 *src_p, const struct nexthop *nh,
+ unsigned short instance, uint32_t flags, const struct prefix *p,
+ const struct prefix_ipv6 *src_p, const struct nexthop *nh,
uint32_t nhe_id, uint32_t table_id, uint32_t metric,
uint8_t distance, bool fromkernel)
{
@@ -4458,6 +4499,9 @@ static const char *rib_update_event2str(enum rib_update_event event)
const char *ret = "UNKNOWN";
switch (event) {
+ case RIB_UPDATE_INTERFACE_DOWN:
+ ret = "RIB_UPDATE_INTERFACE_DOWN";
+ break;
case RIB_UPDATE_KERNEL:
ret = "RIB_UPDATE_KERNEL";
break;
@@ -4474,15 +4518,56 @@ static const char *rib_update_event2str(enum rib_update_event event)
return ret;
}
+/*
+ * We now keep kernel routes, but we don't have any
+ * trigger events for them when they are implicitly
+ * deleted. Since we are already walking the
+ * entire table on a down event let's look at
+ * the few kernel routes we may have
+ */
+static void
+rib_update_handle_kernel_route_down_possibility(struct route_node *rn,
+ struct route_entry *re)
+{
+ struct nexthop *nexthop = NULL;
+ bool alive = false;
+
+ for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
+ struct interface *ifp = if_lookup_by_index(nexthop->ifindex,
+ nexthop->vrf_id);
+
+ if (ifp && if_is_up(ifp)) {
+ alive = true;
+ break;
+ }
+ }
+
+ if (!alive) {
+ struct rib_table_info *rib_table = srcdest_rnode_table_info(rn);
+ const struct prefix *p;
+ const struct prefix_ipv6 *src_p;
+
+ srcdest_rnode_prefixes(rn, &p, (const struct prefix **)&src_p);
+
+ rib_delete(rib_table->afi, rib_table->safi, re->vrf_id,
+ re->type, re->instance, re->flags, p, src_p, NULL, 0,
+ re->table, re->metric, re->distance, true);
+ }
+}
+
/* Schedule route nodes to be processed if they match the type */
-static void rib_update_route_node(struct route_node *rn, int type)
+static void rib_update_route_node(struct route_node *rn, int type,
+ enum rib_update_event event)
{
struct route_entry *re, *next;
bool re_changed = false;
RNODE_FOREACH_RE_SAFE (rn, re, next) {
- if (type == ZEBRA_ROUTE_ALL || type == re->type) {
+ if (event == RIB_UPDATE_INTERFACE_DOWN && type == re->type &&
+ type == ZEBRA_ROUTE_KERNEL)
+ rib_update_handle_kernel_route_down_possibility(rn, re);
+ else if (type == ZEBRA_ROUTE_ALL || type == re->type) {
SET_FLAG(re->status, ROUTE_ENTRY_CHANGED);
re_changed = true;
}
@@ -4522,20 +4607,24 @@ void rib_update_table(struct route_table *table, enum rib_update_event event,
/*
* If we are looking at a route node and the node
* has already been queued we don't
- * need to queue it up again
+ * need to queue it up again, unless it is
+ * an interface down event as that we need
+ * to process this no matter what.
*/
- if (rn->info
- && CHECK_FLAG(rib_dest_from_rnode(rn)->flags,
- RIB_ROUTE_ANY_QUEUED))
+ if (rn->info &&
+ CHECK_FLAG(rib_dest_from_rnode(rn)->flags,
+ RIB_ROUTE_ANY_QUEUED) &&
+ event != RIB_UPDATE_INTERFACE_DOWN)
continue;
switch (event) {
+ case RIB_UPDATE_INTERFACE_DOWN:
case RIB_UPDATE_KERNEL:
- rib_update_route_node(rn, ZEBRA_ROUTE_KERNEL);
+ rib_update_route_node(rn, ZEBRA_ROUTE_KERNEL, event);
break;
case RIB_UPDATE_RMAP_CHANGE:
case RIB_UPDATE_OTHER:
- rib_update_route_node(rn, rtype);
+ rib_update_route_node(rn, rtype, event);
break;
case RIB_UPDATE_MAX:
break;
@@ -4543,7 +4632,7 @@ void rib_update_table(struct route_table *table, enum rib_update_event event,
}
}
-static void rib_update_handle_vrf_all(enum rib_update_event event, int rtype)
+void rib_update_handle_vrf_all(enum rib_update_event event, int rtype)
{
struct zebra_router_table *zrt;
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 5742c38e23..501e9d5268 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -891,6 +891,9 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) {
dest = rib_dest_from_rnode(rn);
+ if (longer_prefix_p && !prefix_match(longer_prefix_p, &rn->p))
+ continue;
+
RNODE_FOREACH_RE (rn, re) {
if (use_fib && re != dest->selected_fib)
continue;
@@ -898,10 +901,6 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
if (tag && re->tag != tag)
continue;
- if (longer_prefix_p
- && !prefix_match(longer_prefix_p, &rn->p))
- continue;
-
/* This can only be true when the afi is IPv4 */
if (supernets_only) {
addr = ntohl(rn->p.u.prefix4.s_addr);
@@ -1196,6 +1195,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
json_object_string_add(json, "uptime", up_str);
json_object_string_add(json, "vrf",
vrf_id_to_name(nhe->vrf_id));
+ json_object_string_add(json, "afi", afi2str(nhe->afi));
} else {
vty_out(vty, "ID: %u (%s)\n", nhe->id,
@@ -1209,7 +1209,8 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
vty_out(vty, "\n");
vty_out(vty, " Uptime: %s\n", up_str);
- vty_out(vty, " VRF: %s\n", vrf_id_to_name(nhe->vrf_id));
+ vty_out(vty, " VRF: %s(%s)\n", vrf_id_to_name(nhe->vrf_id),
+ afi2str(nhe->afi));
}
if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID)) {
@@ -1229,6 +1230,13 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe,
else
vty_out(vty, ", Installed");
}
+ if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INITIAL_DELAY_INSTALL)) {
+ if (json)
+ json_object_boolean_true_add(json,
+ "initialDelay");
+ else
+ vty_out(vty, ", Initial Delay");
+ }
if (!json)
vty_out(vty, "\n");
}
@@ -3909,7 +3917,7 @@ DEFUN (show_zebra,
out = ttable_dump(table, "\n");
vty_out(vty, "%s\n", out);
- XFREE(MTYPE_TMP, out);
+ XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(table);
vty_out(vty,