diff options
55 files changed, 1651 insertions, 446 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 005fad1409..795a4adfc7 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1411,6 +1411,41 @@ DEFUN (no_bgp_cluster_id, return CMD_SUCCESS; } +DEFPY (bgp_norib, + bgp_norib_cmd, + "bgp no-rib", + BGP_STR + "Disable BGP route installation to RIB (Zebra)\n") +{ + if (bgp_option_check(BGP_OPT_NO_FIB)) { + vty_out(vty, + "%% No-RIB option is already set, nothing to do here.\n"); + return CMD_SUCCESS; + } + + bgp_option_norib_set_runtime(); + + return CMD_SUCCESS; +} + +DEFPY (no_bgp_norib, + no_bgp_norib_cmd, + "no bgp no-rib", + NO_STR + BGP_STR + "Disable BGP route installation to RIB (Zebra)\n") +{ + if (!bgp_option_check(BGP_OPT_NO_FIB)) { + vty_out(vty, + "%% No-RIB option is not set, nothing to do here.\n"); + return CMD_SUCCESS; + } + + bgp_option_norib_unset_runtime(); + + return CMD_SUCCESS; +} + DEFUN (bgp_confederation_identifier, bgp_confederation_identifier_cmd, "bgp confederation identifier (1-4294967295)", @@ -15607,6 +15642,10 @@ int bgp_config_write(struct vty *vty) if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) vty_out(vty, "bgp graceful-shutdown\n"); + /* No-RIB (Zebra) option flag configuration */ + if (bgp_option_check(BGP_OPT_NO_FIB)) + vty_out(vty, "bgp no-rib\n"); + /* BGP configuration. */ for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { @@ -16151,6 +16190,10 @@ void bgp_vty_init(void) install_element(BGP_NODE, &bgp_cluster_id_cmd); install_element(BGP_NODE, &no_bgp_cluster_id_cmd); + /* "bgp no-rib" commands. */ + install_element(CONFIG_NODE, &bgp_norib_cmd); + install_element(CONFIG_NODE, &no_bgp_norib_cmd); + /* "bgp confederation" commands. */ install_element(BGP_NODE, &bgp_confederation_identifier_cmd); install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index b203238520..a32e47f446 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1543,6 +1543,30 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) pi, bgp, afi, safi); } +/* Announce routes of any bgp subtype of a table to zebra */ +void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi, + safi_t safi) +{ + struct bgp_dest *dest; + struct bgp_table *table; + struct bgp_path_info *pi; + + if (!bgp_install_info_to_zebra(bgp)) + return; + + table = bgp->rib[afi][safi]; + if (!table) + return; + + for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) + for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) && + pi->type == ZEBRA_ROUTE_BGP) + bgp_zebra_announce(dest, + bgp_dest_get_prefix(dest), + pi, bgp, afi, safi); +} + void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, struct bgp *bgp, safi_t safi) { @@ -1586,6 +1610,30 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); } +/* Withdraw all entries in a BGP instances RIB table from Zebra */ +void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi, safi_t safi) +{ + struct bgp_dest *dest; + struct bgp_table *table; + struct bgp_path_info *pi; + + if (!bgp_install_info_to_zebra(bgp)) + return; + + table = bgp->rib[afi][safi]; + if (!table) + return; + + for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) { + for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) { + if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) + && (pi->type == ZEBRA_ROUTE_BGP)) + bgp_zebra_withdraw(bgp_dest_get_prefix(dest), + pi, bgp, safi); + } + } +} + struct bgp_redist *bgp_redist_lookup(struct bgp *bgp, afi_t afi, uint8_t type, unsigned short instance) { diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index a068c03717..4b357c380a 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -43,6 +43,14 @@ extern void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *path, struct bgp *bgp, safi_t safi); +/* Announce routes of any bgp subtype of a table to zebra */ +extern void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi, + safi_t safi); + +/* Withdraw all entries of any subtype in a BGP instances RIB table from Zebra */ +extern void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi, + safi_t safi); + extern void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer); extern void bgp_zebra_terminate_radv(struct bgp *bgp, struct peer *peer); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3c707b41ca..4260970541 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -202,6 +202,52 @@ int bgp_option_check(int flag) return CHECK_FLAG(bm->options, flag); } +/* set the bgp no-rib option during runtime and remove installed routes */ +void bgp_option_norib_set_runtime(void) +{ + struct bgp *bgp; + struct listnode *node; + afi_t afi; + safi_t safi; + + if (bgp_option_check(BGP_OPT_NO_FIB)) + return; + + bgp_option_set(BGP_OPT_NO_FIB); + + zlog_info("Disabled BGP route installation to RIB (Zebra)"); + + for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { + FOREACH_AFI_SAFI(afi, safi) + bgp_zebra_withdraw_table_all_subtypes(bgp, afi, safi); + } + + zlog_info("All routes have been withdrawn from RIB (Zebra)"); +} + +/* unset the bgp no-rib option during runtime and announce routes to Zebra */ +void bgp_option_norib_unset_runtime(void) +{ + struct bgp *bgp; + struct listnode *node; + afi_t afi; + safi_t safi; + + if (!bgp_option_check(BGP_OPT_NO_FIB)) + return; + + bgp_option_unset(BGP_OPT_NO_FIB); + + zlog_info("Enabled BGP route installation to RIB (Zebra)"); + + for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { + FOREACH_AFI_SAFI(afi, safi) + bgp_zebra_announce_table_all_subtypes(bgp, afi, safi); + } + + zlog_info("All routes have been installed in RIB (Zebra)"); +} + /* Internal function to set BGP structure configureation flag. */ static void bgp_config_set(struct bgp *bgp, int config) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index e282e461df..9f72a3e19e 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1807,6 +1807,12 @@ extern int bgp_option_set(int); extern int bgp_option_unset(int); extern int bgp_option_check(int); +/* set the bgp no-rib option during runtime and remove installed routes */ +extern void bgp_option_norib_set_runtime(void); + +/* unset the bgp no-rib option during runtime and reset all peers */ +extern void bgp_option_norib_unset_runtime(void); + extern int bgp_get(struct bgp **, as_t *, const char *, enum bgp_instance_type); extern void bgp_instance_up(struct bgp *); extern void bgp_instance_down(struct bgp *); diff --git a/configure.ac b/configure.ac index 25157d1fa3..3cc74c4110 100755 --- a/configure.ac +++ b/configure.ac @@ -1561,10 +1561,70 @@ dnl -------------------- dnl Daemon disable check dnl -------------------- +AS_IF([test "$enable_bgpd" != "no"], [ + AC_DEFINE([HAVE_BGPD], [1], [bgpd]) +]) + +AS_IF([test "$enable_ripd" != "no"], [ + AC_DEFINE([HAVE_RIPD], [1], [ripd]) +]) + +AS_IF([test "$enable_ripngd" != "no"], [ + AC_DEFINE([HAVE_RIPNGD], [1], [ripngd]) +]) + +AS_IF([test "$enable_ospfd" != "no"], [ + AC_DEFINE([HAVE_OSPFD], [1], [ospfd]) +]) + +AS_IF([test "$enable_ospf6d" != "no"], [ + AC_DEFINE([HAVE_OSPF6D], [1], [ospf6d]) +]) + AS_IF([test "$enable_ldpd" != "no"], [ AC_DEFINE([HAVE_LDPD], [1], [ldpd]) ]) +AS_IF([test "$enable_nhrpd" != "no"], [ + AC_DEFINE([HAVE_NHRPD], [1], [nhrpd]) +]) + +AS_IF([test "$enable_eigrpd" != "no"], [ + AC_DEFINE([HAVE_EIGRPD], [1], [eigrpd]) +]) + +AS_IF([test "$enable_babeld" != "no"], [ + AC_DEFINE([HAVE_BABELD], [1], [babeld]) +]) + +AS_IF([test "$enable_isisd" != "no"], [ + AC_DEFINE([HAVE_ISISD], [1], [isisd]) +]) + +AS_IF([test "$enable_pimd" != "no"], [ + AC_DEFINE([HAVE_PIMD], [1], [pimd]) +]) + +AS_IF([test "$enable_pbrd" != "no"], [ + AC_DEFINE([HAVE_PBRD], [1], [pbrd]) +]) + +AS_IF([test "$enable_sharpd" = "yes"], [ + AC_DEFINE([HAVE_SHARPD], [1], [sharpd]) +]) + +AS_IF([test "$enable_staticd" != "no"], [ + AC_DEFINE([HAVE_STATICD], [1], [staticd]) +]) + +AS_IF([test "$enable_fabricd" != "no"], [ + AC_DEFINE([HAVE_FABRICD], [1], [fabricd]) +]) + +AS_IF([test "$enable_vrrpd" != "no"], [ + AC_DEFINE([HAVE_VRRPD], [1], [vrrpd]) +]) + if test "$enable_bfdd" = "no"; then AC_DEFINE([HAVE_BFDD], [0], [bfdd]) BFDD="" diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 723cb41f26..10eaaee9fb 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -42,6 +42,13 @@ be specified (:ref:`common-invocation-options`). processes in the same namespace. This option is different than the --no_zebra option in that a ZAPI connection is made. + This option can also be toggled during runtime by using the + ``[no] bgp no-rib`` commands in VTY shell. + + Note that this option will persist after saving the configuration during + runtime, unless unset by the ``no bgp no-rib`` command in VTY shell prior to + a configuration write operation. + .. option:: -S, --skip_runas Skip the normal process of checking capabilities and changing user and group @@ -3072,6 +3079,21 @@ by route reflectors to avoid looping. .. index:: bgp cluster-id A.B.C.D .. clicmd:: bgp cluster-id A.B.C.D +.. index:: [no] bgp no-rib +.. clicmd:: [no] bgp no-rib + +To set and unset the BGP daemon ``-n`` / ``--no_kernel`` options during runtime +to disable BGP route installation to the RIB (Zebra), the ``[no] bgp no-rib`` +commands can be used; + +Please note that setting the option during runtime will withdraw all routes in +the daemons RIB from Zebra and unsetting it will announce all routes in the +daemons RIB to Zebra. If the option is passed as a command line argument when +starting the daemon and the configuration gets saved, the option will persist +unless removed from the configuration with the negating command prior to the +configuration write operation. + + .. _routing-policy: Routing Policy diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index fe2778c877..01caff5b52 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -721,12 +721,23 @@ void pbr_map_policy_delete(struct pbr_map *pbrm, struct pbr_map_interface *pmi) { struct listnode *node; struct pbr_map_sequence *pbrms; + bool sent = false; for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms)) - pbr_send_pbr_map(pbrms, pmi, false, false); + if (pbr_send_pbr_map(pbrms, pmi, false, true)) + sent = true; /* rule removal sent to zebra */ pmi->delete = true; + + /* + * If we actually sent something for deletion, wait on zapi callback + * before clearing data. + */ + if (sent) + return; + + pbr_map_final_interface_deletion(pbrm, pmi); } /* diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index 269bd6da8d..8ef675186f 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -549,7 +549,7 @@ static void pbr_encode_pbr_map_sequence(struct stream *s, stream_put(s, ifp->name, INTERFACE_NAMSIZ); } -void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, +bool pbr_send_pbr_map(struct pbr_map_sequence *pbrms, struct pbr_map_interface *pmi, bool install, bool changed) { struct pbr_map *pbrm = pbrms->parent; @@ -569,10 +569,10 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, * to delete just return. */ if (install && is_installed && !changed) - return; + return false; if (!install && !is_installed) - return; + return false; s = zclient->obuf; stream_reset(s); @@ -595,4 +595,6 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, stream_putw_at(s, 0, stream_get_endp(s)); zclient_send_message(zclient); + + return true; } diff --git a/pbrd/pbr_zebra.h b/pbrd/pbr_zebra.h index cc42e21abe..e8f9bff5d9 100644 --- a/pbrd/pbr_zebra.h +++ b/pbrd/pbr_zebra.h @@ -35,7 +35,7 @@ extern void route_delete(struct pbr_nexthop_group_cache *pnhgc, extern void pbr_send_rnh(struct nexthop *nhop, bool reg); -extern void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, +extern bool pbr_send_pbr_map(struct pbr_map_sequence *pbrms, struct pbr_map_interface *pmi, bool install, bool changed); diff --git a/tests/subdir.am b/tests/subdir.am index 2cdb214f0b..d7318efc72 100644 --- a/tests/subdir.am +++ b/tests/subdir.am @@ -12,8 +12,10 @@ TESTS_BGPD = \ tests/bgpd/test_mp_attr \ tests/bgpd/test_mpath \ tests/bgpd/test_bgp_table +IGNORE_BGPD = else TESTS_BGPD = +IGNORE_BGPD = --ignore=bgpd/ endif if ISISD @@ -23,16 +25,20 @@ TESTS_ISISD = \ tests/isisd/test_isis_spf \ tests/isisd/test_isis_vertex_queue \ # end +IGNORE_ISISD = else TESTS_ISISD = +IGNORE_ISISD = --ignore=isisd/ endif if OSPF6D TESTS_OSPF6D = \ tests/ospf6d/test_lsdb \ # end +IGNORE_OSPF6D = else TESTS_OSPF6D = +IGNORE_OSPF6D = --ignore=ospf6d/ endif clippy_scan += \ @@ -368,7 +374,7 @@ EXTRA_DIST += \ .PHONY: tests/tests.xml tests/tests.xml: $(check_PROGRAMS) - ( cd tests; $(PYTHON) ../$(srcdir)/tests/runtests.py --junitxml=tests.xml -v ../$(srcdir)/tests; ) + ( cd tests; $(PYTHON) ../$(srcdir)/tests/runtests.py --junitxml=tests.xml -v ../$(srcdir)/tests $(IGNORE_BGPD) $(IGNORE_ISISD) $(IGNORE_OSPF6D); ) check: tests/tests.xml clean-local: clean-tests diff --git a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py index f2af5fdc5c..32b219283b 100755..100644 --- a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py +++ b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py @@ -113,8 +113,8 @@ def setup_module(module): net['r%s' % i].loadConf('ospfd', '%s/r%s/ospfd.conf' % (thisDir, i)) if net['r1'].checkRouterVersion('<', '4.0'): net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf-pre-v4' % (thisDir, i)) - else: - net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i)) + else: + net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i)) net['r%s' % i].loadConf('isisd', '%s/r%s/isisd.conf' % (thisDir, i)) net['r%s' % i].loadConf('bgpd', '%s/r%s/bgpd.conf' % (thisDir, i)) if net['r%s' % i].daemon_available('ldpd'): @@ -621,7 +621,7 @@ def test_ospfv2_interfaces(): actual = net['r%s' % i].cmd('vtysh -c "show ip ospf interface" 2> /dev/null').rstrip() # Mask out Bandwidth portion. They may change.. actual = re.sub(r"BW [0-9]+ Mbit", "BW XX Mbit", actual) - actual = re.sub(r"ifindex [0-9]", "ifindex X", actual) + actual = re.sub(r"ifindex [0-9]", "ifindex X", actual) # Drop time in next due actual = re.sub(r"Hello due in [0-9\.]+s", "Hello due in XX.XXXs", actual) @@ -892,45 +892,45 @@ def test_bgp_ipv4(): print("******************************************\n") diffresult = {} for i in range(1, 2): - success = 0 - for refTableFile in (glob.glob( - '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))): - if os.path.isfile(refTableFile): - # Read expected result from file - expected = open(refTableFile).read().rstrip() - # Fix newlines (make them all the same) - expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) - - # Actual output from router - actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip() - # Remove summary line (changed recently) - actual = re.sub(r'Total number.*', '', actual) - actual = re.sub(r'Displayed.*', '', actual) - actual = actual.rstrip() - # Fix newlines (make them all the same) - actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) - - # Generate Diff - diff = topotest.get_textdiff(actual, expected, - title1="actual SHOW BGP IPv4", - title2="expected SHOW BGP IPv4") - - # Empty string if it matches, otherwise diff contains unified diff - if diff: - diffresult[refTableFile] = diff - else: - success = 1 - print("template %s matched: r%s ok" % (refTableFile, i)) - break - - if not success: - resultstr = 'No template matched.\n' - for f in diffresult.iterkeys(): - resultstr += ( - 'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n' - % (f, i, diffresult[f])) - raise AssertionError( - "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr)) + success = 0 + for refTableFile in (glob.glob( + '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))): + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) + + # Actual output from router + actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip() + # Remove summary line (changed recently) + actual = re.sub(r'Total number.*', '', actual) + actual = re.sub(r'Displayed.*', '', actual) + actual = actual.rstrip() + # Fix newlines (make them all the same) + actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff(actual, expected, + title1="actual SHOW BGP IPv4", + title2="expected SHOW BGP IPv4") + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + diffresult[refTableFile] = diff + else: + success = 1 + print("template %s matched: r%s ok" % (refTableFile, i)) + break + + if not success: + resultstr = 'No template matched.\n' + for f in diffresult.iterkeys(): + resultstr += ( + 'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n' + % (f, i, diffresult[f])) + raise AssertionError( + "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr)) # Make sure that all daemons are running for i in range(1, 2): @@ -955,44 +955,44 @@ def test_bgp_ipv6(): print("******************************************\n") diffresult = {} for i in range(1, 2): - success = 0 - for refTableFile in (glob.glob( - '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))): - if os.path.isfile(refTableFile): - # Read expected result from file - expected = open(refTableFile).read().rstrip() - # Fix newlines (make them all the same) - expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) - - # Actual output from router - actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip() - # Remove summary line (changed recently) - actual = re.sub(r'Total number.*', '', actual) - actual = re.sub(r'Displayed.*', '', actual) - actual = actual.rstrip() - # Fix newlines (make them all the same) - actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) - - # Generate Diff - diff = topotest.get_textdiff(actual, expected, - title1="actual SHOW BGP IPv6", - title2="expected SHOW BGP IPv6") - - # Empty string if it matches, otherwise diff contains unified diff - if diff: - diffresult[refTableFile] = diff - else: - success = 1 - print("template %s matched: r%s ok" % (refTableFile, i)) - - if not success: - resultstr = 'No template matched.\n' - for f in diffresult.iterkeys(): - resultstr += ( - 'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n' - % (f, i, diffresult[f])) - raise AssertionError( - "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr)) + success = 0 + for refTableFile in (glob.glob( + '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))): + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) + + # Actual output from router + actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip() + # Remove summary line (changed recently) + actual = re.sub(r'Total number.*', '', actual) + actual = re.sub(r'Displayed.*', '', actual) + actual = actual.rstrip() + # Fix newlines (make them all the same) + actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff(actual, expected, + title1="actual SHOW BGP IPv6", + title2="expected SHOW BGP IPv6") + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + diffresult[refTableFile] = diff + else: + success = 1 + print("template %s matched: r%s ok" % (refTableFile, i)) + + if not success: + resultstr = 'No template matched.\n' + for f in diffresult.iterkeys(): + resultstr += ( + 'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n' + % (f, i, diffresult[f])) + raise AssertionError( + "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr)) # Make sure that all daemons are running for i in range(1, 2): diff --git a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py index 41fa7c0a09..41fa7c0a09 100755..100644 --- a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py +++ b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py diff --git a/tests/topotests/bgp-evpn-mh/test_evpn_mh.py b/tests/topotests/bgp-evpn-mh/test_evpn_mh.py index ee50a422a7..9af22c06bd 100644 --- a/tests/topotests/bgp-evpn-mh/test_evpn_mh.py +++ b/tests/topotests/bgp-evpn-mh/test_evpn_mh.py @@ -477,9 +477,9 @@ def check_es(dut): vtep_ips.append(vtep["vtep_ip"]) if "local" in types: - result = check_local_es(esi, vtep_ips, dut.name, []) + result = check_local_es(esi, vtep_ips, dut.name, []) else: - result = check_remote_es(esi, vtep_ips, dut.name, []) + result = check_remote_es(esi, vtep_ips, dut.name, []) if result: return result diff --git a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py index 607b036c6a..607b036c6a 100755..100644 --- a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py +++ b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py diff --git a/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py b/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py index 22952f645c..22952f645c 100755..100644 --- a/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py +++ b/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py diff --git a/tests/topotests/bgp-route-map/test_route_map_topo1.py b/tests/topotests/bgp-route-map/test_route_map_topo1.py index 1aa951edaa..1aa951edaa 100755..100644 --- a/tests/topotests/bgp-route-map/test_route_map_topo1.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo1.py diff --git a/tests/topotests/bgp-route-map/test_route_map_topo2.py b/tests/topotests/bgp-route-map/test_route_map_topo2.py index 3056aa29f3..3056aa29f3 100755..100644 --- a/tests/topotests/bgp-route-map/test_route_map_topo2.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo2.py diff --git a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py index f9d22a3a36..f9d22a3a36 100755..100644 --- a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py +++ b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py diff --git a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py index 3ad989c601..0d99f23ad9 100755..100644 --- a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py +++ b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py @@ -143,7 +143,7 @@ def setup_module(mod): logger.info('result: '+output); router = tgen.gears['r1'] - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): if rname == 'r1': router.load_config( TopoRouter.RD_ZEBRA, diff --git a/tests/topotests/bgp_features/r1/ip_route.json b/tests/topotests/bgp_features/r1/ip_route.json new file mode 100644 index 0000000000..cf1764140a --- /dev/null +++ b/tests/topotests/bgp_features/r1/ip_route.json @@ -0,0 +1,382 @@ +{ + "0.0.0.0\/0":[ + { + "prefix":"0.0.0.0\/0", + "protocol":"bgp", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.101.2", + "afi":"ipv4", + "interfaceIndex":4, + "interfaceName":"r1-eth3", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.0.1\/32":[ + { + "prefix":"192.168.0.1\/32", + "protocol":"ospf", + "distance":110, + "metric":0, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":1, + "interfaceName":"lo", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.0.1\/32", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":1, + "interfaceName":"lo", + "active":true + } + ] + } + ], + "192.168.0.2\/32":[ + { + "prefix":"192.168.0.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.0.3\/32":[ + { + "prefix":"192.168.0.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.1.0\/24":[ + { + "prefix":"192.168.1.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "table":254, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.1.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "192.168.2.0\/24":[ + { + "prefix":"192.168.2.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + }, + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.3.0\/24":[ + { + "prefix":"192.168.3.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.3.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true + } + ] + } + ], + "192.168.6.0\/24":[ + { + "prefix":"192.168.6.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":5, + "interfaceName":"r1-eth0", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.6.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":5, + "interfaceName":"r1-eth0", + "active":true + } + ] + } + ], + "192.168.7.0\/24":[ + { + "prefix":"192.168.7.0\/24", + "protocol":"bgp", + "distance":200, + "metric":0, + "nexthops":[ + { + "flags":5, + "ip":"192.168.0.2", + "afi":"ipv4", + "active":true, + "recursive":true, + "weight":1 + }, + { + "flags":1, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.7.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.8.0\/24":[ + { + "prefix":"192.168.8.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.101.0\/24":[ + { + "prefix":"192.168.101.0\/24", + "protocol":"bgp", + "distance":20, + "metric":0, + "nexthops":[ + { + "flags":0, + "ip":"192.168.101.2", + "afi":"ipv4", + "weight":1 + } + ] + }, + { + "prefix":"192.168.101.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":4, + "interfaceName":"r1-eth3", + "active":true + } + ] + } + ], + "192.168.102.0\/24":[ + { + "prefix":"192.168.102.0\/24", + "protocol":"bgp", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.101.2", + "afi":"ipv4", + "interfaceIndex":4, + "interfaceName":"r1-eth3", + "active":true, + "weight":1 + } + ] + } + ] +} diff --git a/tests/topotests/bgp_features/r1/ip_route_norib.json b/tests/topotests/bgp_features/r1/ip_route_norib.json new file mode 100644 index 0000000000..30f67f53a4 --- /dev/null +++ b/tests/topotests/bgp_features/r1/ip_route_norib.json @@ -0,0 +1,296 @@ +{ + "192.168.0.1\/32":[ + { + "prefix":"192.168.0.1\/32", + "protocol":"ospf", + "distance":110, + "metric":0, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":1, + "interfaceName":"lo", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.0.1\/32", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":1, + "interfaceName":"lo", + "active":true + } + ] + } + ], + "192.168.0.2\/32":[ + { + "prefix":"192.168.0.2\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.0.3\/32":[ + { + "prefix":"192.168.0.3\/32", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":10, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.1.0\/24":[ + { + "prefix":"192.168.1.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.1.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "192.168.2.0\/24":[ + { + "prefix":"192.168.2.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + }, + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.3.0\/24":[ + { + "prefix":"192.168.3.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.3.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true + } + ] + } + ], + "192.168.6.0\/24":[ + { + "prefix":"192.168.6.0\/24", + "protocol":"ospf", + "distance":110, + "metric":10, + "nexthops":[ + { + "flags":1, + "directlyConnected":true, + "interfaceIndex":5, + "interfaceName":"r1-eth0", + "active":true, + "weight":1 + } + ] + }, + { + "prefix":"192.168.6.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":5, + "interfaceName":"r1-eth0", + "active":true + } + ] + } + ], + "192.168.7.0\/24":[ + { + "prefix":"192.168.7.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.1.2", + "afi":"ipv4", + "interfaceIndex":2, + "interfaceName":"r1-eth1", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.8.0\/24":[ + { + "prefix":"192.168.8.0\/24", + "protocol":"ospf", + "selected":true, + "destSelected":true, + "distance":110, + "metric":20, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "ip":"192.168.3.2", + "afi":"ipv4", + "interfaceIndex":3, + "interfaceName":"r1-eth2", + "active":true, + "weight":1 + } + ] + } + ], + "192.168.101.0\/24":[ + { + "prefix":"192.168.101.0\/24", + "protocol":"connected", + "selected":true, + "destSelected":true, + "distance":0, + "metric":0, + "installed":true, + "nexthops":[ + { + "flags":3, + "fib":true, + "directlyConnected":true, + "interfaceIndex":4, + "interfaceName":"r1-eth3", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/bgp_features/test_bgp_features.py b/tests/topotests/bgp_features/test_bgp_features.py index 7c45ca8a29..4ec060b642 100644 --- a/tests/topotests/bgp_features/test_bgp_features.py +++ b/tests/topotests/bgp_features/test_bgp_features.py @@ -102,7 +102,7 @@ def setup_module(module): # Starting Routers router_list = tgen.routers() - for rname, router in router_list.items(): + for rname, router in router_list.iteritems(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) @@ -538,6 +538,133 @@ def test_bgp_remove_metric_rmaps(): assert res is None, assertmsg +def test_bgp_norib(): + "Test BGP disable RIB (Zebra) Route Install" + + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("Configuring 'bgp no-rib' on router r1") + + tgen.net['r1'].cmd('vtysh -c \"conf t\" -c \"bgp no-rib\"') + + # Checking BGP config - should show the "bgp no-rib" under the router bgp section + logger.info("Checking BGP configuration for 'bgp no-rib'") + + norib_cfg = tgen.net['r1'].cmd('vtysh -c "show running bgpd" | grep "^bgp no-rib"').rstrip() + + assertmsg = "'bgp no-rib' configuration applied, but not visible in configuration" + assert norib_cfg == 'bgp no-rib', assertmsg + + +def test_bgp_norib_routes(): + "Test Routes in Zebra and BGP with the 'bgp-norib' configuration" + + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + # Checking local BGP routes - they need to be gone from Zebra + logger.info("Checking Zebra routes after removing bgp shutdown on router r1") + + router = tgen.gears["r1"] + reffile = os.path.join(CWD, "r1/ip_route_norib.json") + expected = json.loads(open(reffile).read()) + + test_func = functools.partial( + topotest.router_json_cmp, router, "show ip route json", expected + ) + _, res = topotest.run_and_expect(test_func, None, count=30, wait=2) + assertmsg = "Zebra IPv4 Routes after configuring 'bgp no-rib' (There should be no BGP routes in Zebra anymore)" + assert res is None, assertmsg + + # Check BGP Summary on local and remote routers + for rtrNum in [1, 2, 4]: + logger.info("Checking BGP Summary after 'bgp no-rib' on router r1 on router r{}".format(rtrNum)) + + router = tgen.gears["r{}".format(rtrNum)] + reffile = os.path.join(CWD, "r{}/bgp_summary.json".format(rtrNum)) + expected = json.loads(open(reffile).read()) + + test_func = functools.partial( + topotest.router_json_cmp, router, "show ip bgp summary json", expected + ) + _, res = topotest.run_and_expect(test_func, None, count=30, wait=2) + assertmsg = "BGP sessions on router R{} has incorrect routes after adding 'bgp no-rib on r1'".format(rtrNum) + assert res is None, assertmsg + + # tgen.mininet_cli() + + +def test_bgp_disable_norib(): + "Test BGP disabling the no-RIB (Zebra) Route Install" + + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + logger.info("Configuring 'no bgp no-rib' on router r1") + + tgen.net['r1'].cmd('vtysh -c \"conf t\" -c \"no bgp no-rib\"') + + # Checking BGP config - should show the "bgp no-rib" under the router bgp section + logger.info("Checking BGP configuration for 'bgp no-rib'") + + norib_cfg = tgen.net['r1'].cmd('vtysh -c "show running bgpd" | grep "^ bgp no-rib"').rstrip() + + assertmsg = "'no bgp no-rib'configuration applied, but still visible in configuration" + assert norib_cfg == '', assertmsg + + +def test_bgp_disable_norib_routes(): + "Test Routes in Zebra and BGP with the 'bgp-norib' configuration" + + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + # Checking local BGP routes - they need to be gone from Zebra + logger.info("Checking Zebra routes after removing bgp shutdown on router r1") + + router = tgen.gears["r1"] + reffile = os.path.join(CWD, "r1/ip_route.json") + expected = json.loads(open(reffile).read()) + + test_func = functools.partial( + topotest.router_json_cmp, router, "show ip route json", expected + ) + _, res = topotest.run_and_expect(test_func, None, count=30, wait=2) + assertmsg = "Zebra IPv4 Routes wrong after removing the 'bgp no-rib'" + assert res is None, assertmsg + + # Check BGP Summary on local and remote routers + for rtrNum in [1, 2, 4]: + logger.info("Checking BGP Summary after removing the 'bgp no-rib' on router r1 on router r{}".format(rtrNum)) + + router = tgen.gears["r{}".format(rtrNum)] + reffile = os.path.join(CWD, "r{}/bgp_summary.json".format(rtrNum)) + expected = json.loads(open(reffile).read()) + + test_func = functools.partial( + topotest.router_json_cmp, router, "show ip bgp summary json", expected + ) + _, res = topotest.run_and_expect(test_func, None, count=30, wait=2) + assertmsg = "BGP sessions on router R{} has incorrect routes after removing 'bgp no-rib on r1'".format(rtrNum) + assert res is None, assertmsg + + # tgen.mininet_cli() + + + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py index fdbd317093..fdbd317093 100755..100644 --- a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py +++ b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py diff --git a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py index e1ec0ea81b..e1ec0ea81b 100755..100644 --- a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py +++ b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py index dc06b7131a..dc06b7131a 100755..100644 --- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py +++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py index bb88e47415..bb88e47415 100755..100644 --- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py +++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py diff --git a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py index c15b88d371..c15b88d371 100755..100644 --- a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py +++ b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py diff --git a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py index bb13d54019..bb13d54019 100755..100644 --- a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py +++ b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py diff --git a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py index 6344f7bb40..6344f7bb40 100755..100644 --- a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py +++ b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py diff --git a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py index fef6eb71dc..fef6eb71dc 100755..100644 --- a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py +++ b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py diff --git a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py index 0fabd90341..0fabd90341 100755..100644 --- a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py +++ b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py index 1947548b3e..1947548b3e 100755..100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py index 6c106060b8..6c106060b8 100755..100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py diff --git a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py index 70666a3d61..3ce1472ac0 100644 --- a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py +++ b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py @@ -252,7 +252,7 @@ def ip_eigrp_topo(node): if code not in ["P", "A", "U", "Q", "R", "r", "s"]: continue - if not result.has_key(code): + if code not in result: result[code] = {} # Split network from the rest diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py index e913105e43..e913105e43 100755..100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py index 9e385823fc..c1eb7d68bb 100755..100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py @@ -26,9 +26,9 @@ Following tests are covered to test EVPN-Type5 functionality: 1. RD verification (manual/auto). 2. RT verification(manual) 3. In an active/standby EVPN implementation, if active DCG goes down, - secondary takes over. + secondary takes over. 4. EVPN routes are advertised/withdrawn, based on VNFs - advertising/withdrawing IP prefixes. + advertising/withdrawing IP prefixes. 5. Route-map operations for EVPN address family. 6. BGP attributes for EVPN address-family. """ diff --git a/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py b/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py index 65515f22cc..7943b94189 100644 --- a/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py +++ b/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py @@ -210,7 +210,7 @@ def test_isis_linux_route_installation(): dist = platform.dist() if (dist[1] == "16.04"): - pytest.skip("Kernel not supported for vrf") + pytest.skip("Kernel not supported for vrf") "Check whether all expected routes are present and installed in the OS" tgen = get_topogen() @@ -267,7 +267,7 @@ def test_isis_linux_route6_installation(): dist = platform.dist() if (dist[1] == "16.04"): - pytest.skip("Kernel not supported for vrf") + pytest.skip("Kernel not supported for vrf") "Check whether all expected routes are present and installed in the OS" tgen = get_topogen() diff --git a/tests/topotests/ldp-topo1/test_ldp_topo1.py b/tests/topotests/ldp-topo1/test_ldp_topo1.py index 31adeafbf6..31adeafbf6 100755..100644 --- a/tests/topotests/ldp-topo1/test_ldp_topo1.py +++ b/tests/topotests/ldp-topo1/test_ldp_topo1.py diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index a3d846edbb..72b99eeba8 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -28,6 +28,7 @@ from lib import topotest from lib.topolog import logger from lib.topogen import TopoRouter, get_topogen +from lib.topotest import frr_unicode # Import common_config to use commomnly used APIs from lib.common_config import ( @@ -393,7 +394,7 @@ def __create_bgp_unicast_neighbor( # Generating IPs for verification network_list = generate_ips(network, no_of_network) for ip in network_list: - ip = str(ipaddress.ip_network(unicode(ip))) + ip = str(ipaddress.ip_network(frr_unicode(ip))) cmd = "network {}".format(ip) if del_action: @@ -1037,7 +1038,7 @@ def verify_router_id(tgen, topo, input_dict): logger.info("Checking router %s router-id", router) show_bgp_json = run_frr_cmd(rnode, "show bgp summary json", isjson=True) router_id_out = show_bgp_json["ipv4Unicast"]["routerId"] - router_id_out = ipaddress.IPv4Address(unicode(router_id_out)) + router_id_out = ipaddress.IPv4Address(frr_unicode(router_id_out)) # Once router-id is deleted, highest interface ip should become # router-id @@ -1045,7 +1046,7 @@ def verify_router_id(tgen, topo, input_dict): router_id = find_interface_with_greater_ip(topo, router) else: router_id = input_dict[router]["bgp"]["router_id"] - router_id = ipaddress.IPv4Address(unicode(router_id)) + router_id = ipaddress.IPv4Address(frr_unicode(router_id)) if router_id == router_id_out: logger.info("Found expected router-id %s for router %s", router_id, router) @@ -2286,7 +2287,7 @@ def verify_best_path_as_per_bgp_attribute( routes = generate_ips(_network, no_of_ip) for route in routes: - route = str(ipaddress.ip_network(unicode(route))) + route = str(ipaddress.ip_network(frr_unicode(route))) if route in sh_ip_bgp_json["routes"]: route_attributes = sh_ip_bgp_json["routes"][route] @@ -2604,7 +2605,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None) ip_list = generate_ips(network, no_of_ip) for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -2742,7 +2743,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None) ip_list = generate_ips(network, no_of_network) for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index 6dd8d646f3..1fa6d35101 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -31,16 +31,14 @@ from re import search as re_search from tempfile import mkdtemp import os +import io import sys -import ConfigParser import traceback import socket import ipaddress import platform - if sys.version_info[0] > 2: - import io import configparser else: import StringIO @@ -48,7 +46,7 @@ else: from lib.topolog import logger, logger_config from lib.topogen import TopoRouter, get_topogen -from lib.topotest import interface_set_status, version_cmp +from lib.topotest import interface_set_status, version_cmp, frr_unicode FRRCFG_FILE = "frr_json.conf" FRRCFG_BKUP_FILE = "frr_json_initial.conf" @@ -638,7 +636,7 @@ def get_frr_ipv6_linklocal(tgen, router, intf=None, vrf=None): ll_per_if_count = 0 # Interface ip - m1 = re_search("inet6 (fe80[:a-fA-F0-9]+[\/0-9]+)", line) + m1 = re_search("inet6 (fe80[:a-fA-F0-9]+[/0-9]+)", line) if m1: local = m1.group(1) ll_per_if_count += 1 @@ -700,18 +698,20 @@ def start_topology(tgen, daemon=None): router_list = tgen.routers() ROUTER_LIST = sorted( - router_list.keys(), key=lambda x: int(re_search("\d+", x).group(0)) + router_list.keys(), key=lambda x: int(re_search("[0-9]+", x).group(0)) ) TMPDIR = os.path.join(LOGDIR, tgen.modname) + linux_ver = '' router_list = tgen.routers() for rname in ROUTER_LIST: router = router_list[rname] # It will help in debugging the failures, will give more details on which # specific kernel version tests are failing - linux_ver = router.run("uname -a") - logger.info("Logging platform related details: \n %s \n", linux_ver) + if linux_ver == '': + linux_ver = router.run("uname -a") + logger.info("Logging platform related details: \n %s \n", linux_ver) try: os.chdir(TMPDIR) @@ -827,7 +827,7 @@ def topo_daemons(tgen, topo): router_list = tgen.routers() ROUTER_LIST = sorted( - router_list.keys(), key=lambda x: int(re_search("\d+", x).group(0)) + router_list.keys(), key=lambda x: int(re_search("[0-9]+", x).group(0)) ) for rtr in ROUTER_LIST: @@ -1152,10 +1152,10 @@ def generate_ips(network, no_of_ips): addr_type = validate_ip_address(start_ip) if addr_type == "ipv4": - start_ip = ipaddress.IPv4Address(unicode(start_ip)) + start_ip = ipaddress.IPv4Address(frr_unicode(start_ip)) step = 2 ** (32 - mask) if addr_type == "ipv6": - start_ip = ipaddress.IPv6Address(unicode(start_ip)) + start_ip = ipaddress.IPv6Address(frr_unicode(start_ip)) step = 2 ** (128 - mask) next_ip = start_ip @@ -2667,7 +2667,7 @@ def verify_rib( nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -2863,7 +2863,7 @@ def verify_rib( nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -3012,7 +3012,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) #st_rt = str(ipaddr.IPNetwork(unicode(st_rt))) _addr_type = validate_ip_address(st_rt) @@ -3119,7 +3119,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): for st_rt in ip_list: #st_rt = str(ipaddr.IPNetwork(unicode(st_rt))) - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -3268,7 +3268,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -3373,7 +3373,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py index 192c121008..3c93e1ac5c 100644 --- a/tests/topotests/lib/ltemplate.py +++ b/tests/topotests/lib/ltemplate.py @@ -157,8 +157,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None, if SkipIfFailed and tgen.routers_have_failure(): pytest.skip(tgen.errors) if numEntry > 0: - if not KeepGoing: - pytest.skip("Have %d errors" % numEntry) + if not KeepGoing: + pytest.skip("Have %d errors" % numEntry) if CheckFuncStr != None: check = eval(CheckFuncStr) @@ -172,8 +172,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None, if numFail > 0: luShowFail() fatal_error = "%d tests failed" % numFail - if not KeepGoing: - assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error + if not KeepGoing: + assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error # Memory leak test template def test_memory_leak(): diff --git a/tests/topotests/lib/lutil.py b/tests/topotests/lib/lutil.py index 4ea97a3692..05ed9c007d 100755..100644 --- a/tests/topotests/lib/lutil.py +++ b/tests/topotests/lib/lutil.py @@ -204,17 +204,17 @@ Total %-4d %-4d %d\n\ self.log('WARNING: JSON load failed -- confirm command output is in JSON format.') self.log('COMMAND OUTPUT:%s:' % report) - # Experiment: can we achieve the same match behavior via DOTALL - # without converting newlines to spaces? - out_nl = out - search_nl = re.search(regexp, out_nl, re.DOTALL); - self.l_last_nl = search_nl - # Set up for comparison - if search_nl != None: - group_nl = search_nl.group() - group_nl_converted = " ".join(group_nl.splitlines()) + # Experiment: can we achieve the same match behavior via DOTALL + # without converting newlines to spaces? + out_nl = out + search_nl = re.search(regexp, out_nl, re.DOTALL); + self.l_last_nl = search_nl + # Set up for comparison + if search_nl != None: + group_nl = search_nl.group() + group_nl_converted = " ".join(group_nl.splitlines()) else: - group_nl_converted = None + group_nl_converted = None out = " ".join(out.splitlines()) search = re.search(regexp, out) @@ -234,9 +234,9 @@ Total %-4d %-4d %d\n\ success = False level = 5 self.log('found:%s:' % ret, level) - # Experiment: compare matched strings obtained each way - if self.l_dotall_experiment and (group_nl_converted != ret): - self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9) + # Experiment: compare matched strings obtained each way + if self.l_dotall_experiment and (group_nl_converted != ret): + self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9) if op == 'pass' or op == 'fail': self.result(target, success, result) if js != None: @@ -297,13 +297,13 @@ def luCommand(target, command, regexp='.', op='none', result='', time=10, return def luLast(usenl=False): if usenl: - if LUtil.l_last_nl != None: - LUtil.log('luLast:%s:' % LUtil.l_last_nl.group(), 7) - return LUtil.l_last_nl + if LUtil.l_last_nl != None: + LUtil.log('luLast:%s:' % LUtil.l_last_nl.group(), 7) + return LUtil.l_last_nl else: - if LUtil.l_last != None: - LUtil.log('luLast:%s:' % LUtil.l_last.group(), 7) - return LUtil.l_last + if LUtil.l_last != None: + LUtil.log('luLast:%s:' % LUtil.l_last.group(), 7) + return LUtil.l_last def luInclude(filename, CallOnFail=None): tstFile = LUtil.base_script_dir + '/' + filename diff --git a/tests/topotests/lib/ospf.py b/tests/topotests/lib/ospf.py index a2351bf747..9d6b8fa691 100644 --- a/tests/topotests/lib/ospf.py +++ b/tests/topotests/lib/ospf.py @@ -23,7 +23,7 @@ import traceback from time import sleep from lib.topolog import logger import ipaddr - +from lib.topotest import frr_unicode # Import common_config to use commomnly used APIs from lib.common_config import (create_common_configuration, @@ -516,7 +516,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False): logger.debug("Entering lib API: verify_ospf_neighbor()") result = False if input_dict: - for router, rnode in tgen.routers().iteritems(): + for router, rnode in tgen.routers().items(): if 'ospf' not in topo['routers'][router]: continue @@ -584,7 +584,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False): return errormsg continue else: - for router, rnode in tgen.routers().iteritems(): + for router, rnode in tgen.routers().items(): if 'ospf' not in topo['routers'][router]: continue @@ -694,7 +694,7 @@ def verify_ospf_rib(tgen, dut, input_dict, next_hop=None, additional_nexthops_in_required_nhs = [] found_hops = [] for routerInput in input_dict.keys(): - for router, rnode in router_list.iteritems(): + for router, rnode in router_list.items(): if router != dut: continue @@ -739,7 +739,7 @@ def verify_ospf_rib(tgen, dut, input_dict, next_hop=None, nh_found = False for st_rt in ip_list: - st_rt = str(ipaddr.IPNetwork(unicode(st_rt))) + st_rt = str(ipaddr.IPNetwork(frr_unicode(st_rt))) _addr_type = validate_ip_address(st_rt) if _addr_type != 'ipv4': @@ -927,7 +927,7 @@ def verify_ospf_interface(tgen, topo, dut=None,lan=False, input_dict=None): logger.debug("Entering lib API: verify_ospf_interface()") result = False - for router, rnode in tgen.routers().iteritems(): + for router, rnode in tgen.routers().items(): if 'ospf' not in topo['routers'][router]: continue diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 171a894b35..ffdcb683e7 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -40,6 +40,7 @@ Basic usage instructions: import os import sys +import io import logging import json @@ -97,7 +98,7 @@ tgen_defaults = { "verbosity": "info", "frrdir": "/usr/lib/frr", "routertype": "frr", - "memleak_path": None, + "memleak_path": "", } @@ -182,7 +183,7 @@ class Topogen(object): params["frrdir"] = self.config.get(self.CONFIG_SECTION, "frrdir") params["memleak_path"] = self.config.get(self.CONFIG_SECTION, "memleak_path") - if not params.has_key("routertype"): + if "routertype" not in params: params["routertype"] = self.config.get(self.CONFIG_SECTION, "routertype") self.gears[name] = TopoRouter(self, cls, name, **params) @@ -360,7 +361,7 @@ class Topogen(object): memleak_file = os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.config.get( self.CONFIG_SECTION, "memleak_path" ) - if memleak_file is None: + if memleak_file == "" or memleak_file == None: return False return True @@ -586,7 +587,7 @@ class TopoRouter(TopoGear): self.cls = cls self.options = {} self.routertype = params.get("routertype", "frr") - if not params.has_key("privateDirs"): + if "privateDirs" not in params: params["privateDirs"] = self.PRIVATE_DIRS self.options["memleak_path"] = params.get("memleak_path", None) @@ -822,7 +823,7 @@ class TopoRouter(TopoGear): memleak_file = ( os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.options["memleak_path"] ) - if memleak_file is None: + if memleak_file == "" or memleak_file == None: return self.stop() @@ -1011,7 +1012,7 @@ def diagnose_env_linux(): logger.info("Running environment diagnostics") # Load configuration - config = configparser.ConfigParser(tgen_defaults) + config = configparser.ConfigParser(defaults=tgen_defaults) pytestini_path = os.path.join(CWD, "../pytest.ini") config.read(pytestini_path) @@ -1106,10 +1107,10 @@ def diagnose_env_linux(): # TODO remove me when we start supporting exabgp >= 4 try: - output = subprocess.check_output(["exabgp", "-v"]) - line = output.split("\n")[0] - version = line.split(" ")[2] - if topotest.version_cmp(version, "4") >= 0: + p = os.popen("exabgp -v") + line = p.readlines() + version = line[0].split() + if topotest.version_cmp(version[2], "4") >= 0: logger.warning( "BGP topologies are still using exabgp version 3, expect failures" ) diff --git a/tests/topotests/lib/topojson.py b/tests/topotests/lib/topojson.py index b3af09aa99..6535918e36 100644 --- a/tests/topotests/lib/topojson.py +++ b/tests/topotests/lib/topojson.py @@ -216,7 +216,7 @@ def build_topo_from_json(tgen, topo): # Physical Interfaces if "links" in topo['switches'][curSwitch]: for destRouterLink, data in sorted( - topo['switches'][curSwitch]['links'].iteritems()): + topo['switches'][curSwitch]['links'].items()): # Loopback interfaces if "dst_node" in data: diff --git a/tests/topotests/lib/topolog.py b/tests/topotests/lib/topolog.py index 0dfa870930..9fde01cca0 100644 --- a/tests/topotests/lib/topolog.py +++ b/tests/topotests/lib/topolog.py @@ -93,7 +93,7 @@ class Logger(object): """ if log_level is None: log_level = self.log_level - if self.loggers.has_key(name): + if name in self.loggers: return self.loggers[name] nlogger = logging.Logger(name, level=log_level) diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 00bfac4103..a187971e41 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -992,11 +992,11 @@ class Router(Node): # Backward compatibility: # Load configuration defaults like topogen. self.config_defaults = configparser.ConfigParser( - { + defaults = { "verbosity": "info", "frrdir": "/usr/lib/frr", "routertype": "frr", - "memleak_path": None, + "memleak_path": "", } ) self.config_defaults.read( @@ -1525,7 +1525,7 @@ class Router(Node): for daemon in self.daemons: if (self.daemons[daemon] == 1) and not (daemon in daemonsRunning): sys.stderr.write("%s: Daemon %s not running\n" % (self.name, daemon)) - if daemon is "staticd": + if daemon == "staticd": sys.stderr.write( "You may have a copy of staticd installed but are attempting to test against\n" ) @@ -1591,7 +1591,7 @@ class Router(Node): logger.info("{}: running version: {}".format(self.name, self.version)) rversion = self.version - if rversion is None: + if rversion == None: return False result = version_cmp(rversion, version) @@ -1737,3 +1737,10 @@ class LegacySwitch(OVSSwitch): def __init__(self, name, **params): OVSSwitch.__init__(self, name, failMode="standalone", **params) self.switchIP = None + +def frr_unicode(s): + '''Convert string to unicode, depending on python version''' + if sys.version_info[0] > 2: + return s + else: + return unicode(s) diff --git a/tests/topotests/ospf-topo2/test_ospf_topo2.py b/tests/topotests/ospf-topo2/test_ospf_topo2.py index 0b6f568462..79e8e6bf58 100644 --- a/tests/topotests/ospf-topo2/test_ospf_topo2.py +++ b/tests/topotests/ospf-topo2/test_ospf_topo2.py @@ -86,19 +86,19 @@ def setup_module(mod): os.path.join(CWD, '{}/ospfd.conf'.format(rname)) ) - # What is this? OSPF Unnumbered depends on the rp_filter - # being set appropriately( HA! ) - # Effectively we are putting different /32's on the interface - # the multicast packet delivery is somewhat controlled by - # the rp_filter. Setting it to '0' allows the OS to pass - # up the mcast packet not destined for the local routers - # network. - topotest.set_sysctl(tgen.net['r1'], - 'net.ipv4.conf.r1-eth1.rp_filter', 0) + # What is this? OSPF Unnumbered depends on the rp_filter + # being set appropriately( HA! ) + # Effectively we are putting different /32's on the interface + # the multicast packet delivery is somewhat controlled by + # the rp_filter. Setting it to '0' allows the OS to pass + # up the mcast packet not destined for the local routers + # network. + topotest.set_sysctl(tgen.net['r1'], + 'net.ipv4.conf.r1-eth1.rp_filter', 0) topotest.set_sysctl(tgen.net['r1'], 'net.ipv4.conf.all.rp_filter', 0) - topotest.set_sysctl(tgen.net['r2'], - 'net.ipv4.conf.r2-eth1.rp_filter', 0) + topotest.set_sysctl(tgen.net['r2'], + 'net.ipv4.conf.r2-eth1.rp_filter', 0) topotest.set_sysctl(tgen.net['r2'], 'net.ipv4.conf.all.rp_filter', 0) diff --git a/tests/topotests/pbr-topo1/test_pbr_topo1.py b/tests/topotests/pbr-topo1/test_pbr_topo1.py index 9ae4cce360..91979a8f04 100644 --- a/tests/topotests/pbr-topo1/test_pbr_topo1.py +++ b/tests/topotests/pbr-topo1/test_pbr_topo1.py @@ -88,8 +88,8 @@ def setup_module(module): krel = platform.release() if topotest.version_cmp(krel, "4.10") < 0: - tgen.errors = "Newer kernel than 4.9 needed for pbr tests" - pytest.skip(tgen.errors) + tgen.errors = "Newer kernel than 4.9 needed for pbr tests" + pytest.skip(tgen.errors) router_list = tgen.routers() for rname, router in router_list.items(): @@ -150,8 +150,8 @@ def test_pbr_data(): test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected) _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assertmsg = '"show pbr interface" mismatches on {}'.format(router.name) - if result is not None: - gather_pbr_data_on_error(router) + if result is not None: + gather_pbr_data_on_error(router) assert result is None, assertmsg map_file = "{}/{}/pbr-map.json".format(CWD, router.name) @@ -164,8 +164,8 @@ def test_pbr_data(): test_func = partial(topotest.router_json_cmp, router, "show pbr map json", expected) _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assertmsg = '"show pbr map" mismatches on {}'.format(router.name) - if result is not None: - gather_pbr_data_on_error(router) + if result is not None: + gather_pbr_data_on_error(router) assert result is None, assertmsg nexthop_file = "{}/{}/pbr-nexthop-groups.json".format(CWD, router.name) @@ -178,8 +178,8 @@ def test_pbr_data(): test_func = partial(topotest.router_json_cmp, router, "show pbr nexthop-groups json", expected) _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assertmsg = '"show pbr nexthop-groups" mismatches on {}'.format(router.name) - if result is not None: - gather_pbr_data_on_error(router) + if result is not None: + gather_pbr_data_on_error(router) assert result is None, assertmsg def test_pbr_flap(): @@ -215,8 +215,8 @@ def test_pbr_flap(): test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected) _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assertmsg = '"show pbr interface" mismatches on {}'.format(router.name) - if result is not None: - gather_pbr_data_on_error(router) + if result is not None: + gather_pbr_data_on_error(router) assert result is None, assertmsg diff --git a/tests/topotests/rip-topo1/test_rip_topo1.py b/tests/topotests/rip-topo1/test_rip_topo1.py index 7ff18ba524..de11b78824 100755..100644 --- a/tests/topotests/rip-topo1/test_rip_topo1.py +++ b/tests/topotests/rip-topo1/test_rip_topo1.py @@ -91,11 +91,11 @@ class NetworkTopo(Topo): switch[4] = self.addSwitch("sw4", cls=topotest.LegacySwitch) self.addLink(switch[4], router[3], intfName2="r3-eth0") - switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch) - self.addLink(switch[5], router[1], intfName2="r1-eth2") + switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch) + self.addLink(switch[5], router[1], intfName2="r1-eth2") - switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch) - self.addLink(switch[6], router[1], intfName2="r1-eth3") + switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch) + self.addLink(switch[6], router[1], intfName2="r1-eth3") ##################################################### diff --git a/tests/topotests/ripng-topo1/test_ripng_topo1.py b/tests/topotests/ripng-topo1/test_ripng_topo1.py index 2976cdefe4..2976cdefe4 100755..100644 --- a/tests/topotests/ripng-topo1/test_ripng_topo1.py +++ b/tests/topotests/ripng-topo1/test_ripng_topo1.py diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index bb158f3c9e..9993e73353 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1173,12 +1173,14 @@ static char **new_completion(const char *text, int start, int end) } /* Vty node structures. */ +#ifdef HAVE_BGPD static struct cmd_node bgp_node = { .name = "bgp", .node = BGP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_BGPD */ static struct cmd_node rip_node = { .name = "rip", @@ -1187,19 +1189,23 @@ static struct cmd_node rip_node = { .prompt = "%s(config-router)# ", }; +#ifdef HAVE_ISISD static struct cmd_node isis_node = { .name = "isis", .node = ISIS_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_ISISD */ +#ifdef HAVE_FABRICD static struct cmd_node openfabric_node = { .name = "openfabric", .node = OPENFABRIC_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_FABRICD */ static struct cmd_node interface_node = { .name = "interface", @@ -1236,12 +1242,14 @@ static struct cmd_node rmap_node = { .prompt = "%s(config-route-map)# ", }; +#ifdef HAVE_PBRD static struct cmd_node pbr_map_node = { .name = "pbr-map", .node = PBRMAP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-pbr-map)# ", }; +#endif /* HAVE_PBRD */ static struct cmd_node zebra_node = { .name = "zebra", @@ -1250,6 +1258,7 @@ static struct cmd_node zebra_node = { .prompt = "%s(config-router)# ", }; +#ifdef HAVE_BGPD static struct cmd_node bgp_vpnv4_node = { .name = "bgp vpnv4", .node = BGP_VPNV4_NODE, @@ -1334,6 +1343,7 @@ static struct cmd_node bgp_ipv6l_node = { .prompt = "%s(config-router-af)# ", }; +#ifdef ENABLE_BGP_VNC static struct cmd_node bgp_vnc_defaults_node = { .name = "bgp vnc defaults", .node = BGP_VNC_DEFAULTS_NODE, @@ -1361,6 +1371,7 @@ static struct cmd_node bgp_vnc_l2_group_node = { .parent_node = BGP_NODE, .prompt = "%s(config-router-vnc-l2-group)# ", }; +#endif /* ENABLE_BGP_VNC */ static struct cmd_node bmp_node = { .name = "bmp", @@ -1368,27 +1379,34 @@ static struct cmd_node bmp_node = { .parent_node = BGP_NODE, .prompt = "%s(config-bgp-bmp)# " }; +#endif /* HAVE_BGPD */ +#ifdef HAVE_OSPFD static struct cmd_node ospf_node = { .name = "ospf", .node = OSPF_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_OSPFD */ +#ifdef HAVE_EIGRPD static struct cmd_node eigrp_node = { .name = "eigrp", .node = EIGRP_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_EIGRPD */ +#ifdef HAVE_BABELD static struct cmd_node babel_node = { .name = "babel", .node = BABEL_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-router)# ", }; +#endif /* HAVE_BABELD */ static struct cmd_node ripng_node = { .name = "ripng", @@ -1397,13 +1415,16 @@ static struct cmd_node ripng_node = { .prompt = "%s(config-router)# ", }; +#ifdef HAVE_OSPF6D static struct cmd_node ospf6_node = { .name = "ospf6", .node = OSPF6_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-ospf6)# ", }; +#endif /* HAVE_OSPF6D */ +#ifdef HAVE_LDPD static struct cmd_node ldp_node = { .name = "ldp", .node = LDP_NODE, @@ -1452,6 +1473,7 @@ static struct cmd_node ldp_pseudowire_node = { .parent_node = LDP_L2VPN_NODE, .prompt = "%s(config-l2vpn-pw)# ", }; +#endif /* HAVE_LDPD */ static struct cmd_node keychain_node = { .name = "keychain", @@ -1474,12 +1496,14 @@ struct cmd_node link_params_node = { .prompt = "%s(config-link-params)# ", }; +#ifdef HAVE_BGPD static struct cmd_node rpki_node = { .name = "rpki", .node = RPKI_NODE, .parent_node = CONFIG_NODE, .prompt = "%s(config-rpki)# ", }; +#endif /* HAVE_BGPD */ #if HAVE_BFDD > 0 static struct cmd_node bfd_node = { @@ -1528,6 +1552,7 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_end_all, vtysh_end_all_cmd, "end", return vtysh_end(); } +#ifdef HAVE_BGPD DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd, "router bgp [(1-4294967295) [<view|vrf> WORD]]", ROUTER_STR BGP_STR AS_STR @@ -1748,6 +1773,7 @@ DEFUNSH(VTYSH_BGPD, vnc_l2_group, vnc_l2_group_cmd, "vnc l2-group NAME", return CMD_SUCCESS; } #endif +#endif /* HAVE_BGPD */ DEFUNSH(VTYSH_KEYS, key_chain, key_chain_cmd, "key chain WORD", "Authentication key management\n" @@ -1766,20 +1792,25 @@ DEFUNSH(VTYSH_KEYS, key, key_cmd, "key (0-2147483647)", return CMD_SUCCESS; } +#ifdef HAVE_RIPD DEFUNSH(VTYSH_RIPD, router_rip, router_rip_cmd, "router rip [vrf NAME]", ROUTER_STR "RIP\n" VRF_CMD_HELP_STR) { vty->node = RIP_NODE; return CMD_SUCCESS; } +#endif /* HAVE_RIPD */ +#ifdef HAVE_RIPNGD DEFUNSH(VTYSH_RIPNGD, router_ripng, router_ripng_cmd, "router ripng [vrf NAME]", ROUTER_STR "RIPng\n" VRF_CMD_HELP_STR) { vty->node = RIPNG_NODE; return CMD_SUCCESS; } +#endif /* HAVE_RIPNGD */ +#ifdef HAVE_OSPFD DEFUNSH(VTYSH_OSPFD, router_ospf, router_ospf_cmd, "router ospf [(1-65535)] [vrf NAME]", "Enable a routing process\n" @@ -1790,7 +1821,9 @@ DEFUNSH(VTYSH_OSPFD, router_ospf, router_ospf_cmd, vty->node = OSPF_NODE; return CMD_SUCCESS; } +#endif /* HAVE_OSPFD */ +#ifdef HAVE_EIGRPD DEFUNSH(VTYSH_EIGRPD, router_eigrp, router_eigrp_cmd, "router eigrp (1-65535) [vrf NAME]", "Enable a routing process\n" "Start EIGRP configuration\n" @@ -1800,7 +1833,9 @@ DEFUNSH(VTYSH_EIGRPD, router_eigrp, router_eigrp_cmd, "router eigrp (1-65535) [v vty->node = EIGRP_NODE; return CMD_SUCCESS; } +#endif /* HAVE_EIGRPD */ +#ifdef HAVE_BABELD DEFUNSH(VTYSH_BABELD, router_babel, router_babel_cmd, "router babel", "Enable a routing process\n" "Make Babel instance command\n") @@ -1808,13 +1843,16 @@ DEFUNSH(VTYSH_BABELD, router_babel, router_babel_cmd, "router babel", vty->node = BABEL_NODE; return CMD_SUCCESS; } +#endif /* HAVE_BABELD */ +#ifdef HAVE_OSPF6D DEFUNSH(VTYSH_OSPF6D, router_ospf6, router_ospf6_cmd, "router ospf6", ROUTER_STR OSPF6_STR) { vty->node = OSPF6_NODE; return CMD_SUCCESS; } +#endif #if defined(HAVE_LDPD) DEFUNSH(VTYSH_LDPD, ldp_mpls_ldp, ldp_mpls_ldp_cmd, "mpls ldp", @@ -1892,6 +1930,7 @@ DEFUNSH(VTYSH_LDPD, ldp_member_pseudowire_ifname, } #endif +#ifdef HAVE_ISISD DEFUNSH(VTYSH_ISISD, router_isis, router_isis_cmd, "router isis WORD [vrf NAME]", ROUTER_STR @@ -1901,7 +1940,9 @@ DEFUNSH(VTYSH_ISISD, router_isis, router_isis_cmd, vty->node = ISIS_NODE; return CMD_SUCCESS; } +#endif /* HAVE_ISISD */ +#ifdef HAVE_FABRICD DEFUNSH(VTYSH_FABRICD, router_openfabric, router_openfabric_cmd, "router openfabric WORD", ROUTER_STR "OpenFabric routing protocol\n" @@ -1910,6 +1951,7 @@ DEFUNSH(VTYSH_FABRICD, router_openfabric, router_openfabric_cmd, "router openfab vty->node = OPENFABRIC_NODE; return CMD_SUCCESS; } +#endif /* HAVE_FABRICD */ DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd, "route-map WORD <deny|permit> (1-65535)", @@ -1923,6 +1965,7 @@ DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd, return CMD_SUCCESS; } +#ifdef HAVE_PBRD DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, "pbr-map PBRMAP seq (1-700)", "Create pbr-map or enter pbr-map command mode\n" @@ -1934,6 +1977,14 @@ DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd, return CMD_SUCCESS; } +DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map PBRMAP [seq (1-700)]", + NO_STR + "Delete pbr-map\n" + "The name of the PBR MAP\n" + "Sequence to delete from existing pbr-map entry\n" + "Sequence number\n") +#endif /* HAVE_PBRD */ + #if HAVE_BFDD > 0 DEFUNSH(VTYSH_BFDD, bfd_enter, bfd_enter_cmd, "bfd", "Configure BFD peers\n") { @@ -1969,13 +2020,6 @@ DEFUNSH(VTYSH_BFDD, bfd_profile_enter, bfd_profile_enter_cmd, } #endif /* HAVE_BFDD */ -DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map PBRMAP [seq (1-700)]", - NO_STR - "Delete pbr-map\n" - "The name of the PBR MAP\n" - "Sequence to delete from existing pbr-map entry\n" - "Sequence number\n") - DEFUNSH(VTYSH_ALL, vtysh_line_vty, vtysh_line_vty_cmd, "line vty", "Configure a terminal line\n" "Virtual terminal\n") @@ -2039,6 +2083,7 @@ DEFUNSH(VTYSH_ALL, vtysh_quit_all, vtysh_quit_all_cmd, "quit", return vtysh_exit_all(self, vty, argc, argv); } +#ifdef HAVE_BGPD DEFUNSH(VTYSH_BGPD, exit_address_family, exit_address_family_cmd, "exit-address-family", "Exit from Address Family configuration mode\n") { @@ -2097,14 +2142,6 @@ DEFUNSH(VTYSH_BGPD, bmp_quit, bmp_quit_cmd, "quit", return bmp_exit(self, vty, argc, argv); } -DEFUNSH(VTYSH_VRF, exit_vrf_config, exit_vrf_config_cmd, "exit-vrf", - "Exit from VRF configuration mode\n") -{ - if (vty->node == VRF_NODE) - vty->node = CONFIG_NODE; - return CMD_SUCCESS; -} - DEFUNSH(VTYSH_BGPD, exit_vrf_policy, exit_vrf_policy_cmd, "exit-vrf-policy", "Exit from VRF policy configuration mode\n") { @@ -2112,7 +2149,17 @@ DEFUNSH(VTYSH_BGPD, exit_vrf_policy, exit_vrf_policy_cmd, "exit-vrf-policy", vty->node = BGP_NODE; return CMD_SUCCESS; } +#endif /* HAVE_BGPD */ + +DEFUNSH(VTYSH_VRF, exit_vrf_config, exit_vrf_config_cmd, "exit-vrf", + "Exit from VRF configuration mode\n") +{ + if (vty->node == VRF_NODE) + vty->node = CONFIG_NODE; + return CMD_SUCCESS; +} +#ifdef HAVE_RIPD DEFUNSH(VTYSH_RIPD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2124,7 +2171,9 @@ DEFUNSH(VTYSH_RIPD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", { return vtysh_exit_ripd(self, vty, argc, argv); } +#endif /* HAVE_RIPD */ +#ifdef HAVE_RIPNGD DEFUNSH(VTYSH_RIPNGD, vtysh_exit_ripngd, vtysh_exit_ripngd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2136,6 +2185,7 @@ DEFUNSH(VTYSH_RIPNGD, vtysh_quit_ripngd, vtysh_quit_ripngd_cmd, "quit", { return vtysh_exit_ripngd(self, vty, argc, argv); } +#endif /* HAVE_RIPNGD */ DEFUNSH(VTYSH_RMAP, vtysh_exit_rmap, vtysh_exit_rmap_cmd, "exit", "Exit current mode and down to previous mode\n") @@ -2149,6 +2199,7 @@ DEFUNSH(VTYSH_RMAP, vtysh_quit_rmap, vtysh_quit_rmap_cmd, "quit", return vtysh_exit_rmap(self, vty, argc, argv); } +#ifdef HAVE_PBRD DEFUNSH(VTYSH_PBRD, vtysh_exit_pbr_map, vtysh_exit_pbr_map_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2160,7 +2211,9 @@ DEFUNSH(VTYSH_PBRD, vtysh_quit_pbr_map, vtysh_quit_pbr_map_cmd, "quit", { return vtysh_exit_rmap(self, vty, argc, argv); } +#endif /* HAVE_PBRD */ +#ifdef HAVE_BGPD DEFUNSH(VTYSH_BGPD, vtysh_exit_bgpd, vtysh_exit_bgpd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2172,7 +2225,9 @@ DEFUNSH(VTYSH_BGPD, vtysh_quit_bgpd, vtysh_quit_bgpd_cmd, "quit", { return vtysh_exit_bgpd(self, vty, argc, argv); } +#endif /* HAVE_BGPD */ +#ifdef HAVE_OSPFD DEFUNSH(VTYSH_OSPFD, vtysh_exit_ospfd, vtysh_exit_ospfd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2184,7 +2239,9 @@ DEFUNSH(VTYSH_OSPFD, vtysh_quit_ospfd, vtysh_quit_ospfd_cmd, "quit", { return vtysh_exit_ospfd(self, vty, argc, argv); } +#endif /* HAVE_OSPFD */ +#ifdef HAVE_EIGRPD DEFUNSH(VTYSH_EIGRPD, vtysh_exit_eigrpd, vtysh_exit_eigrpd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2196,7 +2253,9 @@ DEFUNSH(VTYSH_EIGRPD, vtysh_quit_eigrpd, vtysh_quit_eigrpd_cmd, "quit", { return vtysh_exit(vty); } +#endif /* HAVE_EIGRPD */ +#ifdef HAVE_BABELD DEFUNSH(VTYSH_BABELD, vtysh_exit_babeld, vtysh_exit_babeld_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2208,7 +2267,9 @@ DEFUNSH(VTYSH_BABELD, vtysh_quit_babeld, vtysh_quit_babeld_cmd, "quit", { return vtysh_exit(vty); } +#endif /* HAVE_BABELD */ +#ifdef HAVE_OSPF6D DEFUNSH(VTYSH_OSPF6D, vtysh_exit_ospf6d, vtysh_exit_ospf6d_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2220,6 +2281,7 @@ DEFUNSH(VTYSH_OSPF6D, vtysh_quit_ospf6d, vtysh_quit_ospf6d_cmd, "quit", { return vtysh_exit_ospf6d(self, vty, argc, argv); } +#endif /* HAVE_OSPF6D */ #if defined(HAVE_LDPD) DEFUNSH(VTYSH_LDPD, vtysh_exit_ldpd, vtysh_exit_ldpd_cmd, "exit", @@ -2232,6 +2294,7 @@ ALIAS(vtysh_exit_ldpd, vtysh_quit_ldpd_cmd, "quit", "Exit current mode and down to previous mode\n") #endif +#ifdef HAVE_ISISD DEFUNSH(VTYSH_ISISD, vtysh_exit_isisd, vtysh_exit_isisd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2243,6 +2306,7 @@ DEFUNSH(VTYSH_ISISD, vtysh_quit_isisd, vtysh_quit_isisd_cmd, "quit", { return vtysh_exit_isisd(self, vty, argc, argv); } +#endif /* HAVE_ISISD */ #if HAVE_BFDD > 0 DEFUNSH(VTYSH_BFDD, vtysh_exit_bfdd, vtysh_exit_bfdd_cmd, "exit", @@ -2255,6 +2319,7 @@ ALIAS(vtysh_exit_bfdd, vtysh_quit_bfdd_cmd, "quit", "Exit current mode and down to previous mode\n") #endif +#ifdef HAVE_FABRICD DEFUNSH(VTYSH_FABRICD, vtysh_exit_fabricd, vtysh_exit_fabricd_cmd, "exit", "Exit current mode and down to previous mode\n") { @@ -2266,6 +2331,7 @@ DEFUNSH(VTYSH_FABRICD, vtysh_quit_fabricd, vtysh_quit_fabricd_cmd, "quit", { return vtysh_exit_fabricd(self, vty, argc, argv); } +#endif /* HAVE_FABRICD */ DEFUNSH(VTYSH_KEYS, vtysh_exit_keys, vtysh_exit_keys_cmd, "exit", "Exit current mode and down to previous mode\n") @@ -3783,331 +3849,394 @@ void vtysh_init_vty(void) cmd_init(0); cmd_variable_handler_register(vtysh_var_handler); - /* Install nodes. */ + /* bgpd */ +#ifdef HAVE_BGPD install_node(&bgp_node); - install_node(&rip_node); - install_node(&interface_node); - install_node(&pw_node); - install_node(&link_params_node); - install_node(&vrf_node); - install_node(&nh_group_node); - install_node(&rmap_node); - install_node(&pbr_map_node); - install_node(&zebra_node); + install_element(CONFIG_NODE, &router_bgp_cmd); + install_element(BGP_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_NODE, &vtysh_end_all_cmd); + install_node(&bgp_vpnv4_node); + install_element(BGP_NODE, &address_family_ipv4_vpn_cmd); +#ifdef KEEP_OLD_VPN_COMMANDS + install_element(BGP_NODE, &address_family_vpnv4_cmd); +#endif /* KEEP_OLD_VPN_COMMANDS */ + install_element(BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VPNV4_NODE, &vtysh_end_all_cmd); + install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); + install_node(&bgp_vpnv6_node); + install_element(BGP_NODE, &address_family_ipv6_vpn_cmd); +#ifdef KEEP_OLD_VPN_COMMANDS + install_element(BGP_NODE, &address_family_vpnv6_cmd); +#endif /* KEEP_OLD_VPN_COMMANDS */ + install_element(BGP_VPNV6_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VPNV6_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VPNV6_NODE, &vtysh_end_all_cmd); + install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); + install_node(&bgp_flowspecv4_node); + install_element(BGP_NODE, &address_family_flowspecv4_cmd); + install_element(BGP_FLOWSPECV4_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_FLOWSPECV4_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_FLOWSPECV4_NODE, &vtysh_end_all_cmd); + install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); + install_node(&bgp_flowspecv6_node); + install_element(BGP_NODE, &address_family_flowspecv6_cmd); + install_element(BGP_FLOWSPECV6_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_FLOWSPECV6_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_FLOWSPECV6_NODE, &vtysh_end_all_cmd); + install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv4_node); + install_element(BGP_NODE, &address_family_ipv4_cmd); + install_element(BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV4_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV4_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv4m_node); + install_element(BGP_NODE, &address_family_ipv4_multicast_cmd); + install_element(BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV4M_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv4l_node); + install_element(BGP_NODE, &address_family_ipv4_labeled_unicast_cmd); + install_element(BGP_IPV4L_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV4L_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV4L_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv6_node); + install_element(BGP_NODE, &address_family_ipv6_cmd); + install_element(BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV6_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV6_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv6m_node); + install_element(BGP_NODE, &address_family_ipv6_multicast_cmd); + install_element(BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV6M_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); + install_node(&bgp_ipv6l_node); + install_element(BGP_NODE, &address_family_ipv6_labeled_unicast_cmd); + install_element(BGP_IPV6L_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_IPV6L_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_IPV6L_NODE, &vtysh_end_all_cmd); + install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); + +#if defined(ENABLE_BGP_VNC) install_node(&bgp_vrf_policy_node); - install_node(&bgp_evpn_node); - install_node(&bgp_evpn_vni_node); + install_element(BGP_NODE, &vnc_vrf_policy_cmd); + install_element(BGP_VRF_POLICY_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VRF_POLICY_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VRF_POLICY_NODE, &vtysh_end_all_cmd); + install_element(BGP_VRF_POLICY_NODE, &exit_vrf_policy_cmd); + install_node(&bgp_vnc_defaults_node); + install_element(BGP_NODE, &vnc_defaults_cmd); + install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_end_all_cmd); + install_element(BGP_VNC_DEFAULTS_NODE, &exit_vnc_config_cmd); + install_node(&bgp_vnc_nve_group_node); + install_element(BGP_NODE, &vnc_nve_group_cmd); + install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_end_all_cmd); + install_element(BGP_VNC_NVE_GROUP_NODE, &exit_vnc_config_cmd); + install_node(&bgp_vnc_l2_group_node); - install_node(&ospf_node); - install_node(&eigrp_node); - install_node(&babel_node); - install_node(&ripng_node); - install_node(&ospf6_node); - install_node(&ldp_node); - install_node(&ldp_ipv4_node); - install_node(&ldp_ipv6_node); - install_node(&ldp_ipv4_iface_node); - install_node(&ldp_ipv6_iface_node); - install_node(&ldp_l2vpn_node); - install_node(&ldp_pseudowire_node); - install_node(&keychain_node); - install_node(&keychain_key_node); - install_node(&isis_node); - install_node(&openfabric_node); - install_node(&vty_node); - install_node(&rpki_node); - install_node(&bmp_node); -#if HAVE_BFDD > 0 - install_node(&bfd_node); - install_node(&bfd_peer_node); - install_node(&bfd_profile_node); -#endif /* HAVE_BFDD */ + install_element(BGP_NODE, &vnc_l2_group_cmd); + install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_end_all_cmd); + install_element(BGP_VNC_L2_GROUP_NODE, &exit_vnc_config_cmd); +#endif - struct cmd_node *node; - for (unsigned int i = 0; i < vector_active(cmdvec); i++) { - node = vector_slot(cmdvec, i); - if (!node || node->node == VIEW_NODE) - continue; - vtysh_install_default(node->node); - } + install_node(&bgp_evpn_node); + install_element(BGP_NODE, &address_family_evpn_cmd); +#if defined(HAVE_CUMULUS) + install_element(BGP_NODE, &address_family_evpn2_cmd); +#endif + install_element(BGP_EVPN_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_EVPN_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_EVPN_NODE, &vtysh_end_all_cmd); + install_element(BGP_EVPN_NODE, &exit_address_family_cmd); - install_element(VIEW_NODE, &vtysh_enable_cmd); - install_element(ENABLE_NODE, &vtysh_config_terminal_cmd); - install_element(ENABLE_NODE, &vtysh_disable_cmd); + install_node(&bgp_evpn_vni_node); + install_element(BGP_EVPN_NODE, &bgp_evpn_vni_cmd); + install_element(BGP_EVPN_VNI_NODE, &vtysh_exit_bgpd_cmd); + install_element(BGP_EVPN_VNI_NODE, &vtysh_quit_bgpd_cmd); + install_element(BGP_EVPN_VNI_NODE, &vtysh_end_all_cmd); + install_element(BGP_EVPN_VNI_NODE, &exit_vni_cmd); - /* "exit" command. */ - install_element(VIEW_NODE, &vtysh_exit_all_cmd); - install_element(CONFIG_NODE, &vtysh_exit_all_cmd); - install_element(VIEW_NODE, &vtysh_quit_all_cmd); - install_element(CONFIG_NODE, &vtysh_quit_all_cmd); + install_node(&rpki_node); + install_element(CONFIG_NODE, &rpki_cmd); + install_element(RPKI_NODE, &rpki_exit_cmd); + install_element(RPKI_NODE, &rpki_quit_cmd); + install_element(RPKI_NODE, &vtysh_end_all_cmd); + + install_node(&bmp_node); + install_element(BGP_NODE, &bmp_targets_cmd); + install_element(BMP_NODE, &bmp_exit_cmd); + install_element(BMP_NODE, &bmp_quit_cmd); + install_element(BMP_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_BGPD */ + + /* ripd */ + install_node(&rip_node); +#ifdef HAVE_RIPD + install_element(CONFIG_NODE, &router_rip_cmd); install_element(RIP_NODE, &vtysh_exit_ripd_cmd); install_element(RIP_NODE, &vtysh_quit_ripd_cmd); + install_element(RIP_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_RIPD */ + + /* ripngd */ + install_node(&ripng_node); +#ifdef HAVE_RIPNGD + install_element(CONFIG_NODE, &router_ripng_cmd); install_element(RIPNG_NODE, &vtysh_exit_ripngd_cmd); install_element(RIPNG_NODE, &vtysh_quit_ripngd_cmd); + install_element(RIPNG_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_RIPNGD */ + + /* ospfd */ +#ifdef HAVE_OSPFD + install_node(&ospf_node); + install_element(CONFIG_NODE, &router_ospf_cmd); install_element(OSPF_NODE, &vtysh_exit_ospfd_cmd); install_element(OSPF_NODE, &vtysh_quit_ospfd_cmd); - install_element(EIGRP_NODE, &vtysh_exit_eigrpd_cmd); - install_element(EIGRP_NODE, &vtysh_quit_eigrpd_cmd); - install_element(BABEL_NODE, &vtysh_exit_babeld_cmd); - install_element(BABEL_NODE, &vtysh_quit_babeld_cmd); + install_element(OSPF_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_OSPFD */ + + /* ospf6d */ +#ifdef HAVE_OSPF6D + install_node(&ospf6_node); + install_element(CONFIG_NODE, &router_ospf6_cmd); install_element(OSPF6_NODE, &vtysh_exit_ospf6d_cmd); install_element(OSPF6_NODE, &vtysh_quit_ospf6d_cmd); + install_element(OSPF6_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_OSPF6D */ + + /* ldpd */ #if defined(HAVE_LDPD) + install_node(&ldp_node); + install_element(CONFIG_NODE, &ldp_mpls_ldp_cmd); install_element(LDP_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_NODE, &vtysh_quit_ldpd_cmd); + install_element(LDP_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_ipv4_node); + install_element(LDP_NODE, &ldp_address_family_ipv4_cmd); install_element(LDP_IPV4_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_IPV4_NODE, &vtysh_quit_ldpd_cmd); install_element(LDP_IPV4_NODE, &ldp_exit_address_family_cmd); + install_element(LDP_IPV4_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_ipv6_node); + install_element(LDP_NODE, &ldp_address_family_ipv6_cmd); install_element(LDP_IPV6_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_IPV6_NODE, &vtysh_quit_ldpd_cmd); install_element(LDP_IPV6_NODE, &ldp_exit_address_family_cmd); + install_element(LDP_IPV6_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_ipv4_iface_node); + install_element(LDP_IPV4_NODE, &ldp_interface_ifname_cmd); install_element(LDP_IPV4_IFACE_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_IPV4_IFACE_NODE, &vtysh_quit_ldpd_cmd); + install_element(LDP_IPV4_IFACE_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_ipv6_iface_node); + install_element(LDP_IPV6_NODE, &ldp_interface_ifname_cmd); install_element(LDP_IPV6_IFACE_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_IPV6_IFACE_NODE, &vtysh_quit_ldpd_cmd); + install_element(LDP_IPV6_IFACE_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_l2vpn_node); + install_element(CONFIG_NODE, &ldp_l2vpn_word_type_vpls_cmd); install_element(LDP_L2VPN_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_L2VPN_NODE, &vtysh_quit_ldpd_cmd); + install_element(LDP_L2VPN_NODE, &vtysh_end_all_cmd); + + install_node(&ldp_pseudowire_node); + install_element(LDP_L2VPN_NODE, &ldp_member_pseudowire_ifname_cmd); install_element(LDP_PSEUDOWIRE_NODE, &vtysh_exit_ldpd_cmd); install_element(LDP_PSEUDOWIRE_NODE, &vtysh_quit_ldpd_cmd); + install_element(LDP_PSEUDOWIRE_NODE, &vtysh_end_all_cmd); #endif - install_element(BGP_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_VPNV4_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VPNV4_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_VPNV6_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VPNV6_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_FLOWSPECV4_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_FLOWSPECV4_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_FLOWSPECV6_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_FLOWSPECV6_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV4_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV4_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV4M_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV4M_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV4L_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV4L_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV6_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV6_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV6M_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV6M_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_EVPN_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_EVPN_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_EVPN_VNI_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_EVPN_VNI_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_IPV6L_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_IPV6L_NODE, &vtysh_quit_bgpd_cmd); -#if defined(ENABLE_BGP_VNC) - install_element(BGP_VRF_POLICY_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VRF_POLICY_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_quit_bgpd_cmd); - install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_exit_bgpd_cmd); - install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_quit_bgpd_cmd); -#endif + + /* eigrpd */ +#ifdef HAVE_EIGRPD + install_node(&eigrp_node); + install_element(CONFIG_NODE, &router_eigrp_cmd); + install_element(EIGRP_NODE, &vtysh_exit_eigrpd_cmd); + install_element(EIGRP_NODE, &vtysh_quit_eigrpd_cmd); + install_element(EIGRP_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_EIGRPD */ + + /* babeld */ +#ifdef HAVE_BABELD + install_node(&babel_node); + install_element(CONFIG_NODE, &router_babel_cmd); + install_element(BABEL_NODE, &vtysh_exit_babeld_cmd); + install_element(BABEL_NODE, &vtysh_quit_babeld_cmd); + install_element(BABEL_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_BABELD */ + + /* isisd */ +#ifdef HAVE_ISISD + install_node(&isis_node); + install_element(CONFIG_NODE, &router_isis_cmd); install_element(ISIS_NODE, &vtysh_exit_isisd_cmd); install_element(ISIS_NODE, &vtysh_quit_isisd_cmd); + install_element(ISIS_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_ISISD */ + + /* fabricd */ +#ifdef HAVE_FABRICD + install_node(&openfabric_node); + install_element(CONFIG_NODE, &router_openfabric_cmd); install_element(OPENFABRIC_NODE, &vtysh_exit_fabricd_cmd); install_element(OPENFABRIC_NODE, &vtysh_quit_fabricd_cmd); - install_element(KEYCHAIN_NODE, &vtysh_exit_keys_cmd); - install_element(KEYCHAIN_NODE, &vtysh_quit_keys_cmd); - install_element(KEYCHAIN_KEY_NODE, &vtysh_exit_keys_cmd); - install_element(KEYCHAIN_KEY_NODE, &vtysh_quit_keys_cmd); - install_element(RMAP_NODE, &vtysh_exit_rmap_cmd); - install_element(RMAP_NODE, &vtysh_quit_rmap_cmd); + install_element(OPENFABRIC_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_FABRICD */ + + /* pbrd */ +#ifdef HAVE_PBRD + install_node(&pbr_map_node); + install_element(CONFIG_NODE, &vtysh_pbr_map_cmd); + install_element(CONFIG_NODE, &vtysh_no_pbr_map_cmd); install_element(PBRMAP_NODE, &vtysh_exit_pbr_map_cmd); install_element(PBRMAP_NODE, &vtysh_quit_pbr_map_cmd); + install_element(PBRMAP_NODE, &vtysh_end_all_cmd); +#endif /* HAVE_PBRD */ + + /* bfdd */ #if HAVE_BFDD > 0 - /* Enter node. */ + install_node(&bfd_node); install_element(CONFIG_NODE, &bfd_enter_cmd); - install_element(BFD_NODE, &bfd_peer_enter_cmd); - install_element(BFD_NODE, &bfd_profile_enter_cmd); - - /* Exit/quit node. */ install_element(BFD_NODE, &vtysh_exit_bfdd_cmd); install_element(BFD_NODE, &vtysh_quit_bfdd_cmd); + install_element(BFD_NODE, &vtysh_end_all_cmd); + + install_node(&bfd_peer_node); + install_element(BFD_NODE, &bfd_peer_enter_cmd); install_element(BFD_PEER_NODE, &vtysh_exit_bfdd_cmd); install_element(BFD_PEER_NODE, &vtysh_quit_bfdd_cmd); + install_element(BFD_PEER_NODE, &vtysh_end_all_cmd); + + install_node(&bfd_profile_node); + install_element(BFD_NODE, &bfd_profile_enter_cmd); install_element(BFD_PROFILE_NODE, &vtysh_exit_bfdd_cmd); install_element(BFD_PROFILE_NODE, &vtysh_quit_bfdd_cmd); - - /* End/exit all. */ - install_element(BFD_NODE, &vtysh_end_all_cmd); - install_element(BFD_PEER_NODE, &vtysh_end_all_cmd); install_element(BFD_PROFILE_NODE, &vtysh_end_all_cmd); #endif /* HAVE_BFDD */ - install_element(VTY_NODE, &vtysh_exit_line_vty_cmd); - install_element(VTY_NODE, &vtysh_quit_line_vty_cmd); - /* "end" command. */ - install_element(CONFIG_NODE, &vtysh_end_all_cmd); - install_element(ENABLE_NODE, &vtysh_end_all_cmd); - install_element(RIP_NODE, &vtysh_end_all_cmd); - install_element(RIPNG_NODE, &vtysh_end_all_cmd); - install_element(OSPF_NODE, &vtysh_end_all_cmd); - install_element(EIGRP_NODE, &vtysh_end_all_cmd); - install_element(BABEL_NODE, &vtysh_end_all_cmd); - install_element(OSPF6_NODE, &vtysh_end_all_cmd); - install_element(LDP_NODE, &vtysh_end_all_cmd); - install_element(LDP_IPV4_NODE, &vtysh_end_all_cmd); - install_element(LDP_IPV6_NODE, &vtysh_end_all_cmd); - install_element(LDP_IPV4_IFACE_NODE, &vtysh_end_all_cmd); - install_element(LDP_IPV6_IFACE_NODE, &vtysh_end_all_cmd); - install_element(LDP_L2VPN_NODE, &vtysh_end_all_cmd); - install_element(LDP_PSEUDOWIRE_NODE, &vtysh_end_all_cmd); - install_element(BGP_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV4_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV4M_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV4L_NODE, &vtysh_end_all_cmd); - install_element(BGP_VPNV4_NODE, &vtysh_end_all_cmd); - install_element(BGP_VPNV6_NODE, &vtysh_end_all_cmd); - install_element(BGP_FLOWSPECV4_NODE, &vtysh_end_all_cmd); - install_element(BGP_FLOWSPECV6_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV6_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV6M_NODE, &vtysh_end_all_cmd); - install_element(BGP_IPV6L_NODE, &vtysh_end_all_cmd); - install_element(BGP_VRF_POLICY_NODE, &vtysh_end_all_cmd); - install_element(BGP_EVPN_NODE, &vtysh_end_all_cmd); - install_element(BGP_EVPN_VNI_NODE, &vtysh_end_all_cmd); - install_element(BGP_VNC_DEFAULTS_NODE, &vtysh_end_all_cmd); - install_element(BGP_VNC_NVE_GROUP_NODE, &vtysh_end_all_cmd); - install_element(BGP_VNC_L2_GROUP_NODE, &vtysh_end_all_cmd); - install_element(ISIS_NODE, &vtysh_end_all_cmd); - install_element(OPENFABRIC_NODE, &vtysh_end_all_cmd); + /* keychain */ + install_node(&keychain_node); + install_element(CONFIG_NODE, &key_chain_cmd); + install_element(KEYCHAIN_NODE, &key_chain_cmd); + install_element(KEYCHAIN_NODE, &vtysh_exit_keys_cmd); + install_element(KEYCHAIN_NODE, &vtysh_quit_keys_cmd); install_element(KEYCHAIN_NODE, &vtysh_end_all_cmd); + + install_node(&keychain_key_node); + install_element(KEYCHAIN_NODE, &key_cmd); + install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd); + install_element(KEYCHAIN_KEY_NODE, &vtysh_exit_keys_cmd); + install_element(KEYCHAIN_KEY_NODE, &vtysh_quit_keys_cmd); install_element(KEYCHAIN_KEY_NODE, &vtysh_end_all_cmd); - install_element(RMAP_NODE, &vtysh_end_all_cmd); - install_element(PBRMAP_NODE, &vtysh_end_all_cmd); - install_element(VTY_NODE, &vtysh_end_all_cmd); + /* nexthop-group */ + install_node(&nh_group_node); + install_element(CONFIG_NODE, &vtysh_nexthop_group_cmd); + install_element(CONFIG_NODE, &vtysh_no_nexthop_group_cmd); + install_element(NH_GROUP_NODE, &vtysh_end_all_cmd); + install_element(NH_GROUP_NODE, &vtysh_exit_nexthop_group_cmd); + install_element(NH_GROUP_NODE, &vtysh_quit_nexthop_group_cmd); + + /* zebra and all */ + install_node(&zebra_node); + + install_node(&interface_node); + install_element(CONFIG_NODE, &vtysh_interface_cmd); install_element(INTERFACE_NODE, &vtysh_end_all_cmd); install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd); + install_element(INTERFACE_NODE, &vtysh_quit_interface_cmd); + + install_node(&link_params_node); + install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(LINK_PARAMS_NODE, &exit_link_params_cmd); install_element(LINK_PARAMS_NODE, &vtysh_end_all_cmd); install_element(LINK_PARAMS_NODE, &vtysh_exit_interface_cmd); - install_element(INTERFACE_NODE, &vtysh_quit_interface_cmd); + install_node(&pw_node); + install_element(CONFIG_NODE, &vtysh_pseudowire_cmd); install_element(PW_NODE, &vtysh_end_all_cmd); install_element(PW_NODE, &vtysh_exit_interface_cmd); install_element(PW_NODE, &vtysh_quit_interface_cmd); - install_element(CONFIG_NODE, &vtysh_nexthop_group_cmd); - install_element(NH_GROUP_NODE, &vtysh_end_all_cmd); - install_element(NH_GROUP_NODE, &vtysh_exit_nexthop_group_cmd); - install_element(NH_GROUP_NODE, &vtysh_quit_nexthop_group_cmd); - + install_node(&vrf_node); + install_element(CONFIG_NODE, &vtysh_vrf_cmd); + install_element(VRF_NODE, &vtysh_vrf_netns_cmd); + install_element(VRF_NODE, &vtysh_no_vrf_netns_cmd); + install_element(VRF_NODE, &exit_vrf_config_cmd); install_element(VRF_NODE, &vtysh_end_all_cmd); install_element(VRF_NODE, &vtysh_exit_vrf_cmd); install_element(VRF_NODE, &vtysh_quit_vrf_cmd); + + install_node(&rmap_node); + install_element(CONFIG_NODE, &vtysh_route_map_cmd); + install_element(RMAP_NODE, &vtysh_exit_rmap_cmd); + install_element(RMAP_NODE, &vtysh_quit_rmap_cmd); + install_element(RMAP_NODE, &vtysh_end_all_cmd); - install_element(CONFIG_NODE, &router_eigrp_cmd); - install_element(CONFIG_NODE, &router_babel_cmd); - install_element(CONFIG_NODE, &router_rip_cmd); - install_element(CONFIG_NODE, &router_ripng_cmd); - install_element(CONFIG_NODE, &router_ospf_cmd); - install_element(CONFIG_NODE, &router_ospf6_cmd); -#if defined(HAVE_LDPD) - install_element(CONFIG_NODE, &ldp_mpls_ldp_cmd); - install_element(LDP_NODE, &ldp_address_family_ipv4_cmd); - install_element(LDP_NODE, &ldp_address_family_ipv6_cmd); - install_element(LDP_IPV4_NODE, &ldp_interface_ifname_cmd); - install_element(LDP_IPV6_NODE, &ldp_interface_ifname_cmd); - install_element(CONFIG_NODE, &ldp_l2vpn_word_type_vpls_cmd); - install_element(LDP_L2VPN_NODE, &ldp_member_pseudowire_ifname_cmd); -#endif - install_element(CONFIG_NODE, &router_isis_cmd); - install_element(CONFIG_NODE, &router_openfabric_cmd); - install_element(CONFIG_NODE, &router_bgp_cmd); -#ifdef KEEP_OLD_VPN_COMMANDS - install_element(BGP_NODE, &address_family_vpnv4_cmd); - install_element(BGP_NODE, &address_family_vpnv6_cmd); -#endif /* KEEP_OLD_VPN_COMMANDS */ -#if defined(ENABLE_BGP_VNC) - install_element(BGP_NODE, &vnc_vrf_policy_cmd); - install_element(BGP_NODE, &vnc_defaults_cmd); - install_element(BGP_NODE, &vnc_nve_group_cmd); - install_element(BGP_NODE, &vnc_l2_group_cmd); -#endif - install_element(BGP_NODE, &address_family_ipv4_cmd); - install_element(BGP_NODE, &address_family_ipv4_multicast_cmd); - install_element(BGP_NODE, &address_family_ipv4_vpn_cmd); - install_element(BGP_NODE, &address_family_ipv4_labeled_unicast_cmd); - install_element(BGP_NODE, &address_family_ipv6_cmd); - install_element(BGP_NODE, &address_family_ipv6_multicast_cmd); - install_element(BGP_NODE, &address_family_ipv6_vpn_cmd); - install_element(BGP_NODE, &address_family_ipv6_labeled_unicast_cmd); - install_element(BGP_NODE, &address_family_evpn_cmd); - install_element(BGP_NODE, &address_family_flowspecv4_cmd); - install_element(BGP_NODE, &address_family_flowspecv6_cmd); -#if defined(HAVE_CUMULUS) - install_element(BGP_NODE, &address_family_evpn2_cmd); -#endif - install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); - install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); - install_element(BGP_IPV4_NODE, &exit_address_family_cmd); - install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); - install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); - install_element(BGP_IPV6_NODE, &exit_address_family_cmd); - install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); - install_element(BGP_EVPN_NODE, &exit_address_family_cmd); - install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); - install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); - install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); + install_node(&vty_node); + install_element(CONFIG_NODE, &vtysh_line_vty_cmd); + install_element(VTY_NODE, &vtysh_exit_line_vty_cmd); + install_element(VTY_NODE, &vtysh_quit_line_vty_cmd); + install_element(VTY_NODE, &vtysh_end_all_cmd); - install_element(BGP_NODE, &bmp_targets_cmd); - install_element(BMP_NODE, &bmp_exit_cmd); - install_element(BMP_NODE, &bmp_quit_cmd); - install_element(BMP_NODE, &vtysh_end_all_cmd); - install_element(CONFIG_NODE, &rpki_cmd); - install_element(RPKI_NODE, &rpki_exit_cmd); - install_element(RPKI_NODE, &rpki_quit_cmd); - install_element(RPKI_NODE, &vtysh_end_all_cmd); + struct cmd_node *node; + for (unsigned int i = 0; i < vector_active(cmdvec); i++) { + node = vector_slot(cmdvec, i); + if (!node || node->node == VIEW_NODE) + continue; + vtysh_install_default(node->node); + } - /* EVPN commands */ - install_element(BGP_EVPN_NODE, &bgp_evpn_vni_cmd); - install_element(BGP_EVPN_VNI_NODE, &exit_vni_cmd); + /* vtysh */ - install_element(BGP_VRF_POLICY_NODE, &exit_vrf_policy_cmd); - install_element(BGP_VNC_DEFAULTS_NODE, &exit_vnc_config_cmd); - install_element(BGP_VNC_NVE_GROUP_NODE, &exit_vnc_config_cmd); - install_element(BGP_VNC_L2_GROUP_NODE, &exit_vnc_config_cmd); + install_element(VIEW_NODE, &vtysh_enable_cmd); + install_element(ENABLE_NODE, &vtysh_config_terminal_cmd); + install_element(ENABLE_NODE, &vtysh_disable_cmd); + + /* "exit" command. */ + install_element(VIEW_NODE, &vtysh_exit_all_cmd); + install_element(CONFIG_NODE, &vtysh_exit_all_cmd); + install_element(VIEW_NODE, &vtysh_quit_all_cmd); + install_element(CONFIG_NODE, &vtysh_quit_all_cmd); + + /* "end" command. */ + install_element(CONFIG_NODE, &vtysh_end_all_cmd); + install_element(ENABLE_NODE, &vtysh_end_all_cmd); - install_element(CONFIG_NODE, &key_chain_cmd); - install_element(CONFIG_NODE, &vtysh_route_map_cmd); - install_element(CONFIG_NODE, &vtysh_pbr_map_cmd); - install_element(CONFIG_NODE, &vtysh_no_pbr_map_cmd); - install_element(CONFIG_NODE, &vtysh_line_vty_cmd); - install_element(KEYCHAIN_NODE, &key_cmd); - install_element(KEYCHAIN_NODE, &key_chain_cmd); - install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd); - install_element(CONFIG_NODE, &vtysh_interface_cmd); - install_element(CONFIG_NODE, &vtysh_pseudowire_cmd); - install_element(INTERFACE_NODE, &vtysh_link_params_cmd); install_element(ENABLE_NODE, &vtysh_show_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd); install_element(ENABLE_NODE, &vtysh_copy_to_running_cmd); - install_element(CONFIG_NODE, &vtysh_vrf_cmd); - install_element(VRF_NODE, &vtysh_vrf_netns_cmd); - install_element(VRF_NODE, &vtysh_no_vrf_netns_cmd); - install_element(VRF_NODE, &exit_vrf_config_cmd); - - install_element(CONFIG_NODE, &vtysh_no_nexthop_group_cmd); - /* "write terminal" command. */ install_element(ENABLE_NODE, &vtysh_write_terminal_cmd); diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 6aa9ba0ebc..de79c59caa 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1823,13 +1823,13 @@ static int nexthop_active(afi_t afi, struct route_entry *re, if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) { ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); if (!ifp) { - if (IS_ZEBRA_DEBUG_NHG_DETAIL) + if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug("nexthop %pNHv marked onlink but nhif %u doesn't exist", nexthop, nexthop->ifindex); return 0; } if (!if_is_operative(ifp)) { - if (IS_ZEBRA_DEBUG_NHG_DETAIL) + if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug("nexthop %pNHv marked onlink but nhif %s is not operational", nexthop, ifp->name); return 0; @@ -1985,6 +1985,11 @@ static int nexthop_active(afi_t afi, struct route_entry *re, || nexthop->type == NEXTHOP_TYPE_IPV6) nexthop->ifindex = newhop->ifindex; else if (nexthop->ifindex != newhop->ifindex) { + if (IS_ZEBRA_DEBUG_RIB_DETAILED) + zlog_debug( + "%s: %pNHv given ifindex does not match nexthops ifindex found found: %pNHv", + __func__, nexthop, + newhop); /* * NEXTHOP_TYPE_*_IFINDEX but ifindex * doesn't match what we found. @@ -2006,7 +2011,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re, /* Only useful if installed */ if (!CHECK_FLAG(match->status, ROUTE_ENTRY_INSTALLED)) { - if (IS_ZEBRA_DEBUG_NHG_DETAIL) + if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug("%s: match %p (%u) not installed", __func__, match, match->nhe->id); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 61498973e9..d8ed58edef 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -4594,6 +4594,11 @@ int zebra_vxlan_if_down(struct interface *ifp) assert(zevpn->vxlan_if == ifp); + /* remove from l3-vni list */ + zl3vni = zl3vni_from_vrf(zevpn->vrf_id); + if (zl3vni) + listnode_delete(zl3vni->l2vnis, zevpn); + /* Delete this VNI from BGP. */ zebra_evpn_send_del_to_client(zevpn); @@ -4668,7 +4673,7 @@ int zebra_vxlan_if_up(struct interface *ifp) zevpn->vrf_id = vlan_if->vrf_id; zl3vni = zl3vni_from_vrf(vlan_if->vrf_id); if (zl3vni) - listnode_add_sort(zl3vni->l2vnis, zevpn); + listnode_add_sort_nodup(zl3vni->l2vnis, zevpn); } /* If part of a bridge, inform BGP about this VNI. */ @@ -5007,7 +5012,7 @@ int zebra_vxlan_if_add(struct interface *ifp) zevpn->vrf_id = vlan_if->vrf_id; zl3vni = zl3vni_from_vrf(vlan_if->vrf_id); if (zl3vni) - listnode_add_sort(zl3vni->l2vnis, zevpn); + listnode_add_sort_nodup(zl3vni->l2vnis, zevpn); } if (IS_ZEBRA_DEBUG_VXLAN) { |
