summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_debug.c12
-rw-r--r--bgpd/bgp_route.c78
-rw-r--r--bgpd/bgp_routemap.c195
-rw-r--r--bgpd/bgp_vty.c429
-rw-r--r--bgpd/bgpd.c15
-rw-r--r--bgpd/bgpd.h10
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c393
-rw-r--r--bgpd/rfp-example/librfp/rfp_example.c2
-rw-r--r--isisd/Makefile.am3
-rw-r--r--isisd/isisd.c12
-rw-r--r--ldpd/Makefile.am3
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/if.c2
-rw-r--r--lib/keychain.c2
-rw-r--r--lib/qobj.c2
-rw-r--r--lib/qobj.h2
-rw-r--r--lib/routemap.c2
-rw-r--r--lib/vrf.c2
-rw-r--r--lib/vty.h35
-rw-r--r--ospf6d/ospf6_asbr.c29
-rw-r--r--ospf6d/ospf6_bfd.c11
-rw-r--r--ospf6d/ospf6_interface.c76
-rw-r--r--ospf6d/ospf6_interface.h4
-rw-r--r--ospf6d/ospf6_spf.c2
-rw-r--r--ospf6d/ospf6_top.c48
-rw-r--r--ospf6d/ospf6_top.h4
-rw-r--r--ospfd/ospf_bfd.c6
-rw-r--r--ospfd/ospf_interface.c6
-rw-r--r--ospfd/ospf_interface.h4
-rw-r--r--ospfd/ospf_opaque.c10
-rw-r--r--ospfd/ospf_routemap.c18
-rw-r--r--ospfd/ospf_te.c15
-rw-r--r--ospfd/ospf_vty.c473
-rw-r--r--ospfd/ospfd.c5
-rw-r--r--ospfd/ospfd.h4
-rw-r--r--pimd/pim_cmd.c76
-rw-r--r--ripd/rip_interface.c60
-rw-r--r--ripd/ripd.c9
-rw-r--r--ripd/ripd.h4
-rw-r--r--ripngd/ripng_interface.c9
-rw-r--r--tools/cocci.h34
-rw-r--r--tools/vty_check.cocci22
-rw-r--r--tools/vty_index.cocci244
-rwxr-xr-xtools/vty_index.sh21
-rw-r--r--zebra/Makefile.am3
45 files changed, 1015 insertions, 1384 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 0c74ba5459..de175de5a0 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -182,12 +182,14 @@ const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
static struct peer *
bgp_find_peer (struct vty *vty, const char *peer_str)
{
+ struct bgp *bgp = VTY_GET_CONTEXT(bgp);
int ret;
union sockunion su;
- struct bgp *bgp;
struct peer *peer;
- bgp = vty->index;
+ if (!bgp) {
+ return NULL;
+ }
ret = str2sockunion (peer_str, &su);
/* 'swpX' string */
@@ -1380,11 +1382,12 @@ DEFUN (no_debug_bgp_update,
BGP_STR
"BGP updates\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_debug_list_free(bgp_debug_update_in_peers);
bgp_debug_list_free(bgp_debug_update_out_peers);
bgp_debug_list_free(bgp_debug_update_prefixes);
- bgp_debug_clear_updgrp_update_dbg(vty->index);
+ bgp_debug_clear_updgrp_update_dbg(bgp);
if (vty->node == CONFIG_NODE)
{
@@ -1615,6 +1618,7 @@ DEFUN (no_debug_bgp,
DEBUG_STR
BGP_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_debug_list_free(bgp_debug_neighbor_events_peers);
bgp_debug_list_free(bgp_debug_keepalive_peers);
bgp_debug_list_free(bgp_debug_update_in_peers);
@@ -1623,7 +1627,7 @@ DEFUN (no_debug_bgp,
bgp_debug_list_free(bgp_debug_bestpath_prefixes);
bgp_debug_list_free(bgp_debug_zebra_prefixes);
- bgp_debug_clear_updgrp_update_dbg(vty->index);
+ bgp_debug_clear_updgrp_update_dbg(bgp);
TERM_DEBUG_OFF (keepalive, KEEPALIVE);
TERM_DEBUG_OFF (update, UPDATE_IN);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index e53d4493eb..cfc4ec3407 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3991,9 +3991,10 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
/* Configure static BGP network. When user don't run zebra, static
route should be installed as valid. */
static int
-bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
+bgp_static_set (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi, const char *rmap, int backdoor)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
struct bgp_static *bgp_static;
@@ -4080,9 +4081,10 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
/* Configure static BGP network. */
static int
-bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
+bgp_static_unset (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
struct bgp_static *bgp_static;
@@ -4278,18 +4280,16 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
const char *rd_str, const char *tag_str,
const char *rmap_str)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
struct prefix_rd prd;
- struct bgp *bgp;
struct bgp_node *prn;
struct bgp_node *rn;
struct bgp_table *table;
struct bgp_static *bgp_static;
u_char tag[3];
- bgp = vty->index;
-
ret = str2prefix (ip_str, &p);
if (! ret)
{
@@ -4359,8 +4359,8 @@ int
bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
const char *rd_str, const char *tag_str)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
- struct bgp *bgp;
struct prefix p;
struct prefix_rd prd;
struct bgp_node *prn;
@@ -4369,8 +4369,6 @@ bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
struct bgp_static *bgp_static;
u_char tag[3];
- bgp = vty->index;
-
/* Convert IP prefix string to struct prefix. */
ret = str2prefix (ip_str, &p);
if (! ret)
@@ -4421,9 +4419,10 @@ bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
}
static int
-bgp_table_map_set (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
+bgp_table_map_set (struct vty *vty, afi_t afi, safi_t safi,
const char *rmap_name)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct bgp_rmap *rmap;
rmap = &bgp->table_map[afi][safi];
@@ -4448,9 +4447,10 @@ bgp_table_map_set (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
}
static int
-bgp_table_map_unset (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
+bgp_table_map_unset (struct vty *vty, afi_t afi, safi_t safi,
const char *rmap_name)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct bgp_rmap *rmap;
rmap = &bgp->table_map[afi][safi];
@@ -4486,7 +4486,7 @@ DEFUN (bgp_table_map,
"Name of the route map\n")
{
int idx_word = 1;
- return bgp_table_map_set (vty, vty->index,
+ return bgp_table_map_set (vty,
bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg);
}
DEFUN (no_bgp_table_map,
@@ -4497,7 +4497,7 @@ DEFUN (no_bgp_table_map,
"Name of the route map\n")
{
int idx_word = 2;
- return bgp_table_map_unset (vty, vty->index,
+ return bgp_table_map_unset (vty,
bgp_node_afi (vty), bgp_node_safi (vty), argv[idx_word]->arg);
}
@@ -4508,7 +4508,7 @@ DEFUN (bgp_network,
"IPv4 prefix\n")
{
int idx_ipv4_prefixlen = 1;
- return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg,
+ return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg,
AFI_IP, bgp_node_safi (vty), NULL, 0);
}
@@ -4522,7 +4522,7 @@ DEFUN (bgp_network_route_map,
{
int idx_ipv4_prefixlen = 1;
int idx_word = 3;
- return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg,
+ return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg,
AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
}
@@ -4534,7 +4534,7 @@ DEFUN (bgp_network_backdoor,
"Specify a BGP backdoor route\n")
{
int idx_ipv4_prefixlen = 1;
- return bgp_static_set (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST,
+ return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST,
NULL, 1);
}
@@ -4558,7 +4558,7 @@ DEFUN (bgp_network_mask,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str,
+ return bgp_static_set (vty, prefix_str,
AFI_IP, bgp_node_safi (vty), NULL, 0);
}
@@ -4585,7 +4585,7 @@ DEFUN (bgp_network_mask_route_map,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str,
+ return bgp_static_set (vty, prefix_str,
AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
}
@@ -4610,7 +4610,7 @@ DEFUN (bgp_network_mask_backdoor,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
+ return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST,
NULL, 1);
}
@@ -4631,7 +4631,7 @@ DEFUN (bgp_network_mask_natural,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str,
+ return bgp_static_set (vty, prefix_str,
AFI_IP, bgp_node_safi (vty), NULL, 0);
}
@@ -4655,7 +4655,7 @@ DEFUN (bgp_network_mask_natural_route_map,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str,
+ return bgp_static_set (vty, prefix_str,
AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
}
@@ -4677,7 +4677,7 @@ DEFUN (bgp_network_mask_natural_backdoor,
return CMD_WARNING;
}
- return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
+ return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST,
NULL, 1);
}
@@ -4692,7 +4692,7 @@ DEFUN (no_bgp_network,
"Name of the route map\n")
{
int idx_ipv4_prefixlen = 2;
- return bgp_static_unset (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP,
+ return bgp_static_unset (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP,
bgp_node_safi (vty));
}
@@ -4720,7 +4720,7 @@ DEFUN (no_bgp_network_mask,
return CMD_WARNING;
}
- return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
+ return bgp_static_unset (vty, prefix_str, AFI_IP,
bgp_node_safi (vty));
}
@@ -4745,7 +4745,7 @@ DEFUN (no_bgp_network_mask_natural,
return CMD_WARNING;
}
- return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
+ return bgp_static_unset (vty, prefix_str, AFI_IP,
bgp_node_safi (vty));
}
@@ -4756,7 +4756,7 @@ DEFUN (ipv6_bgp_network,
"IPv6 prefix\n")
{
int idx_ipv6_prefixlen = 1;
- return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty),
+ return bgp_static_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty),
NULL, 0);
}
@@ -4770,7 +4770,7 @@ DEFUN (ipv6_bgp_network_route_map,
{
int idx_ipv6_prefixlen = 1;
int idx_word = 3;
- return bgp_static_set (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
+ return bgp_static_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
bgp_node_safi (vty), argv[idx_word]->arg, 0);
}
@@ -4784,7 +4784,7 @@ DEFUN (no_ipv6_bgp_network,
"Name of the route map\n")
{
int idx_ipv6_prefixlen = 2;
- return bgp_static_unset (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty));
+ return bgp_static_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty));
}
/* Aggreagete address:
@@ -5291,10 +5291,10 @@ static int
bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
afi_t afi, safi_t safi)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
struct bgp_node *rn;
- struct bgp *bgp;
struct bgp_aggregate *aggregate;
/* Convert string to prefix structure. */
@@ -5306,9 +5306,6 @@ bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
}
apply_mask (&p);
- /* Get BGP structure. */
- bgp = vty->index;
-
/* Old configuration check. */
rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
if (! rn)
@@ -5338,10 +5335,10 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str,
afi_t afi, safi_t safi,
u_char summary_only, u_char as_set)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
struct bgp_node *rn;
- struct bgp *bgp;
struct bgp_aggregate *aggregate;
/* Convert string to prefix structure. */
@@ -5353,9 +5350,6 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str,
}
apply_mask (&p);
- /* Get BGP structure. */
- bgp = vty->index;
-
/* Old configuration check. */
rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
@@ -9940,14 +9934,13 @@ DEFUN (bgp_distance,
"Distance for routes internal to the AS\n"
"Distance for local routes\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 2;
int idx_number_2 = 3;
int idx_number_3 = 4;
- struct bgp *bgp;
afi_t afi;
safi_t safi;
- bgp = vty->index;
afi = bgp_node_afi (vty);
safi = bgp_node_safi (vty);
@@ -9967,11 +9960,10 @@ DEFUN (no_bgp_distance,
"Distance for routes internal to the AS\n"
"Distance for local routes\n")
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
afi_t afi;
safi_t safi;
- bgp = vty->index;
afi = bgp_node_afi (vty);
safi = bgp_node_safi (vty);
@@ -10098,11 +10090,11 @@ DEFUN (bgp_damp_set,
"Value to start suppressing a route\n"
"Maximum duration to suppress a stable route\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_half_life = 2;
int idx_reuse = 3;
int idx_suppress = 4;
int idx_max_suppress = 5;
- struct bgp *bgp;
int half = DEFAULT_HALF_LIFE * 60;
int reuse = DEFAULT_REUSE;
int suppress = DEFAULT_SUPPRESS;
@@ -10121,8 +10113,6 @@ DEFUN (bgp_damp_set,
max = 4 * half;
}
- bgp = vty->index;
-
if (suppress < reuse)
{
vty_out (vty, "Suppress value cannot be less than reuse value %s",
@@ -10145,9 +10135,7 @@ DEFUN (bgp_damp_unset,
"Value to start suppressing a route\n"
"Maximum duration to suppress a stable route\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
}
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index aaf01ff772..e3e018c07f 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -2459,10 +2459,11 @@ struct route_map_rule_cmd route_set_originator_id_cmd =
/* Add bgp route map rule. */
static int
-bgp_route_match_add (struct vty *vty, struct route_map_index *index,
+bgp_route_match_add (struct vty *vty,
const char *command, const char *arg,
route_map_event_t type)
{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
int ret;
ret = route_map_add_match (index, command, arg);
@@ -2489,10 +2490,11 @@ bgp_route_match_add (struct vty *vty, struct route_map_index *index,
/* Delete bgp route map rule. */
static int
-bgp_route_match_delete (struct vty *vty, struct route_map_index *index,
+bgp_route_match_delete (struct vty *vty,
const char *command, const char *arg,
route_map_event_t type)
{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
int ret;
char *dep_name = NULL;
const char *tmpstr;
@@ -2892,7 +2894,7 @@ DEFUN (match_peer,
"IPv6 address of peer\n")
{
int idx_ip = 2;
- return bgp_route_match_add (vty, vty->index, "peer", argv[idx_ip]->arg,
+ return bgp_route_match_add (vty, "peer", argv[idx_ip]->arg,
RMAP_EVENT_MATCH_ADDED);
}
@@ -2903,7 +2905,7 @@ DEFUN (match_peer_local,
"Match peer address\n"
"Static or Redistributed routes\n")
{
- return bgp_route_match_add (vty, vty->index, "peer", "local",
+ return bgp_route_match_add (vty, "peer", "local",
RMAP_EVENT_MATCH_DELETED);
}
@@ -2920,9 +2922,9 @@ DEFUN (no_match_peer,
int idx_peer = 3;
if (argc <= idx_peer)
- return bgp_route_match_delete (vty, vty->index, "peer", NULL,
+ return bgp_route_match_delete (vty, "peer", NULL,
RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete (vty, vty->index, "peer", argv[idx_peer]->arg,
+ return bgp_route_match_delete (vty, "peer", argv[idx_peer]->arg,
RMAP_EVENT_MATCH_DELETED);
}
@@ -2936,7 +2938,7 @@ DEFUN (match_probability,
"Percentage of routes\n")
{
int idx_number = 2;
- return bgp_route_match_add (vty, vty->index, "probability", argv[idx_number]->arg,
+ return bgp_route_match_add (vty, "probability", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED);
}
@@ -2951,9 +2953,9 @@ DEFUN (no_match_probability,
{
int idx_number = 3;
if (argc <= idx_number)
- return bgp_route_match_delete (vty, vty->index, "probability", NULL,
+ return bgp_route_match_delete (vty, "probability", NULL,
RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete (vty, vty->index, "probability", argv[idx_number]->arg,
+ return bgp_route_match_delete (vty, "probability", argv[idx_number]->arg,
RMAP_EVENT_MATCH_DELETED);
}
@@ -2969,7 +2971,7 @@ DEFUN (match_ip_route_source,
"IP standard access-list name\n")
{
int idx_acl = 3;
- return bgp_route_match_add (vty, vty->index, "ip route-source", argv[idx_acl]->arg,
+ return bgp_route_match_add (vty, "ip route-source", argv[idx_acl]->arg,
RMAP_EVENT_FILTER_ADDED);
}
@@ -2987,9 +2989,9 @@ DEFUN (no_match_ip_route_source,
{
int idx_number = 4;
if (argc <= idx_number)
- return bgp_route_match_delete (vty, vty->index, "ip route-source",
+ return bgp_route_match_delete (vty, "ip route-source",
NULL, RMAP_EVENT_FILTER_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip route-source",
+ return bgp_route_match_delete (vty, "ip route-source",
argv[idx_number]->arg, RMAP_EVENT_FILTER_DELETED);
}
@@ -3004,7 +3006,7 @@ DEFUN (match_ip_route_source_prefix_list,
"IP prefix-list name\n")
{
int idx_word = 4;
- return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list",
+ return bgp_route_match_add (vty, "ip route-source prefix-list",
argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
}
@@ -3021,9 +3023,9 @@ DEFUN (no_match_ip_route_source_prefix_list,
{
int idx_word = 5;
if (argc <= idx_word)
- return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list",
+ return bgp_route_match_delete (vty, "ip route-source prefix-list",
NULL, RMAP_EVENT_PLIST_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list",
+ return bgp_route_match_delete (vty, "ip route-source prefix-list",
argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
}
@@ -3036,7 +3038,7 @@ DEFUN (match_local_pref,
"Metric value\n")
{
int idx_number = 2;
- return bgp_route_match_add (vty, vty->index, "local-preference", argv[idx_number]->arg,
+ return bgp_route_match_add (vty, "local-preference", argv[idx_number]->arg,
RMAP_EVENT_MATCH_ADDED);
}
@@ -3051,9 +3053,9 @@ DEFUN (no_match_local_pref,
{
int idx_localpref = 3;
if (argc <= idx_localpref)
- return bgp_route_match_delete (vty, vty->index, "local-preference",
+ return bgp_route_match_delete (vty, "local-preference",
NULL, RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete (vty, vty->index, "local-preference",
+ return bgp_route_match_delete (vty, "local-preference",
argv[idx_localpref]->arg,
RMAP_EVENT_MATCH_DELETED);
}
@@ -3069,7 +3071,7 @@ DEFUN (match_community,
"Community-list name\n")
{
int idx_comm_list = 2;
- return bgp_route_match_add (vty, vty->index, "community", argv[idx_comm_list]->arg,
+ return bgp_route_match_add (vty, "community", argv[idx_comm_list]->arg,
RMAP_EVENT_CLIST_ADDED);
}
@@ -3092,7 +3094,7 @@ DEFUN (match_community_exact,
sprintf (argstr, "%s exact-match", argv[idx_comm_list]->arg);
- ret = bgp_route_match_add (vty, vty->index, "community", argstr,
+ ret = bgp_route_match_add (vty, "community", argstr,
RMAP_EVENT_CLIST_ADDED);
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
@@ -3111,7 +3113,7 @@ DEFUN (no_match_community,
"Community-list name\n"
"Do exact matching of communities\n")
{
- return bgp_route_match_delete (vty, vty->index, "community", NULL,
+ return bgp_route_match_delete (vty, "community", NULL,
RMAP_EVENT_CLIST_DELETED);
}
@@ -3127,7 +3129,7 @@ DEFUN (match_ecommunity,
"Extended community-list name\n")
{
int idx_comm_list = 2;
- return bgp_route_match_add (vty, vty->index, "extcommunity", argv[idx_comm_list]->arg,
+ return bgp_route_match_add (vty, "extcommunity", argv[idx_comm_list]->arg,
RMAP_EVENT_ECLIST_ADDED);
}
@@ -3142,7 +3144,7 @@ DEFUN (no_match_ecommunity,
"Extended community-list number (expanded)\n"
"Extended community-list name\n")
{
- return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL,
+ return bgp_route_match_delete (vty, "extcommunity", NULL,
RMAP_EVENT_ECLIST_DELETED);
}
@@ -3155,7 +3157,7 @@ DEFUN (match_aspath,
"AS path access-list name\n")
{
int idx_word = 2;
- return bgp_route_match_add (vty, vty->index, "as-path", argv[idx_word]->arg,
+ return bgp_route_match_add (vty, "as-path", argv[idx_word]->arg,
RMAP_EVENT_ASLIST_ADDED);
}
@@ -3168,7 +3170,7 @@ DEFUN (no_match_aspath,
"Match BGP AS path list\n"
"AS path access-list name\n")
{
- return bgp_route_match_delete (vty, vty->index, "as-path", NULL,
+ return bgp_route_match_delete (vty, "as-path", NULL,
RMAP_EVENT_ASLIST_DELETED);
}
@@ -3184,13 +3186,13 @@ DEFUN (match_origin,
{
int idx_origin = 2;
if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0)
- return bgp_route_match_add (vty, vty->index, "origin", "igp",
+ return bgp_route_match_add (vty, "origin", "igp",
RMAP_EVENT_MATCH_ADDED);
if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0)
- return bgp_route_match_add (vty, vty->index, "origin", "egp",
+ return bgp_route_match_add (vty, "origin", "egp",
RMAP_EVENT_MATCH_ADDED);
if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0)
- return bgp_route_match_add (vty, vty->index, "origin", "incomplete",
+ return bgp_route_match_add (vty, "origin", "incomplete",
RMAP_EVENT_MATCH_ADDED);
return CMD_WARNING;
@@ -3207,7 +3209,7 @@ DEFUN (no_match_origin,
"local IGP\n"
"unknown heritage\n")
{
- return bgp_route_match_delete (vty, vty->index, "origin", NULL,
+ return bgp_route_match_delete (vty, "origin", NULL,
RMAP_EVENT_MATCH_DELETED);
}
@@ -3219,7 +3221,8 @@ DEFUN (set_ip_nexthop_peer,
"Next hop address\n"
"Use peer address (for BGP only)\n")
{
- return generic_set_add (vty, vty->index, "ip next-hop", "peer-address");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "ip next-hop", "peer-address");
}
DEFUN (set_ip_nexthop_unchanged,
@@ -3230,7 +3233,8 @@ DEFUN (set_ip_nexthop_unchanged,
"Next hop address\n"
"Don't modify existing Next hop address\n")
{
- return generic_set_add (vty, vty->index, "ip next-hop", "unchanged");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "ip next-hop", "unchanged");
}
@@ -3242,7 +3246,8 @@ DEFUN (set_local_pref,
"Preference value\n")
{
int idx_number = 2;
- return generic_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "local-preference", argv[idx_number]->arg);
}
@@ -3256,8 +3261,10 @@ DEFUN (no_set_local_pref,
{
int idx_localpref = 3;
if (argc <= idx_localpref)
- return generic_set_delete (vty, vty->index, "local-preference", NULL);
- return generic_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "local-preference", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "local-preference", argv[idx_localpref]->arg);
}
@@ -3269,7 +3276,8 @@ DEFUN (set_weight,
"Weight value\n")
{
int idx_number = 2;
- return generic_set_add (vty, vty->index, "weight", argv[idx_number]->arg);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "weight",
+ argv[idx_number]->arg);
}
@@ -3283,8 +3291,10 @@ DEFUN (no_set_weight,
{
int idx_weight = 3;
if (argc <= idx_weight)
- return generic_set_delete (vty, vty->index, "weight", NULL);
- return generic_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "weight", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), "weight",
+ argv[idx_weight]->arg);
}
@@ -3301,7 +3311,8 @@ DEFUN (set_aspath_prepend_asn,
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = generic_set_add (vty, vty->index, "as-path prepend", str);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "as-path prepend", str);
XFREE (MTYPE_TMP, str);
return ret;
@@ -3333,7 +3344,8 @@ DEFUN (no_set_aspath_prepend,
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = generic_set_delete (vty, vty->index, "as-path prepend", str);
+ ret = generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "as-path prepend", str);
XFREE (MTYPE_TMP, str);
return ret;
}
@@ -3352,7 +3364,8 @@ DEFUN (set_aspath_exclude,
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = generic_set_add (vty, vty->index, "as-path exclude", str);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "as-path exclude", str);
XFREE (MTYPE_TMP, str);
return ret;
}
@@ -3371,7 +3384,8 @@ DEFUN (no_set_aspath_exclude,
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = generic_set_delete (vty, vty->index, "as-path exclude", str);
+ ret = generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "as-path exclude", str);
XFREE (MTYPE_TMP, str);
return ret;
}
@@ -3460,11 +3474,13 @@ DEFUN (set_community,
argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1);
strcpy (argstr, str);
strcpy (argstr + strlen (str), " additive");
- ret = generic_set_add (vty, vty->index, "community", argstr);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "community", argstr);
XFREE (MTYPE_TMP, argstr);
}
else
- ret = generic_set_add (vty, vty->index, "community", str);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "community", str);
community_free (com);
@@ -3478,7 +3494,8 @@ DEFUN (set_community_none,
"BGP community attribute\n"
"No community attribute\n")
{
- return generic_set_add (vty, vty->index, "community", "none");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "community",
+ "none");
}
DEFUN (no_set_community,
@@ -3489,7 +3506,8 @@ DEFUN (no_set_community,
"BGP community attribute\n"
COMMUNITY_VAL_STR)
{
- return generic_set_delete (vty, vty->index, "community", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "community", NULL);
}
@@ -3511,7 +3529,7 @@ DEFUN (set_community_delete,
strcpy (str, argv[idx_comm_list]->arg);
strcpy (str + strlen (argv[idx_comm_list]->arg), " delete");
- generic_set_add (vty, vty->index, "comm-list", str);
+ generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "comm-list", str);
XFREE (MTYPE_TMP, str);
return CMD_SUCCESS;
@@ -3528,7 +3546,8 @@ DEFUN (no_set_community_delete,
"Community-list name\n"
"Delete matching communities\n")
{
- return generic_set_delete (vty, vty->index, "comm-list", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "comm-list", NULL);
}
@@ -3545,7 +3564,8 @@ DEFUN (set_ecommunity_rt,
char *str;
str = argv_concat (argv, argc, idx_asn_nn);
- ret = generic_set_add (vty, vty->index, "extcommunity rt", str);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "extcommunity rt", str);
XFREE (MTYPE_TMP, str);
return ret;
@@ -3560,7 +3580,8 @@ DEFUN (no_set_ecommunity_rt,
"Route Target extended community\n"
"VPN extended community\n")
{
- return generic_set_delete (vty, vty->index, "extcommunity rt", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "extcommunity rt", NULL);
}
@@ -3577,7 +3598,8 @@ DEFUN (set_ecommunity_soo,
char *str;
str = argv_concat (argv, argc, idx_asn_nn);
- ret = generic_set_add (vty, vty->index, "extcommunity soo", str);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "extcommunity soo", str);
XFREE (MTYPE_TMP, str);
return ret;
}
@@ -3592,7 +3614,8 @@ DEFUN (no_set_ecommunity_soo,
"Site-of-Origin extended community\n"
"VPN extended community\n")
{
- return generic_set_delete (vty, vty->index, "extcommunity soo", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "extcommunity soo", NULL);
}
@@ -3607,11 +3630,14 @@ DEFUN (set_origin,
{
int idx_origin = 2;
if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0)
- return generic_set_add (vty, vty->index, "origin", "igp");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "origin",
+ "igp");
if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0)
- return generic_set_add (vty, vty->index, "origin", "egp");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "origin",
+ "egp");
if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0)
- return generic_set_add (vty, vty->index, "origin", "incomplete");
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "origin",
+ "incomplete");
return CMD_WARNING;
}
@@ -3627,7 +3653,8 @@ DEFUN (no_set_origin,
"local IGP\n"
"unknown heritage\n")
{
- return generic_set_delete (vty, vty->index, "origin", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), "origin",
+ NULL);
}
@@ -3637,7 +3664,8 @@ DEFUN (set_atomic_aggregate,
SET_STR
"BGP atomic aggregate attribute\n" )
{
- return generic_set_add (vty, vty->index, "atomic-aggregate", NULL);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "atomic-aggregate", NULL);
}
DEFUN (no_set_atomic_aggregate,
@@ -3647,7 +3675,8 @@ DEFUN (no_set_atomic_aggregate,
SET_STR
"BGP atomic aggregate attribute\n" )
{
- return generic_set_delete (vty, vty->index, "atomic-aggregate", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "atomic-aggregate", NULL);
}
DEFUN (set_aggregator_as,
@@ -3677,7 +3706,8 @@ DEFUN (set_aggregator_as,
sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg);
- ret = generic_set_add (vty, vty->index, "aggregator as", argstr);
+ ret = generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "aggregator as", argstr);
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
@@ -3702,7 +3732,8 @@ DEFUN (no_set_aggregator_as,
char *argstr;
if (argc <= idx_asn)
- return generic_set_delete (vty, vty->index, "aggregator as", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "aggregator as", NULL);
ret = inet_aton (argv[idx_ip]->arg, &address);
if (ret == 0)
@@ -3716,7 +3747,8 @@ DEFUN (no_set_aggregator_as,
sprintf (argstr, "%s %s", argv[idx_asn]->arg, argv[idx_ip]->arg);
- ret = generic_set_delete (vty, vty->index, "aggregator as", argstr);
+ ret = generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "aggregator as", argstr);
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
@@ -3733,7 +3765,7 @@ DEFUN (match_ipv6_next_hop,
"IPv6 address of next hop\n")
{
int idx_ipv6 = 3;
- return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg,
+ return bgp_route_match_add (vty, "ipv6 next-hop", argv[idx_ipv6]->arg,
RMAP_EVENT_MATCH_ADDED);
}
@@ -3747,7 +3779,7 @@ DEFUN (no_match_ipv6_next_hop,
"IPv6 address of next hop\n")
{
int idx_ipv6 = 4;
- return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[idx_ipv6]->arg,
+ return bgp_route_match_delete (vty, "ipv6 next-hop", argv[idx_ipv6]->arg,
RMAP_EVENT_MATCH_DELETED);
}
@@ -3760,7 +3792,8 @@ DEFUN (set_ipv6_nexthop_peer,
"Next hop address\n"
"Use peer address (for BGP only)\n")
{
- return generic_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop peer-address", NULL);
}
DEFUN (no_set_ipv6_nexthop_peer,
@@ -3772,7 +3805,8 @@ DEFUN (no_set_ipv6_nexthop_peer,
"IPv6 next-hop address\n"
"Use peer address (for BGP only)\n")
{
- return generic_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop peer-address", NULL);
}
DEFUN (set_ipv6_nexthop_prefer_global,
@@ -3783,7 +3817,8 @@ DEFUN (set_ipv6_nexthop_prefer_global,
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
- return generic_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);;
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop prefer-global", NULL);;
}
DEFUN (no_set_ipv6_nexthop_prefer_global,
@@ -3795,7 +3830,8 @@ DEFUN (no_set_ipv6_nexthop_prefer_global,
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
- return generic_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop prefer-global", NULL);
}
DEFUN (set_ipv6_nexthop_global,
@@ -3826,7 +3862,8 @@ DEFUN (set_ipv6_nexthop_global,
return CMD_WARNING;
}
- return generic_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop global", argv[idx_ipv6]->arg);
}
@@ -3842,8 +3879,10 @@ DEFUN (no_set_ipv6_nexthop_global,
{
int idx_ipv6 = 5;
if (argc <= idx_ipv6)
- return generic_set_delete (vty, vty->index, "ipv6 next-hop global", NULL);
- return generic_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop global", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "ipv6 next-hop global", argv[idx_ipv6]->arg);
}
#endif /* HAVE_IPV6 */
@@ -3856,7 +3895,8 @@ DEFUN (set_vpnv4_nexthop,
"IP address of next hop\n")
{
int idx_ipv4 = 3;
- return generic_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "vpnv4 next-hop", argv[idx_ipv4]->arg);
}
@@ -3871,8 +3911,10 @@ DEFUN (no_set_vpnv4_nexthop,
{
int idx_ipv4 = 4;
if (argc <= idx_ipv4)
- return generic_set_delete (vty, vty->index, "vpnv4 next-hop", NULL);
- return generic_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "vpnv4 next-hop", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "vpnv4 next-hop", argv[idx_ipv4]->arg);
}
@@ -3884,7 +3926,8 @@ DEFUN (set_originator_id,
"IP address of originator\n")
{
int idx_ipv4 = 2;
- return generic_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "originator-id", argv[idx_ipv4]->arg);
}
@@ -3898,8 +3941,10 @@ DEFUN (no_set_originator_id,
{
int idx_id = 3;
if (argc < idx_id)
- return generic_set_delete (vty, vty->index, "originator-id", NULL);
- return generic_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "originator-id", NULL);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "originator-id", argv[idx_id]->arg);
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 5ba99f1bdf..1c2cc037f9 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -171,12 +171,14 @@ peer_address_self_check (struct bgp *bgp, union sockunion *su)
static struct peer *
peer_lookup_vty (struct vty *vty, const char *ip_str)
{
+ struct bgp *bgp = VTY_GET_CONTEXT(bgp);
int ret;
- struct bgp *bgp;
union sockunion su;
struct peer *peer;
- bgp = vty->index;
+ if (!bgp) {
+ return NULL;
+ }
ret = str2sockunion (ip_str, &su);
if (ret < 0)
@@ -218,13 +220,15 @@ peer_lookup_vty (struct vty *vty, const char *ip_str)
struct peer *
peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
{
+ struct bgp *bgp = VTY_GET_CONTEXT(bgp);
int ret;
- struct bgp *bgp;
union sockunion su;
struct peer *peer = NULL;
struct peer_group *group = NULL;
- bgp = vty->index;
+ if (!bgp) {
+ return NULL;
+ }
ret = str2sockunion (peer_str, &su);
if (ret == 0)
@@ -728,8 +732,7 @@ DEFUN (router_bgp,
/* Pending: handle when user tries to change a view to vrf n vv. */
}
- vty->node = BGP_NODE;
- vty->index = bgp;
+ VTY_PUSH_CONTEXT(BGP_NODE, bgp);
return CMD_SUCCESS;
}
@@ -800,12 +803,10 @@ DEFUN (bgp_router_id,
"Override configured router identifier\n"
"Manually configured router identifier\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ipv4 = 2;
int ret;
struct in_addr id;
- struct bgp *bgp;
-
- bgp = vty->index;
ret = inet_aton (argv[idx_ipv4]->arg, &id);
if (! ret)
@@ -827,12 +828,10 @@ DEFUN (no_bgp_router_id,
"Override configured router identifier\n"
"Manually configured router identifier\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_router_id = 3;
int ret;
struct in_addr id;
- struct bgp *bgp;
-
- bgp = vty->index;
if (argc > idx_router_id)
{
@@ -866,13 +865,11 @@ DEFUN (bgp_cluster_id,
"Route-Reflector Cluster-id in IP address format\n"
"Route-Reflector Cluster-id as 32 bit quantity\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ipv4 = 2;
int ret;
- struct bgp *bgp;
struct in_addr cluster;
- bgp = vty->index;
-
ret = inet_aton (argv[idx_ipv4]->arg, &cluster);
if (! ret)
{
@@ -895,9 +892,7 @@ DEFUN (no_bgp_cluster_id,
"Route-Reflector Cluster-id in IP address format\n"
"Route-Reflector Cluster-id as 32 bit quantity\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_cluster_id_unset (bgp);
bgp_clear_star_soft_out (vty, bgp->name);
@@ -912,12 +907,10 @@ DEFUN (bgp_confederation_identifier,
"AS number\n"
"Set routing domain confederation AS\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
as_t as;
- bgp = vty->index;
-
VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
bgp_confederation_id_set (bgp, as);
@@ -934,9 +927,7 @@ DEFUN (no_bgp_confederation_identifier,
"AS number\n"
"Set routing domain confederation AS\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_confederation_id_unset (bgp);
return CMD_SUCCESS;
@@ -950,13 +941,11 @@ DEFUN (bgp_confederation_peers,
"Peer ASs in BGP confederation\n"
AS_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_asn = 3;
- struct bgp *bgp;
as_t as;
int i;
- bgp = vty->index;
-
for (i = idx_asn; i < argc; i++)
{
VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
@@ -982,13 +971,11 @@ DEFUN (no_bgp_confederation_peers,
"Peer ASs in BGP confederation\n"
AS_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_asn = 4;
- struct bgp *bgp;
as_t as;
int i;
- bgp = vty->index;
-
for (i = idx_asn; i < argc; i++)
{
VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
@@ -1007,13 +994,12 @@ static int
bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
u_int16_t options, int set)
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
u_int16_t maxpaths = 0;
int ret;
afi_t afi;
safi_t safi;
- bgp = vty->index;
afi = bgp_node_afi (vty);
safi = bgp_node_safi (vty);
@@ -1047,9 +1033,7 @@ DEFUN (bgp_maxmed_admin,
"Advertise routes with max-med\n"
"Administratively applied, for an indefinite period\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->v_maxmed_admin = 1;
bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
@@ -1067,10 +1051,8 @@ DEFUN (bgp_maxmed_admin_medv,
"Administratively applied, for an indefinite period\n"
"Max MED value to be used\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
-
- bgp = vty->index;
bgp->v_maxmed_admin = 1;
VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg);
@@ -1089,9 +1071,7 @@ DEFUN (no_bgp_maxmed_admin,
"Administratively applied, for an indefinite period\n"
"Max MED value to be used\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
bgp_maxmed_update(bgp);
@@ -1107,10 +1087,8 @@ DEFUN (bgp_maxmed_onstartup,
"Effective on a startup\n"
"Time (seconds) period for max-med\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
-
- bgp = vty->index;
VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
bgp_maxmed_update(bgp);
@@ -1127,11 +1105,9 @@ DEFUN (bgp_maxmed_onstartup_medv,
"Time (seconds) period for max-med\n"
"Max MED value to be used\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
int idx_number_2 = 4;
- struct bgp *bgp;
-
- bgp = vty->index;
VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg);
bgp_maxmed_update(bgp);
@@ -1149,9 +1125,7 @@ DEFUN (no_bgp_maxmed_onstartup,
"Time (seconds) period for max-med\n"
"Max MED value to be used\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
/* Cancel max-med onstartup if its on */
if (bgp->t_maxmed_onstartup)
@@ -1172,13 +1146,10 @@ static int
bgp_update_delay_config_vty (struct vty *vty, const char *delay,
const char *wait)
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
u_int16_t update_delay;
u_int16_t establish_wait;
-
- bgp = vty->index;
-
VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
@@ -1207,9 +1178,7 @@ bgp_update_delay_config_vty (struct vty *vty, const char *delay,
static int
bgp_update_delay_deconfig_vty (struct vty *vty)
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
bgp->v_establish_wait = bgp->v_update_delay;
@@ -1272,9 +1241,7 @@ DEFUN (no_bgp_update_delay,
static int
bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (set)
VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
@@ -1322,9 +1289,7 @@ DEFUN (no_bgp_wpkt_quanta,
static int
bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (set)
VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
@@ -1459,14 +1424,12 @@ DEFUN (bgp_timers,
"Keepalive interval\n"
"Holdtime\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 2;
int idx_number_2 = 3;
- struct bgp *bgp;
unsigned long keepalive = 0;
unsigned long holdtime = 0;
- bgp = vty->index;
-
VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg);
VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg);
@@ -1492,9 +1455,7 @@ DEFUN (no_bgp_timers,
"Keepalive interval\n"
"Holdtime\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_timers_unset (bgp);
return CMD_SUCCESS;
@@ -1508,9 +1469,7 @@ DEFUN (bgp_client_to_client_reflection,
"Configure client to client route reflection\n"
"reflection of routes allowed\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
bgp_clear_star_soft_out (vty, bgp->name);
@@ -1525,9 +1484,7 @@ DEFUN (no_bgp_client_to_client_reflection,
"Configure client to client route reflection\n"
"reflection of routes allowed\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
bgp_clear_star_soft_out (vty, bgp->name);
@@ -1541,9 +1498,7 @@ DEFUN (bgp_always_compare_med,
"BGP specific commands\n"
"Allow comparing MED from different neighbors\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
bgp_recalculate_all_bestpaths (bgp);
@@ -1557,9 +1512,7 @@ DEFUN (no_bgp_always_compare_med,
"BGP specific commands\n"
"Allow comparing MED from different neighbors\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
bgp_recalculate_all_bestpaths (bgp);
@@ -1573,9 +1526,7 @@ DEFUN (bgp_deterministic_med,
"BGP specific commands\n"
"Pick the best-MED path among paths advertised from the neighboring AS\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
{
@@ -1593,15 +1544,13 @@ DEFUN (no_bgp_deterministic_med,
"BGP specific commands\n"
"Pick the best-MED path among paths advertised from the neighboring AS\n")
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int bestpath_per_as_used;
afi_t afi;
safi_t safi;
struct peer *peer;
struct listnode *node, *nnode;
- bgp = vty->index;
-
if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
{
bestpath_per_as_used = 0;
@@ -1643,9 +1592,7 @@ DEFUN (bgp_graceful_restart,
"BGP specific commands\n"
"Graceful restart capability parameters\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
return CMD_SUCCESS;
}
@@ -1657,9 +1604,7 @@ DEFUN (no_bgp_graceful_restart,
"BGP specific commands\n"
"Graceful restart capability parameters\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
return CMD_SUCCESS;
}
@@ -1672,14 +1617,10 @@ DEFUN (bgp_graceful_restart_stalepath_time,
"Set the max time to hold onto restarting peer's stale paths\n"
"Delay value (seconds)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
u_int32_t stalepath;
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
-
VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600);
bgp->stalepath_time = stalepath;
return CMD_SUCCESS;
@@ -1693,14 +1634,10 @@ DEFUN (bgp_graceful_restart_restart_time,
"Set the time to wait to delete stale routes before a BGP open message is received\n"
"Delay value (seconds)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
u_int32_t restart;
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
-
VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600);
bgp->restart_time = restart;
return CMD_SUCCESS;
@@ -1715,11 +1652,7 @@ DEFUN (no_bgp_graceful_restart_stalepath_time,
"Set the max time to hold onto restarting peer's stale paths\n"
"Delay value (seconds)\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
return CMD_SUCCESS;
@@ -1734,11 +1667,7 @@ DEFUN (no_bgp_graceful_restart_restart_time,
"Set the time to wait to delete stale routes before a BGP open message is received\n"
"Delay value (seconds)\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
return CMD_SUCCESS;
@@ -1751,9 +1680,7 @@ DEFUN (bgp_fast_external_failover,
BGP_STR
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
return CMD_SUCCESS;
}
@@ -1765,9 +1692,7 @@ DEFUN (no_bgp_fast_external_failover,
BGP_STR
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
return CMD_SUCCESS;
}
@@ -1779,9 +1704,7 @@ DEFUN (bgp_enforce_first_as,
BGP_STR
"Enforce the first AS for EBGP routes\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
bgp_clear_star_soft_in (vty, bgp->name);
@@ -1795,9 +1718,7 @@ DEFUN (no_bgp_enforce_first_as,
BGP_STR
"Enforce the first AS for EBGP routes\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
bgp_clear_star_soft_in (vty, bgp->name);
@@ -1812,9 +1733,7 @@ DEFUN (bgp_bestpath_compare_router_id,
"Change the default bestpath selection\n"
"Compare router-id for identical EBGP paths\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
bgp_recalculate_all_bestpaths (bgp);
@@ -1829,9 +1748,7 @@ DEFUN (no_bgp_bestpath_compare_router_id,
"Change the default bestpath selection\n"
"Compare router-id for identical EBGP paths\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
bgp_recalculate_all_bestpaths (bgp);
@@ -1847,9 +1764,7 @@ DEFUN (bgp_bestpath_aspath_ignore,
"AS-path attribute\n"
"Ignore as-path length in selecting a route\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
bgp_recalculate_all_bestpaths (bgp);
@@ -1865,9 +1780,7 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
"AS-path attribute\n"
"Ignore as-path length in selecting a route\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
bgp_recalculate_all_bestpaths (bgp);
@@ -1883,9 +1796,7 @@ DEFUN (bgp_bestpath_aspath_confed,
"AS-path attribute\n"
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
bgp_recalculate_all_bestpaths (bgp);
@@ -1901,9 +1812,7 @@ DEFUN (no_bgp_bestpath_aspath_confed,
"AS-path attribute\n"
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
bgp_recalculate_all_bestpaths (bgp);
@@ -1921,10 +1830,8 @@ DEFUN (bgp_bestpath_aspath_multipath_relax,
"Generate an AS_SET\n"
"Do not generate an AS_SET\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
- struct bgp *bgp;
-
- bgp = vty->index;
bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
/* no-as-set is now the default behavior so we can silently
@@ -1950,9 +1857,7 @@ DEFUN (no_bgp_bestpath_aspath_multipath_relax,
"Generate an AS_SET\n"
"Do not generate an AS_SET\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
bgp_recalculate_all_bestpaths (bgp);
@@ -1967,9 +1872,7 @@ DEFUN (bgp_log_neighbor_changes,
"BGP specific commands\n"
"Log neighbor up/down and reset reason\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
return CMD_SUCCESS;
}
@@ -1981,9 +1884,7 @@ DEFUN (no_bgp_log_neighbor_changes,
"BGP specific commands\n"
"Log neighbor up/down and reset reason\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
return CMD_SUCCESS;
}
@@ -2000,7 +1901,7 @@ DEFUN (bgp_bestpath_med,
"Treat missing MED as the least preferred one\n"
"Compare MED among confederation paths\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
if (argv_find (argv, argc, "confed", &idx))
@@ -2026,7 +1927,7 @@ DEFUN (no_bgp_bestpath_med,
"Treat missing MED as the least preferred one\n"
"Compare MED among confederation paths\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
if (argv_find (argv, argc, "confed", &idx))
@@ -2049,9 +1950,7 @@ DEFUN (no_bgp_default_ipv4_unicast,
"Configure BGP defaults\n"
"Activate ipv4-unicast for a peer by default\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
return CMD_SUCCESS;
}
@@ -2063,9 +1962,7 @@ DEFUN (bgp_default_ipv4_unicast,
"Configure BGP defaults\n"
"Activate ipv4-unicast for a peer by default\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
return CMD_SUCCESS;
}
@@ -2078,9 +1975,7 @@ DEFUN (bgp_default_show_hostname,
"Configure BGP defaults\n"
"Show hostname in certain command ouputs\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
return CMD_SUCCESS;
}
@@ -2093,9 +1988,7 @@ DEFUN (no_bgp_default_show_hostname,
"Configure BGP defaults\n"
"Show hostname in certain command ouputs\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
return CMD_SUCCESS;
}
@@ -2108,9 +2001,7 @@ DEFUN (bgp_network_import_check,
"BGP network command\n"
"Check BGP network route exists in IGP\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
{
bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
@@ -2136,9 +2027,7 @@ DEFUN (no_bgp_network_import_check,
"BGP network command\n"
"Check BGP network route exists in IGP\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
{
bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
@@ -2156,12 +2045,10 @@ DEFUN (bgp_default_local_preference,
"local preference (higher=more preferred)\n"
"Configure default local preference value\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
u_int32_t local_pref;
- bgp = vty->index;
-
VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg);
bgp_default_local_preference_set (bgp, local_pref);
@@ -2179,9 +2066,7 @@ DEFUN (no_bgp_default_local_preference,
"local preference (higher=more preferred)\n"
"Configure default local preference value\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_default_local_preference_unset (bgp);
bgp_clear_star_soft_in (vty, bgp->name);
@@ -2197,12 +2082,10 @@ DEFUN (bgp_default_subgroup_pkt_queue_max,
"subgroup-pkt-queue-max\n"
"Configure subgroup packet queue max\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
u_int32_t max_size;
- bgp = vty->index;
-
VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg);
bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
@@ -2219,9 +2102,7 @@ DEFUN (no_bgp_default_subgroup_pkt_queue_max,
"subgroup-pkt-queue-max\n"
"Configure subgroup packet queue max\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_default_subgroup_pkt_queue_max_unset (bgp);
return CMD_SUCCESS;
}
@@ -2234,9 +2115,7 @@ DEFUN (bgp_rr_allow_outbound_policy,
"Allow modifications made by out route-map\n"
"on ibgp neighbors\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
{
@@ -2256,9 +2135,7 @@ DEFUN (no_bgp_rr_allow_outbound_policy,
"Allow modifications made by out route-map\n"
"on ibgp neighbors\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
{
@@ -2278,12 +2155,10 @@ DEFUN (bgp_listen_limit,
"maximum number of BGP Dynamic Neighbors that can be created\n"
"Configure Dynamic Neighbors listen limit value\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- struct bgp *bgp;
int listen_limit;
- bgp = vty->index;
-
VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg,
BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
@@ -2302,9 +2177,7 @@ DEFUN (no_bgp_listen_limit,
"Configure Dynamic Neighbors listen limit value to default\n"
"Configure Dynamic Neighbors listen limit value\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_listen_limit_unset (bgp);
return CMD_SUCCESS;
}
@@ -2352,7 +2225,7 @@ DEFUN (bgp_listen_range,
"Member of the peer-group\n"
"Peer-group name\n")
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct prefix range;
struct peer_group *group, *existing_group;
afi_t afi;
@@ -2365,8 +2238,6 @@ DEFUN (bgp_listen_range,
argv_find (argv, argc, "WORD", &idx);
char *peergroup = argv[idx]->arg;
- bgp = vty->index;
-
/* Convert IP prefix string to struct prefix. */
ret = str2prefix (prefix, &range);
if (! ret)
@@ -2430,7 +2301,7 @@ DEFUN (no_bgp_listen_range,
"Member of the peer-group\n"
"Peer-group name\n")
{
- struct bgp *bgp;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct prefix range;
struct peer_group *group;
afi_t afi;
@@ -2443,8 +2314,6 @@ DEFUN (no_bgp_listen_range,
argv_find (argv, argc, "WORD", &idx);
char *peergroup = argv[idx]->arg;
- bgp = vty->index;
-
// VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg);
/* Convert IP prefix string to struct prefix. */
@@ -2513,9 +2382,7 @@ DEFUN (bgp_disable_connected_route_check,
"BGP specific commands\n"
"Disable checking if nexthop is connected on ebgp sessions\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
bgp_clear_star_soft_in (vty, bgp->name);
@@ -2529,9 +2396,7 @@ DEFUN (no_bgp_disable_connected_route_check,
"BGP specific commands\n"
"Disable checking if nexthop is connected on ebgp sessions\n")
{
- struct bgp *bgp;
-
- bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
bgp_clear_star_soft_in (vty, bgp->name);
@@ -2543,14 +2408,12 @@ static int
peer_remote_as_vty (struct vty *vty, const char *peer_str,
const char *as_str, afi_t afi, safi_t safi)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
- struct bgp *bgp;
as_t as;
int as_type = AS_SPECIFIED;
union sockunion su;
- bgp = vty->index;
-
if (as_str[0] == 'i')
{
as = 0;
@@ -2629,15 +2492,14 @@ peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
safi_t safi, int v6only, const char *peer_group_name,
const char *as_str)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
as_t as = 0;
int as_type = AS_UNSPECIFIED;
- struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
int ret = 0;
union sockunion su;
- bgp = vty->index;
group = peer_group_lookup (bgp, conf_if);
if (group)
@@ -2810,12 +2672,11 @@ DEFUN (neighbor_peer_group,
"Interface name or neighbor tag\n"
"Configure peer-group\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 1;
- struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- bgp = vty->index;
peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
if (peer)
{
@@ -2841,6 +2702,7 @@ DEFUN (no_neighbor,
"Internal BGP peer\n"
"External BGP peer\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_peer = 2;
int ret;
union sockunion su;
@@ -2852,7 +2714,7 @@ DEFUN (no_neighbor,
if (ret < 0)
{
/* look up for neighbor by interface name config. */
- peer = peer_lookup_by_conf_if (vty->index, argv[idx_peer]->arg);
+ peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg);
if (peer)
{
/* Request zebra to terminate IPv6 RAs on this interface. */
@@ -2862,7 +2724,7 @@ DEFUN (no_neighbor,
return CMD_SUCCESS;
}
- group = peer_group_lookup (vty->index, argv[idx_peer]->arg);
+ group = peer_group_lookup (bgp, argv[idx_peer]->arg);
if (group)
peer_group_delete (group);
else
@@ -2873,7 +2735,7 @@ DEFUN (no_neighbor,
}
else
{
- peer = peer_lookup (vty->index, &su);
+ peer = peer_lookup (bgp, &su);
if (peer)
{
if (peer_dynamic_neighbor (peer))
@@ -2908,11 +2770,12 @@ DEFUN (no_neighbor_interface_config,
"Internal BGP peer\n"
"External BGP peer\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 2;
struct peer *peer;
/* look up for neighbor by interface name config. */
- peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg);
+ peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
if (peer)
{
/* Request zebra to terminate IPv6 RAs on this interface. */
@@ -2936,10 +2799,11 @@ DEFUN (no_neighbor_peer_group,
"Neighbor tag\n"
"Configure peer-group\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 2;
struct peer_group *group;
- group = peer_group_lookup (vty->index, argv[idx_word]->arg);
+ group = peer_group_lookup (bgp, argv[idx_word]->arg);
if (group)
peer_group_delete (group);
else
@@ -2961,19 +2825,20 @@ DEFUN (no_neighbor_interface_peer_group_remote_as,
"Internal BGP peer\n"
"External BGP peer\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 2;
struct peer_group *group;
struct peer *peer;
/* look up for neighbor by interface name config. */
- peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg);
+ peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
if (peer)
{
peer_as_change (peer, 0, AS_SPECIFIED);
return CMD_SUCCESS;
}
- group = peer_group_lookup (vty->index, argv[idx_word]->arg);
+ group = peer_group_lookup (bgp, argv[idx_word]->arg);
if (group)
peer_group_remote_as_delete (group);
else
@@ -3212,16 +3077,15 @@ DEFUN (neighbor_set_peer_group,
"Member of the peer-group\n"
"Peer-group name\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_peer = 1;
int idx_word = 3;
int ret;
as_t as;
union sockunion su;
- struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- bgp = vty->index;
peer = NULL;
ret = str2sockunion (argv[idx_peer]->arg, &su);
@@ -3280,15 +3144,13 @@ DEFUN (no_neighbor_set_peer_group,
"Member of the peer-group\n"
"Peer-group name\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_peer = 2;
int idx_word = 4;
int ret;
- struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- bgp = vty->index;
-
peer = peer_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
@@ -5766,6 +5628,7 @@ DEFUN (clear_ip_bgp_all,
"Push out prefix-list ORF and do inbound soft reconfig\n"
BGP_SOFT_OUT_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
char *vrf = NULL;
afi_t afi = AFI_IP6;
@@ -5806,7 +5669,7 @@ DEFUN (clear_ip_bgp_all,
idx++;
clr_arg = argv[idx]->arg;
- if (! peer_group_lookup (vty->index, clr_arg))
+ if (! peer_group_lookup (bgp, clr_arg))
{
vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -5814,7 +5677,7 @@ DEFUN (clear_ip_bgp_all,
}
else if (argv_find (argv, argc, "WORD", &idx))
{
- if (peer_lookup_by_conf_if (vty->index, argv[idx]->arg))
+ if (peer_lookup_by_conf_if (bgp, argv[idx]->arg))
{
clr_sort = clear_peer;
clr_arg = argv[idx]->arg;
@@ -9237,6 +9100,7 @@ DEFUN (bgp_redistribute_ipv4,
"Redistribute information from another routing protocol\n"
QUAGGA_IP_REDIST_HELP_STR_BGPD)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int type;
@@ -9246,8 +9110,8 @@ DEFUN (bgp_redistribute_ipv4,
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
- bgp_redist_add(vty->index, AFI_IP, type, 0);
- return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
+ bgp_redist_add(bgp, AFI_IP, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap,
@@ -9258,6 +9122,7 @@ DEFUN (bgp_redistribute_ipv4_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_word = 3;
int type;
@@ -9270,9 +9135,9 @@ DEFUN (bgp_redistribute_ipv4_rmap,
return CMD_WARNING;
}
- red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP, type, 0);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric,
@@ -9283,6 +9148,7 @@ DEFUN (bgp_redistribute_ipv4_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_number = 3;
int type;
@@ -9297,9 +9163,9 @@ DEFUN (bgp_redistribute_ipv4_metric,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, type, 0);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
+ return bgp_redistribute_set (bgp, AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap_metric,
@@ -9312,6 +9178,7 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_word = 3;
int idx_number = 5;
@@ -9327,10 +9194,10 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP, type, 0);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
+ return bgp_redistribute_set (bgp, AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric_rmap,
@@ -9343,6 +9210,7 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
@@ -9358,10 +9226,10 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, type, 0);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
+ red = bgp_redist_add(bgp, AFI_IP, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_ospf,
@@ -9372,6 +9240,7 @@ DEFUN (bgp_redistribute_ipv4_ospf,
"Non-main Kernel Routing Table\n"
"Instance ID/Table ID\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 1;
int idx_number = 2;
u_short instance;
@@ -9384,8 +9253,8 @@ DEFUN (bgp_redistribute_ipv4_ospf,
else
protocol = ZEBRA_ROUTE_TABLE;
- bgp_redist_add(vty->index, AFI_IP, protocol, instance);
- return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
+ bgp_redist_add(bgp, AFI_IP, protocol, instance);
+ return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_rmap,
@@ -9398,6 +9267,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 1;
int idx_number = 2;
int idx_word = 4;
@@ -9411,9 +9281,9 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
protocol = ZEBRA_ROUTE_TABLE;
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
+ red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
+ return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_metric,
@@ -9426,6 +9296,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 1;
int idx_number = 2;
int idx_number_2 = 4;
@@ -9442,9 +9313,9 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
+ red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
+ return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
@@ -9459,6 +9330,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 1;
int idx_number = 2;
int idx_word = 4;
@@ -9476,10 +9348,10 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
+ red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
+ return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
@@ -9494,6 +9366,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 1;
int idx_number = 2;
int idx_number_2 = 4;
@@ -9511,10 +9384,10 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
- red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
+ red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
+ return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
}
DEFUN (no_bgp_redistribute_ipv4_ospf,
@@ -9530,6 +9403,7 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ospf_table = 2;
int idx_number = 3;
u_short instance;
@@ -9541,7 +9415,7 @@ DEFUN (no_bgp_redistribute_ipv4_ospf,
protocol = ZEBRA_ROUTE_TABLE;
VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
- return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
+ return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance);
}
DEFUN (no_bgp_redistribute_ipv4,
@@ -9555,6 +9429,7 @@ DEFUN (no_bgp_redistribute_ipv4,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 2;
int type;
@@ -9564,7 +9439,7 @@ DEFUN (no_bgp_redistribute_ipv4,
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
+ return bgp_redistribute_unset (bgp, AFI_IP, type, 0);
}
#ifdef HAVE_IPV6
@@ -9574,6 +9449,7 @@ DEFUN (bgp_redistribute_ipv6,
"Redistribute information from another routing protocol\n"
QUAGGA_IP6_REDIST_HELP_STR_BGPD)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int type;
@@ -9584,8 +9460,8 @@ DEFUN (bgp_redistribute_ipv6,
return CMD_WARNING;
}
- bgp_redist_add(vty->index, AFI_IP6, type, 0);
- return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
+ bgp_redist_add(bgp, AFI_IP6, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap,
@@ -9596,6 +9472,7 @@ DEFUN (bgp_redistribute_ipv6_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_word = 3;
int type;
@@ -9608,9 +9485,9 @@ DEFUN (bgp_redistribute_ipv6_rmap,
return CMD_WARNING;
}
- red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP6, type, 0);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric,
@@ -9621,6 +9498,7 @@ DEFUN (bgp_redistribute_ipv6_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_number = 3;
int type;
@@ -9635,9 +9513,9 @@ DEFUN (bgp_redistribute_ipv6_metric,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP6, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
+ return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap_metric,
@@ -9650,6 +9528,7 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
"Metric for redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_word = 3;
int idx_number = 5;
@@ -9665,10 +9544,10 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ red = bgp_redist_add(bgp, AFI_IP6, type, 0);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
+ return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric_rmap,
@@ -9681,6 +9560,7 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
@@ -9696,10 +9576,10 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
}
VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
- red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
- bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
+ red = bgp_redist_add(bgp, AFI_IP6, type, 0);
+ bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric);
bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
- return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
+ return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
}
DEFUN (no_bgp_redistribute_ipv6,
@@ -9713,6 +9593,7 @@ DEFUN (no_bgp_redistribute_ipv6,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_protocol = 2;
int type;
@@ -9723,7 +9604,7 @@ DEFUN (no_bgp_redistribute_ipv6,
return CMD_WARNING;
}
- return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
+ return bgp_redistribute_unset (bgp, AFI_IP6, type, 0);
}
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 6d479e1021..5ed630b49d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -78,6 +78,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_bfd.h"
#include "bgpd/bgp_memory.h"
+DEFINE_QOBJ_TYPE(bgp_master)
+DEFINE_QOBJ_TYPE(bgp)
+DEFINE_QOBJ_TYPE(peer)
+
/* BGP process wide configuration. */
static struct bgp_master bgp_master;
@@ -1018,6 +1022,8 @@ peer_free (struct peer *peer)
{
assert (peer->status == Deleted);
+ QOBJ_UNREG (peer);
+
/* this /ought/ to have been done already through bgp_stop earlier,
* but just to be sure..
*/
@@ -1201,6 +1207,7 @@ peer_new (struct bgp *bgp)
sp = getservbyname ("bgp", "tcp");
peer->port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
+ QOBJ_REG (peer, peer);
return peer;
}
@@ -2917,6 +2924,8 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type)
bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
+ QOBJ_REG (bgp, bgp);
+
update_bgp_group_init(bgp);
return bgp;
}
@@ -3233,6 +3242,8 @@ bgp_free (struct bgp *bgp)
afi_t afi;
safi_t safi;
+ QOBJ_UNREG (bgp);
+
list_delete (bgp->group);
list_delete (bgp->peer);
@@ -7481,6 +7492,8 @@ bgp_master_init (void)
/* Enable multiple instances by default. */
bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
+
+ QOBJ_REG (bm, bgp_master);
}
/*
@@ -7582,6 +7595,8 @@ bgp_terminate (void)
struct listnode *node, *nnode;
struct listnode *mnode, *mnnode;
+ QOBJ_UNREG (bm);
+
/* Close the listener sockets first as this prevents peers from attempting
* to reconnect on receiving the peer unconfig message. In the presence
* of a large number of peers this will ensure that no peer is left with
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 510082fdc2..86fa207b6b 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -21,6 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGPD_H
#define _QUAGGA_BGPD_H
+#include "qobj.h"
#include "lib/json.h"
#include "vrf.h"
@@ -120,7 +121,10 @@ struct bgp_master
struct thread *t_rmap_update; /* Handle route map updates */
u_int32_t rmap_update_timer; /* Route map update timer */
#define RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(bgp_master)
/* BGP route-map structure. */
struct bgp_rmap
@@ -356,7 +360,10 @@ struct bgp
struct rfapi_cfg *rfapi_cfg;
struct rfapi *rfapi;
#endif
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(bgp)
#define BGP_ROUTE_ADV_HOLD(bgp) (bgp->main_peers_update_hold)
@@ -879,7 +886,10 @@ u_char last_reset_cause[BGP_MAX_PACKET_SIZE];
/* hostname and domainname advertised by host */
char *hostname;
char *domainname;
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(peer)
/* Check if suppress start/restart of sessions to peer. */
#define BGP_PEER_START_SUPPRESSED(P) \
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index 52c5267bf5..b6c162eb16 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -297,13 +297,7 @@ DEFUN (vnc_advertise_un_method,
"Via Encapsulation SAFI\n"
"Via Tunnel Encap attribute (in VPN SAFI)\n")
{
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp->rfapi_cfg)
{
@@ -386,12 +380,7 @@ DEFUN (vnc_defaults_rt_import,
"Import filter\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
- struct bgp *bgp = vty->index;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
return set_ecom_list (vty, argc - 2, argv + 2,
&bgp->rfapi_cfg->default_rt_import_list);
}
@@ -403,12 +392,7 @@ DEFUN (vnc_defaults_rt_export,
"Export filter\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
- struct bgp *bgp = vty->index;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
return set_ecom_list (vty, argc - 2, argv + 2,
&bgp->rfapi_cfg->default_rt_export_list);
}
@@ -420,14 +404,9 @@ DEFUN (vnc_defaults_rt_both,
"Export+import filters\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int rc;
- struct bgp *bgp = vty->index;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
rc = set_ecom_list (vty, argc - 2, argv + 2,
&bgp->rfapi_cfg->default_rt_import_list);
if (rc != CMD_SUCCESS)
@@ -442,15 +421,9 @@ DEFUN (vnc_defaults_rd,
"Specify default route distinguisher\n"
"Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix_rd prd;
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!strncmp (argv[1]->arg, "auto:vn:", 8))
{
@@ -505,15 +478,9 @@ DEFUN (vnc_defaults_l2rd,
"Fixed value 1-255\n"
"use the low-order octet of the NVE's VN address\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
uint8_t value = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!strcmp (argv[1]->arg, "auto:vn"))
{
value = 0;
@@ -550,13 +517,7 @@ DEFUN (vnc_defaults_no_l2rd,
NO_STR
"Specify default Local Nve ID value to use in RD for L2 routes\n")
{
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->rfapi_cfg->default_l2rd = 0;
bgp->rfapi_cfg->flags &= ~BGP_VNC_CONFIG_L2RD;
@@ -570,18 +531,12 @@ DEFUN (vnc_defaults_responselifetime,
"Specify default response lifetime\n"
"Response lifetime in seconds\n" "Infinite response lifetime\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
uint32_t rspint;
- struct bgp *bgp = vty->index;
struct rfapi *h = NULL;
struct listnode *hdnode;
struct rfapi_descriptor *rfd;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
h = bgp->rfapi;
if (!h)
return CMD_WARNING;
@@ -830,15 +785,10 @@ DEFUN (vnc_redistribute_rh_roo_localadmin,
"Resolve-NVE mode\n"
"Route Origin Extended Community Local Admin Field\n" "Field value\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
uint32_t localadmin;
char *endptr;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!bgp->rfapi_cfg)
{
vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE);
@@ -892,14 +842,9 @@ DEFUN (vnc_redistribute_mode,
"Based on redistribute nve-group\n"
"Unmodified\n" "Resolve each nexthop to connected NVEs\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
vnc_redist_mode_t newmode;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!bgp->rfapi_cfg)
{
vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE);
@@ -951,15 +896,10 @@ DEFUN (vnc_redistribute_protocol,
"From Open Shortest Path First (OSPF)\n"
"From Routing Information Protocol (RIP)\n" "From Static routes\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int type = ZEBRA_ROUTE_MAX; /* init to bogus value */
- struct bgp *bgp = vty->index;
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!bgp->rfapi_cfg)
{
vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE);
@@ -1004,15 +944,10 @@ DEFUN (vnc_no_redistribute_protocol,
"From Open Shortest Path First (OSPF)\n"
"From Routing Information Protocol (RIP)\n" "From Static routes\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int type;
- struct bgp *bgp = vty->index;
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!bgp->rfapi_cfg)
{
vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE);
@@ -1050,15 +985,10 @@ DEFUN (vnc_redistribute_bgp_exterior,
"From BGP without Zebra, only to configured NVE groups\n"
"From BGP view\n" "BGP view name\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int type;
- struct bgp *bgp = vty->index;
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
if (!bgp->rfapi_cfg)
{
vty_out (vty, "RFAPI not configured%s", VTY_NEWLINE);
@@ -1089,13 +1019,7 @@ DEFUN (vnc_redistribute_nvegroup,
"Assign a NVE group to routes redistributed from another routing protocol\n"
"NVE group\n" "Group name\n")
{
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp->rfapi_cfg)
{
@@ -1127,13 +1051,7 @@ DEFUN (vnc_redistribute_no_nvegroup,
"Redistribute from other protocol\n"
"Assign a NVE group to routes redistributed from another routing protocol\n")
{
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp->rfapi_cfg)
{
@@ -1161,13 +1079,7 @@ DEFUN (vnc_redistribute_lifetime,
"Assign a lifetime to routes redistributed from another routing protocol\n"
"lifetime value (32 bit)\n")
{
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
if (!bgp->rfapi_cfg)
{
@@ -1205,17 +1117,11 @@ DEFUN (vnc_redist_bgpdirect_no_prefixlist,
"IPv4 routes\n"
"IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
afi_t afi;
struct rfapi_cfg *hc;
uint8_t route_type = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1264,17 +1170,11 @@ DEFUN (vnc_redist_bgpdirect_prefixlist,
"Prefix-list for filtering redistributed routes\n"
"prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
afi_t afi;
uint8_t route_type = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1321,16 +1221,10 @@ DEFUN (vnc_redist_bgpdirect_no_routemap,
"Redistribute from BGP without Zebra, only to configured NVE groups\n"
"Route-map for filtering redistributed routes\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
uint8_t route_type = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1367,16 +1261,10 @@ DEFUN (vnc_redist_bgpdirect_routemap,
"Redistribute from BGP without Zebra, only to configured NVE groups\n"
"Route-map for filtering exported routes\n" "route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
uint8_t route_type = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1418,16 +1306,10 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_prefixlist,
"IPv4 routes\n"
"IPv6 routes\n" "Prefix-list for filtering redistributed routes\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg)
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1473,16 +1355,10 @@ DEFUN (vnc_nve_group_redist_bgpdirect_prefixlist,
"Prefix-list for filtering redistributed routes\n"
"prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1528,15 +1404,9 @@ DEFUN (vnc_nve_group_redist_bgpdirect_no_routemap,
"Disable redistribute filter\n"
"Route-map for filtering redistributed routes\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1570,15 +1440,9 @@ DEFUN (vnc_nve_group_redist_bgpdirect_routemap,
"Redistribute from BGP directly\n"
"Route-map for filtering exported routes\n" "route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1624,16 +1488,10 @@ DEFUN (vnc_export_mode,
"Export routes with NVE connected router next-hops\n"
"Disable export\n" "Export routes with registering NVE as next-hop\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
uint32_t oldmode = 0;
uint32_t newmode = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "VNC not configured%s", VTY_NEWLINE);
@@ -1753,15 +1611,9 @@ DEFUN (vnc_export_nvegroup,
"NVE group, used in 'group-nve' export mode\n"
"NVE group\n" "Group name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_nve_group_cfg *rfg_new;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1860,16 +1712,10 @@ DEFUN (vnc_no_export_nvegroup,
"NVE group, used in 'group-nve' export mode\n"
"Disable export of VNC routes\n" "NVE group\n" "Group name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct listnode *node, *nnode;
struct rfapi_rfg_name *rfgn;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -1927,16 +1773,10 @@ DEFUN (vnc_nve_group_export_no_prefixlist,
"IPv6 routes\n"
"Prefix-list for filtering exported routes\n" "prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2002,16 +1842,10 @@ DEFUN (vnc_nve_group_export_prefixlist,
"IPv6 routes\n"
"Prefix-list for filtering exported routes\n" "prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2066,15 +1900,9 @@ DEFUN (vnc_nve_group_export_no_routemap,
"Export to Zebra (experimental)\n"
"Route-map for filtering exported routes\n" "route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2131,15 +1959,9 @@ DEFUN (vnc_nve_group_export_routemap,
"Export to Zebra (experimental)\n"
"Route-map for filtering exported routes\n" "route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!bgp->rfapi_cfg)
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2187,16 +2009,10 @@ DEFUN (vnc_nve_export_no_prefixlist,
"IPv6 prefixes\n"
"Prefix-list for filtering exported routes\n" "Prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2255,16 +2071,10 @@ DEFUN (vnc_nve_export_prefixlist,
"IPv6 prefixes\n"
"Prefix-list for filtering exported routes\n" "Prefix list name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
afi_t afi;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2309,15 +2119,9 @@ DEFUN (vnc_nve_export_no_routemap,
"Export to Zebra (experimental)\n"
"Route-map for filtering exported routes\n" "Route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2367,15 +2171,9 @@ DEFUN (vnc_nve_export_routemap,
"Filters, used in 'registering-nve' export mode\n"
"Route-map for filtering exported routes\n" "Route map name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_cfg *hc;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (!(hc = bgp->rfapi_cfg))
{
vty_out (vty, "rfapi not configured%s", VTY_NEWLINE);
@@ -2611,17 +2409,11 @@ DEFUN (vnc_nve_group,
"vnc nve-group NAME",
VNC_CONFIG_STR "Configure a NVE group\n" "Group name\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_nve_group_cfg *rfg;
- struct bgp *bgp = vty->index;
struct listnode *node, *nnode;
struct rfapi_rfg_name *rfgn;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* Search for name */
rfg = rfapi_group_lookup_byname (bgp, argv[2]->arg);
@@ -2911,13 +2703,8 @@ DEFUN (vnc_no_nve_group,
"Configure a NVE group\n"
"Group name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
return bgp_rfapi_delete_named_nve_group (vty, bgp, argv[3]->arg);
}
@@ -2930,6 +2717,7 @@ DEFUN (vnc_nve_group_prefix,
"IPv4 prefix\n"
"IPv6 prefix\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
struct prefix p;
int afi;
@@ -2937,14 +2725,6 @@ DEFUN (vnc_nve_group_prefix,
struct route_node *rn;
int is_un_prefix = 0;
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
{
@@ -3056,20 +2836,14 @@ DEFUN (vnc_nve_group_rt_import,
"Import filter\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
int rc;
struct listnode *node;
struct rfapi_rfg_name *rfgn;
int is_export_bgp = 0;
int is_export_zebra = 0;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
{
@@ -3132,16 +2906,10 @@ DEFUN (vnc_nve_group_rt_export,
"Export filter\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
int rc;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
{
@@ -3172,20 +2940,14 @@ DEFUN (vnc_nve_group_rt_both,
"Export+import filters\n"
"Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
int rc;
int is_export_bgp = 0;
int is_export_zebra = 0;
struct listnode *node;
struct rfapi_rfg_name *rfgn;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
{
@@ -3264,14 +3026,8 @@ DEFUN (vnc_nve_group_l2rd,
"Fixed value 1-255\n"
"use the low-order octet of the NVE's VN address\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
@@ -3318,14 +3074,8 @@ DEFUN (vnc_nve_group_no_l2rd,
NO_STR
"Specify default Local Nve ID value to use in RD for L2 routes\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
@@ -3347,16 +3097,10 @@ DEFUN (vnc_nve_group_rd,
"Specify route distinguisher\n"
"Route Distinguisher (<as-number>:<number> | <ip-address>:<number> | auto:vn:<number> )\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix_rd prd;
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
@@ -3428,18 +3172,12 @@ DEFUN (vnc_nve_group_responselifetime,
"Specify response lifetime\n"
"Response lifetime in seconds\n" "Infinite response lifetime\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
unsigned int rspint;
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
- struct bgp *bgp = vty->index;
struct rfapi_descriptor *rfd;
struct listnode *hdnode;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->nve_groups_sequential, rfg))
{
@@ -3507,14 +3245,8 @@ DEFUN (vnc_l2_group,
"vnc l2-group NAME",
VNC_CONFIG_STR "Configure a L2 group\n" "Group name\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
struct rfapi_l2_group_cfg *rfg;
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
/* Search for name */
rfg = rfapi_l2_group_lookup_byname (bgp, argv[2]->arg);
@@ -3600,13 +3332,8 @@ DEFUN (vnc_no_l2_group,
"Configure a L2 group\n"
"Group name\n")
{
- struct bgp *bgp = vty->index;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
return bgp_rfapi_delete_named_l2_group (vty, bgp, argv[3]->arg);
}
@@ -3617,14 +3344,8 @@ DEFUN (vnc_l2_group_lni,
"Specify Logical Network ID associated with group\n"
"value\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
- struct bgp *bgp = vty->index;
-
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg))
@@ -3645,16 +3366,10 @@ DEFUN (vnc_l2_group_labels,
"Specify label values associated with group\n"
"Space separated list of label values <0-1048575>\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
- struct bgp *bgp = vty->index;
struct list *ll;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg))
{
@@ -3691,16 +3406,10 @@ DEFUN (vnc_l2_group_no_labels,
"Specify label values associated with L2 group\n"
"Space separated list of label values <0-1048575>\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
- struct bgp *bgp = vty->index;
struct list *ll;
- if (!bgp)
- {
- vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* make sure it's still in list */
if (!listnode_lookup (bgp->rfapi_cfg->l2_groups, rfg))
{
@@ -3737,8 +3446,8 @@ DEFUN (vnc_l2_group_rt,
"Import filters\n"
"A route target\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
- struct bgp *bgp = vty->index;
int rc = CMD_SUCCESS;
int do_import = 0;
int do_export = 0;
diff --git a/bgpd/rfp-example/librfp/rfp_example.c b/bgpd/rfp-example/librfp/rfp_example.c
index 614e2464a4..b7dfe7987c 100644
--- a/bgpd/rfp-example/librfp/rfp_example.c
+++ b/bgpd/rfp-example/librfp/rfp_example.c
@@ -45,7 +45,7 @@ DEFUN (rfp_example_config_value,
{
uint32_t value = 0;
struct rfp_instance_t *rfi = NULL;
- rfi = rfapi_get_rfp_start_val (vty->index); /* index=bgp for BGP_NODE */
+ rfi = rfapi_get_rfp_start_val (VTY_GET_CONTEXT (bgp)); /* BGP_NODE */
assert (rfi != NULL);
VTY_GET_INTEGER ("Example value", value, argv[2]->arg);
diff --git a/isisd/Makefile.am b/isisd/Makefile.am
index 05f96c3807..89a39ef065 100644
--- a/isisd/Makefile.am
+++ b/isisd/Makefile.am
@@ -1,7 +1,6 @@
## Process this file with automake to produce Makefile.in.
-AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \
- -DVTY_DEPRECATE_INDEX
+AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
LIBS = @LIBS@
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 4ca9e7fff3..f09afeb931 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -320,12 +320,6 @@ area_net_title (struct vty *vty, const char *net_title)
u_char buff[255];
- if (!area)
- {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_ERR_NO_MATCH;
- }
-
/* We check that we are not over the maximal number of addresses */
if (listcount (area->area_addrs) >= isis->max_area_addrs)
{
@@ -420,12 +414,6 @@ area_clear_net_title (struct vty *vty, const char *net_title)
struct listnode *node;
u_char buff[255];
- if (!area)
- {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_ERR_NO_MATCH;
- }
-
addr.addr_len = dotformat2buff (buff, net_title);
if (addr.addr_len < 8 || addr.addr_len > 20)
{
diff --git a/ldpd/Makefile.am b/ldpd/Makefile.am
index 1f4d910192..c292adf6fc 100644
--- a/ldpd/Makefile.am
+++ b/ldpd/Makefile.am
@@ -1,7 +1,6 @@
## Process this file with automake to produce Makefile.in.
-AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \
- -DVTY_DEPRECATE_INDEX
+AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
diff --git a/lib/Makefile.am b/lib/Makefile.am
index ffbbacc872..29584f82b5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,7 +1,6 @@
## Process this file with automake to produce Makefile.in.
-AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \
- -DVTY_DEPRECATE_INDEX
+AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
AM_CFLAGS = $(WERROR)
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
AM_YFLAGS = -d
diff --git a/lib/if.c b/lib/if.c
index a1bac2ce81..fb12f201b2 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -784,7 +784,7 @@ DEFUN (interface,
vty_out (vty, "%% interface %s not in %s%s", ifname, vrfname, VTY_NEWLINE);
return CMD_WARNING;
}
- VTY_PUSH_CONTEXT_COMPAT (INTERFACE_NODE, ifp);
+ VTY_PUSH_CONTEXT (INTERFACE_NODE, ifp);
return CMD_SUCCESS;
}
diff --git a/lib/keychain.c b/lib/keychain.c
index f8a3ffc012..cd8039b95b 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -251,7 +251,7 @@ DEFUN (key_chain,
struct keychain *keychain;
keychain = keychain_get (argv[idx_word]->arg);
- VTY_PUSH_CONTEXT_COMPAT (KEYCHAIN_NODE, keychain);
+ VTY_PUSH_CONTEXT (KEYCHAIN_NODE, keychain);
return CMD_SUCCESS;
}
diff --git a/lib/qobj.c b/lib/qobj.c
index f64972e32a..aeae52e029 100644
--- a/lib/qobj.c
+++ b/lib/qobj.c
@@ -49,7 +49,7 @@ void qobj_reg(struct qobj_node *node, struct qobj_nodetype *type)
node->nid = (uint64_t)random();
node->nid ^= (uint64_t)random() << 32;
}
- while (hash_get (nodes, node, hash_alloc_intern) != node);
+ while (!node->nid || hash_get (nodes, node, hash_alloc_intern) != node);
}
void qobj_unreg(struct qobj_node *node)
diff --git a/lib/qobj.h b/lib/qobj.h
index 4c326731ed..64a6774bff 100644
--- a/lib/qobj.h
+++ b/lib/qobj.h
@@ -109,6 +109,8 @@ void *qobj_get_typed(uint64_t id, struct qobj_nodetype *type);
#define QOBJ_ID(ptr) \
((ptr)->qobj_node.nid)
+#define QOBJ_ID_0SAFE(ptr) \
+ ({ typeof (ptr) _ptr = (ptr); _ptr ? _ptr->qobj_node.nid : 0ULL; })
void qobj_init(void);
void qobj_finish(void);
diff --git a/lib/routemap.c b/lib/routemap.c
index d6a5b713c5..5f2b2c0dfb 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -2549,7 +2549,7 @@ DEFUN (route_map,
map = route_map_get (mapname);
index = route_map_index_get (map, permit, pref);
- VTY_PUSH_CONTEXT_COMPAT (RMAP_NODE, index);
+ VTY_PUSH_CONTEXT (RMAP_NODE, index);
return CMD_SUCCESS;
}
diff --git a/lib/vrf.c b/lib/vrf.c
index 0d0b1cc27d..14501c5265 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -494,7 +494,7 @@ DEFUN (vrf,
vrfp = vrf_get (VRF_UNKNOWN, vrfname);
- VTY_PUSH_CONTEXT_COMPAT (VRF_NODE, vrfp);
+ VTY_PUSH_CONTEXT (VRF_NODE, vrfp);
return CMD_SUCCESS;
}
diff --git a/lib/vty.h b/lib/vty.h
index 51d61b4a8c..24bdcd1817 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -29,14 +29,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define VTY_BUFSIZ 512
#define VTY_MAXHIST 20
-#if defined(VTY_DEPRECATE_INDEX) && defined(__GNUC__) && \
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && \
- !defined(__ICC)
-#define INDEX_WARNING __attribute__((deprecated))
-#else
-#define INDEX_WARNING
-#endif
-
/* VTY struct. */
struct vty
{
@@ -82,10 +74,6 @@ struct vty
/* History insert end point */
int hindex;
- /* For current referencing point of interface, route-map,
- access-list etc... */
- void *index INDEX_WARNING;
-
/* qobj object ID (replacement for "index") */
uint64_t qobj_index;
@@ -139,32 +127,23 @@ struct vty
char address[SU_ADDRSTRLEN];
};
-#undef INDEX_WARNING
-
static inline void vty_push_context(struct vty *vty,
- int node, uint64_t id, void *idx)
+ int node, uint64_t id)
{
vty->node = node;
vty->qobj_index = id;
-#if defined(VTY_DEPRECATE_INDEX) && defined(__GNUC__) && \
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- vty->index = idx;
-#pragma GCC diagnostic pop
-#else
- vty->index = idx;
-#endif
}
+/* note: VTY_PUSH_CONTEXT(..., NULL) doesn't work, since it will try to
+ * dereference "NULL->qobj_node.nid" */
#define VTY_PUSH_CONTEXT(nodeval, ptr) \
- vty_push_context(vty, nodeval, QOBJ_ID(ptr), NULL)
-#define VTY_PUSH_CONTEXT_COMPAT(nodeval, ptr) \
- vty_push_context(vty, nodeval, QOBJ_ID(ptr), ptr)
+ vty_push_context(vty, nodeval, QOBJ_ID_0SAFE(ptr))
+#define VTY_PUSH_CONTEXT_NULL(nodeval) \
+ vty_push_context(vty, nodeval, 0ULL)
#define VTY_PUSH_CONTEXT_SUB(nodeval, ptr) do { \
vty->node = nodeval; \
/* qobj_index stays untouched */ \
- vty->qobj_index_sub = QOBJ_ID(ptr); \
+ vty->qobj_index_sub = QOBJ_ID_0SAFE(ptr); \
} while (0)
/* can return NULL if context is invalid! */
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index c00445e34a..d31b4b95b4 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -1103,8 +1103,9 @@ DEFUN (ospf6_routemap_match_address_prefixlist,
"Match entries of prefix-lists\n"
"IPv6 prefix-list name\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_word = 4;
- int ret = route_map_add_match ((struct route_map_index *) vty->index,
+ int ret = route_map_add_match (route_map_index,
"ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret);
}
@@ -1120,8 +1121,9 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist,
"Match entries of prefix-lists\n"
"IPv6 prefix-list name\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_word = 5;
- int ret = route_map_delete_match ((struct route_map_index *) vty->index,
+ int ret = route_map_delete_match (route_map_index,
"ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret);
}
@@ -1134,8 +1136,9 @@ DEFUN (ospf6_routemap_match_interface,
"Match first hop interface of route\n"
"Interface name\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_word = 2;
- return route_map_add_match ((struct route_map_index *) vty->index,
+ return route_map_add_match (route_map_index,
"interface", argv[idx_word]->arg);
}
@@ -1148,14 +1151,15 @@ DEFUN (ospf6_routemap_no_match_interface,
"Match first hop interface of route\n"
"Interface name\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_word = 3;
int ret;
if (argc == 4)
- ret = route_map_delete_match ((struct route_map_index *) vty->index,
+ ret = route_map_delete_match (route_map_index,
"interface", argv[idx_word]->arg);
else
- ret = route_map_delete_match ((struct route_map_index *) vty->index,
+ ret = route_map_delete_match (route_map_index,
"interface", NULL);
return route_map_command_status (vty, ret);
}
@@ -1169,8 +1173,9 @@ DEFUN (ospf6_routemap_set_metric_type,
"OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_external = 2;
- int ret = route_map_add_set ((struct route_map_index *) vty->index,
+ int ret = route_map_add_set (route_map_index,
"metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret);
}
@@ -1185,8 +1190,9 @@ DEFUN (ospf6_routemap_no_set_metric_type,
"OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_external = 3;
- int ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ int ret = route_map_delete_set (route_map_index,
"metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret);
}
@@ -1199,8 +1205,9 @@ DEFUN (ospf6_routemap_set_forwarding,
"Forwarding Address\n"
"IPv6 Address\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_ipv6 = 2;
- int ret = route_map_add_set ((struct route_map_index *) vty->index,
+ int ret = route_map_add_set (route_map_index,
"forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret);
}
@@ -1214,8 +1221,9 @@ DEFUN (ospf6_routemap_no_set_forwarding,
"Forwarding Address\n"
"IPv6 Address\n")
{
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
int idx_ipv6 = 3;
- int ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ int ret = route_map_delete_set (route_map_index,
"forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret);
}
@@ -1228,7 +1236,8 @@ DEFUN (ospf6_routemap_set_tag,
"Tag value for routing protocol\n"
"Tag value\n")
{
- int ret = route_map_add_set ((struct route_map_index *) vty->index,
+ VTY_DECLVAR_CONTEXT(route_map_index, route_map_index);
+ int ret = route_map_add_set (route_map_index,
"tag", argv[2]->arg);
return route_map_command_status (vty, ret);
}
diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c
index ffbefd139d..28126918b5 100644
--- a/ospf6d/ospf6_bfd.c
+++ b/ospf6d/ospf6_bfd.c
@@ -328,10 +328,8 @@ DEFUN (ipv6_ospf6_bfd,
"Enables BFD support\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -354,17 +352,16 @@ DEFUN (ipv6_ospf6_bfd_param,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct ospf6_interface *oi;
- struct interface *ifp;
u_int32_t rx_val;
u_int32_t tx_val;
u_int8_t dm_val;
int ret;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -390,10 +387,8 @@ DEFUN (no_ipv6_ospf6_bfd,
"Disables BFD support\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 74c9ac739f..0ed8d30a8b 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -46,6 +46,7 @@
#include "ospf6_bfd.h"
DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names")
+DEFINE_QOBJ_TYPE(ospf6_interface)
unsigned char conf_debug_ospf6_interface = 0;
@@ -212,6 +213,8 @@ ospf6_interface_create (struct interface *ifp)
oi->ifmtu = iobuflen;
}
+ QOBJ_REG (oi, ospf6_interface);
+
oi->lsupdate_list = ospf6_lsdb_create (oi);
oi->lsack_list = ospf6_lsdb_create (oi);
oi->lsdb = ospf6_lsdb_create (oi);
@@ -238,6 +241,8 @@ ospf6_interface_delete (struct ospf6_interface *oi)
struct listnode *node, *nnode;
struct ospf6_neighbor *on;
+ QOBJ_UNREG (oi);
+
for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete (on);
@@ -1097,14 +1102,13 @@ DEFUN (ipv6_ospf6_ifmtu,
"OSPFv3 Interface MTU\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
unsigned int ifmtu, iobuflen;
struct listnode *node, *nnode;
struct ospf6_neighbor *on;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1158,13 +1162,12 @@ DEFUN (no_ipv6_ospf6_ifmtu,
"Interface MTU\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
unsigned int iobuflen;
struct listnode *node, *nnode;
struct ospf6_neighbor *on;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1206,12 +1209,11 @@ DEFUN (ipv6_ospf6_cost,
"Outgoing metric of this interface\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
unsigned long int lcost;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1247,10 +1249,8 @@ DEFUN (no_ipv6_ospf6_cost,
"Calculate interface cost from bandwidth\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1272,8 +1272,8 @@ DEFUN (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(ospf6, o);
int idx_number = 2;
- struct ospf6 *o = vty->index;
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct listnode *i, *j;
@@ -1306,7 +1306,7 @@ DEFUN (no_auto_cost_reference_bandwidth,
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct listnode *i, *j;
@@ -1332,11 +1332,9 @@ DEFUN (ipv6_ospf6_hellointerval,
SECONDS_STR
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1358,11 +1356,9 @@ DEFUN (ipv6_ospf6_deadinterval,
SECONDS_STR
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1383,11 +1379,9 @@ DEFUN (ipv6_ospf6_transmitdelay,
"Link state transmit delay\n"
SECONDS_STR)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1409,11 +1403,9 @@ DEFUN (ipv6_ospf6_retransmitinterval,
SECONDS_STR
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1435,11 +1427,9 @@ DEFUN (ipv6_ospf6_priority,
"Priority value\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1467,11 +1457,9 @@ DEFUN (ipv6_ospf6_instance,
"Instance ID value\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *)vty->index;
assert (ifp);
oi = (struct ospf6_interface *)ifp->info;
@@ -1491,12 +1479,11 @@ DEFUN (ipv6_ospf6_passive,
"Passive interface; no adjacency will be formed on this interface\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
struct listnode *node, *nnode;
struct ospf6_neighbor *on;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1525,10 +1512,8 @@ DEFUN (no_ipv6_ospf6_passive,
"passive interface: No Adjacency will be formed on this I/F\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1552,10 +1537,8 @@ DEFUN (ipv6_ospf6_mtu_ignore,
"Disable MTU mismatch detection on this interface\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1577,10 +1560,8 @@ DEFUN (no_ipv6_ospf6_mtu_ignore,
"Disable MTU mismatch detection on this interface\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1603,11 +1584,9 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
"Prefix list name\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_word = 4;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1645,10 +1624,8 @@ DEFUN (no_ipv6_ospf6_advertise_prefix_list,
"Filter prefix using prefix-list\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1688,11 +1665,9 @@ DEFUN (ipv6_ospf6_network,
"Specify OSPF6 point-to-point network\n"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_network = 3;
struct ospf6_interface *oi;
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
@@ -1733,11 +1708,10 @@ DEFUN (no_ipv6_ospf6_network,
"Default to whatever interface type system specifies"
)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf6_interface *oi;
- struct interface *ifp;
int type;
- ifp = (struct interface *) vty->index;
assert (ifp);
oi = (struct ospf6_interface *) ifp->info;
diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h
index 3e09bfb930..179477a634 100644
--- a/ospf6d/ospf6_interface.h
+++ b/ospf6d/ospf6_interface.h
@@ -22,6 +22,7 @@
#ifndef OSPF6_INTERFACE_H
#define OSPF6_INTERFACE_H
+#include "qobj.h"
#include "if.h"
/* Debug option */
@@ -116,7 +117,10 @@ struct ospf6_interface
/* BFD information */
void *bfd_info;
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(ospf6_interface)
/* interface state */
#define OSPF6_INTERFACE_NONE 0
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index df8925c453..04519e7d46 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -866,7 +866,7 @@ ospf6_timers_spf_set (struct vty *vty, unsigned int delay,
unsigned int hold,
unsigned int max)
{
- struct ospf6 *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf);
ospf->spf_delay = delay;
ospf->spf_holdtime = hold;
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 16fb012ea9..6da9680fe2 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -49,6 +49,8 @@
#include "ospf6_spf.h"
#include "ospf6d.h"
+DEFINE_QOBJ_TYPE(ospf6)
+
/* global ospf6d variable */
struct ospf6 *ospf6;
@@ -159,6 +161,7 @@ ospf6_create (void)
/* Enable "log-adjacency-changes" */
SET_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
+ QOBJ_REG (o, ospf6);
return o;
}
@@ -169,6 +172,7 @@ ospf6_delete (struct ospf6 *o)
struct listnode *node, *nnode;
struct ospf6_area *oa;
+ QOBJ_UNREG (o);
ospf6_disable (ospf6);
for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
@@ -294,8 +298,7 @@ DEFUN (router_ospf6,
ospf6 = ospf6_create ();
/* set current ospf point. */
- vty->node = OSPF6_NODE;
- vty->index = ospf6;
+ VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6);
return CMD_SUCCESS;
}
@@ -309,8 +312,7 @@ DEFUN (no_router_ospf6,
OSPF6_STR)
{
/* return to config node . */
- vty->node = CONFIG_NODE;
- vty->index = NULL;
+ VTY_PUSH_CONTEXT_NULL(CONFIG_NODE);
return CMD_SUCCESS;
}
@@ -322,12 +324,10 @@ DEFUN (ospf6_router_id,
"Configure OSPF Router-ID\n"
V4NOTATION_STR)
{
+ VTY_DECLVAR_CONTEXT(ospf6, o);
int idx_ipv4 = 1;
int ret;
u_int32_t router_id;
- struct ospf6 *o;
-
- o = (struct ospf6 *) vty->index;
ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
if (ret == 0)
@@ -348,7 +348,7 @@ DEFUN (ospf6_log_adjacency_changes,
"log-adjacency-changes",
"Log changes in adjacency state\n")
{
- struct ospf6 *ospf6 = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
@@ -361,7 +361,7 @@ DEFUN (ospf6_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
- struct ospf6 *ospf6 = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
@@ -374,7 +374,7 @@ DEFUN (no_ospf6_log_adjacency_changes,
NO_STR
"Log changes in adjacency state\n")
{
- struct ospf6 *ospf6 = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
@@ -388,7 +388,7 @@ DEFUN (no_ospf6_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
- struct ospf6 *ospf6 = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
@@ -403,12 +403,9 @@ DEFUN (ospf6_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf6, ospf);
int idx_number = 3;
unsigned int minarrival;
- struct ospf6 *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg);
ospf->lsa_minarrival = minarrival;
@@ -425,12 +422,9 @@ DEFUN (no_ospf6_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf6, ospf);
int idx_number = 4;
unsigned int minarrival;
- struct ospf6 *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc == 5)
{
@@ -453,7 +447,7 @@ DEFUN (ospf6_distance,
"Administrative distance\n"
"OSPF6 Administrative distance\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
o->distance_all = atoi (argv[1]->arg);
@@ -467,7 +461,7 @@ DEFUN (no_ospf6_distance,
"Administrative distance\n"
"OSPF6 Administrative distance\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
o->distance_all = 0;
@@ -498,7 +492,7 @@ DEFUN (ospf6_distance_ospf6,
"External routes\n"
"Distance for external routes\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
char *intra, *inter, *external;
intra = inter = external = NULL;
@@ -568,7 +562,7 @@ DEFUN (no_ospf6_distance_ospf6,
"External routes\n"
"Distance for external routes\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
char *intra, *inter, *external;
intra = inter = external = NULL;
@@ -632,7 +626,7 @@ DEFUN (ospf6_distance_source,
"IP source prefix\n"
"Access list name\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
char *alname = (argc == 4) ? argv[3]->arg : NULL;
ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname);
@@ -648,7 +642,7 @@ DEFUN (no_ospf6_distance_source,
"IP source prefix\n"
"Access list name\n")
{
- struct ospf6 *o = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf6, o);
char *alname = (argc == 5) ? argv[4]->arg : NULL;
ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname);
@@ -665,16 +659,14 @@ DEFUN (ospf6_interface_area,
"OSPF6 area ID in IPv4 address notation\n"
)
{
+ VTY_DECLVAR_CONTEXT(ospf6, o);
int idx_ifname = 1;
int idx_ipv4 = 3;
- struct ospf6 *o;
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct interface *ifp;
u_int32_t area_id;
- o = (struct ospf6 *) vty->index;
-
/* find/create ospf6 interface */
ifp = if_get_by_name (argv[idx_ifname]->arg);
oi = (struct ospf6_interface *) ifp->info;
diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h
index 8985eeaa28..42a4d12483 100644
--- a/ospf6d/ospf6_top.h
+++ b/ospf6d/ospf6_top.h
@@ -22,6 +22,7 @@
#ifndef OSPF6_TOP_H
#define OSPF6_TOP_H
+#include "qobj.h"
#include "routemap.h"
/* OSPFv3 top level data structure */
@@ -93,7 +94,10 @@ struct ospf6
u_char distance_external;
struct route_table *distance_table;
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(ospf6)
#define OSPF6_DISABLED 0x01
#define OSPF6_STUB_ROUTER 0x02
diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c
index b6c871b6e4..b4d50a6b9f 100644
--- a/ospfd/ospf_bfd.c
+++ b/ospfd/ospf_bfd.c
@@ -368,7 +368,7 @@ DEFUN (ip_ospf_bfd,
"OSPF interface commands\n"
"Enables BFD support\n")
{
- struct interface *ifp = (struct interface *) vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf_if_params *params;
struct bfd_info *bfd_info;
@@ -393,10 +393,10 @@ DEFUN (ip_ospf_bfd_param,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
- struct interface *ifp = (struct interface *) vty->index;
u_int32_t rx_val;
u_int32_t tx_val;
u_int8_t dm_val;
@@ -424,7 +424,7 @@ DEFUN (no_ip_ospf_bfd,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
- struct interface *ifp = (struct interface *)vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ospf_if_params *params;
assert (ifp);
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 8440765579..936ec69666 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -51,6 +51,7 @@
#include "ospfd/ospf_snmp.h"
#endif /* HAVE_SNMP */
+DEFINE_QOBJ_TYPE(ospf_interface)
int
ospf_if_get_output_cost (struct ospf_interface *oi)
@@ -246,7 +247,8 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
ospf_opaque_type9_lsa_init (oi);
oi->ospf = ospf;
-
+ QOBJ_REG (oi, ospf_interface);
+
return oi;
}
@@ -307,6 +309,8 @@ ospf_if_free (struct ospf_interface *oi)
ospf_opaque_type9_lsa_term (oi);
+ QOBJ_UNREG (oi);
+
/* Free Pseudo Neighbour */
ospf_nbr_delete (oi->nbr_self);
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index 7a74288bff..bd51bbf422 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -23,6 +23,7 @@
#ifndef _ZEBRA_OSPF_INTERFACE_H
#define _ZEBRA_OSPF_INTERFACE_H
+#include "qobj.h"
#include "ospfd/ospf_packet.h"
#include "ospfd/ospf_spf.h"
@@ -228,7 +229,10 @@ struct ospf_interface
u_int32_t state_change; /* Number of status change. */
u_int32_t full_nbrs;
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(ospf_interface)
/* Prototypes. */
extern char *ospf_if_name (struct ospf_interface *);
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index a1981be86d..56efa2ebd6 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -769,10 +769,7 @@ DEFUN (capability_opaque,
"Enable specific OSPF feature\n"
"Opaque LSA\n")
{
- struct ospf *ospf = (struct ospf *) vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
/* Turn on the "master switch" of opaque-lsa capability. */
if (!CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
@@ -802,10 +799,7 @@ DEFUN (no_capability_opaque,
"Enable specific OSPF feature\n"
"Opaque LSA\n")
{
- struct ospf *ospf = (struct ospf *) vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
/* Turn off the "master switch" of opaque-lsa capability. */
if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 4166aabe21..717dc25f94 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -119,9 +119,10 @@ ospf_route_map_event (route_map_event_t event, const char *name)
/* Delete rip route map rule. */
static int
-ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
+ospf_route_match_delete (struct vty *vty,
const char *command, const char *arg)
{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
int ret;
ret = route_map_delete_match (index, command, arg);
@@ -142,9 +143,10 @@ ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
}
static int
-ospf_route_match_add (struct vty *vty, struct route_map_index *index,
+ospf_route_match_add (struct vty *vty,
const char *command, const char *arg)
-{
+{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
int ret;
ret = route_map_add_match (index, command, arg);
@@ -590,7 +592,7 @@ DEFUN (match_ip_nexthop,
"IP access-list name\n")
{
int idx_acl = 3;
- return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg);
+ return ospf_route_match_add (vty, "ip next-hop", argv[idx_acl]->arg);
}
DEFUN (no_match_ip_nexthop,
@@ -605,7 +607,7 @@ DEFUN (no_match_ip_nexthop,
"IP access-list name\n")
{
char *al = (argc == 5) ? argv[4]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "ip next-hop", al);
+ return ospf_route_match_delete (vty, "ip next-hop", al);
}
DEFUN (set_metric_type,
@@ -617,7 +619,8 @@ DEFUN (set_metric_type,
"OSPF[6] external type 2 metric\n")
{
char *ext = argv[2]->text;
- return generic_set_add (vty, vty->index, "metric-type", ext);
+ return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
+ "metric-type", ext);
}
DEFUN (no_set_metric_type,
@@ -630,7 +633,8 @@ DEFUN (no_set_metric_type,
"OSPF[6] external type 2 metric\n")
{
char *ext = (argc == 4) ? argv[3]->text : NULL;
- return generic_set_delete (vty, vty->index, "metric-type", ext);
+ return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
+ "metric-type", ext);
}
/* Route-map init */
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 321c035d3a..c691aac040 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -2264,12 +2264,9 @@ DEFUN (ospf_mpls_te_on,
MPLS_TE_STR
"Enable the MPLS-TE functionality\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct listnode *node;
struct mpls_te_link *lp;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (OspfMplsTE.status == enabled)
return CMD_SUCCESS;
@@ -2304,12 +2301,9 @@ DEFUN (no_ospf_mpls_te,
MPLS_TE_STR
"Disable the MPLS-TE functionality\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct listnode *node, *nnode;
struct mpls_te_link *lp;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (OspfMplsTE.status == disabled)
return CMD_SUCCESS;
@@ -2334,13 +2328,10 @@ 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);
int idx_ipv4 = 2;
struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr;
struct in_addr value;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (! inet_aton (argv[idx_ipv4]->arg, &value))
{
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index df989982d1..c2999ca02a 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -160,21 +160,19 @@ DEFUN (router_ospf,
return CMD_WARNING;
}
- vty->node = OSPF_NODE;
-
if (argc > 2)
VTY_GET_INTEGER ("Instance", instance, argv[2]->arg);
- /* The following logic to set the vty->index is in place to be able
+ /* The following logic to set the vty qobj index is in place to be able
to ignore the commands which dont belong to this instance. */
if (ospf->instance != instance)
- vty->index = NULL;
+ VTY_PUSH_CONTEXT_NULL(OSPF_NODE);
else
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Config command 'router ospf %d' received", instance);
ospf->oi_running = 1;
- vty->index = ospf;
+ VTY_PUSH_CONTEXT(OSPF_NODE, ospf);
ospf_router_id_update (ospf);
}
@@ -211,16 +209,13 @@ DEFUN (ospf_router_id,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
- struct ospf *ospf = vty->index;
struct listnode *node;
struct ospf_area *area;
struct in_addr router_id;
int ret;
- if (!ospf)
- return CMD_SUCCESS;
-
ret = inet_aton (argv[idx_ipv4]->arg, &router_id);
if (!ret)
{
@@ -249,16 +244,13 @@ 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);
int idx_ipv4 = 1;
- struct ospf *ospf = vty->index;
struct listnode *node;
struct ospf_area *area;
struct in_addr router_id;
int ret;
- if (!ospf)
- return CMD_SUCCESS;
-
ret = inet_aton (argv[idx_ipv4]->arg, &router_id);
if (!ret)
{
@@ -289,13 +281,10 @@ DEFUN (no_ospf_router_id,
"router-id for the OSPF process\n"
"OSPF router-id in IP address format\n")
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct listnode *node;
struct ospf_area *area;
- if (!ospf)
- return CMD_SUCCESS;
-
ospf->router_id_static.s_addr = 0;
for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
@@ -383,16 +372,13 @@ DEFUN (ospf_passive_interface,
"IPv4 address\n"
"Suppress routing updates on interfaces by default\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
struct interface *ifp;
struct in_addr addr = { .s_addr = INADDR_ANY };
int ret;
struct ospf_if_params *params;
struct route_node *rn;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (strcmp (argv[1]->text, "default") == 0)
{
@@ -456,16 +442,13 @@ DEFUN (no_ospf_passive_interface,
"IPv4 address\n"
"Allow routing updates on interfaces by default\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 3;
struct interface *ifp;
struct in_addr addr = { .s_addr = INADDR_ANY };
struct ospf_if_params *params;
int ret;
struct route_node *rn;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (strcmp (argv[2]->text, "default") == 0)
{
@@ -524,16 +507,13 @@ 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);
int idx_ipv4_prefixlen = 1;
int idx_ipv4_number = 3;
- struct ospf *ospf= vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
if (ospf->instance)
{
vty_out (vty, "The network command is not supported in multi-instance ospf%s",
@@ -572,16 +552,13 @@ 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);
int idx_ipv4_prefixlen = 2;
int idx_ipv4_number = 4;
- struct ospf *ospf = (struct ospf *) vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
if (ospf->instance)
{
vty_out (vty, "The network command is not supported in multi-instance ospf%s",
@@ -616,18 +593,15 @@ DEFUN (ospf_area_range,
"User specified metric for this range\n"
"Advertised metric for this range\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_cost = 6;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int format;
u_int32_t cost;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
@@ -652,18 +626,15 @@ DEFUN (ospf_area_range_cost,
"User specified metric for this range\n"
"Advertised metric for this range\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_cost = 5;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int format;
u_int32_t cost;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
@@ -685,16 +656,13 @@ DEFUN (ospf_area_range_not_advertise,
"Area range prefix\n"
"DoNotAdvertise this range\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
@@ -719,16 +687,13 @@ DEFUN (no_ospf_area_range,
"Advertised metric for this range\n"
"DoNotAdvertise this range\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_ipv4_prefixlen = 4;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
@@ -748,17 +713,14 @@ 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);
int idx_ipv4_number = 1;
int idx_ipv4_prefixlen = 3;
int idx_ipv4_prefixlen_2 = 5;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p, s;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg);
@@ -780,17 +742,14 @@ 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);
int idx_ipv4_number = 2;
int idx_ipv4_prefixlen = 4;
int idx_ipv4_prefixlen_2 = 6;
- struct ospf *ospf = vty->index;
struct prefix_ipv4 p, s;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg);
@@ -1064,17 +1023,14 @@ DEFUN (ospf_area_vlink,
"Use MD5 algorithm\n" \
"The OSPF password (key)")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_ipv4 = 3;
- struct ospf *ospf = vty->index;
struct ospf_vl_config_data vl_config;
char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
char md5_key[OSPF_AUTH_MD5_SIZE+1];
int i;
int ret;
-
- if (!ospf)
- return CMD_SUCCESS;
ospf_vl_config_data_init(&vl_config, vty);
@@ -1181,13 +1137,10 @@ DEFUN (ospf_area_vlink_intervals,
VLINK_HELPSTR_TIME_PARAM
VLINK_HELPSTR_TIME_PARAM)
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct ospf_vl_config_data vl_config;
int ret = 0;
- if (!ospf)
- return CMD_SUCCESS;
-
ospf_vl_config_data_init(&vl_config, vty);
char *area_id = argv[1]->arg;
@@ -1236,9 +1189,9 @@ DEFUN (no_ospf_area_vlink,
"Use MD5 algorithm\n" \
"The OSPF password (key)")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
int idx_ipv4 = 4;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct ospf_vl_config_data vl_config;
struct ospf_vl_data *vl_data = NULL;
@@ -1246,9 +1199,6 @@ DEFUN (no_ospf_area_vlink,
int i;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
ospf_vl_config_data_init(&vl_config, vty);
ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format);
@@ -1346,13 +1296,10 @@ DEFUN (no_ospf_area_vlink_intervals,
VLINK_HELPSTR_TIME_PARAM
VLINK_HELPSTR_TIME_PARAM)
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct ospf_vl_config_data vl_config;
int ret = 0;
- if (!ospf)
- return CMD_SUCCESS;
-
ospf_vl_config_data_init(&vl_config, vty);
char *area_id = argv[2]->arg;
@@ -1400,17 +1347,14 @@ DEFUN (ospf_area_shortcut,
"Enable shortcutting through the area\n"
"Disable shortcutting through the area\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_enable_disable = 3;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int mode;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -1445,15 +1389,12 @@ DEFUN (no_ospf_area_shortcut,
"Deconfigure enabled shortcutting through the area\n"
"Deconfigure disabled shortcutting through the area\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1474,14 +1415,11 @@ DEFUN (ospf_area_stub,
"OSPF area ID as a decimal value\n"
"Configure OSPF area as stub\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct in_addr area_id;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ret = ospf_area_stub_set (ospf, area_id);
@@ -1506,14 +1444,11 @@ 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);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct in_addr area_id;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ret = ospf_area_stub_set (ospf, area_id);
@@ -1538,14 +1473,11 @@ DEFUN (no_ospf_area_stub,
"OSPF area ID as a decimal value\n"
"Configure OSPF area as stub\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ospf_area_stub_unset (ospf, area_id);
@@ -1564,14 +1496,11 @@ 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);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ospf_area_no_summary_unset (ospf, area_id);
@@ -1582,13 +1511,10 @@ static int
ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv,
int nosum)
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct in_addr area_id;
int ret, format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg);
ret = ospf_area_nssa_set (ospf, area_id);
@@ -1692,14 +1618,11 @@ 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);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg);
ospf_area_nssa_unset (ospf, area_id);
@@ -1720,18 +1643,15 @@ 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);
int idx_ipv4_number = 1;
int idx_number = 3;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
u_int32_t cost;
int format;
struct prefix_ipv4 p;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215);
@@ -1767,17 +1687,14 @@ 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);
int idx_ipv4_number = 2;
int idx_number = 4;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
struct prefix_ipv4 p;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg);
VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY);
@@ -1817,15 +1734,12 @@ 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);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -1844,15 +1758,12 @@ 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);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1874,15 +1785,12 @@ 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);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -1901,15 +1809,12 @@ 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);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1933,18 +1838,15 @@ DEFUN (ospf_area_filter_list,
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
int idx_word = 4;
int idx_in_out = 5;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
struct prefix_list *plist;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -1984,17 +1886,14 @@ 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);
int idx_ipv4_number = 2;
int idx_word = 5;
int idx_in_out = 6;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
@@ -2042,15 +1941,12 @@ DEFUN (ospf_area_authentication_message_digest,
"Enable authentication\n"
"Use message-digest authentication\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -2067,15 +1963,12 @@ DEFUN (ospf_area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 1;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_get (ospf, area_id, format);
@@ -2093,15 +1986,12 @@ DEFUN (no_ospf_area_authentication,
"OSPF area ID as a decimal value\n"
"Enable authentication\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4_number = 2;
- struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
int format;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -2126,13 +2016,10 @@ DEFUN (ospf_abr_type,
"Shortcut ABR\n"
"Standard behavior (RFC2328)\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_vendor = 2;
- struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
- if (!ospf)
- return CMD_SUCCESS;
-
if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0)
abr_type = OSPF_ABR_CISCO;
else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0)
@@ -2165,13 +2052,10 @@ DEFUN (no_ospf_abr_type,
"Shortcut ABR\n"
"Standard ABR\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_vendor = 3;
- struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
- if (!ospf)
- return CMD_SUCCESS;
-
if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0)
abr_type = OSPF_ABR_CISCO;
else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0)
@@ -2198,10 +2082,7 @@ DEFUN (ospf_log_adjacency_changes,
"log-adjacency-changes",
"Log changes in adjacency state\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
@@ -2214,10 +2095,7 @@ DEFUN (ospf_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
@@ -2230,10 +2108,7 @@ DEFUN (no_ospf_log_adjacency_changes,
NO_STR
"Log changes in adjacency state\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
@@ -2247,10 +2122,7 @@ DEFUN (no_ospf_log_adjacency_changes_detail,
"Log changes in adjacency state\n"
"Log all state changes\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
@@ -2263,10 +2135,7 @@ DEFUN (ospf_compatible_rfc1583,
"OSPF compatibility list\n"
"compatible with RFC 1583\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
@@ -2283,10 +2152,7 @@ DEFUN (no_ospf_compatible_rfc1583,
"OSPF compatibility list\n"
"compatible with RFC 1583\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
@@ -2314,10 +2180,7 @@ ospf_timers_spf_set (struct vty *vty, unsigned int delay,
unsigned int hold,
unsigned int max)
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->spf_delay = delay;
ospf->spf_holdtime = hold;
@@ -2335,13 +2198,10 @@ DEFUN (ospf_timers_min_ls_interval,
"All LSA types\n"
"Delay (msec) between sending LSAs\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 4;
- struct ospf *ospf = vty->index;
unsigned int interval;
- if (!ospf)
- return CMD_SUCCESS;
-
if (argc != 1)
{
vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
@@ -2365,7 +2225,7 @@ DEFUN (no_ospf_timers_min_ls_interval,
"All LSA types\n"
"Delay (msec) between sending LSAs\n")
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
return CMD_SUCCESS;
@@ -2380,13 +2240,10 @@ DEFUN (ospf_timers_min_ls_arrival,
"OSPF minimum arrival interval delay\n"
"Delay (msec) between accepted LSAs\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 3;
- struct ospf *ospf = vty->index;
unsigned int arrival;
- if (!ospf)
- return CMD_SUCCESS;
-
if (argc != 1)
{
vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
@@ -2409,10 +2266,7 @@ DEFUN (no_ospf_timers_min_ls_arrival,
"OSPF minimum arrival interval delay\n"
"Delay (msec) between accepted LSAs\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
@@ -2474,12 +2328,9 @@ DEFUN (ospf_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 3;
unsigned int minarrival;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc != 1)
{
@@ -2503,11 +2354,8 @@ DEFUN (no_ospf_timers_lsa,
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
unsigned int minarrival;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc > 4)
{
@@ -2533,17 +2381,14 @@ DEFUN (ospf_neighbor,
"Dead Neighbor Polling interval\n"
"Seconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 1;
int idx_pri = 3;
int idx_poll = 5;
- struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg);
if (argc > 2)
@@ -2573,17 +2418,14 @@ DEFUN (ospf_neighbor_poll_interval,
"OSPF priority of non-broadcast neighbor\n"
"Priority\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 1;
int idx_poll = 3;
int idx_pri = 5;
- struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg);
VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535);
@@ -2611,13 +2453,10 @@ DEFUN (no_ospf_neighbor,
"Dead Neighbor Polling interval\n"
"Seconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
- struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg);
(void)ospf_nbr_nbma_unset (ospf, nbr_addr);
@@ -2636,13 +2475,10 @@ DEFUN (no_ospf_neighbor_poll,
"Neighbor Priority\n"
"Priority\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ipv4 = 2;
- struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
- if (!ospf)
- return CMD_SUCCESS;
-
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg);
(void)ospf_nbr_nbma_unset (ospf, nbr_addr);
@@ -2657,12 +2493,9 @@ DEFUN (ospf_refresh_timer,
"Set refresh timer\n"
"Timer value in seconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 2;
- struct ospf *ospf = vty->index;
unsigned int interval;
-
- if (!ospf)
- return CMD_SUCCESS;
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800);
interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY;
@@ -2680,13 +2513,10 @@ DEFUN (no_ospf_refresh_timer,
"Unset refresh timer\n"
"Timer value in seconds\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 3;
- struct ospf *ospf = vty->index;
unsigned int interval;
- if (!ospf)
- return CMD_SUCCESS;
-
if (argc == 1)
{
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800);
@@ -2709,15 +2539,12 @@ 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);
int idx_number = 2;
- struct ospf *ospf = vty->index;
u_int32_t refbw;
struct listnode *node;
struct interface *ifp;
- if (!ospf)
- return CMD_SUCCESS;
-
refbw = strtol (argv[idx_number]->arg, NULL, 10);
if (refbw < 1 || refbw > 4294967)
{
@@ -2744,13 +2571,10 @@ 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")
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct listnode *node, *nnode;
struct interface *ifp;
- if (!ospf)
- return CMD_SUCCESS;
-
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
@@ -2771,13 +2595,10 @@ DEFUN (ospf_write_multiplier,
"Write multiplier\n"
"Maximum number of interface serviced per write\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number;
- struct ospf *ospf = vty->index;
u_int32_t write_oi_count;
- if (!ospf)
- return CMD_SUCCESS;
-
if (argc == 3)
idx_number = 2;
else
@@ -2808,10 +2629,7 @@ DEFUN (no_ospf_write_multiplier,
"Write multiplier\n"
"Maximum number of interface serviced per write\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
return CMD_SUCCESS;
@@ -5770,14 +5588,13 @@ DEFUN (ip_ospf_authentication_args,
"Use message-digest authentication\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_encryption = 3;
int idx_ipv4 = 4;
- struct interface *ifp;
struct in_addr addr;
int ret;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argc == 5)
@@ -5822,13 +5639,12 @@ DEFUN (ip_ospf_authentication,
"Enable authentication on this interface\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 3;
- struct interface *ifp;
struct in_addr addr;
int ret;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argc == 4)
@@ -5862,16 +5678,15 @@ DEFUN (no_ip_ospf_authentication_args,
"Use message-digest authentication\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_encryption = 4;
int idx_ipv4 = 5;
- struct interface *ifp;
struct in_addr addr;
int ret;
struct ospf_if_params *params;
struct route_node *rn;
int auth_type;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argc == 6)
@@ -5955,14 +5770,13 @@ DEFUN (no_ip_ospf_authentication,
"Enable authentication on this interface\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 4;
- struct interface *ifp;
struct in_addr addr;
int ret;
struct ospf_if_params *params;
struct route_node *rn;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argc == 5)
@@ -6039,12 +5853,11 @@ DEFUN (ip_ospf_authentication_key,
"The OSPF password (key)\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -6087,11 +5900,10 @@ DEFUN (no_ip_ospf_authentication_key,
"Authentication password (key)\n"
"The OSPF password (key)")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -6142,13 +5954,12 @@ DEFUN (ip_ospf_message_digest_key,
"The OSPF password (key)\n"
"Address of interface\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct crypt_key *ck;
u_char key_id;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
int idx = 0;
@@ -6213,13 +6024,12 @@ DEFUN (no_ip_ospf_message_digest_key,
"The OSPF password (key)\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp;
struct crypt_key *ck;
int key_id;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
argv_find (argv, argc, "(1-255)", &idx);
@@ -6279,8 +6089,8 @@ DEFUN (ip_ospf_cost,
"Cost\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
u_int32_t cost;
struct in_addr addr;
struct ospf_if_params *params;
@@ -6333,12 +6143,11 @@ DEFUN (no_ip_ospf_cost,
"Interface cost\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
// get arguments
@@ -6409,7 +6218,7 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
const char *nbr_str,
const char *fast_hello_str)
{
- struct interface *ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
u_int32_t seconds;
u_char hellomult;
struct in_addr addr;
@@ -6539,15 +6348,14 @@ DEFUN (no_ip_ospf_dead_interval,
"Seconds\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = argc - 1;
- struct interface *ifp = vty->index;
struct in_addr addr;
int ret;
struct ospf_if_params *params;
struct ospf_interface *oi;
struct route_node *rn;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv[idx_ipv4]->type == IPV4_TKN)
@@ -6620,8 +6428,8 @@ DEFUN (ip_ospf_hello_interval,
"Seconds\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct in_addr addr;
struct ospf_if_params *params;
params = IF_DEF_PARAMS (ifp);
@@ -6670,8 +6478,8 @@ DEFUN (no_ip_ospf_hello_interval,
"Seconds\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct in_addr addr;
struct ospf_if_params *params;
params = IF_DEF_PARAMS (ifp);
@@ -6725,8 +6533,8 @@ DEFUN (ip_ospf_network,
"Specify OSPF point-to-multipoint network\n"
"Specify OSPF point-to-point network\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
int old_type = IF_DEF_PARAMS (ifp)->type;
struct route_node *rn;
@@ -6794,7 +6602,7 @@ DEFUN (no_ip_ospf_network,
"Specify OSPF point-to-multipoint network\n"
"Specify OSPF point-to-point network\n")
{
- struct interface *ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int old_type = IF_DEF_PARAMS (ifp)->type;
struct route_node *rn;
@@ -6845,8 +6653,8 @@ DEFUN (ip_ospf_priority,
"Priority\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
long priority;
struct route_node *rn;
struct in_addr addr;
@@ -6910,13 +6718,12 @@ DEFUN (no_ip_ospf_priority,
"Priority\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct route_node *rn;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -6980,8 +6787,8 @@ DEFUN (ip_ospf_retransmit_interval,
"Seconds\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
u_int32_t seconds;
struct in_addr addr;
struct ospf_if_params *params;
@@ -7030,12 +6837,11 @@ DEFUN (no_ip_ospf_retransmit_interval,
"Seconds\n"
"Address of interface\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -7085,8 +6891,8 @@ DEFUN (ip_ospf_transmit_delay,
"Seconds\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
u_int32_t seconds;
struct in_addr addr;
struct ospf_if_params *params;
@@ -7134,12 +6940,11 @@ DEFUN (no_ip_ospf_transmit_delay,
"Link state transmit delay\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct in_addr addr;
struct ospf_if_params *params;
- ifp = vty->index;
params = IF_DEF_PARAMS (ifp);
if (argv_find (argv, argc, "A.B.C.D", &idx))
@@ -7189,8 +6994,8 @@ DEFUN (ip_ospf_area,
"OSPF area ID in IP address format\n"
"OSPF area ID as a decimal value\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
int format, ret;
struct in_addr area_id;
struct ospf *ospf;
@@ -7264,8 +7069,8 @@ DEFUN (no_ip_ospf_area,
"OSPF area ID in IP address format\n"
"OSPF area ID as a decimal value\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx = 0;
- struct interface *ifp = vty->index;
struct ospf *ospf;
struct ospf_if_params *params;
u_short instance = 0;
@@ -7301,9 +7106,9 @@ DEFUN (ospf_redistribute_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_protocol = 1;
int idx_redist_param = 2;
- struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
@@ -7357,12 +7162,10 @@ DEFUN (no_ospf_redistribute_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_protocol = 2;
- struct ospf *ospf = vty->index;
int source;
struct ospf_redist *red;
- if (!ospf)
- return CMD_SUCCESS;
source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
@@ -7391,10 +7194,10 @@ DEFUN (ospf_redistribute_instance_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ospf_table = 1;
int idx_number = 2;
int idx_redist_param = 3;
- struct ospf *ospf = vty->index;
int source;
int type = -1;
int metric = -1;
@@ -7464,16 +7267,13 @@ DEFUN (no_ospf_redistribute_instance_source,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_ospf_table = 2;
int idx_number = 3;
- struct ospf *ospf = vty->index;
u_int instance;
struct ospf_redist *red;
int source;
- if (!ospf)
- return CMD_SUCCESS;
-
if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
source = ZEBRA_ROUTE_OSPF;
else
@@ -7511,13 +7311,10 @@ DEFUN (ospf_distribute_list_out,
OUT_STR
QUAGGA_REDIST_HELP_STR_OSPFD)
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_word = 1;
- struct ospf *ospf = vty->index;
int source;
- if (!ospf)
- return CMD_SUCCESS;
-
/* Get distribute source. */
source = proto_redistnum(AFI_IP, argv[4]->arg);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
@@ -7535,13 +7332,10 @@ DEFUN (no_ospf_distribute_list_out,
OUT_STR
QUAGGA_REDIST_HELP_STR_OSPFD)
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_word = 2;
- struct ospf *ospf = vty->index;
int source;
- if (!ospf)
- return CMD_SUCCESS;
-
source = proto_redistnum(AFI_IP, argv[5]->arg);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
@@ -7564,16 +7358,13 @@ DEFUN (ospf_default_information_originate,
"Route map reference\n"
"Pointer to route-map entries\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_redist_param = 2;
- struct ospf *ospf = vty->index;
int default_originate = DEFAULT_ORIGINATE_ZEBRA;
int type = -1;
int metric = -1;
struct ospf_redist *red;
- if (!ospf)
- return CMD_SUCCESS;
-
if (argc < 4)
return CMD_WARNING; /* this should not happen */
@@ -7617,13 +7408,10 @@ DEFUN (no_ospf_default_information_originate,
"Route map reference\n"
"Pointer to route-map entries\n")
{
- struct ospf *ospf = vty->index;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
struct prefix_ipv4 p;
struct ospf_external *ext;
struct ospf_redist *red;
-
- if (!ospf)
- return CMD_SUCCESS;
p.family = AF_INET;
p.prefix.s_addr = 0;
@@ -7651,13 +7439,10 @@ DEFUN (ospf_default_metric,
"Set metric of redistributed routes\n"
"Default metric\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 1;
- struct ospf *ospf = vty->index;
int metric = -1;
- if (!ospf)
- return CMD_SUCCESS;
-
if (!str2metric (argv[idx_number]->arg, &metric))
return CMD_WARNING;
@@ -7673,10 +7458,7 @@ DEFUN (no_ospf_default_metric,
"Set metric of redistributed routes\n"
"Default metric\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->default_metric = -1;
@@ -7690,11 +7472,8 @@ DEFUN (ospf_distance,
"Define an administrative distance\n"
"OSPF Administrative distance\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 1;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
ospf->distance_all = atoi (argv[idx_number]->arg);
@@ -7708,10 +7487,7 @@ DEFUN (no_ospf_distance,
"Define an administrative distance\n"
"OSPF Administrative distance\n")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->distance_all = 0;
@@ -7731,8 +7507,8 @@ DEFUN (no_ospf_distance_ospf,
"External routes\n"
"Distance for external routes\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_area_distance = 3;
- struct ospf *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
@@ -7775,11 +7551,8 @@ DEFUN (ospf_distance_ospf,
"External routes\n"
"Distance for external routes\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_area_distance = 2;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc < 3) /* should not happen */
return CMD_WARNING;
@@ -7811,9 +7584,9 @@ DEFUN (ospf_distance_source,
"Distance value\n"
"IP source prefix\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 1;
int idx_ipv4_prefixlen = 2;
- struct ospf *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
@@ -7831,9 +7604,9 @@ DEFUN (no_ospf_distance_source,
"Distance value\n"
"IP source prefix\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 2;
int idx_ipv4_prefixlen = 3;
- struct ospf *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
@@ -7851,10 +7624,10 @@ DEFUN (ospf_distance_source_access_list,
"IP source prefix\n"
"Access list name\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 1;
int idx_ipv4_prefixlen = 2;
int idx_word = 3;
- struct ospf *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
@@ -7873,10 +7646,10 @@ DEFUN (no_ospf_distance_source_access_list,
"IP source prefix\n"
"Access list name\n")
{
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
int idx_number = 2;
int idx_ipv4_prefixlen = 3;
int idx_word = 4;
- struct ospf *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
@@ -7895,8 +7668,8 @@ DEFUN (ip_ospf_mtu_ignore,
"Disable MTU mismatch detection on this interface\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 3;
- struct interface *ifp = vty->index;
struct in_addr addr;
int ret;
@@ -7938,8 +7711,8 @@ DEFUN (no_ip_ospf_mtu_ignore,
"Disable MTU mismatch detection on this interface\n"
"Address of interface")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 4;
- struct interface *ifp = vty->index;
struct in_addr addr;
int ret;
@@ -7981,12 +7754,9 @@ 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);
struct listnode *ln;
struct ospf_area *area;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
{
@@ -8010,12 +7780,9 @@ 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);
struct listnode *ln;
struct ospf_area *area;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
{
@@ -8041,12 +7808,9 @@ 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);
int idx_number = 3;
unsigned int seconds;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc != 1)
{
@@ -8070,12 +7834,9 @@ 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);
struct listnode *ln;
struct ospf_area *area;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
@@ -8103,12 +7864,9 @@ 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);
int idx_number = 3;
unsigned int seconds;
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
if (argc != 1)
{
@@ -8132,10 +7890,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")
{
- struct ospf *ospf = vty->index;
-
- if (!ospf)
- return CMD_SUCCESS;
+ VTY_DECLVAR_CONTEXT(ospf, ospf);
ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 1a7691c529..b7542c2a8b 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -55,6 +55,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "ospfd/ospf_ase.h"
+DEFINE_QOBJ_TYPE(ospf)
/* OSPF process wide configuration. */
static struct ospf_master ospf_master;
@@ -292,6 +293,8 @@ ospf_new (u_short instance)
/* Enable "log-adjacency-changes" */
SET_FLAG(new->config, OSPF_LOG_ADJACENCY_CHANGES);
+ QOBJ_REG (new, ospf);
+
return new;
}
@@ -505,6 +508,8 @@ ospf_finish_final (struct ospf *ospf)
int i;
u_short instance = 0;
+ QOBJ_UNREG (ospf);
+
ospf_opaque_type11_lsa_term (ospf);
/* be nice if this worked, but it doesn't */
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 41a7a30d85..a9e3efeeab 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -24,6 +24,7 @@
#define _ZEBRA_OSPFD_H
#include <zebra.h>
+#include "qobj.h"
#include "libospf.h"
#include "filter.h"
@@ -302,7 +303,10 @@ struct ospf
u_int32_t if_ospf_cli_count;
struct route_table *distance_table;
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(ospf)
/* OSPF area structure. */
struct ospf_area
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 8d7579aafc..e50837ebed 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -2551,10 +2551,9 @@ DEFUN (interface_ip_igmp,
IP_STR
IFACE_IGMP_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -2582,10 +2581,9 @@ DEFUN (interface_no_ip_igmp,
IP_STR
IFACE_IGMP_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp)
return CMD_SUCCESS;
@@ -2612,17 +2610,15 @@ DEFUN (interface_ip_igmp_join,
"Multicast group address\n"
"Source address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 3;
int idx_ipv4_2 = 4;
- struct interface *ifp;
const char *group_str;
const char *source_str;
struct in_addr group_addr;
struct in_addr source_addr;
int result;
- ifp = vty->index;
-
/* Group address */
group_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, group_str, &group_addr);
@@ -2661,17 +2657,15 @@ DEFUN (interface_no_ip_igmp_join,
"Multicast group address\n"
"Source address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
- struct interface *ifp;
const char *group_str;
const char *source_str;
struct in_addr group_addr;
struct in_addr source_addr;
int result;
- ifp = vty->index;
-
/* Group address */
group_str = argv[idx_ipv4]->arg;
result = inet_pton(AF_INET, group_str, &group_addr);
@@ -2839,12 +2833,11 @@ DEFUN (interface_ip_igmp_query_interval,
IFACE_IGMP_QUERY_INTERVAL_STR
"Query interval in seconds\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int query_interval;
int query_interval_dsec;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -2898,11 +2891,10 @@ DEFUN (interface_no_ip_igmp_query_interval,
IFACE_IGMP_STR
IFACE_IGMP_QUERY_INTERVAL_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int default_query_interval_dsec;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp)
@@ -2934,11 +2926,10 @@ DEFUN (interface_ip_igmp_query_max_response_time,
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
"Query response value in seconds\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int query_max_response_time;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -2991,11 +2982,10 @@ DEFUN (interface_no_ip_igmp_query_max_response_time,
IFACE_IGMP_STR
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int default_query_interval_dsec;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp)
@@ -3027,12 +3017,11 @@ DEFUN (interface_ip_igmp_query_max_response_time_dsec,
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
"Query response value in deciseconds\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int query_max_response_time_dsec;
int default_query_interval_dsec;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -3087,11 +3076,10 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
IFACE_IGMP_STR
IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
int default_query_interval_dsec;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp)
@@ -3120,12 +3108,11 @@ DEFUN (interface_ip_pim_drprio,
"Set the Designated Router Election Priority\n"
"Value of the new DR Priority\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3;
- struct interface *ifp;
struct pim_interface *pim_ifp;
uint32_t old_dr_prio;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -3154,10 +3141,9 @@ DEFUN (interface_no_ip_pim_drprio,
"Revert the Designated Router Priority to default\n"
"Old Value of the Priority\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -3206,9 +3192,7 @@ DEFUN (interface_ip_pim_ssm,
PIM_STR
IFACE_PIM_STR)
{
- struct interface *ifp;
-
- ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SSM)) {
vty_out(vty, "Could not enable PIM SSM on interface%s", VTY_NEWLINE);
@@ -3225,9 +3209,7 @@ DEFUN (interface_ip_pim_sm,
PIM_STR
IFACE_PIM_SM_STR)
{
- struct interface *ifp;
-
- ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SM)) {
vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -3277,9 +3259,7 @@ DEFUN (interface_no_ip_pim_ssm,
PIM_STR
IFACE_PIM_STR)
{
- struct interface *ifp;
-
- ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
if (!pim_cmd_interface_delete(ifp)) {
vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -3296,9 +3276,7 @@ DEFUN (interface_no_ip_pim_sm,
PIM_STR
IFACE_PIM_SM_STR)
{
- struct interface *ifp;
-
- ifp = vty->index;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
if (!pim_cmd_interface_delete(ifp)) {
vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -3315,9 +3293,9 @@ DEFUN (interface_ip_mroute,
"Outgoing interface name\n"
"Group address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, iif);
int idx_interface = 2;
int idx_ipv4 = 3;
- struct interface *iif;
struct interface *oif;
const char *oifname;
const char *grp_str;
@@ -3325,8 +3303,6 @@ DEFUN (interface_ip_mroute,
struct in_addr src_addr;
int result;
- iif = vty->index;
-
oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname);
if (!oif) {
@@ -3362,10 +3338,10 @@ DEFUN (interface_ip_mroute_source,
"Group address\n"
"Source address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, iif);
int idx_interface = 2;
int idx_ipv4 = 3;
int idx_ipv4_2 = 4;
- struct interface *iif;
struct interface *oif;
const char *oifname;
const char *grp_str;
@@ -3374,8 +3350,6 @@ DEFUN (interface_ip_mroute_source,
struct in_addr src_addr;
int result;
- iif = vty->index;
-
oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname);
if (!oif) {
@@ -3417,9 +3391,9 @@ DEFUN (interface_no_ip_mroute,
"Outgoing interface name\n"
"Group Address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, iif);
int idx_interface = 3;
int idx_ipv4 = 4;
- struct interface *iif;
struct interface *oif;
const char *oifname;
const char *grp_str;
@@ -3427,8 +3401,6 @@ DEFUN (interface_no_ip_mroute,
struct in_addr src_addr;
int result;
- iif = vty->index;
-
oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname);
if (!oif) {
@@ -3465,10 +3437,10 @@ DEFUN (interface_no_ip_mroute_source,
"Group Address\n"
"Source Address\n")
{
+ VTY_DECLVAR_CONTEXT(interface, iif);
int idx_interface = 3;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
- struct interface *iif;
struct interface *oif;
const char *oifname;
const char *grp_str;
@@ -3477,8 +3449,6 @@ DEFUN (interface_no_ip_mroute_source,
struct in_addr src_addr;
int result;
- iif = vty->index;
-
oifname = argv[idx_interface]->arg;
oif = if_lookup_by_name(oifname);
if (!oif) {
@@ -3520,12 +3490,11 @@ DEFUN (interface_ip_pim_hello,
IFACE_PIM_HELLO_TIME_STR
IFACE_PIM_HELLO_HOLD_STR)
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_time = 3;
int idx_hold = 4;
- struct interface *ifp;
struct pim_interface *pim_ifp;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
@@ -3553,10 +3522,9 @@ DEFUN (interface_no_ip_pim_hello,
IFACE_PIM_HELLO_TIME_STR
IFACE_PIM_HELLO_HOLD_STR)
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct pim_interface *pim_ifp;
- ifp = vty->index;
pim_ifp = ifp->info;
if (!pim_ifp) {
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 900266178c..9f8b279eb8 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -1332,11 +1332,10 @@ DEFUN (ip_rip_receive_version,
"RIP version 2\n"
"None\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_type = 4;
- struct interface *ifp;
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
switch (argv[idx_type]->arg[0])
@@ -1367,10 +1366,9 @@ DEFUN (ip_rip_receive_version_1,
"RIP version 1\n"
"RIP version 2\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
/* Version 1 and 2. */
@@ -1388,10 +1386,9 @@ DEFUN (ip_rip_receive_version_2,
"RIP version 2\n"
"RIP version 1\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
/* Version 1 and 2. */
@@ -1410,10 +1407,9 @@ DEFUN (no_ip_rip_receive_version,
"Version 1\n"
"Version 2\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
ri->ri_receive = RI_RIP_UNSPEC;
@@ -1431,11 +1427,10 @@ DEFUN (ip_rip_send_version,
"RIP version 1\n"
"RIP version 2\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_type = 4;
- struct interface *ifp;
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
/* Version 1. */
@@ -1462,10 +1457,9 @@ DEFUN (ip_rip_send_version_1,
"RIP version 1\n"
"RIP version 2\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
/* Version 1 and 2. */
@@ -1483,10 +1477,9 @@ DEFUN (ip_rip_send_version_2,
"RIP version 2\n"
"RIP version 1\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
/* Version 1 and 2. */
@@ -1505,10 +1498,9 @@ DEFUN (no_ip_rip_send_version,
"Version 1\n"
"Version 2\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
ri->ri_send = RI_RIP_UNSPEC;
@@ -1523,10 +1515,9 @@ DEFUN (ip_rip_v2_broadcast,
"Routing Information Protocol\n"
"Send ip broadcast v2 update\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
ri->v2_broadcast = 1;
@@ -1541,10 +1532,9 @@ DEFUN (no_ip_rip_v2_broadcast,
"Routing Information Protocol\n"
"Send ip broadcast v2 update\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
ri->v2_broadcast = 0;
@@ -1564,13 +1554,12 @@ DEFUN (ip_rip_authentication_mode,
"RFC compatible\n"
"Old ripd compatible\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
char *cryptmode = argv[4]->text;
char *authlen = (argc > 5) ? argv[6]->text : NULL;
- struct interface *ifp;
struct rip_interface *ri;
int auth_type;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
if (strmatch ("md5", cryptmode))
@@ -1615,10 +1604,9 @@ DEFUN (no_ip_rip_authentication_mode,
"RFC compatible\n"
"Old ripd compatible\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
ri->auth_type = RIP_NO_AUTH;
@@ -1636,11 +1624,10 @@ DEFUN (ip_rip_authentication_string,
"Authentication string\n"
"Authentication string\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_line = 4;
- struct interface *ifp;
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
if (strlen (argv[idx_line]->arg) > 16)
@@ -1674,10 +1661,9 @@ DEFUN (no_ip_rip_authentication_string,
"Authentication string\n"
"Authentication string\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *)vty->index;
ri = ifp->info;
if (ri->auth_str)
@@ -1698,11 +1684,10 @@ DEFUN (ip_rip_authentication_key_chain,
"Authentication key-chain\n"
"name of key-chain\n")
{
+ VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_line = 4;
- struct interface *ifp;
struct rip_interface *ri;
- ifp = (struct interface *) vty->index;
ri = ifp->info;
if (ri->auth_str)
@@ -1730,10 +1715,9 @@ DEFUN (no_ip_rip_authentication_key_chain,
"Authentication key-chain\n"
"name of key-chain\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = (struct interface *) vty->index;
ri = ifp->info;
if (ri->key_chain)
@@ -1756,10 +1740,9 @@ DEFUN (ip_rip_split_horizon,
"Routing Information Protocol\n"
"Perform split horizon\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIP_SPLIT_HORIZON;
@@ -1774,10 +1757,9 @@ DEFUN (ip_rip_split_horizon_poisoned_reverse,
"Perform split horizon\n"
"With poisoned-reverse\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIP_SPLIT_HORIZON_POISONED_REVERSE;
@@ -1796,10 +1778,9 @@ DEFUN (no_ip_rip_split_horizon,
"Routing Information Protocol\n"
"Perform split horizon\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIP_NO_SPLIT_HORIZON;
@@ -1815,10 +1796,9 @@ DEFUN (no_ip_rip_split_horizon_poisoned_reverse,
"Perform split horizon\n"
"With poisoned-reverse\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct rip_interface *ri;
- ifp = vty->index;
ri = ifp->info;
switch( ri->split_horizon )
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 9de3ca7c3d..29a444be43 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -45,6 +45,8 @@
#include "ripd/ripd.h"
#include "ripd/rip_debug.h"
+DEFINE_QOBJ_TYPE(rip)
+
/* UDP receive buffer size */
#define RIP_UDP_RCV_BUF 41600
@@ -2698,6 +2700,8 @@ rip_create (void)
rip_event (RIP_READ, rip->sock);
rip_event (RIP_UPDATE_EVENT, 1);
+ QOBJ_REG (rip, rip);
+
return 0;
}
@@ -2816,8 +2820,7 @@ DEFUN (router_rip,
return CMD_WARNING;
}
}
- vty->node = RIP_NODE;
- vty->index = rip;
+ VTY_PUSH_CONTEXT(RIP_NODE, rip);
return CMD_SUCCESS;
}
@@ -3851,6 +3854,8 @@ rip_clean (void)
if (rip)
{
+ QOBJ_UNREG (rip);
+
/* Clear RIP routes */
for (rp = route_top (rip->table); rp; rp = route_next (rp))
if ((list = rp->info) != NULL)
diff --git a/ripd/ripd.h b/ripd/ripd.h
index cd4d560af9..68b3d1fc6e 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -22,6 +22,7 @@
#ifndef _ZEBRA_RIP_H
#define _ZEBRA_RIP_H
+#include "qobj.h"
#include "rip_memory.h"
/* RIP version number. */
@@ -156,7 +157,10 @@ struct rip
int metric_config;
u_int32_t metric;
} route_map[ZEBRA_ROUTE_MAX];
+
+ QOBJ_FIELDS
};
+DECLARE_QOBJ_TYPE(rip)
/* RIP routing table entry which belong to rip_packet. */
struct rte
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 8505fd4c2c..1ac9e40f67 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -1012,10 +1012,9 @@ DEFUN (ipv6_ripng_split_horizon,
"Routing Information Protocol\n"
"Perform split horizon\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ripng_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIPNG_SPLIT_HORIZON;
@@ -1030,10 +1029,9 @@ DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,
"Perform split horizon\n"
"With poisoned-reverse\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ripng_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE;
@@ -1049,10 +1047,9 @@ DEFUN (no_ipv6_ripng_split_horizon,
"Perform split horizon\n"
"With poisoned-reverse\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(interface, ifp);
struct ripng_interface *ri;
- ifp = vty->index;
ri = ifp->info;
ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
diff --git a/tools/cocci.h b/tools/cocci.h
new file mode 100644
index 0000000000..3d877a7b4b
--- /dev/null
+++ b/tools/cocci.h
@@ -0,0 +1,34 @@
+/* some of this stuff doesn't seem to parse properly in coccinelle */
+
+#define DEFUN(funcname, cmdname, str, help) \
+ static int funcname \
+ (const struct cmd_element *self, \
+ struct vty *vty, \
+ int argc, \
+ struct cmd_token *argv[])
+#define DEFUN_HIDDEN(funcname, cmdname, str, help) \
+ static int funcname \
+ (const struct cmd_element *self, \
+ struct vty *vty, \
+ int argc, \
+ struct cmd_token *argv[])
+
+#define ENABLE_BGP_VNC 1
+#define ALL_LIST_ELEMENTS_RO(list,node,data) \
+ (node) = listhead(list), ((data) = NULL);\
+ (node) != NULL && ((data) = listgetdata(node)); \
+ (node) = listnextnode(node), ((data) = NULL)
+#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \
+ (node) = listhead(list), ((data) = NULL); \
+ (node) != NULL && \
+ ((data) = listgetdata(node),(nextnode) = node->next); \
+ (node) = (nextnode), ((data) = NULL)
+#define LIST_HEAD(name, type) \
+ struct name { \
+ struct type *lh_first; /* first element */ \
+ }
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
diff --git a/tools/vty_check.cocci b/tools/vty_check.cocci
new file mode 100644
index 0000000000..7e5fcc405b
--- /dev/null
+++ b/tools/vty_check.cocci
@@ -0,0 +1,22 @@
+/*
+ * VTY_DECLVAR_CONTEXT contains a built-in "if (!var) return;"
+ */
+@@
+identifier var, typ;
+statement S;
+@@
+
+ {
+ ...
+ \(
+ VTY_DECLVAR_CONTEXT(typ, var);
+ \|
+ VTY_DECLVAR_CONTEXT_SUB(typ, var);
+ \)
+ ...
+- if (
+- \( !var \| var == NULL \)
+- )
+- S
+ ...
+ }
diff --git a/tools/vty_index.cocci b/tools/vty_index.cocci
new file mode 100644
index 0000000000..8290e80b91
--- /dev/null
+++ b/tools/vty_index.cocci
@@ -0,0 +1,244 @@
+/*
+ * prep: strip off casts, they cause things to fail matching later.
+ */
+
+@@
+identifier casttarget;
+symbol vty;
+@@
+
+- (struct casttarget *)vty->index
++ vty->index
+
+/*
+ * variant 1: local variable assigned from vty->index
+ */
+
+@@
+identifier sn, nn;
+identifier fn;
+@@
+
+ int fn(...)
+ {
++ VTY_DECLVAR_CONTEXT (sn, nn);
+ ...
+ \(
+- struct sn *nn;
+ ...
+- nn = vty->index;
+ \|
+- struct sn *nn = vty->index;
+ \|
+- struct sn *nn = vty->index;
+ ...
+- nn = vty->index;
+ \)
+ ...
+ }
+
+@@
+identifier sn, nn;
+identifier fn;
+type Tr;
+@@
+
+ Tr *fn(...)
+ {
++ struct sn *nn = VTY_GET_CONTEXT(sn);
+ ...
+ \(
+- struct sn *nn;
+ ...
+- nn = vty->index;
++ if (!nn) {
++ return NULL;
++ }
+ \|
+- struct sn *nn = vty->index;
++ if (!nn) {
++ return NULL;
++ }
+ \|
+- struct sn *nn = vty->index;
+ ...
+- nn = vty->index;
++ if (!nn) {
++ return NULL;
++ }
+ \)
+ ...
+ }
+
+/*
+ * variant 2: vty wrapper func with (vty, vty->index, ...) signature
+ */
+
+/* find calls of this pattern first; arg will be dropped in rule3 */
+@rule1@
+identifier fn !~ "generic_(set|match)_";
+expression arg;
+@@
+
+ fn(arg, arg->index, ...)
+
+@ script:python @
+fn << rule1.fn;
+arg << rule1.arg;
+@@
+print "R01 removing vty-index argument on %s(%s, ...)" % (fn, arg)
+
+#/* strip arg on the vty wrapper func, add local handling */
+@ rule2 @
+identifier rule1.fn;
+identifier arg;
+identifier T;
+@@
+
+ static int fn (struct vty *vty,
+- struct T * arg,
+ ...)
+ {
++ VTY_DECLVAR_CONTEXT (T, arg);
+ ...
+ }
+
+/* drop argument on call sites identified earlier */
+@ rule3 @
+identifier rule1.fn;
+expression arg;
+@@
+
+ fn(arg,
+- arg->index,
+ ...)
+
+
+/*
+ * variant 3: function calls with "vty->index" argument (but no vty)
+ *
+ * a bit more complicated since we need to find the type from the header.
+ */
+
+/* find call sites first
+ * remember function name for later declvar insertion
+ */
+@ rule11 exists@
+identifier fn;
+identifier fparent;
+type Tr;
+@@
+
+ Tr fparent (...)
+ {
+ ...
+ fn(vty->index, ...)
+ ...
+ }
+
+@ script:python @
+fn << rule11.fn;
+@@
+print "R11 removing vty-index argument on %s(...)" % (fn)
+
+#/* find type of the argument - note args are mostly unnamed in Quagga :( */
+@ rule12 @
+identifier rule11.fn;
+identifier T, argname;
+type Tr;
+@@
+
+(
+ Tr fn(struct T *, ...);
+|
+ Tr fn(struct T * argname, ...);
+)
+
+@ script:python @
+fn << rule11.fn;
+T << rule12.T;
+@@
+print "R12 removing vty-index type is %s for %s(...)" % (T, fn)
+
+#/* add declvar
+# * this is split from rule14 so we support multiple calls in one func */
+@ rule13a @
+identifier rule11.fparent;
+identifier rule12.T;
+@@
+
+ int fparent (...)
+ {
++ VTY_DECLVAR_CONTEXT(T, T);
+ ...
+ }
+
+@ rule13b @
+identifier rule11.fparent;
+identifier rule12.T;
+type Tr;
+@@
+
+ Tr *fparent (...)
+ {
++ struct T *T = VTY_GET_CONTEXT(T);
++ if (!T) {
++ return NULL;
++ }
+ ...
+ }
+
+/* now replace the argument in the call */
+@ rule14 exists @
+identifier rule11.fn;
+identifier rule12.T;
+@@
+
+ {
+ ...
+ \(
+ fn(
+- vty->index,
++ T,
+ ...)
+ \|
+ fn(
+- vty->index
++ T
+ )
+ \)
+ ...
+ }
+
+/* special case ... */
+@rule30@
+identifier fn =~ "generic_(set|match)_";
+expression arg;
+@@
+
+ fn(arg,
+- arg->index,
++ VTY_GET_CONTEXT(route_map_index),
+ ...)
+
+/* and finally - PUSH_CONTEXT */
+@ rule99a exists @
+identifier tnode;
+identifier vexpr =~ "NULL";
+@@
+
+- vty->node = tnode;
+ ...
+- vty->index = vexpr;
++ VTY_PUSH_CONTEXT_NULL(tnode);
+
+@ rule99b exists @
+identifier tnode;
+expression vexpr;
+@@
+
+- vty->node = tnode;
+ ...
+- vty->index = vexpr;
++ VTY_PUSH_CONTEXT(tnode, vexpr);
+
diff --git a/tools/vty_index.sh b/tools/vty_index.sh
new file mode 100755
index 0000000000..0ac8bfb341
--- /dev/null
+++ b/tools/vty_index.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+sed -e '1istatic void bgp_debug_clear_updgrp_update_dbg(struct bgp *bgp);' -i \
+ bgpd/bgp_debug.c
+sed -e 's%^#if 0%#if 1 /* 0 */%' -i \
+ ospfd/ospf_vty.c \
+ ospf6d/ospf6_top.c \
+ #
+spatch \
+ --sp-file tools/vty_index.cocci \
+ --macro-file tools/cocci.h \
+ --all-includes -I . -I lib \
+ --use-gitgrep --dir . --in-place
+
+sed -e 's%^#if 1 /\* 0 \*/%#if 0%' -i \
+ ospfd/ospf_vty.c \
+ ospf6d/ospf6_top.c \
+ #
+sed -e '1d' -i \
+ bgpd/bgp_debug.c
+
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index d1c160ade6..65927262f2 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -2,8 +2,7 @@ include ../common.am
## Process this file with automake to produce Makefile.in.
-AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \
- -DVTY_DEPRECATE_INDEX
+AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600