ospfd: Fix MI-OSPF configuraton clis

Multi-Instance OSPF configuration CLI would fail because
first client return error upon seeing qobj_index being 0.
With new marco generate new error code to return from each
instance (vtysh client) and if the command is intended for given
instance, its qobj_index would be nonzero and process the command
and push correct ospf context. Other instance would return the error.
On vtysh end, check all instance return an error log a message to a
file.

Testing Done:
Verfied various MI-OSPF configuration CLI with multi instances.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
Chirag Shah 2017-08-03 16:34:17 -07:00
parent ef8482267d
commit a3d826f0ea
6 changed files with 103 additions and 86 deletions

View File

@ -181,6 +181,7 @@ struct cmd_node {
#define CMD_ERR_NO_FILE 11
#define CMD_SUSPEND 12
#define CMD_WARNING_CONFIG_FAILED 13
#define CMD_NOT_MY_INSTANCE 14
/* Argc max counts. */
#define CMD_ARGC_MAX 25

View File

@ -166,6 +166,11 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
#define VTY_DECLVAR_CONTEXT_SUB(structname, ptr) \
struct structname *ptr = VTY_GET_CONTEXT_SUB(structname); \
VTY_CHECK_CONTEXT(ptr);
#define VTY_DECLVAR_INSTANCE_CONTEXT(structname, ptr) \
if (vty->qobj_index == 0) \
return CMD_NOT_MY_INSTANCE; \
struct structname *ptr = VTY_GET_CONTEXT(structname); \
VTY_CHECK_CONTEXT(ptr);
struct vty_arg {
const char *name;

View File

@ -750,7 +750,7 @@ DEFUN (capability_opaque,
"Enable specific OSPF feature\n"
"Opaque LSA\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
/* Turn on the "master switch" of opaque-lsa capability. */
if (!CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE)) {
@ -779,7 +779,7 @@ DEFUN (no_capability_opaque,
"Enable specific OSPF feature\n"
"Opaque LSA\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
/* Turn off the "master switch" of opaque-lsa capability. */
if (CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE)) {

View File

@ -2179,7 +2179,7 @@ DEFUN (ospf_mpls_te_on,
MPLS_TE_STR
"Enable the MPLS-TE functionality\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *node;
struct mpls_te_link *lp;
@ -2215,7 +2215,7 @@ DEFUN (no_ospf_mpls_te,
MPLS_TE_STR
"Disable the MPLS-TE functionality\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *node, *nnode;
struct mpls_te_link *lp;
@ -2242,7 +2242,7 @@ DEFUN (ospf_mpls_te_router_addr,
"Stable IP address of the advertising router\n"
"MPLS-TE router address in IPv4 address format\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr;
struct in_addr value;

View File

@ -191,7 +191,7 @@ DEFUN (ospf_router_id,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct listnode *node;
struct ospf_area *area;
@ -225,7 +225,7 @@ DEFUN_HIDDEN (ospf_router_id_old,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 1;
struct listnode *node;
struct ospf_area *area;
@ -261,7 +261,7 @@ DEFUN (no_ospf_router_id,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *node;
struct ospf_area *area;
@ -350,7 +350,7 @@ DEFUN (ospf_passive_interface,
"IPv4 address\n"
"Suppress routing updates on interfaces by default\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct interface *ifp;
struct in_addr addr = {.s_addr = INADDR_ANY};
@ -417,7 +417,7 @@ DEFUN (no_ospf_passive_interface,
"IPv4 address\n"
"Allow routing updates on interfaces by default\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 3;
struct interface *ifp;
struct in_addr addr = {.s_addr = INADDR_ANY};
@ -478,7 +478,7 @@ DEFUN (ospf_network_area,
"OSPF area ID in IP address format\n"
"OSPF area ID as a decimal value\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_prefixlen = 1;
int idx_ipv4_number = 3;
struct prefix_ipv4 p;
@ -520,7 +520,7 @@ DEFUN (no_ospf_network_area,
"OSPF area ID in IP address format\n"
"OSPF area ID as a decimal value\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_prefixlen = 2;
int idx_ipv4_number = 4;
struct prefix_ipv4 p;
@ -559,7 +559,7 @@ DEFUN (ospf_area_range,
"User specified metric for this range\n"
"Advertised metric for this range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_cost = 6;
@ -591,7 +591,7 @@ DEFUN (ospf_area_range_cost,
"User specified metric for this range\n"
"Advertised metric for this range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_cost = 5;
@ -623,7 +623,7 @@ DEFUN (ospf_area_range_not_advertise,
"Area range prefix\n"
"DoNotAdvertise this range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
struct prefix_ipv4 p;
@ -656,7 +656,7 @@ DEFUN (no_ospf_area_range,
"Advertised metric for this range\n"
"DoNotAdvertise this range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_ipv4_prefixlen = 4;
struct prefix_ipv4 p;
@ -682,7 +682,7 @@ DEFUN (ospf_area_range_substitute,
"Announce area range as another prefix\n"
"Network prefix to be announced instead of range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_ipv4_prefixlen_2 = 5;
@ -713,7 +713,7 @@ DEFUN (no_ospf_area_range_substitute,
"Announce area range as another prefix\n"
"Network prefix to be announced instead of range\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_ipv4_prefixlen = 4;
int idx_ipv4_prefixlen_2 = 6;
@ -981,7 +981,7 @@ DEFUN (ospf_area_vlink,
"Use MD5 algorithm\n" \
"The OSPF password (key)")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4 = 3;
struct ospf_vl_config_data vl_config;
@ -1105,7 +1105,7 @@ DEFUN (no_ospf_area_vlink,
"Use MD5 algorithm\n" \
"The OSPF password (key)")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_ipv4 = 4;
struct ospf_area *area;
@ -1204,7 +1204,7 @@ DEFUN (ospf_area_vlink_intervals,
VLINK_HELPSTR_IPADDR
VLINK_HELPSTR_TIME_PARAM)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct ospf_vl_config_data vl_config;
int ret = 0;
@ -1251,7 +1251,7 @@ DEFUN (no_ospf_area_vlink_intervals,
VLINK_HELPSTR_IPADDR
VLINK_HELPSTR_TIME_PARAM)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct ospf_vl_config_data vl_config;
int ret = 0;
@ -1300,7 +1300,7 @@ DEFUN (ospf_area_shortcut,
"Enable shortcutting through the area\n"
"Disable shortcutting through the area\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_enable_disable = 3;
struct ospf_area *area;
@ -1344,7 +1344,7 @@ DEFUN (no_ospf_area_shortcut,
"Deconfigure enabled shortcutting through the area\n"
"Deconfigure disabled shortcutting through the area\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct ospf_area *area;
struct in_addr area_id;
@ -1371,7 +1371,7 @@ DEFUN (ospf_area_stub,
"OSPF area ID as a decimal value\n"
"Configure OSPF area as stub\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct in_addr area_id;
int ret, format;
@ -1402,7 +1402,7 @@ DEFUN (ospf_area_stub_no_summary,
"Configure OSPF area as stub\n"
"Do not inject inter-area routes into stub\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct in_addr area_id;
int ret, format;
@ -1433,7 +1433,7 @@ DEFUN (no_ospf_area_stub,
"OSPF area ID as a decimal value\n"
"Configure OSPF area as stub\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct in_addr area_id;
int format;
@ -1457,7 +1457,7 @@ DEFUN (no_ospf_area_stub_no_summary,
"Configure OSPF area as stub\n"
"Do not inject inter-area routes into area\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct in_addr area_id;
int format;
@ -1472,7 +1472,7 @@ DEFUN (no_ospf_area_stub_no_summary,
static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc,
struct cmd_token **argv, int nosum)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct in_addr area_id;
int ret, format;
@ -1577,7 +1577,7 @@ DEFUN (no_ospf_area_nssa,
"Configure NSSA-ABR to always translate\n"
"Do not inject inter-area routes into nssa\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct in_addr area_id;
int format;
@ -1603,7 +1603,7 @@ DEFUN (ospf_area_default_cost,
"Set the summary-default cost of a NSSA or stub area\n"
"Stub's advertised default summary cost\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_number = 3;
struct ospf_area *area;
@ -1649,7 +1649,7 @@ DEFUN (no_ospf_area_default_cost,
"Set the summary-default cost of a NSSA or stub area\n"
"Stub's advertised default summary cost\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct ospf_area *area;
struct in_addr area_id;
@ -1695,7 +1695,7 @@ DEFUN (ospf_area_export_list,
"Set the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct ospf_area *area;
struct in_addr area_id;
@ -1720,7 +1720,7 @@ DEFUN (no_ospf_area_export_list,
"Unset the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct ospf_area *area;
struct in_addr area_id;
@ -1747,7 +1747,7 @@ DEFUN (ospf_area_import_list,
"Set the filter for networks from other areas announced to the specified one\n"
"Name of the access-list\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct ospf_area *area;
struct in_addr area_id;
@ -1772,7 +1772,7 @@ DEFUN (no_ospf_area_import_list,
"Unset the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct ospf_area *area;
struct in_addr area_id;
@ -1801,7 +1801,7 @@ DEFUN (ospf_area_filter_list,
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_word = 4;
int idx_in_out = 5;
@ -1847,7 +1847,7 @@ DEFUN (no_ospf_area_filter_list,
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_word = 5;
int idx_in_out = 6;
@ -1901,7 +1901,7 @@ DEFUN (ospf_area_authentication_message_digest,
"Enable authentication\n"
"Use message-digest authentication\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct ospf_area *area;
struct in_addr area_id;
@ -1924,7 +1924,7 @@ DEFUN (ospf_area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
struct ospf_area *area;
struct in_addr area_id;
@ -1948,7 +1948,7 @@ DEFUN (no_ospf_area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
struct ospf_area *area;
struct in_addr area_id;
@ -1978,7 +1978,7 @@ DEFUN (ospf_abr_type,
"Shortcut ABR\n"
"Standard behavior (RFC2328)\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_vendor = 2;
u_char abr_type = OSPF_ABR_UNKNOWN;
@ -2013,7 +2013,7 @@ DEFUN (no_ospf_abr_type,
"Shortcut ABR\n"
"Standard ABR\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_vendor = 3;
u_char abr_type = OSPF_ABR_UNKNOWN;
@ -2042,7 +2042,7 @@ DEFUN (ospf_log_adjacency_changes,
"log-adjacency-changes",
"Log changes in adjacency state\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
@ -2055,7 +2055,7 @@ DEFUN (ospf_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
@ -2068,7 +2068,7 @@ DEFUN (no_ospf_log_adjacency_changes,
NO_STR
"Log changes in adjacency state\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
@ -2082,7 +2082,7 @@ DEFUN (no_ospf_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
return CMD_SUCCESS;
@ -2094,7 +2094,7 @@ DEFUN (ospf_compatible_rfc1583,
"OSPF compatibility list\n"
"compatible with RFC 1583\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
if (!CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) {
SET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE);
@ -2110,7 +2110,7 @@ DEFUN (no_ospf_compatible_rfc1583,
"OSPF compatibility list\n"
"compatible with RFC 1583\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
if (CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) {
UNSET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE);
@ -2132,7 +2132,7 @@ ALIAS(no_ospf_compatible_rfc1583, no_ospf_rfc1583_flag_cmd,
static int ospf_timers_spf_set(struct vty *vty, unsigned int delay,
unsigned int hold, unsigned int max)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->spf_delay = delay;
ospf->spf_holdtime = hold;
@ -2150,7 +2150,7 @@ DEFUN (ospf_timers_min_ls_interval,
"All LSA types\n"
"Delay (msec) between sending LSAs\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 4;
unsigned int interval;
@ -2176,7 +2176,7 @@ DEFUN (no_ospf_timers_min_ls_interval,
"All LSA types\n"
"Delay (msec) between sending LSAs\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
return CMD_SUCCESS;
@ -2191,7 +2191,7 @@ DEFUN (ospf_timers_min_ls_arrival,
"OSPF minimum arrival interval delay\n"
"Delay (msec) between accepted LSAs\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int arrival;
@ -2216,7 +2216,7 @@ DEFUN (no_ospf_timers_min_ls_arrival,
"OSPF minimum arrival interval delay\n"
"Delay (msec) between accepted LSAs\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
@ -2276,7 +2276,7 @@ DEFUN (ospf_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int minarrival;
@ -2301,7 +2301,7 @@ DEFUN (no_ospf_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
unsigned int minarrival;
if (argc > 4) {
@ -2327,7 +2327,7 @@ DEFUN (ospf_neighbor,
"Dead Neighbor Polling interval\n"
"Seconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 1;
int idx_pri = 3;
int idx_poll = 5;
@ -2364,7 +2364,7 @@ DEFUN (ospf_neighbor_poll_interval,
"OSPF priority of non-broadcast neighbor\n"
"Priority\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 1;
int idx_poll = 3;
int idx_pri = 5;
@ -2399,7 +2399,7 @@ DEFUN (no_ospf_neighbor,
"Dead Neighbor Polling interval\n"
"Seconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct in_addr nbr_addr;
@ -2421,7 +2421,7 @@ DEFUN (no_ospf_neighbor_poll,
"Neighbor Priority\n"
"Priority\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct in_addr nbr_addr;
@ -2439,7 +2439,7 @@ DEFUN (ospf_refresh_timer,
"Set refresh timer\n"
"Timer value in seconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 2;
unsigned int interval;
@ -2460,7 +2460,7 @@ DEFUN (no_ospf_refresh_timer,
"Unset refresh timer\n"
"Timer value in seconds\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int interval;
@ -2485,7 +2485,7 @@ DEFUN (ospf_auto_cost_reference_bandwidth,
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 2;
u_int32_t refbw;
struct listnode *node;
@ -2516,7 +2516,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *node, *nnode;
struct interface *ifp;
@ -2541,7 +2541,7 @@ DEFUN (ospf_write_multiplier,
"Write multiplier\n"
"Maximum number of interface serviced per write\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number;
u_int32_t write_oi_count;
@ -2572,7 +2572,7 @@ DEFUN (no_ospf_write_multiplier,
"Write multiplier\n"
"Maximum number of interface serviced per write\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
return CMD_SUCCESS;
@ -7038,7 +7038,7 @@ DEFUN (ospf_redistribute_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_protocol = 1;
int source;
int type = -1;
@ -7088,7 +7088,7 @@ DEFUN (no_ospf_redistribute_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_protocol = 2;
int source;
struct ospf_redist *red;
@ -7119,7 +7119,7 @@ DEFUN (ospf_redistribute_instance_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ospf_table = 1;
int idx_number = 2;
int idx = 3;
@ -7187,7 +7187,7 @@ DEFUN (no_ospf_redistribute_instance_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_ospf_table = 2;
int idx_number = 3;
u_int instance;
@ -7228,7 +7228,7 @@ DEFUN (ospf_distribute_list_out,
OUT_STR
FRR_REDIST_HELP_STR_OSPFD)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_word = 1;
int source;
@ -7251,7 +7251,7 @@ DEFUN (no_ospf_distribute_list_out,
OUT_STR
FRR_REDIST_HELP_STR_OSPFD)
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_word = 2;
int source;
@ -7278,7 +7278,7 @@ DEFUN (ospf_default_information_originate,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int default_originate = DEFAULT_ORIGINATE_ZEBRA;
int type = -1;
int metric = -1;
@ -7324,7 +7324,7 @@ DEFUN (no_ospf_default_information_originate,
"Route map reference\n"
"Pointer to route-map entries\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct prefix_ipv4 p;
struct ospf_external *ext;
struct ospf_redist *red;
@ -7355,7 +7355,7 @@ DEFUN (ospf_default_metric,
"Set metric of redistributed routes\n"
"Default metric\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 1;
int metric = -1;
@ -7374,7 +7374,7 @@ DEFUN (no_ospf_default_metric,
"Set metric of redistributed routes\n"
"Default metric\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->default_metric = -1;
@ -7388,7 +7388,7 @@ DEFUN (ospf_distance,
"Administrative distance\n"
"OSPF Administrative distance\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 1;
ospf->distance_all = atoi(argv[idx_number]->arg);
@ -7403,7 +7403,7 @@ DEFUN (no_ospf_distance,
"Administrative distance\n"
"OSPF Administrative distance\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->distance_all = 0;
@ -7423,7 +7423,7 @@ DEFUN (no_ospf_distance_ospf,
"External routes\n"
"Distance for external routes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx = 0;
if (!ospf)
@ -7451,7 +7451,7 @@ DEFUN (ospf_distance_ospf,
"External routes\n"
"Distance for external routes\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx = 0;
if (argv_find(argv, argc, "intra-area", &idx))
@ -7636,7 +7636,7 @@ DEFUN (ospf_max_metric_router_lsa_admin,
"Advertise own Router-LSA with infinite distance (stub router)\n"
"Administratively applied, for an indefinite period\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *ln;
struct ospf_area *area;
@ -7662,7 +7662,7 @@ DEFUN (no_ospf_max_metric_router_lsa_admin,
"Advertise own Router-LSA with infinite distance (stub router)\n"
"Administratively applied, for an indefinite period\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *ln;
struct ospf_area *area;
@ -7691,7 +7691,7 @@ DEFUN (ospf_max_metric_router_lsa_startup,
"Automatically advertise stub Router-LSA on startup of OSPF\n"
"Time (seconds) to advertise self as stub-router\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int seconds;
@ -7716,7 +7716,7 @@ DEFUN (no_ospf_max_metric_router_lsa_startup,
"Automatically advertise stub Router-LSA on startup of OSPF\n"
"Time (seconds) to advertise self as stub-router\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
struct listnode *ln;
struct ospf_area *area;
@ -7747,7 +7747,7 @@ DEFUN (ospf_max_metric_router_lsa_shutdown,
"Advertise stub-router prior to full shutdown of OSPF\n"
"Time (seconds) to wait till full shutdown\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int seconds;
@ -7772,7 +7772,7 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown,
"Advertise stub-router prior to full shutdown of OSPF\n"
"Time (seconds) to wait till full shutdown\n")
{
VTY_DECLVAR_CONTEXT(ospf, ospf);
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;

View File

@ -218,15 +218,26 @@ static int vtysh_client_run_all(struct vtysh_client *head_client,
{
struct vtysh_client *client;
int rc, rc_all = CMD_SUCCESS;
int correct_instance = 0, wrong_instance = 0;
for (client = head_client; client; client = client->next) {
rc = vtysh_client_run(client, line, fp, callback, cbarg);
if (rc == CMD_NOT_MY_INSTANCE) {
wrong_instance++;
continue;
}
correct_instance++;
if (rc != CMD_SUCCESS) {
if (!continue_on_err)
return rc;
rc_all = rc;
}
}
if (wrong_instance && !correct_instance && fp) {
fprintf(fp,
"%% [%s]: command ignored as it targets an instance that is not running",
head_client->name);
}
return rc_all;
}