summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:42 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:42 +0200
commit7c8ff89e9346227f0e721f7686d4c4d58f9c9135 (patch)
tree7a5f73baf68e31220396e2391cdd216cdf981d51 /ospfd
parentinitd: initd-mi.patch (diff)
downloadfrr-7c8ff89e9346227f0e721f7686d4c4d58f9c9135.tar.xz
frr-7c8ff89e9346227f0e721f7686d4c4d58f9c9135.zip
Multi-Instance OSPF Summary
——————————————------------- - etc/init.d/quagga is modified to support creating separate ospf daemon process for each instance. Each individual instance is monitored by watchquagga just like any protocol daemons.(requires initd-mi.patch). - Vtysh is modified to able to connect to multiple daemons of the same protocol (supported for OSPF only for now). - ospfd is modified to remember the Instance-ID that its invoked with. For the entire life of the process it caters to any command request that matches that instance-ID (unless its a non instance specific command). Routes/messages to zebra are tagged with instance-ID. - zebra route/redistribute mechanisms are modified to work with [protocol type + instance-id] - bgpd now has ability to have multiple instance specific redistribution for a protocol (OSPF only supported/tested for now). - zlog ability to display instance-id besides the protocol/daemon name. - Changes in other daemons are to because of the needed integration with some of the modified APIs/routines. (Didn’t prefer replicating too many separate instance specific APIs.) - config/show/debug commands are modified to take instance-id argument as appropriate. Guidelines to start using multi-instance ospf --------------------------------------------- The patch is backward compatible, i.e for any previous way of single ospf deamon(router ospf <cr>) will continue to work as is, including all the show commands etc. To enable multiple instances, do the following: 1. service quagga stop 2. Modify /etc/quagga/daemons to add instance-ids of each desired instance in the following format: ospfd=“yes" ospfd_instances="1,2,3" assuming you want to enable 3 instances with those instance ids. 3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf and ospfd-3.conf. 4. service quagga start/restart 5. Verify that the deamons are started as expected. You should see ospfd started with -n <instance-id> option. ps –ef | grep quagga With that /var/run/quagga/ should have ospfd-<instance-id>.pid and ospfd-<instance-id>/vty to each instance. 6. vtysh to work with instances as you would with any other deamons. 7. Overall most quagga semantics are the same working with the instance deamon, like it is for any other daemon. NOTE: To safeguard against errors leading to too many processes getting invoked, a hard limit on number of instance-ids is in place, currently its 5. Allowed instance-id range is <1-65535> Once daemons are up, show running from vtysh should show the instance-id of each daemon as 'router ospf <instance-id>’ (without needing explicit configuration) Instance-id can not be changed via vtysh, other router ospf configuration is allowed as before. Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_asbr.c50
-rw-r--r--ospfd/ospf_asbr.h12
-rw-r--r--ospfd/ospf_dump.c975
-rw-r--r--ospfd/ospf_flood.c40
-rw-r--r--ospfd/ospf_lsa.c95
-rw-r--r--ospfd/ospf_lsa.h6
-rw-r--r--ospfd/ospf_main.c44
-rw-r--r--ospfd/ospf_nsm.c16
-rw-r--r--ospfd/ospf_opaque.c6
-rw-r--r--ospfd/ospf_packet.c2
-rw-r--r--ospfd/ospf_routemap.c62
-rw-r--r--ospfd/ospf_te.c12
-rw-r--r--ospfd/ospf_vty.c1436
-rw-r--r--ospfd/ospf_zebra.c359
-rw-r--r--ospfd/ospf_zebra.h21
-rw-r--r--ospfd/ospfd.c107
-rw-r--r--ospfd/ospfd.h57
17 files changed, 2616 insertions, 684 deletions
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index f4140b858..5eb97d8f6 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -99,13 +99,14 @@ ospf_external_route_lookup (struct ospf *ospf,
/* Add an External info for AS-external-LSA. */
struct external_info *
-ospf_external_info_new (u_char type)
+ospf_external_info_new (u_char type, u_short instance)
{
struct external_info *new;
new = (struct external_info *)
XCALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info));
new->type = type;
+ new->instance = instance;
ospf_reset_route_map_set_values (&new->route_map_set);
return new;
@@ -134,32 +135,33 @@ ospf_route_map_set_compare (struct route_map_set_values *values1,
/* Add an External info for AS-external-LSA. */
struct external_info *
-ospf_external_info_add (u_char type, struct prefix_ipv4 p,
+ospf_external_info_add (u_char type, u_short instance, struct prefix_ipv4 p,
unsigned int ifindex, struct in_addr nexthop,
u_short tag)
{
struct external_info *new;
struct route_node *rn;
+ struct ospf_external *ext;
- /* Initialize route table. */
- if (EXTERNAL_INFO (type) == NULL)
- EXTERNAL_INFO (type) = route_table_init ();
+ ext = ospf_external_lookup(type, instance);
+ if (!ext)
+ ext = ospf_external_add(type, instance);
- rn = route_node_get (EXTERNAL_INFO (type), (struct prefix *) &p);
+ rn = route_node_get (EXTERNAL_INFO (ext), (struct prefix *) &p);
/* If old info exists, -- discard new one or overwrite with new one? */
if (rn)
if (rn->info)
{
route_unlock_node (rn);
- zlog_warn ("Redistribute[%s]: %s/%d already exists, discard.",
- ospf_redist_string(type),
+ zlog_warn ("Redistribute[%s][%d]: %s/%d already exists, discard.",
+ ospf_redist_string(type), instance,
inet_ntoa (p.prefix), p.prefixlen);
/* XFREE (MTYPE_OSPF_TMP, rn->info); */
return rn->info;
}
/* Create new External info instance. */
- new = ospf_external_info_new (type);
+ new = ospf_external_info_new (type, instance);
new->p = p;
new->ifindex = ifindex;
new->nexthop = nexthop;
@@ -176,11 +178,16 @@ ospf_external_info_add (u_char type, struct prefix_ipv4 p,
}
void
-ospf_external_info_delete (u_char type, struct prefix_ipv4 p)
+ospf_external_info_delete (u_char type, u_short instance, struct prefix_ipv4 p)
{
struct route_node *rn;
+ struct ospf_external *ext;
- rn = route_node_lookup (EXTERNAL_INFO (type), (struct prefix *) &p);
+ ext = ospf_external_lookup(type, instance);
+ if (!ext)
+ return;
+
+ rn = route_node_lookup (EXTERNAL_INFO (ext), (struct prefix *) &p);
if (rn)
{
ospf_external_info_free (rn->info);
@@ -191,10 +198,16 @@ ospf_external_info_delete (u_char type, struct prefix_ipv4 p)
}
struct external_info *
-ospf_external_info_lookup (u_char type, struct prefix_ipv4 *p)
+ospf_external_info_lookup (u_char type, u_short instance, struct prefix_ipv4 *p)
{
struct route_node *rn;
- rn = route_node_lookup (EXTERNAL_INFO (type), (struct prefix *) p);
+ struct ospf_external *ext;
+
+ ext = ospf_external_lookup(type, instance);
+ if (!ext)
+ return NULL;
+
+ rn = route_node_lookup (EXTERNAL_INFO (ext), (struct prefix *) p);
if (rn)
{
route_unlock_node (rn);
@@ -271,14 +284,19 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
}
void
-ospf_redistribute_withdraw (struct ospf *ospf, u_char type)
+ospf_redistribute_withdraw (struct ospf *ospf, u_char type, u_short instance)
{
struct route_node *rn;
struct external_info *ei;
+ struct ospf_external *ext;
+
+ ext = ospf_external_lookup(type, instance);
+ if (!ext)
+ return;
/* Delete external info for specified type. */
- if (EXTERNAL_INFO (type))
- for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
+ if (EXTERNAL_INFO (ext))
+ for (rn = route_top (EXTERNAL_INFO (ext)); rn; rn = route_next (rn))
if ((ei = rn->info))
if (ospf_external_info_find_lsa (ospf, &ei->p))
{
diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h
index bb773c979..ade671013 100644
--- a/ospfd/ospf_asbr.h
+++ b/ospfd/ospf_asbr.h
@@ -35,6 +35,8 @@ struct external_info
/* Type of source protocol. */
u_char type;
+ u_short instance;
+
/* Prefix. */
struct prefix_ipv4 p;
@@ -55,23 +57,23 @@ struct external_info
#define OSPF_ASBR_CHECK_DELAY 30
extern void ospf_external_route_remove (struct ospf *, struct prefix_ipv4 *);
-extern struct external_info *ospf_external_info_new (u_char);
+extern struct external_info *ospf_external_info_new (u_char, u_short);
extern void ospf_reset_route_map_set_values (struct route_map_set_values *);
extern int ospf_route_map_set_compare (struct route_map_set_values *,
struct route_map_set_values *);
-extern struct external_info *ospf_external_info_add (u_char,
+extern struct external_info *ospf_external_info_add (u_char, u_short,
struct prefix_ipv4,
unsigned int,
struct in_addr,
u_short);
-extern void ospf_external_info_delete (u_char, struct prefix_ipv4);
-extern struct external_info *ospf_external_info_lookup (u_char,
+extern void ospf_external_info_delete (u_char, u_short, struct prefix_ipv4);
+extern struct external_info *ospf_external_info_lookup (u_char, u_short,
struct prefix_ipv4 *);
extern struct ospf_route *ospf_external_route_lookup (struct ospf *,
struct prefix_ipv4 *);
extern void ospf_asbr_status_update (struct ospf *, u_char);
-extern void ospf_redistribute_withdraw (struct ospf *, u_char);
+extern void ospf_redistribute_withdraw (struct ospf *, u_char, u_short);
extern void ospf_asbr_check (void);
extern void ospf_schedule_asbr_check (void);
extern void ospf_asbr_route_install_lsa (struct ospf_lsa *);
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index de62e0b7f..af5cbf534 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -755,60 +755,51 @@ ospf_packet_dump (struct stream *s)
/*
- [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)
+ [no] debug ospf [<1-65535>] packet (hello|dd|ls-request|ls-update|ls-ack|all)
[send|recv [detail]]
*/
-DEFUN (debug_ospf_packet,
- debug_ospf_packet_all_cmd,
- "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
- DEBUG_STR
- OSPF_STR
- "OSPF packets\n"
- "OSPF Hello\n"
- "OSPF Database Description\n"
- "OSPF Link State Request\n"
- "OSPF Link State Update\n"
- "OSPF Link State Acknowledgment\n"
- "OSPF all packets\n")
+static int
+debug_ospf_packet_common (struct vty *vty, int arg_base, int argc,
+ const char **argv)
{
int type = 0;
int flag = 0;
int i;
- assert (argc > 0);
+ assert (argc > arg_base + 0);
/* Check packet type. */
- if (strncmp (argv[0], "h", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "h", 1) == 0)
type = OSPF_DEBUG_HELLO;
- else if (strncmp (argv[0], "d", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "d", 1) == 0)
type = OSPF_DEBUG_DB_DESC;
- else if (strncmp (argv[0], "ls-r", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-r", 4) == 0)
type = OSPF_DEBUG_LS_REQ;
- else if (strncmp (argv[0], "ls-u", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-u", 4) == 0)
type = OSPF_DEBUG_LS_UPD;
- else if (strncmp (argv[0], "ls-a", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-a", 4) == 0)
type = OSPF_DEBUG_LS_ACK;
- else if (strncmp (argv[0], "a", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
type = OSPF_DEBUG_ALL;
/* Default, both send and recv. */
- if (argc == 1)
+ if (argc == arg_base + 1)
flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV;
/* send or recv. */
- if (argc >= 2)
+ if (argc >= arg_base + 2)
{
- if (strncmp (argv[1], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 1], "s", 1) == 0)
flag = OSPF_DEBUG_SEND;
- else if (strncmp (argv[1], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 1], "r", 1) == 0)
flag = OSPF_DEBUG_RECV;
- else if (strncmp (argv[1], "d", 1) == 0)
+ else if (strncmp (argv[arg_base + 1], "d", 1) == 0)
flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
}
/* detail. */
- if (argc == 3)
- if (strncmp (argv[2], "d", 1) == 0)
+ if (argc == arg_base + 3)
+ if (strncmp (argv[arg_base + 2], "d", 1) == 0)
flag |= OSPF_DEBUG_DETAIL;
for (i = 0; i < 5; i++)
@@ -823,6 +814,22 @@ DEFUN (debug_ospf_packet,
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_packet,
+ debug_ospf_packet_all_cmd,
+ "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
+ DEBUG_STR
+ OSPF_STR
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n")
+{
+ return (debug_ospf_packet_common(vty, 0, argc, argv));
+}
+
ALIAS (debug_ospf_packet,
debug_ospf_packet_send_recv_cmd,
"debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
@@ -855,13 +862,12 @@ ALIAS (debug_ospf_packet,
"Packet received\n"
"Detail Information\n")
-
-DEFUN (no_debug_ospf_packet,
- no_debug_ospf_packet_all_cmd,
- "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
- NO_STR
+DEFUN (debug_ospf_instance_packet,
+ debug_ospf_instance_packet_all_cmd,
+ "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)",
DEBUG_STR
OSPF_STR
+ "Instance ID\n"
"OSPF packets\n"
"OSPF Hello\n"
"OSPF Database Description\n"
@@ -870,44 +876,91 @@ DEFUN (no_debug_ospf_packet,
"OSPF Link State Acknowledgment\n"
"OSPF all packets\n")
{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return (debug_ospf_packet_common(vty, 1, argc, argv));
+}
+
+ALIAS (debug_ospf_instance_packet,
+ debug_ospf_instance_packet_send_recv_cmd,
+ "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n"
+ "Packet sent\n"
+ "Packet received\n"
+ "Detail information\n")
+
+ALIAS (debug_ospf_instance_packet,
+ debug_ospf_instance_packet_send_recv_detail_cmd,
+ "debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n"
+ "Packet sent\n"
+ "Packet received\n"
+ "Detail Information\n")
+
+static int
+no_debug_ospf_packet_common (struct vty *vty, int arg_base, int argc,
+ const char **argv)
+{
int type = 0;
int flag = 0;
int i;
- assert (argc > 0);
+ assert (argc > arg_base + 0);
/* Check packet type. */
- if (strncmp (argv[0], "h", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "h", 1) == 0)
type = OSPF_DEBUG_HELLO;
- else if (strncmp (argv[0], "d", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "d", 1) == 0)
type = OSPF_DEBUG_DB_DESC;
- else if (strncmp (argv[0], "ls-r", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-r", 4) == 0)
type = OSPF_DEBUG_LS_REQ;
- else if (strncmp (argv[0], "ls-u", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-u", 4) == 0)
type = OSPF_DEBUG_LS_UPD;
- else if (strncmp (argv[0], "ls-a", 4) == 0)
+ else if (strncmp (argv[arg_base + 0], "ls-a", 4) == 0)
type = OSPF_DEBUG_LS_ACK;
- else if (strncmp (argv[0], "a", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
type = OSPF_DEBUG_ALL;
/* Default, both send and recv. */
- if (argc == 1)
+ if (argc == arg_base + 1)
flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ;
/* send or recv. */
- if (argc == 2)
+ if (argc == arg_base + 2)
{
- if (strncmp (argv[1], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 1], "s", 1) == 0)
flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL;
- else if (strncmp (argv[1], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 1], "r", 1) == 0)
flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL;
- else if (strncmp (argv[1], "d", 1) == 0)
+ else if (strncmp (argv[arg_base + 1], "d", 1) == 0)
flag = OSPF_DEBUG_DETAIL;
}
/* detail. */
- if (argc == 3)
- if (strncmp (argv[2], "d", 1) == 0)
+ if (argc == arg_base + 3)
+ if (strncmp (argv[arg_base + 2], "d", 1) == 0)
flag = OSPF_DEBUG_DETAIL;
for (i = 0; i < 5; i++)
@@ -929,6 +982,23 @@ DEFUN (no_debug_ospf_packet,
return CMD_SUCCESS;
}
+DEFUN (no_debug_ospf_packet,
+ no_debug_ospf_packet_all_cmd,
+ "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n")
+{
+ return no_debug_ospf_packet_common(vty, 0, argc, argv);
+}
+
ALIAS (no_debug_ospf_packet,
no_debug_ospf_packet_send_recv_cmd,
"no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
@@ -963,25 +1033,81 @@ ALIAS (no_debug_ospf_packet,
"Packet received\n"
"Detail Information\n")
-
-DEFUN (debug_ospf_ism,
- debug_ospf_ism_cmd,
- "debug ospf ism",
+DEFUN (no_debug_ospf_instance_packet,
+ no_debug_ospf_instance_packet_all_cmd,
+ "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all)",
+ NO_STR
DEBUG_STR
OSPF_STR
- "OSPF Interface State Machine\n")
+ "Instance ID\n"
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return (no_debug_ospf_packet_common(vty, 1, argc, argv));
+}
+
+ALIAS (no_debug_ospf_instance_packet,
+ no_debug_ospf_instance_packet_send_recv_cmd,
+ "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)",
+ NO_STR
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n"
+ "Packet sent\n"
+ "Packet received\n"
+ "Detail Information\n")
+
+ALIAS (no_debug_ospf_instance_packet,
+ no_debug_ospf_instance_packet_send_recv_detail_cmd,
+ "no debug ospf <1-65535> packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)",
+ NO_STR
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF packets\n"
+ "OSPF Hello\n"
+ "OSPF Database Description\n"
+ "OSPF Link State Request\n"
+ "OSPF Link State Update\n"
+ "OSPF Link State Acknowledgment\n"
+ "OSPF all packets\n"
+ "Packet sent\n"
+ "Packet received\n"
+ "Detail Information\n")
+
+
+static int
+debug_ospf_ism_common (struct vty *vty, int arg_base, int argc, const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_ON (ism, ISM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
DEBUG_ON (ism, ISM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
DEBUG_ON (ism, ISM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
DEBUG_ON (ism, ISM_TIMERS);
}
@@ -989,21 +1115,31 @@ DEFUN (debug_ospf_ism,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_ON (ism, ISM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
TERM_DEBUG_ON (ism, ISM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
TERM_DEBUG_ON (ism, ISM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
TERM_DEBUG_ON (ism, ISM_TIMERS);
}
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_ism,
+ debug_ospf_ism_cmd,
+ "debug ospf ism",
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Interface State Machine\n")
+{
+ return debug_ospf_ism_common(vty, 0, argc, argv);
+}
+
ALIAS (debug_ospf_ism,
debug_ospf_ism_sub_cmd,
"debug ospf ism (status|events|timers)",
@@ -1014,46 +1150,81 @@ ALIAS (debug_ospf_ism,
"ISM Event Information\n"
"ISM TImer Information\n")
-DEFUN (no_debug_ospf_ism,
- no_debug_ospf_ism_cmd,
- "no debug ospf ism",
- NO_STR
+DEFUN (debug_ospf_instance_ism,
+ debug_ospf_instance_ism_cmd,
+ "debug ospf <1-65535> ism",
DEBUG_STR
OSPF_STR
- "OSPF Interface State Machine")
+ "Instance ID\n"
+ "OSPF Interface State Machine\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return debug_ospf_ism_common(vty, 1, argc, argv);
+}
+
+ALIAS (debug_ospf_instance_ism,
+ debug_ospf_instance_ism_sub_cmd,
+ "debug ospf <1-65535> ism (status|events|timers)",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Interface State Machine\n"
+ "ISM Status Information\n"
+ "ISM Event Information\n"
+ "ISM TImer Information\n")
+
+static int
+no_debug_ospf_ism_common(struct vty *vty, int arg_base, int argc,
+ const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_OFF (ism, ISM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
DEBUG_OFF (ism, ISM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
DEBUG_OFF (ism, ISM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
DEBUG_OFF (ism, ISM_TIMERS);
}
return CMD_SUCCESS;
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_OFF (ism, ISM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
TERM_DEBUG_OFF (ism, ISM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
TERM_DEBUG_OFF (ism, ISM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
TERM_DEBUG_OFF (ism, ISM_TIMERS);
}
return CMD_SUCCESS;
}
+DEFUN (no_debug_ospf_ism,
+ no_debug_ospf_ism_cmd,
+ "no debug ospf ism",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Interface State Machine")
+{
+ return no_debug_ospf_ism_common(vty, 0, argc, argv);
+}
+
ALIAS (no_debug_ospf_ism,
no_debug_ospf_ism_sub_cmd,
"no debug ospf ism (status|events|timers)",
@@ -1065,25 +1236,50 @@ ALIAS (no_debug_ospf_ism,
"ISM Event Information\n"
"ISM Timer Information\n")
-
-DEFUN (debug_ospf_nsm,
- debug_ospf_nsm_cmd,
- "debug ospf nsm",
+DEFUN (no_debug_ospf_instance_ism,
+ no_debug_ospf_instance_ism_cmd,
+ "no debug ospf <1-65535> ism",
+ NO_STR
DEBUG_STR
OSPF_STR
- "OSPF Neighbor State Machine\n")
+ "Instance ID\n"
+ "OSPF Interface State Machine")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return no_debug_ospf_ism_common(vty, 1, argc, argv);
+}
+
+ALIAS (no_debug_ospf_instance_ism,
+ no_debug_ospf_instance_ism_sub_cmd,
+ "no debug ospf <1-65535> ism (status|events|timers)",
+ NO_STR
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF Interface State Machine\n"
+ "ISM Status Information\n"
+ "ISM Event Information\n"
+ "ISM Timer Information\n")
+
+static int
+debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_ON (nsm, NSM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
DEBUG_ON (nsm, NSM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
DEBUG_ON (nsm, NSM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
DEBUG_ON (nsm, NSM_TIMERS);
}
@@ -1091,21 +1287,31 @@ DEFUN (debug_ospf_nsm,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_ON (nsm, NSM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
TERM_DEBUG_ON (nsm, NSM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
TERM_DEBUG_ON (nsm, NSM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
TERM_DEBUG_ON (nsm, NSM_TIMERS);
}
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_nsm,
+ debug_ospf_nsm_cmd,
+ "debug ospf nsm",
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Neighbor State Machine\n")
+{
+ return debug_ospf_nsm_common (vty, 0, argc, argv);
+}
+
ALIAS (debug_ospf_nsm,
debug_ospf_nsm_sub_cmd,
"debug ospf nsm (status|events|timers)",
@@ -1116,25 +1322,48 @@ ALIAS (debug_ospf_nsm,
"NSM Event Information\n"
"NSM Timer Information\n")
-DEFUN (no_debug_ospf_nsm,
- no_debug_ospf_nsm_cmd,
- "no debug ospf nsm",
- NO_STR
+DEFUN (debug_ospf_instance_nsm,
+ debug_ospf_instance_nsm_cmd,
+ "debug ospf <1-65535> nsm",
DEBUG_STR
OSPF_STR
- "OSPF Neighbor State Machine")
+ "Instance ID\n"
+ "OSPF Neighbor State Machine\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return debug_ospf_nsm_common (vty, 1, argc, argv);
+}
+
+ALIAS (debug_ospf_instance_nsm,
+ debug_ospf_instance_nsm_sub_cmd,
+ "debug ospf <1-65535> nsm (status|events|timers)",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Neighbor State Machine\n"
+ "NSM Status Information\n"
+ "NSM Event Information\n"
+ "NSM Timer Information\n")
+
+static int
+no_debug_ospf_nsm_common (struct vty *vty, int arg_base, int argc, const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_OFF (nsm, NSM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
DEBUG_OFF (nsm, NSM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
DEBUG_OFF (nsm, NSM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
DEBUG_OFF (nsm, NSM_TIMERS);
}
@@ -1142,21 +1371,32 @@ DEFUN (no_debug_ospf_nsm,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_OFF (nsm, NSM);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "s", 1) == 0)
TERM_DEBUG_OFF (nsm, NSM_STATUS);
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
TERM_DEBUG_OFF (nsm, NSM_EVENTS);
- else if (strncmp (argv[0], "t", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "t", 1) == 0)
TERM_DEBUG_OFF (nsm, NSM_TIMERS);
}
return CMD_SUCCESS;
}
+DEFUN (no_debug_ospf_nsm,
+ no_debug_ospf_nsm_cmd,
+ "no debug ospf nsm",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Neighbor State Machine")
+{
+ return no_debug_ospf_nsm_common(vty, 0, argc, argv);
+}
+
ALIAS (no_debug_ospf_nsm,
no_debug_ospf_nsm_sub_cmd,
"no debug ospf nsm (status|events|timers)",
@@ -1168,27 +1408,53 @@ ALIAS (no_debug_ospf_nsm,
"NSM Event Information\n"
"NSM Timer Information\n")
-
-DEFUN (debug_ospf_lsa,
- debug_ospf_lsa_cmd,
- "debug ospf lsa",
+DEFUN (no_debug_ospf_instance_nsm,
+ no_debug_ospf_instance_nsm_cmd,
+ "no debug ospf <1-65535> nsm",
+ NO_STR
DEBUG_STR
OSPF_STR
- "OSPF Link State Advertisement\n")
+ "Instance ID\n"
+ "OSPF Neighbor State Machine")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return no_debug_ospf_nsm_common(vty, 1, argc, argv);
+}
+
+ALIAS (no_debug_ospf_instance_nsm,
+ no_debug_ospf_instance_nsm_sub_cmd,
+ "no debug ospf <1-65535> nsm (status|events|timers)",
+ NO_STR
+ "Debugging functions\n"
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF Interface State Machine\n"
+ "NSM Status Information\n"
+ "NSM Event Information\n"
+ "NSM Timer Information\n")
+
+
+static int
+debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_ON (lsa, LSA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "g", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "g", 1) == 0)
DEBUG_ON (lsa, LSA_GENERATE);
- else if (strncmp (argv[0], "f", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "f", 1) == 0)
DEBUG_ON (lsa, LSA_FLOODING);
- else if (strncmp (argv[0], "i", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "i", 1) == 0)
DEBUG_ON (lsa, LSA_INSTALL);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
DEBUG_ON (lsa, LSA_REFRESH);
}
@@ -1196,23 +1462,33 @@ DEFUN (debug_ospf_lsa,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_ON (lsa, LSA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "g", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "g", 1) == 0)
TERM_DEBUG_ON (lsa, LSA_GENERATE);
- else if (strncmp (argv[0], "f", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "f", 1) == 0)
TERM_DEBUG_ON (lsa, LSA_FLOODING);
- else if (strncmp (argv[0], "i", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "i", 1) == 0)
TERM_DEBUG_ON (lsa, LSA_INSTALL);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
TERM_DEBUG_ON (lsa, LSA_REFRESH);
}
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_lsa,
+ debug_ospf_lsa_cmd,
+ "debug ospf lsa",
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Link State Advertisement\n")
+{
+ return debug_ospf_lsa_common(vty, 0, argc, argv);
+}
+
ALIAS (debug_ospf_lsa,
debug_ospf_lsa_sub_cmd,
"debug ospf lsa (generate|flooding|install|refresh)",
@@ -1224,27 +1500,51 @@ ALIAS (debug_ospf_lsa,
"LSA Install/Delete\n"
"LSA Refresh\n")
-DEFUN (no_debug_ospf_lsa,
- no_debug_ospf_lsa_cmd,
- "no debug ospf lsa",
- NO_STR
+DEFUN (debug_ospf_instance_lsa,
+ debug_ospf_instance_lsa_cmd,
+ "debug ospf <1-65535> lsa",
DEBUG_STR
OSPF_STR
+ "Instance ID\n"
"OSPF Link State Advertisement\n")
{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return debug_ospf_lsa_common(vty, 1, argc, argv);
+}
+
+ALIAS (debug_ospf_instance_lsa,
+ debug_ospf_instance_lsa_sub_cmd,
+ "debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Link State Advertisement\n"
+ "LSA Generation\n"
+ "LSA Flooding\n"
+ "LSA Install/Delete\n"
+ "LSA Refresh\n")
+
+static int
+no_debug_ospf_lsa_common (struct vty *vty, int arg_base, int argc, const char **argv)
+{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_OFF (lsa, LSA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "g", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "g", 1) == 0)
DEBUG_OFF (lsa, LSA_GENERATE);
- else if (strncmp (argv[0], "f", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "f", 1) == 0)
DEBUG_OFF (lsa, LSA_FLOODING);
- else if (strncmp (argv[0], "i", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "i", 1) == 0)
DEBUG_OFF (lsa, LSA_INSTALL);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
DEBUG_OFF (lsa, LSA_REFRESH);
}
@@ -1252,23 +1552,34 @@ DEFUN (no_debug_ospf_lsa,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_OFF (lsa, LSA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "g", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "g", 1) == 0)
TERM_DEBUG_OFF (lsa, LSA_GENERATE);
- else if (strncmp (argv[0], "f", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "f", 1) == 0)
TERM_DEBUG_OFF (lsa, LSA_FLOODING);
- else if (strncmp (argv[0], "i", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "i", 1) == 0)
TERM_DEBUG_OFF (lsa, LSA_INSTALL);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
TERM_DEBUG_OFF (lsa, LSA_REFRESH);
}
return CMD_SUCCESS;
}
+DEFUN (no_debug_ospf_lsa,
+ no_debug_ospf_lsa_cmd,
+ "no debug ospf lsa",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Link State Advertisement\n")
+{
+ return no_debug_ospf_lsa_common (vty, 0, argc, argv);
+}
+
ALIAS (no_debug_ospf_lsa,
no_debug_ospf_lsa_sub_cmd,
"no debug ospf lsa (generate|flooding|install|refresh)",
@@ -1281,23 +1592,50 @@ ALIAS (no_debug_ospf_lsa,
"LSA Install/Delete\n"
"LSA Refres\n")
+DEFUN (no_debug_ospf_instance_lsa,
+ no_debug_ospf_instance_lsa_cmd,
+ "no debug ospf <1-65535> lsa",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Link State Advertisement\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
-DEFUN (debug_ospf_zebra,
- debug_ospf_zebra_cmd,
- "debug ospf zebra",
+ return no_debug_ospf_lsa_common (vty, 1, argc, argv);
+}
+
+ALIAS (no_debug_ospf_instance_lsa,
+ no_debug_ospf_instance_lsa_sub_cmd,
+ "no debug ospf <1-65535> lsa (generate|flooding|install|refresh)",
+ NO_STR
DEBUG_STR
OSPF_STR
- "OSPF Zebra information\n")
+ "Instance ID\n"
+ "OSPF Link State Advertisement\n"
+ "LSA Generation\n"
+ "LSA Flooding\n"
+ "LSA Install/Delete\n"
+ "LSA Refres\n")
+
+
+static int
+debug_ospf_zebra_common (struct vty *vty, int arg_base, int argc, const char **argv)
{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_ON (zebra, ZEBRA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "i", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "i", 1) == 0)
DEBUG_ON (zebra, ZEBRA_INTERFACE);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
}
@@ -1305,19 +1643,29 @@ DEFUN (debug_ospf_zebra,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_ON (zebra, ZEBRA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "i", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "i", 1) == 0)
TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE);
}
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_zebra,
+ debug_ospf_zebra_cmd,
+ "debug ospf zebra",
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Zebra information\n")
+{
+ return debug_ospf_zebra_common(vty, 0, argc, argv);
+}
+
ALIAS (debug_ospf_zebra,
debug_ospf_zebra_sub_cmd,
"debug ospf zebra (interface|redistribute)",
@@ -1327,23 +1675,46 @@ ALIAS (debug_ospf_zebra,
"Zebra interface\n"
"Zebra redistribute\n")
-DEFUN (no_debug_ospf_zebra,
- no_debug_ospf_zebra_cmd,
- "no debug ospf zebra",
- NO_STR
+DEFUN (debug_ospf_instance_zebra,
+ debug_ospf_instance_zebra_cmd,
+ "debug ospf <1-65535> zebra",
DEBUG_STR
OSPF_STR
+ "Instance ID\n"
"OSPF Zebra information\n")
{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return debug_ospf_zebra_common(vty, 1, argc, argv);
+}
+
+ALIAS (debug_ospf_instance_zebra,
+ debug_ospf_instance_zebra_sub_cmd,
+ "debug ospf <1-65535> zebra (interface|redistribute)",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Zebra information\n"
+ "Zebra interface\n"
+ "Zebra redistribute\n")
+
+static int
+no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc,
+ const char **argv)
+{
if (vty->node == CONFIG_NODE)
{
- if (argc == 0)
+ if (argc == arg_base + 0)
DEBUG_OFF (zebra, ZEBRA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "i", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "i", 1) == 0)
DEBUG_OFF (zebra, ZEBRA_INTERFACE);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
}
@@ -1351,19 +1722,30 @@ DEFUN (no_debug_ospf_zebra,
}
/* ENABLE_NODE. */
- if (argc == 0)
+ if (argc == arg_base + 0)
TERM_DEBUG_OFF (zebra, ZEBRA);
- else if (argc == 1)
+ else if (argc == arg_base + 1)
{
- if (strncmp (argv[0], "i", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "i", 1) == 0)
TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE);
- else if (strncmp (argv[0], "r", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "r", 1) == 0)
TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE);
}
return CMD_SUCCESS;
}
+DEFUN (no_debug_ospf_zebra,
+ no_debug_ospf_zebra_cmd,
+ "no debug ospf zebra",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "OSPF Zebra information\n")
+{
+ return no_debug_ospf_zebra_common(vty, 0, argc, argv);
+}
+
ALIAS (no_debug_ospf_zebra,
no_debug_ospf_zebra_sub_cmd,
"no debug ospf zebra (interface|redistribute)",
@@ -1374,6 +1756,36 @@ ALIAS (no_debug_ospf_zebra,
"Zebra interface\n"
"Zebra redistribute\n")
+DEFUN (no_debug_ospf_instance_zebra,
+ no_debug_ospf_instance_zebra_cmd,
+ "no debug ospf <1-65535> zebra",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Zebra information\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ return no_debug_ospf_zebra_common(vty, 1, argc, argv);
+}
+
+ALIAS (no_debug_ospf_instance_zebra,
+ no_debug_ospf_instance_zebra_sub_cmd,
+ "no debug ospf <1-65535> zebra (interface|redistribute)",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF Zebra information\n"
+ "Zebra interface\n"
+ "Zebra redistribute\n")
+
+
DEFUN (debug_ospf_event,
debug_ospf_event_cmd,
"debug ospf event",
@@ -1401,6 +1813,47 @@ DEFUN (no_debug_ospf_event,
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_instance_event,
+ debug_ospf_instance_event_cmd,
+ "debug ospf <1-65535> event",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF event information\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ if (vty->node == CONFIG_NODE)
+ CONF_DEBUG_ON (event, EVENT);
+ TERM_DEBUG_ON (event, EVENT);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_ospf_instance_event,
+ no_debug_ospf_instance_event_cmd,
+ "no debug ospf <1-65535> event",
+ NO_STR
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF event information\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ if (vty->node == CONFIG_NODE)
+ CONF_DEBUG_OFF (event, EVENT);
+ TERM_DEBUG_OFF (event, EVENT);
+ return CMD_SUCCESS;
+}
+
DEFUN (debug_ospf_nssa,
debug_ospf_nssa_cmd,
"debug ospf nssa",
@@ -1428,16 +1881,57 @@ DEFUN (no_debug_ospf_nssa,
return CMD_SUCCESS;
}
+DEFUN (debug_ospf_instance_nssa,
+ debug_ospf_instance_nssa_cmd,
+ "debug ospf <1-65535> nssa",
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF nssa information\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
-DEFUN (show_debugging_ospf,
- show_debugging_ospf_cmd,
- "show debugging ospf",
- SHOW_STR
+ if (vty->node == CONFIG_NODE)
+ CONF_DEBUG_ON (nssa, NSSA);
+ TERM_DEBUG_ON (nssa, NSSA);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_ospf_instance_nssa,
+ no_debug_ospf_instance_nssa_cmd,
+ "no debug ospf <1-65535> nssa",
+ NO_STR
DEBUG_STR
- OSPF_STR)
+ OSPF_STR
+ "Instance ID\n"
+ "OSPF nssa information\n")
+{
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if (!ospf_lookup_instance (instance))
+ return CMD_SUCCESS;
+
+ if (vty->node == CONFIG_NODE)
+ CONF_DEBUG_OFF (nssa, NSSA);
+ TERM_DEBUG_OFF (nssa, NSSA);
+ return CMD_SUCCESS;
+}
+
+
+static int
+show_debugging_ospf_common (struct vty *vty, struct ospf *ospf)
{
int i;
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
+
vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE);
/* Show debug status for events. */
@@ -1523,9 +2017,44 @@ DEFUN (show_debugging_ospf,
if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
+DEFUN (show_debugging_ospf,
+ show_debugging_ospf_cmd,
+ "show debugging ospf",
+ SHOW_STR
+ DEBUG_STR
+ OSPF_STR)
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_debugging_ospf_common(vty, ospf);
+}
+
+DEFUN (show_debugging_ospf_instance,
+ show_debugging_ospf_instance_cmd,
+ "show debugging ospf <1-65535>",
+ SHOW_STR
+ DEBUG_STR
+ OSPF_STR
+ "Instance ID\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL )
+ return CMD_SUCCESS;
+
+ return show_debugging_ospf_common(vty, ospf);
+}
+
/* Debug node. */
static struct cmd_node debug_node =
{
@@ -1544,58 +2073,69 @@ config_write_debug (struct vty *vty)
const char *detail_str[] = {"", " send", " recv", "", " detail",
" send detail", " recv detail", " detail"};
+ struct ospf *ospf;
+ char str[16];
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ if (ospf->instance)
+ sprintf(str, " %d", ospf->instance);
+ else
+ sprintf(str, "");
+
/* debug ospf ism (status|events|timers). */
if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM)
- vty_out (vty, "debug ospf ism%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s ism%s", str, VTY_NEWLINE);
else
{
if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS))
- vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s ism status%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS))
- vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s ism event%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS))
- vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s ism timer%s", str, VTY_NEWLINE);
}
/* debug ospf nsm (status|events|timers). */
if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM)
- vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s nsm%s", str, VTY_NEWLINE);
else
{
if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS))
- vty_out (vty, "debug ospf nsm status%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s nsm status%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS))
- vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s nsm event%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS))
- vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s nsm timer%s", str, VTY_NEWLINE);
}
/* debug ospf lsa (generate|flooding|install|refresh). */
if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
- vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s lsa%s", str, VTY_NEWLINE);
else
{
if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE))
- vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s lsa generate%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING))
- vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s lsa flooding%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL))
- vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s lsa install%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH))
- vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s lsa refresh%s", str, VTY_NEWLINE);
write = 1;
}
/* debug ospf zebra (interface|redistribute). */
if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA)
- vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s zebra%s", str, VTY_NEWLINE);
else
{
if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
- vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s zebra interface%s", str, VTY_NEWLINE);
if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
- vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s zebra redistribute%s", str, VTY_NEWLINE);
write = 1;
}
@@ -1603,14 +2143,14 @@ config_write_debug (struct vty *vty)
/* debug ospf event. */
if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT)
{
- vty_out (vty, "debug ospf event%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s event%s", str, VTY_NEWLINE);
write = 1;
}
/* debug ospf nssa. */
if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA)
{
- vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s nssa%s", str, VTY_NEWLINE);
write = 1;
}
@@ -1620,7 +2160,7 @@ config_write_debug (struct vty *vty)
r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL);
if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL))
{
- vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s packet all detail%s", str, VTY_NEWLINE);
return 1;
}
@@ -1630,10 +2170,10 @@ config_write_debug (struct vty *vty)
r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV;
if (r == OSPF_DEBUG_SEND_RECV)
{
- vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE);
+ vty_out (vty, "debug ospf%s packet all%s", str, VTY_NEWLINE);
for (i = 0; i < 5; i++)
if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL)
- vty_out (vty, "debug ospf packet %s detail%s",
+ vty_out (vty, "debug ospf%s packet %s detail%s", str,
type_str[i],
VTY_NEWLINE);
return 1;
@@ -1646,7 +2186,7 @@ config_write_debug (struct vty *vty)
if (conf_debug_ospf_packet[i] == 0)
continue;
- vty_out (vty, "debug ospf packet %s%s%s",
+ vty_out (vty, "debug ospf%s packet %s%s%s", str,
type_str[i], detail_str[conf_debug_ospf_packet[i]],
VTY_NEWLINE);
write = 1;
@@ -1689,6 +2229,34 @@ debug_init ()
install_element (ENABLE_NODE, &no_debug_ospf_event_cmd);
install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd);
+ install_element (ENABLE_NODE, &show_debugging_ospf_instance_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_packet_send_recv_detail_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_packet_send_recv_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_packet_all_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_ism_sub_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_ism_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_nsm_sub_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_nsm_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_lsa_sub_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_lsa_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_zebra_sub_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_zebra_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_event_cmd);
+ install_element (ENABLE_NODE, &debug_ospf_instance_nssa_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_send_recv_detail_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_send_recv_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_packet_all_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_ism_sub_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_ism_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_nsm_sub_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_nsm_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_lsa_sub_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_lsa_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_zebra_sub_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_zebra_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_event_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf_instance_nssa_cmd);
+
install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd);
install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd);
install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd);
@@ -1715,4 +2283,31 @@ debug_init ()
install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd);
install_element (CONFIG_NODE, &no_debug_ospf_event_cmd);
install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd);
+
+ install_element (CONFIG_NODE, &debug_ospf_instance_packet_send_recv_detail_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_packet_send_recv_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_packet_all_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_ism_sub_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_ism_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_nsm_sub_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_nsm_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_lsa_sub_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_lsa_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_zebra_sub_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_zebra_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_event_cmd);
+ install_element (CONFIG_NODE, &debug_ospf_instance_nssa_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_send_recv_detail_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_send_recv_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_packet_all_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_ism_sub_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_ism_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_nsm_sub_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_nsm_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_lsa_sub_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_lsa_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_zebra_sub_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_zebra_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_event_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf_instance_nssa_cmd);
}
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index d18314a9d..1d107ca0d 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -92,19 +92,33 @@ ospf_external_info_check (struct ospf_lsa *lsa)
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- int redist_type = is_prefix_default (&p) ? DEFAULT_ROUTE : type;
- if (ospf_is_type_redistributed (redist_type))
- if (EXTERNAL_INFO (type))
- {
- rn = route_node_lookup (EXTERNAL_INFO (type),
- (struct prefix *) &p);
- if (rn)
- {
- route_unlock_node (rn);
- if (rn->info != NULL)
- return (struct external_info *) rn->info;
- }
- }
+ int redist_on = 0;
+
+ redist_on = is_prefix_default (&p) ? zclient->default_information :
+ zclient->redist[type].enabled;
+ if (redist_on)
+ {
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ ext_list = om->external[type];
+ if (!ext_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ {
+ if (ext->external_info)
+ rn = route_node_lookup (ext->external_info,
+ (struct prefix *) &p);
+ if (rn)
+ {
+ route_unlock_node (rn);
+ if (rn->info != NULL)
+ return (struct external_info *) rn->info;
+ }
+ }
+ }
}
return NULL;
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 1de03440c..f988468e3 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -1590,16 +1590,23 @@ ospf_get_nssa_ip (struct ospf_area *area)
#define DEFAULT_METRIC_TYPE EXTERNAL_METRIC_TYPE_2
int
-metric_type (struct ospf *ospf, u_char src)
+metric_type (struct ospf *ospf, u_char src, u_short instance)
{
- return (ospf->dmetric[src].type < 0 ?
- DEFAULT_METRIC_TYPE : ospf->dmetric[src].type);
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, src, instance);
+
+ return ((!red || red->dmetric.type < 0) ?
+ DEFAULT_METRIC_TYPE : red->dmetric.type);
}
int
-metric_value (struct ospf *ospf, u_char src)
+metric_value (struct ospf *ospf, u_char src, u_short instance)
{
- if (ospf->dmetric[src].value < 0)
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, src, instance);
+ if (!red || red->dmetric.value < 0)
{
if (src == DEFAULT_ROUTE)
{
@@ -1614,7 +1621,7 @@ metric_value (struct ospf *ospf, u_char src)
return ospf->default_metric;
}
- return ospf->dmetric[src].value;
+ return red->dmetric.value;
}
/* Set AS-external-LSA body. */
@@ -1627,6 +1634,7 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
u_int32_t mvalue;
int mtype;
int type;
+ u_short instance;
/* Put Network Mask. */
masklen2ip (p->prefixlen, &mask);
@@ -1634,12 +1642,13 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
/* If prefix is default, specify DEFAULT_ROUTE. */
type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
+ instance = is_prefix_default (&ei->p) ? 0 : ei->instance;
mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
- ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type);
+ ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type, instance);
mvalue = (ROUTEMAP_METRIC (ei) != -1) ?
- ROUTEMAP_METRIC (ei) : metric_value (ospf, type);
+ ROUTEMAP_METRIC (ei) : metric_value (ospf, type, instance);
/* Put type of external metric. */
stream_putc (s, (mtype == EXTERNAL_METRIC_TYPE_2 ? 0x80 : 0));
@@ -2106,17 +2115,25 @@ ospf_external_lsa_originate_timer (struct thread *thread)
struct external_info *ei;
struct route_table *rt;
int type = THREAD_VAL (thread);
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
ospf->t_external_lsa = NULL;
- /* Originate As-external-LSA from all type of distribute source. */
- if ((rt = EXTERNAL_INFO (type)))
- for (rn = route_top (rt); rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
- if (!ospf_external_lsa_originate (ospf, ei))
- zlog_warn ("LSA: AS-external-LSA was not originated.");
-
+ ext_list = om->external[type];
+ if (!ext_list)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ /* Originate As-external-LSA from all type of distribute source. */
+ if ((rt = ext->external_info))
+ for (rn = route_top (rt); rn; rn = route_next (rn))
+ if ((ei = rn->info) != NULL)
+ if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
+ if (!ospf_external_lsa_originate (ospf, ei))
+ zlog_warn ("LSA: AS-external-LSA was not originated.");
+
return 0;
}
@@ -2133,17 +2150,30 @@ ospf_default_external_info (struct ospf *ospf)
/* First, lookup redistributed default route. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
- if (EXTERNAL_INFO (type) && type != ZEBRA_ROUTE_OSPF)
- {
- rn = route_node_lookup (EXTERNAL_INFO (type), (struct prefix *) &p);
- if (rn != NULL)
- {
- route_unlock_node (rn);
- assert (rn->info);
- if (ospf_redistribute_check (ospf, rn->info, NULL))
- return rn->info;
- }
- }
+ {
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ if (type == ZEBRA_ROUTE_OSPF)
+ continue;
+
+ ext_list = om->external[type];
+ if (!ext_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ {
+ rn = route_node_lookup (ext->external_info, (struct prefix *) &p);
+ if (rn != NULL)
+ {
+ route_unlock_node (rn);
+ assert (rn->info);
+ if (ospf_redistribute_check (ospf, rn->info, NULL))
+ return rn->info;
+ }
+ }
+ }
return NULL;
}
@@ -2167,7 +2197,7 @@ ospf_default_originate_timer (struct thread *thread)
/* If there is no default route via redistribute,
then originate AS-external-LSA with nexthop 0 (self). */
nexthop.s_addr = 0;
- ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop, 0);
+ ospf_external_info_add (DEFAULT_ROUTE, 0, p, 0, nexthop, 0);
}
if ((ei = ospf_default_external_info (ospf)))
@@ -2298,15 +2328,18 @@ ospf_external_lsa_refresh_default (struct ospf *ospf)
}
void
-ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, int force)
+ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, u_short instance,
+ int force)
{
struct route_node *rn;
struct external_info *ei;
+ struct ospf_external *ext;
if (type != DEFAULT_ROUTE)
- if (EXTERNAL_INFO(type))
+ if ((ext = ospf_external_lookup(type, instance)) &&
+ EXTERNAL_INFO (ext))
/* Refresh each redistributed AS-external-LSAs. */
- for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
+ for (rn = route_top (EXTERNAL_INFO (ext)); rn; rn = route_next (rn))
if ((ei = rn->info))
if (!is_prefix_default (&ei->p))
{
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index c71877da4..624efc4c1 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -314,7 +314,7 @@ extern struct ospf_lsa *ospf_lsa_refresh (struct ospf *, struct ospf_lsa *);
extern void ospf_external_lsa_refresh_default (struct ospf *);
-extern void ospf_external_lsa_refresh_type (struct ospf *, u_char, int);
+extern void ospf_external_lsa_refresh_type (struct ospf *, u_char, u_short, int);
extern struct ospf_lsa *ospf_external_lsa_refresh (struct ospf *,
struct ospf_lsa *,
struct external_info *,
@@ -333,8 +333,8 @@ extern void ospf_lsa_maxage_delete (struct ospf *, struct ospf_lsa *);
extern void ospf_discard_from_db (struct ospf *, struct ospf_lsdb *, struct ospf_lsa*);
extern int is_prefix_default (struct prefix_ipv4 *);
-extern int metric_type (struct ospf *, u_char);
-extern int metric_value (struct ospf *, u_char);
+extern int metric_type (struct ospf *, u_char, u_short);
+extern int metric_value (struct ospf *, u_char, u_short);
extern struct in_addr ospf_get_nssa_ip (struct ospf_area *);
extern int ospf_translated_nssa_compare (struct ospf_lsa *, struct ospf_lsa *);
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 19b9121cc..d34e65dc4 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -73,12 +73,13 @@ struct zebra_privs_t ospfd_privs =
};
/* Configuration filename and directory. */
-char config_default[] = SYSCONFDIR OSPF_DEFAULT_CONFIG;
+char config_default[100];
/* OSPFd options. */
struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
+ { "instance", required_argument, NULL, 'n'},
{ "config_file", required_argument, NULL, 'f'},
{ "pid_file", required_argument, NULL, 'i'},
{ "socket", required_argument, NULL, 'z'},
@@ -99,7 +100,7 @@ struct option longopts[] =
struct thread_master *master;
/* Process ID saved for use by init system */
-const char *pid_file = PATH_OSPFD_PID;
+char pid_file[100];
#ifdef SUPPORT_OSPF_API
extern int ospf_apiserver_enable;
@@ -116,6 +117,7 @@ usage (char *progname, int status)
printf ("Usage : %s [OPTION...]\n\
Daemon which manages OSPF.\n\n\
-d, --daemon Runs in daemon mode\n\
+-n, --instance Set the instance id\n\
-f, --config_file Set configuration file name\n\
-i, --pid_file Set process identifier file name\n\
-z, --socket Set path of zebra socket\n\
@@ -182,9 +184,11 @@ main (int argc, char **argv)
char *p;
char *vty_addr = NULL;
int vty_port = OSPF_VTY_PORT;
+ char vty_path[100];
int daemon_mode = 0;
char *config_file = NULL;
char *progname;
+ u_short instance = 0;
struct thread thread;
int dryrun = 0;
@@ -203,13 +207,18 @@ main (int argc, char **argv)
{
int opt;
- opt = getopt_long (argc, argv, "df:i:z:hA:P:u:g:avC", longopts, 0);
+ opt = getopt_long (argc, argv, "df:i:n:z:hA:P:u:g:avC", longopts, 0);
if (opt == EOF)
break;
switch (opt)
{
+ case 'n':
+ instance = atoi(optarg);
+ if (instance < 1 || instance > 65535)
+ exit(0);
+ break;
case 0:
break;
case 'd':
@@ -222,7 +231,7 @@ main (int argc, char **argv)
vty_addr = optarg;
break;
case 'i':
- pid_file = optarg;
+ strcpy(pid_file,optarg);
break;
case 'z':
zclient_serv_path_set (optarg);
@@ -274,7 +283,7 @@ main (int argc, char **argv)
exit (1);
}
- zlog_default = openzlog (progname, ZLOG_OSPF,
+ zlog_default = openzlog (progname, ZLOG_OSPF, instance,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* OSPF master init. */
@@ -296,7 +305,7 @@ main (int argc, char **argv)
/* OSPFd inits. */
ospf_if_init ();
- ospf_zebra_init ();
+ ospf_zebra_init (instance);
/* OSPF vty inits. */
ospf_vty_init ();
@@ -314,13 +323,17 @@ main (int argc, char **argv)
/* Need to initialize the default ospf structure, so the interface mode
commands can be duly processed if they are received before 'router ospf',
when quagga(ospfd) is restarted */
- if (!ospf_get())
+ if (!ospf_get_instance(instance))
{
zlog_err("OSPF instance init failed: %s", strerror(errno));
exit (1);
}
/* Get configuration file. */
+ if (instance)
+ sprintf(config_default, "%sospfd-%d.conf", SYSCONFDIR, instance);
+ else
+ sprintf(config_default, "%s%s", SYSCONFDIR, OSPF_DEFAULT_CONFIG);
vty_read_config (config_file, config_default);
/* Start execution only if not in dry-run mode */
@@ -334,14 +347,23 @@ main (int argc, char **argv)
exit (1);
}
+ /* Create VTY socket */
+ if (instance)
+ {
+ sprintf(pid_file, "/var/run/quagga/ospfd-%d.pid", instance);
+ sprintf(vty_path, "/var/run/quagga/ospfd-%d.vty", instance);
+ }
+ else
+ {
+ strcpy(pid_file, PATH_OSPFD_PID);
+ strcpy(vty_path, OSPF_VTYSH_PATH);
+ }
/* Process id file create. */
pid_output (pid_file);
-
- /* Create VTY socket */
- vty_serv_sock (vty_addr, vty_port, OSPF_VTYSH_PATH);
+ vty_serv_sock (vty_addr, vty_port, vty_path);
/* Print banner. */
- zlog_notice ("OSPFd %s starting: vty@%d", QUAGGA_VERSION, vty_port);
+ zlog_notice ("OSPFd %s starting: vty@%d, %s", QUAGGA_VERSION, vty_port, vty_path);
/* Fetch next active thread. */
while (thread_fetch (master, &thread))
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index d3266e835..2cbd04bbe 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -719,9 +719,19 @@ nsm_change_state (struct ospf_neighbor *nbr, int state)
/* kevinm: refresh any redistributions */
for (x = ZEBRA_ROUTE_SYSTEM; x < ZEBRA_ROUTE_MAX; x++)
{
- if (x == ZEBRA_ROUTE_OSPF || x == ZEBRA_ROUTE_OSPF6)
- continue;
- ospf_external_lsa_refresh_type (oi->ospf, x, force);
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ if (x == ZEBRA_ROUTE_OSPF6)
+ continue;
+
+ red_list = oi->ospf->redist[x];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ ospf_external_lsa_refresh_type (oi->ospf, x, red->instance, force);
}
/* XXX: Clearly some thing is wrong with refresh of external LSAs
* this added to hack around defaults not refreshing after a timer
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 744952c96..999893ff1 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -767,6 +767,9 @@ DEFUN (capability_opaque,
{
struct ospf *ospf = (struct ospf *) vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
/* Turn on the "master switch" of opaque-lsa capability. */
if (!CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
{
@@ -794,6 +797,9 @@ DEFUN (no_capability_opaque,
{
struct ospf *ospf = (struct ospf *) vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
/* Turn off the "master switch" of opaque-lsa capability. */
if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
{
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index ff1bdae59..491b9c54b 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -2889,7 +2889,7 @@ ospf_read (struct thread *thread)
{
if ((oi = ospf_associate_packet_vl (ospf, ifp, iph, ospfh)) == NULL)
{
- if (IS_DEBUG_OSPF_EVENT)
+ if (!ospf->instance && IS_DEBUG_OSPF_EVENT)
zlog_debug ("Packet from [%s] received on link %s"
" but no ospf_interface",
inet_ntoa (iph->ip_src), ifp->name);
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 425524d48..6e02de3a1 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -45,6 +45,7 @@ ospf_route_map_update (const char *name)
{
struct ospf *ospf;
int type;
+ u_short instance; // PENDING
/* If OSPF instatnce does not exist, return right now. */
ospf = ospf_lookup ();
@@ -54,22 +55,33 @@ ospf_route_map_update (const char *name)
/* Update route-map */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (ospf, type)
- && strcmp (ROUTEMAP_NAME (ospf, type), name) == 0)
- {
- /* Keep old route-map. */
- struct route_map *old = ROUTEMAP (ospf, type);
-
- /* Update route-map. */
- ROUTEMAP (ospf, type) =
- route_map_lookup_by_name (ROUTEMAP_NAME (ospf, type));
-
- /* No update for this distribute type. */
- if (old == NULL && ROUTEMAP (ospf, type) == NULL)
- continue;
-
- ospf_distribute_list_update (ospf, type);
- }
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[type];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ if (ROUTEMAP_NAME (red)
+ && strcmp (ROUTEMAP_NAME (red), name) == 0)
+ {
+ /* Keep old route-map. */
+ struct route_map *old = ROUTEMAP (red);
+
+ /* Update route-map. */
+ ROUTEMAP (red) =
+ route_map_lookup_by_name (ROUTEMAP_NAME (red));
+
+ /* No update for this distribute type. */
+ if (old == NULL && ROUTEMAP (red) == NULL)
+ continue;
+
+ ospf_distribute_list_update (ospf, type, red->instance);
+ }
+ }
}
}
@@ -84,13 +96,23 @@ ospf_route_map_event (route_map_event_t event, const char *name)
if (ospf == NULL)
return;
- /* Update route-map. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (ospf, type) && ROUTEMAP (ospf, type)
- && !strcmp (ROUTEMAP_NAME (ospf, type), name))
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[type];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
{
- ospf_distribute_list_update (ospf, type);
+ if (ROUTEMAP_NAME (red) && ROUTEMAP (red)
+ && !strcmp (ROUTEMAP_NAME (red), name))
+ {
+ ospf_distribute_list_update (ospf, type, red->instance);
+ }
}
}
}
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index c605ce68d..e7e1a4362 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -1473,6 +1473,10 @@ DEFUN (mpls_te,
{
struct listnode *node, *nnode;
struct mpls_te_link *lp;
+ struct ospf *ospf = vty->index;
+
+ if (!ospf)
+ return CMD_SUCCESS;
if (OspfMplsTE.status == enabled)
return CMD_SUCCESS;
@@ -1511,6 +1515,10 @@ DEFUN (no_mpls_te,
{
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;
@@ -1537,6 +1545,10 @@ DEFUN (mpls_te_router_addr,
{
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[0], &value))
{
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 2854a41b4..4f0727b58 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -149,12 +149,38 @@ DEFUN (router_ospf,
"Enable a routing process\n"
"Start OSPF configuration\n")
{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ ospf = ospf_lookup();
+ if (!ospf)
+ {
+ vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
vty->node = OSPF_NODE;
- vty->index = ospf_get ();
+
+ if (argc)
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ /* The following logic to set the vty->index is in place to be able
+ to ignore the commands which dont belong to this instance. */
+ if (ospf->instance != instance)
+ vty->index = NULL;
+ else
+ vty->index = ospf;
return CMD_SUCCESS;
}
+ALIAS (router_ospf,
+ router_ospf_instance_cmd,
+ "router ospf <1-65535>",
+ "Enable a routing process\n"
+ "Start OSPF configuration\n"
+ "Instance ID\n")
+
DEFUN (no_router_ospf,
no_router_ospf_cmd,
"no router ospf",
@@ -163,19 +189,27 @@ DEFUN (no_router_ospf,
"Start OSPF configuration\n")
{
struct ospf *ospf;
+ u_short instance = 0;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (argc)
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
ospf_finish (ospf);
return CMD_SUCCESS;
}
+ALIAS (no_router_ospf,
+ no_router_ospf_instance_cmd,
+ "no router ospf <1-65535>",
+ NO_STR
+ "Enable a routing process\n"
+ "Start OSPF configuration\n"
+ "Instance ID\n")
+
DEFUN (ospf_router_id,
ospf_router_id_cmd,
"ospf router-id A.B.C.D",
@@ -187,6 +221,9 @@ DEFUN (ospf_router_id,
struct in_addr router_id;
int ret;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ret = inet_aton (argv[0], &router_id);
if (!ret)
{
@@ -216,6 +253,9 @@ DEFUN (no_ospf_router_id,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->router_id_static.s_addr = 0;
ospf_router_id_update (ospf);
@@ -298,6 +338,9 @@ DEFUN (ospf_passive_interface,
struct route_node *rn;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc == 0)
{
ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
@@ -374,6 +417,9 @@ DEFUN (no_ospf_passive_interface,
struct route_node *rn;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc == 0)
{
ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
@@ -446,6 +492,16 @@ DEFUN (ospf_network_area,
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",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
if (ospf->if_ospf_cli_count > 0)
{
vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s",
@@ -482,6 +538,16 @@ DEFUN (no_ospf_network_area,
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",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
/* Get network prefix and Area ID. */
VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
@@ -513,6 +579,9 @@ DEFUN (ospf_area_range,
int format;
u_int32_t cost;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
@@ -574,6 +643,9 @@ DEFUN (ospf_area_range_not_advertise,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
@@ -597,6 +669,9 @@ DEFUN (no_ospf_area_range,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
@@ -658,6 +733,9 @@ DEFUN (ospf_area_range_substitute,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
@@ -684,6 +762,9 @@ DEFUN (no_ospf_area_range_substitute,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
@@ -959,6 +1040,9 @@ DEFUN (ospf_area_vlink,
int i;
int ret;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_vl_config_data_init(&vl_config, vty);
/* Read off first 2 parameters and check them */
@@ -1095,6 +1179,9 @@ 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[0], &vl_config.area_id, &format);
@@ -1407,6 +1494,9 @@ DEFUN (ospf_area_shortcut,
int mode;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -1446,6 +1536,9 @@ DEFUN (no_ospf_area_shortcut,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1470,6 +1563,9 @@ DEFUN (ospf_area_stub,
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[0]);
ret = ospf_area_stub_set (ospf, area_id);
@@ -1498,6 +1594,9 @@ DEFUN (ospf_area_stub_no_summary,
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[0]);
ret = ospf_area_stub_set (ospf, area_id);
@@ -1526,6 +1625,9 @@ DEFUN (no_ospf_area_stub,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
ospf_area_stub_unset (ospf, area_id);
@@ -1548,6 +1650,9 @@ DEFUN (no_ospf_area_stub_no_summary,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
ospf_area_no_summary_unset (ospf, area_id);
@@ -1562,6 +1667,9 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
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[0]);
ret = ospf_area_nssa_set (ospf, area_id);
@@ -1665,6 +1773,9 @@ DEFUN (no_ospf_area_nssa,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
ospf_area_nssa_unset (ospf, area_id);
@@ -1689,6 +1800,9 @@ DEFUN (no_ospf_area_nssa_no_summary,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
ospf_area_no_summary_unset (ospf, area_id);
@@ -1711,6 +1825,9 @@ DEFUN (ospf_area_default_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[0]);
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
@@ -1752,6 +1869,9 @@ DEFUN (no_ospf_area_default_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[0]);
VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
@@ -1796,6 +1916,9 @@ DEFUN (ospf_area_export_list,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -1819,6 +1942,9 @@ DEFUN (no_ospf_area_export_list,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1845,6 +1971,9 @@ DEFUN (ospf_area_import_list,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -1868,6 +1997,9 @@ DEFUN (no_ospf_area_import_list,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -1897,6 +2029,9 @@ DEFUN (ospf_area_filter_list,
struct prefix_list *plist;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -1941,6 +2076,9 @@ DEFUN (no_ospf_area_filter_list,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
@@ -1993,6 +2131,9 @@ DEFUN (ospf_area_authentication_message_digest,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -2014,6 +2155,9 @@ DEFUN (ospf_area_authentication,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_get (ospf, area_id, format);
@@ -2036,6 +2180,9 @@ DEFUN (no_ospf_area_authentication,
struct in_addr area_id;
int format;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
area = ospf_area_lookup_by_area_id (ospf, area_id);
@@ -2063,6 +2210,9 @@ DEFUN (ospf_abr_type,
struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (strncmp (argv[0], "c", 1) == 0)
abr_type = OSPF_ABR_CISCO;
else if (strncmp (argv[0], "i", 1) == 0)
@@ -2097,6 +2247,9 @@ DEFUN (no_ospf_abr_type,
struct ospf *ospf = vty->index;
u_char abr_type = OSPF_ABR_UNKNOWN;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (strncmp (argv[0], "c", 1) == 0)
abr_type = OSPF_ABR_CISCO;
else if (strncmp (argv[0], "i", 1) == 0)
@@ -2125,6 +2278,9 @@ DEFUN (ospf_log_adjacency_changes,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
return CMD_SUCCESS;
}
@@ -2137,6 +2293,9 @@ DEFUN (ospf_log_adjacency_changes_detail,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
return CMD_SUCCESS;
@@ -2150,6 +2309,9 @@ DEFUN (no_ospf_log_adjacency_changes,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
return CMD_SUCCESS;
@@ -2164,6 +2326,9 @@ DEFUN (no_ospf_log_adjacency_changes_detail,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
return CMD_SUCCESS;
}
@@ -2176,6 +2341,9 @@ DEFUN (ospf_compatible_rfc1583,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
@@ -2193,6 +2361,9 @@ DEFUN (no_ospf_compatible_rfc1583,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
@@ -2221,6 +2392,9 @@ ospf_timers_spf_set (struct vty *vty, unsigned int delay,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->spf_delay = delay;
ospf->spf_holdtime = hold;
ospf->spf_max_holdtime = max;
@@ -2316,6 +2490,9 @@ DEFUN (ospf_neighbor,
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[0]);
if (argc > 1)
@@ -2364,6 +2541,9 @@ DEFUN (ospf_neighbor_poll_interval,
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[0]);
if (argc > 1)
@@ -2401,6 +2581,9 @@ DEFUN (no_ospf_neighbor,
struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
(void)ospf_nbr_nbma_unset (ospf, nbr_addr);
@@ -2447,6 +2630,9 @@ DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
struct ospf *ospf = vty->index;
unsigned int interval;
+ if (!ospf)
+ return CMD_SUCCESS;
+
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
interval = (interval / 10) * 10;
@@ -2464,6 +2650,9 @@ DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
struct ospf *ospf = vty->index;
unsigned int interval;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc == 1)
{
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
@@ -2496,6 +2685,9 @@ DEFUN (ospf_auto_cost_reference_bandwidth,
struct listnode *node;
struct interface *ifp;
+ if (!ospf)
+ return CMD_SUCCESS;
+
refbw = strtol (argv[0], NULL, 10);
if (refbw < 1 || refbw > 4294967)
{
@@ -2525,6 +2717,9 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
struct listnode *node, *nnode;
struct interface *ifp;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
@@ -2548,6 +2743,9 @@ DEFUN (ospf_write_multiplier,
struct ospf *ospf = vty->index;
u_int32_t write_oi_count;
+ if (!ospf)
+ return CMD_SUCCESS;
+
write_oi_count = strtol (argv[0], NULL, 10);
if (write_oi_count < 1 || write_oi_count > 100)
{
@@ -2574,6 +2772,9 @@ DEFUN (no_ospf_write_multiplier,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
return CMD_SUCCESS;
}
@@ -2726,32 +2927,23 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
vty_out (vty, "%s", VTY_NEWLINE);
}
-DEFUN (show_ip_ospf,
- show_ip_ospf_cmd,
- "show ip ospf",
- SHOW_STR
- IP_STR
- "OSPF information\n")
+static int
+show_ip_ospf_common (struct vty *vty, struct ospf *ospf)
{
struct listnode *node, *nnode;
struct ospf_area * area;
- struct ospf *ospf;
struct timeval result;
char timebuf[OSPF_TIME_DUMP_SIZE];
- /* Check OSPF is enable. */
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
/* Show Router ID. */
vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
inet_ntoa (ospf->router_id),
VTY_NEWLINE);
-
+
/* Graceful shutdown */
if (ospf->t_deferred_shutdown)
vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
@@ -2860,6 +3052,40 @@ DEFUN (show_ip_ospf,
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf,
+ show_ip_ospf_cmd,
+ "show ip ospf",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n")
+
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_common(vty, ospf));
+}
+
+DEFUN (show_ip_ospf_instance,
+ show_ip_ospf_instance_cmd,
+ "show ip ospf <1-65535>",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_common(vty, ospf));
+}
+
static void
show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
@@ -3026,42 +3252,75 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
}
}
-DEFUN (show_ip_ospf_interface,
- show_ip_ospf_interface_cmd,
- "show ip ospf interface [INTERFACE]",
- SHOW_STR
- IP_STR
- "OSPF information\n"
- "Interface information\n"
- "Interface name\n")
+static int
+show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int arg_base,
+ int argc, const char **argv)
{
struct interface *ifp;
- struct ospf *ospf;
struct listnode *node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
+
+ if (argc == arg_base + 0)
{
- vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
+ /* Show All Interfaces. */
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ if (ospf_oi_count(ifp))
+ show_ip_ospf_interface_sub (vty, ospf, ifp);
}
-
- /* Show All Interfaces. */
- if (argc == 0)
- for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
- show_ip_ospf_interface_sub (vty, ospf, ifp);
- /* Interface name is specified. */
else
{
- if ((ifp = if_lookup_by_name (argv[0])) == NULL)
+ /* Interface name is specified. */
+ if ((ifp = if_lookup_by_name (argv[arg_base + 0])) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else
show_ip_ospf_interface_sub (vty, ospf, ifp);
}
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_interface,
+ show_ip_ospf_interface_cmd,
+ "show ip ospf interface [INTERFACE]",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Interface information\n"
+ "Interface name\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_interface_common(vty, ospf, 0, argc, argv);
+}
+
+DEFUN (show_ip_ospf_instance_interface,
+ show_ip_ospf_instance_interface_cmd,
+ "show ip ospf <1-65535> interface [INTERFACE]",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Interface information\n"
+ "Interface name\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_interface_common(vty, ospf, 1, argc, argv);
+}
+
static void
show_ip_ospf_neighbour_header (struct vty *vty)
{
@@ -3110,54 +3369,72 @@ show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
}
}
-DEFUN (show_ip_ospf_neighbor,
- show_ip_ospf_neighbor_cmd,
- "show ip ospf neighbor",
- SHOW_STR
- IP_STR
- "OSPF information\n"
- "Neighbor list\n")
+static int
+show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf)
{
- struct ospf *ospf;
struct ospf_interface *oi;
struct listnode *node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE);
show_ip_ospf_neighbour_header (vty);
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
show_ip_ospf_neighbor_sub (vty, oi);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_neighbor_all,
- show_ip_ospf_neighbor_all_cmd,
- "show ip ospf neighbor all",
+DEFUN (show_ip_ospf_neighbor,
+ show_ip_ospf_neighbor_cmd,
+ "show ip ospf neighbor",
SHOW_STR
IP_STR
"OSPF information\n"
- "Neighbor list\n"
- "include down status neighbor\n")
+ "Neighbor list\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_common(vty, ospf);
+}
+
+
+DEFUN (show_ip_ospf_instance_neighbor,
+ show_ip_ospf_instance_neighbor_cmd,
+ "show ip ospf <1-65535> neighbor",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_common(vty, ospf);
+}
+
+static int
+show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf)
{
- struct ospf *ospf = ospf_lookup ();
struct listnode *node;
struct ospf_interface *oi;
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE);
+
show_ip_ospf_neighbour_header (vty);
-
+
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
struct listnode *nbr_node;
@@ -3180,35 +3457,64 @@ DEFUN (show_ip_ospf_neighbor_all,
}
}
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_neighbor_int,
- show_ip_ospf_neighbor_int_cmd,
- "show ip ospf neighbor IFNAME",
+DEFUN (show_ip_ospf_neighbor_all,
+ show_ip_ospf_neighbor_all_cmd,
+ "show ip ospf neighbor all",
SHOW_STR
IP_STR
"OSPF information\n"
"Neighbor list\n"
- "Interface name\n")
+ "include down status neighbor\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_all_common(vty, ospf);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_all,
+ show_ip_ospf_instance_neighbor_all_cmd,
+ "show ip ospf <1-65535> neighbor all",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "include down status neighbor\n")
{
struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_all_common(vty, ospf);
+}
+
+static int
+show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base,
+ const char **argv)
+{
struct interface *ifp;
struct route_node *rn;
-
- ifp = if_lookup_by_name (argv[0]);
+
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE);
+
+ ifp = if_lookup_by_name (argv[arg_base + 0]);
if (!ifp)
{
vty_out (vty, "No such interface.%s", VTY_NEWLINE);
return CMD_WARNING;
}
-
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
show_ip_ospf_neighbour_header (vty);
@@ -3225,6 +3531,43 @@ DEFUN (show_ip_ospf_neighbor_int,
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_neighbor_int,
+ show_ip_ospf_neighbor_int_cmd,
+ "show ip ospf neighbor IFNAME",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Neighbor list\n"
+ "Interface name\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_int,
+ show_ip_ospf_instance_neighbor_int_cmd,
+ "show ip ospf <1-65535> neighbor IFNAME",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "Interface name\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv);
+}
+
static void
show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
struct ospf_nbr_nbma *nbr_nbma)
@@ -3335,36 +3678,27 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
}
-DEFUN (show_ip_ospf_neighbor_id,
- show_ip_ospf_neighbor_id_cmd,
- "show ip ospf neighbor A.B.C.D",
- SHOW_STR
- IP_STR
- "OSPF information\n"
- "Neighbor list\n"
- "Neighbor ID\n")
+static int
+show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf,
+ int arg_base, const char **argv)
{
- struct ospf *ospf;
struct listnode *node;
struct ospf_neighbor *nbr;
struct ospf_interface *oi;
struct in_addr router_id;
int ret;
- ret = inet_aton (argv[0], &router_id);
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
+
+ ret = inet_aton (argv[arg_base + 0], &router_id);
if (!ret)
{
vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING;
}
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
@@ -3372,25 +3706,52 @@ DEFUN (show_ip_ospf_neighbor_id,
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_neighbor_detail,
- show_ip_ospf_neighbor_detail_cmd,
- "show ip ospf neighbor detail",
+DEFUN (show_ip_ospf_neighbor_id,
+ show_ip_ospf_neighbor_id_cmd,
+ "show ip ospf neighbor A.B.C.D",
SHOW_STR
IP_STR
"OSPF information\n"
"Neighbor list\n"
- "detail of all neighbors\n")
+ "Neighbor ID\n")
{
struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_id,
+ show_ip_ospf_instance_neighbor_id_cmd,
+ "show ip ospf <1-65535> neighbor A.B.C.D",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "Neighbor ID\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv);
+}
+
+static int
+show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf)
+{
struct ospf_interface *oi;
struct listnode *node;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
@@ -3407,26 +3768,52 @@ DEFUN (show_ip_ospf_neighbor_detail,
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_neighbor_detail_all,
- show_ip_ospf_neighbor_detail_all_cmd,
- "show ip ospf neighbor detail all",
+DEFUN (show_ip_ospf_neighbor_detail,
+ show_ip_ospf_neighbor_detail_cmd,
+ "show ip ospf neighbor detail",
SHOW_STR
IP_STR
"OSPF information\n"
"Neighbor list\n"
- "detail of all neighbors\n"
- "include down status neighbor\n")
+ "detail of all neighbors\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_detail_common(vty, ospf);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_detail,
+ show_ip_ospf_instance_neighbor_detail_cmd,
+ "show ip ospf <1-65535> neighbor detail",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "detail of all neighbors\n")
{
struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_detail_common(vty, ospf);
+}
+
+static int
+show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf)
+{
struct listnode *node;
struct ospf_interface *oi;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
{
@@ -3454,37 +3841,65 @@ DEFUN (show_ip_ospf_neighbor_detail_all,
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_neighbor_int_detail,
- show_ip_ospf_neighbor_int_detail_cmd,
- "show ip ospf neighbor IFNAME detail",
+DEFUN (show_ip_ospf_neighbor_detail_all,
+ show_ip_ospf_neighbor_detail_all_cmd,
+ "show ip ospf neighbor detail all",
SHOW_STR
IP_STR
"OSPF information\n"
"Neighbor list\n"
- "Interface name\n"
- "detail of all neighbors")
+ "detail of all neighbors\n"
+ "include down status neighbor\n")
{
struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_detail_all_common(vty, ospf);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_detail_all,
+ show_ip_ospf_instance_neighbor_detail_all_cmd,
+ "show ip ospf <1-65535> neighbor detail all",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "detail of all neighbors\n"
+ "include down status neighbor\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_detail_all_common(vty, ospf);
+}
+
+static int
+show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf,
+ int arg_base, const char **argv)
+{
struct ospf_interface *oi;
struct interface *ifp;
struct route_node *rn, *nrn;
struct ospf_neighbor *nbr;
- ifp = if_lookup_by_name (argv[0]);
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
+
+ ifp = if_lookup_by_name (argv[arg_base + 0]);
if (!ifp)
{
vty_out (vty, "No such interface.%s", VTY_NEWLINE);
return CMD_WARNING;
}
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
-
for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
if ((oi = rn->info))
for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
@@ -3496,6 +3911,44 @@ DEFUN (show_ip_ospf_neighbor_int_detail,
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_neighbor_int_detail,
+ show_ip_ospf_neighbor_int_detail_cmd,
+ "show ip ospf neighbor IFNAME detail",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Neighbor list\n"
+ "Interface name\n"
+ "detail of all neighbors")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv);
+}
+
+DEFUN (show_ip_ospf_instance_neighbor_int_detail,
+ show_ip_ospf_instance_neighbor_int_detail_cmd,
+ "show ip ospf <1-65535> neighbor IFNAME detail",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Neighbor list\n"
+ "Interface name\n"
+ "detail of all neighbors")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance(instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv);
+}
/* Show functions */
static int
@@ -4154,89 +4607,81 @@ show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
OSPF_LSA_TYPE_OPAQUE_AS_DESC
-DEFUN (show_ip_ospf_database,
- show_ip_ospf_database_cmd,
- "show ip ospf database",
- SHOW_STR
- IP_STR
- "OSPF information\n"
- "Database summary\n")
+static int
+show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf,
+ int arg_base, int argc, const char **argv)
{
- struct ospf *ospf;
int type, ret;
struct in_addr id, adv_router;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE);
vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
/* Show all LSA. */
- if (argc == 0)
+ if (argc == arg_base + 0)
{
show_ip_ospf_database_summary (vty, ospf, 0);
return CMD_SUCCESS;
}
/* Set database type to show. */
- if (strncmp (argv[0], "r", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "r", 1) == 0)
type = OSPF_ROUTER_LSA;
- else if (strncmp (argv[0], "ne", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
type = OSPF_NETWORK_LSA;
- else if (strncmp (argv[0], "ns", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
type = OSPF_AS_NSSA_LSA;
- else if (strncmp (argv[0], "su", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "su", 2) == 0)
type = OSPF_SUMMARY_LSA;
- else if (strncmp (argv[0], "a", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
type = OSPF_ASBR_SUMMARY_LSA;
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
type = OSPF_AS_EXTERNAL_LSA;
- else if (strncmp (argv[0], "se", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "se", 2) == 0)
{
show_ip_ospf_database_summary (vty, ospf, 1);
return CMD_SUCCESS;
}
- else if (strncmp (argv[0], "m", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "m", 1) == 0)
{
show_ip_ospf_database_maxage (vty, ospf);
return CMD_SUCCESS;
}
#ifdef HAVE_OPAQUE_LSA
- else if (strncmp (argv[0], "opaque-l", 8) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
type = OSPF_OPAQUE_LINK_LSA;
- else if (strncmp (argv[0], "opaque-ar", 9) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
type = OSPF_OPAQUE_AREA_LSA;
- else if (strncmp (argv[0], "opaque-as", 9) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
type = OSPF_OPAQUE_AS_LSA;
#endif /* HAVE_OPAQUE_LSA */
else
return CMD_WARNING;
/* `show ip ospf database LSA'. */
- if (argc == 1)
+ if (argc == arg_base + 1)
show_lsa_detail (vty, ospf, type, NULL, NULL);
- else if (argc >= 2)
+ else if (argc >= arg_base + 2)
{
- ret = inet_aton (argv[1], &id);
+ ret = inet_aton (argv[arg_base + 1], &id);
if (!ret)
return CMD_WARNING;
/* `show ip ospf database LSA ID'. */
- if (argc == 2)
+ if (argc == arg_base + 2)
show_lsa_detail (vty, ospf, type, &id, NULL);
/* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
- else if (argc == 3)
+ else if (argc == arg_base + 3)
{
- if (strncmp (argv[2], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 2], "s", 1) == 0)
adv_router = ospf->router_id;
else
{
- ret = inet_aton (argv[2], &adv_router);
+ ret = inet_aton (argv[arg_base + 2], &adv_router);
if (!ret)
return CMD_WARNING;
}
@@ -4247,6 +4692,22 @@ DEFUN (show_ip_ospf_database,
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_database,
+ show_ip_ospf_database_cmd,
+ "show ip ospf database",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Database summary\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv));
+}
+
ALIAS (show_ip_ospf_database,
show_ip_ospf_database_type_cmd,
"show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
@@ -4292,64 +4753,123 @@ ALIAS (show_ip_ospf_database,
"Self-originated link states\n"
"\n")
-DEFUN (show_ip_ospf_database_type_adv_router,
- show_ip_ospf_database_type_adv_router_cmd,
- "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
+DEFUN (show_ip_ospf_instance_database,
+ show_ip_ospf_instance_database_cmd,
+ "show ip ospf <1-65535> database",
SHOW_STR
IP_STR
"OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv));
+}
+
+ALIAS (show_ip_ospf_instance_database,
+ show_ip_ospf_instance_database_type_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "LSAs in MaxAge list\n"
+ "Self-originated link states\n")
+
+ALIAS (show_ip_ospf_instance_database,
+ show_ip_ospf_instance_database_type_id_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
"Database summary\n"
OSPF_LSA_TYPES_DESC
+ "Link State ID (as an IP address)\n")
+
+ALIAS (show_ip_ospf_instance_database,
+ show_ip_ospf_instance_database_type_id_adv_router_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "Link State ID (as an IP address)\n"
"Advertising Router link states\n"
"Advertising Router (as an IP address)\n")
+
+ALIAS (show_ip_ospf_instance_database,
+ show_ip_ospf_instance_database_type_id_self_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "Link State ID (as an IP address)\n"
+ "Self-originated link states\n"
+ "\n")
+
+
+static int
+show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf,
+ int arg_base, int argc, const char **argv)
{
- struct ospf *ospf;
int type, ret;
struct in_addr adv_router;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE);
vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
- if (argc != 2)
+ if (argc != arg_base + 2)
return CMD_WARNING;
/* Set database type to show. */
- if (strncmp (argv[0], "r", 1) == 0)
+ if (strncmp (argv[arg_base + 0], "r", 1) == 0)
type = OSPF_ROUTER_LSA;
- else if (strncmp (argv[0], "ne", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
type = OSPF_NETWORK_LSA;
- else if (strncmp (argv[0], "ns", 2) == 0)
+ else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
type = OSPF_AS_NSSA_LSA;
- else if (strncmp (argv[0], "s", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "s", 1) == 0)
type = OSPF_SUMMARY_LSA;
- else if (strncmp (argv[0], "a", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
type = OSPF_ASBR_SUMMARY_LSA;
- else if (strncmp (argv[0], "e", 1) == 0)
+ else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
type = OSPF_AS_EXTERNAL_LSA;
#ifdef HAVE_OPAQUE_LSA
- else if (strncmp (argv[0], "opaque-l", 8) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
type = OSPF_OPAQUE_LINK_LSA;
- else if (strncmp (argv[0], "opaque-ar", 9) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
type = OSPF_OPAQUE_AREA_LSA;
- else if (strncmp (argv[0], "opaque-as", 9) == 0)
+ else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
type = OSPF_OPAQUE_AS_LSA;
#endif /* HAVE_OPAQUE_LSA */
else
return CMD_WARNING;
/* `show ip ospf database LSA adv-router ADV_ROUTER'. */
- if (strncmp (argv[1], "s", 1) == 0)
+ if (strncmp (argv[arg_base + 1], "s", 1) == 0)
adv_router = ospf->router_id;
else
{
- ret = inet_aton (argv[1], &adv_router);
+ ret = inet_aton (argv[arg_base + 1], &adv_router);
if (!ret)
return CMD_WARNING;
}
@@ -4359,6 +4879,25 @@ DEFUN (show_ip_ospf_database_type_adv_router,
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_database_type_adv_router,
+ show_ip_ospf_database_type_adv_router_cmd,
+ "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "Advertising Router link states\n"
+ "Advertising Router (as an IP address)\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup()) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv));
+}
+
ALIAS (show_ip_ospf_database_type_adv_router,
show_ip_ospf_database_type_self_cmd,
"show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
@@ -4369,6 +4908,39 @@ ALIAS (show_ip_ospf_database_type_adv_router,
OSPF_LSA_TYPES_DESC
"Self-originated link states\n")
+DEFUN (show_ip_ospf_instance_database_type_adv_router,
+ show_ip_ospf_instance_database_type_adv_router_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "Advertising Router link states\n"
+ "Advertising Router (as an IP address)\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv));
+}
+
+ALIAS (show_ip_ospf_instance_database_type_adv_router,
+ show_ip_ospf_instance_database_type_self_cmd,
+ "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Database summary\n"
+ OSPF_LSA_TYPES_DESC
+ "Self-originated link states\n")
DEFUN (ip_ospf_authentication_args,
ip_ospf_authentication_args_addr_cmd,
@@ -5909,15 +6481,25 @@ DEFUN (ip_ospf_area,
struct ospf *ospf;
struct ospf_if_params *params;
struct route_node *rn;
+ u_short instance = 0;
- ospf = ospf_lookup ();
+ if (argc == 2)
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ ospf = ospf_lookup_instance (instance);
if (ospf == NULL)
{
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+ params = IF_DEF_PARAMS (ifp);
+ if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
+ {
+ ospf_interface_unset (ifp);
+ ospf = ospf_lookup();
+ ospf->if_ospf_cli_count--;
+ }
return CMD_SUCCESS;
}
- ret = ospf_str2area_id (argv[0], &area_id, &format);
+ ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format);
if (ret < 0)
{
vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s",
@@ -5952,6 +6534,16 @@ DEFUN (ip_ospf_area,
return CMD_SUCCESS;
}
+ALIAS (ip_ospf_area,
+ ip_ospf_instance_area_cmd,
+ "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
+ "IP Information\n"
+ "OSPF interface commands\n"
+ "Instance ID\n"
+ "Enable OSPF on this interface\n"
+ "OSPF area ID in IP address format\n"
+ "OSPF area ID as a decimal value\n")
+
DEFUN (no_ip_ospf_area,
no_ip_ospf_area_cmd,
"no ip ospf area",
@@ -5963,13 +6555,13 @@ DEFUN (no_ip_ospf_area,
struct interface *ifp = vty->index;
struct ospf *ospf;
struct ospf_if_params *params;
+ u_short instance = 0;
- ospf = ospf_lookup ();
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (argc)
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
params = IF_DEF_PARAMS (ifp);
if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
@@ -5983,6 +6575,15 @@ DEFUN (no_ip_ospf_area,
return CMD_SUCCESS;
}
+ALIAS (no_ip_ospf_area,
+ no_ip_ospf_instance_area_cmd,
+ "no ip ospf <1-65535> area",
+ NO_STR
+ "IP Information\n"
+ "OSPF interface commands\n"
+ "Instance ID\n"
+ "Disable OSPF on this interface\n")
+
DEFUN (ospf_redistribute_source,
ospf_redistribute_source_cmd,
"redistribute " QUAGGA_REDIST_STR_OSPFD
@@ -6001,10 +6602,14 @@ DEFUN (ospf_redistribute_source,
int source;
int type = -1;
int metric = -1;
+ struct ospf_redist *red;
if (argc < 4)
return CMD_WARNING; /* should not happen */
+ if (!ospf)
+ return CMD_SUCCESS;
+
/* Get distribute source. */
source = proto_redistnum(AFI_IP, argv[0]);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
@@ -6020,12 +6625,14 @@ DEFUN (ospf_redistribute_source,
if (!str2metric_type (argv[2], &type))
return CMD_WARNING;
+ red = ospf_redist_add(ospf, source, 0);
+
if (argv[3] != NULL)
- ospf_routemap_set (ospf, source, argv[3]);
+ ospf_routemap_set (red, argv[3]);
else
- ospf_routemap_unset (ospf, source);
+ ospf_routemap_unset (red);
- return ospf_redistribute_set (ospf, source, type, metric);
+ return ospf_redistribute_set (ospf, source, 0, type, metric);
}
DEFUN (no_ospf_redistribute_source,
@@ -6037,13 +6644,131 @@ DEFUN (no_ospf_redistribute_source,
{
struct ospf *ospf = vty->index;
int source;
+ struct ospf_redist *red;
+ if (!ospf)
+ return CMD_SUCCESS;
source = proto_redistnum(AFI_IP, argv[0]);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
- ospf_routemap_unset (ospf, source);
- return ospf_redistribute_unset (ospf, source);
+ red = ospf_redist_lookup(ospf, source, 0);
+ if (!red)
+ return CMD_SUCCESS;
+
+ ospf_routemap_unset (red);
+ return ospf_redistribute_unset (ospf, source, 0);
+}
+
+DEFUN (ospf_redistribute_instance_source,
+ ospf_redistribute_instance_source_cmd,
+ "redistribute ospf <1-65535>"
+ " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
+ REDIST_STR
+ "Open Shortest Path First\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "OSPF default metric\n"
+ "OSPF exterior metric type for redistributed routes\n"
+ "Set OSPF External Type 1 metrics\n"
+ "Set OSPF External Type 2 metrics\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+{
+ struct ospf *ospf = vty->index;
+ int source;
+ int type = -1;
+ int metric = -1;
+ u_short instance;
+ struct ospf_redist *red;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+
+ if (!ospf)
+ return CMD_SUCCESS;
+
+ if (!ospf->instance)
+ {
+ vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (ospf->instance == instance)
+ {
+ vty_out (vty, "Same instance OSPF redistribution not allowed%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ source = ZEBRA_ROUTE_OSPF;
+
+ /* Get metric value. */
+ if (argv[1] != NULL)
+ if (!str2metric (argv[1], &metric))
+ return CMD_WARNING;
+
+ /* Get metric type. */
+ if (argv[2] != NULL)
+ if (!str2metric_type (argv[2], &type))
+ return CMD_WARNING;
+
+ red = ospf_redist_add(ospf, source, instance);
+ if (argv[3] != NULL)
+ ospf_routemap_set (red, argv[3]);
+ else
+ ospf_routemap_unset (red);
+
+ return ospf_redistribute_set (ospf, source, instance, type, metric);
+}
+
+DEFUN (no_ospf_redistribute_instance_source,
+ no_ospf_redistribute_instance_source_cmd,
+ "no redistribute ospf <1-65535>"
+ " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
+ NO_STR
+ REDIST_STR
+ "Open Shortest Path First\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "OSPF default metric\n"
+ "OSPF exterior metric type for redistributed routes\n"
+ "Set OSPF External Type 1 metrics\n"
+ "Set OSPF External Type 2 metrics\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+{
+ struct ospf *ospf = vty->index;
+ u_int instance;
+ struct ospf_redist *red;
+ int source;
+
+ if (!ospf)
+ return CMD_SUCCESS;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+
+ if (!ospf->instance)
+ {
+ vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (ospf->instance == instance)
+ {
+ vty_out (vty, "Same instance OSPF redistribution not allowed%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ source = ZEBRA_ROUTE_OSPF;
+ red = ospf_redist_lookup(ospf, source, instance);
+ if (!red)
+ return CMD_SUCCESS;
+
+ ospf_routemap_unset (red);
+ return ospf_redistribute_unset (ospf, source, instance);
}
DEFUN (ospf_distribute_list_out,
@@ -6057,6 +6782,9 @@ DEFUN (ospf_distribute_list_out,
struct ospf *ospf = vty->index;
int source;
+ if (!ospf)
+ return CMD_SUCCESS;
+
/* Get distribute source. */
source = proto_redistnum(AFI_IP, argv[1]);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
@@ -6077,6 +6805,9 @@ DEFUN (no_ospf_distribute_list_out,
struct ospf *ospf = vty->index;
int source;
+ if (!ospf)
+ return CMD_SUCCESS;
+
source = proto_redistnum(AFI_IP, argv[1]);
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
@@ -6104,6 +6835,10 @@ DEFUN (ospf_default_information_originate,
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 */
@@ -6112,6 +6847,8 @@ DEFUN (ospf_default_information_originate,
if (argv[0] != NULL)
default_originate = DEFAULT_ORIGINATE_ALWAYS;
+ red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
+
/* Get metric value. */
if (argv[1] != NULL)
if (!str2metric (argv[1], &metric))
@@ -6123,9 +6860,9 @@ DEFUN (ospf_default_information_originate,
return CMD_WARNING;
if (argv[3] != NULL)
- ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
+ ospf_routemap_set (red, argv[3]);
else
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
+ ospf_routemap_unset (red);
return ospf_redistribute_default_set (ospf, default_originate,
type, metric);
@@ -6140,20 +6877,29 @@ DEFUN (no_ospf_default_information_originate,
{
struct ospf *ospf = vty->index;
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;
p.prefixlen = 0;
ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
- if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
- ospf_external_info_delete (DEFAULT_ROUTE, p);
- route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
- EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
+ if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) &&
+ EXTERNAL_INFO (ext)) {
+ ospf_external_info_delete (DEFAULT_ROUTE, 0, p);
+ ospf_external_del (DEFAULT_ROUTE, 0);
}
- ospf_routemap_unset (ospf, DEFAULT_ROUTE);
+ red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
+ if (!red)
+ return CMD_SUCCESS;
+
+ ospf_routemap_unset (red);
return ospf_redistribute_default_unset (ospf);
}
@@ -6166,6 +6912,9 @@ DEFUN (ospf_default_metric,
struct ospf *ospf = vty->index;
int metric = -1;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (!str2metric (argv[0], &metric))
return CMD_WARNING;
@@ -6182,6 +6931,9 @@ DEFUN (no_ospf_default_metric,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->default_metric = -1;
return CMD_SUCCESS;
@@ -6202,6 +6954,9 @@ DEFUN (ospf_distance,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->distance_all = atoi (argv[0]);
return CMD_SUCCESS;
@@ -6216,6 +6971,9 @@ DEFUN (no_ospf_distance,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->distance_all = 0;
return CMD_SUCCESS;
@@ -6237,6 +6995,9 @@ DEFUN (no_ospf_distance_ospf,
if (argc < 3)
return CMD_WARNING;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argv[0] != NULL)
ospf->distance_intra = 0;
@@ -6303,6 +7064,9 @@ DEFUN (ospf_distance_source,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
return CMD_SUCCESS;
@@ -6318,6 +7082,9 @@ DEFUN (no_ospf_distance_source,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
return CMD_SUCCESS;
@@ -6333,6 +7100,9 @@ DEFUN (ospf_distance_source_access_list,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
return CMD_SUCCESS;
@@ -6349,6 +7119,9 @@ DEFUN (no_ospf_distance_source_access_list,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
return CMD_SUCCESS;
@@ -6464,6 +7237,9 @@ DEFUN (ospf_max_metric_router_lsa_admin,
struct ospf_area *area;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
{
SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
@@ -6490,6 +7266,9 @@ DEFUN (no_ospf_max_metric_router_lsa_admin,
struct ospf_area *area;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
{
UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
@@ -6517,6 +7296,9 @@ DEFUN (ospf_max_metric_router_lsa_startup,
unsigned int seconds;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc != 1)
{
vty_out (vty, "%% Must supply stub-router period");
@@ -6542,6 +7324,9 @@ DEFUN (no_ospf_max_metric_router_lsa_startup,
struct ospf_area *area;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
@@ -6570,6 +7355,9 @@ DEFUN (ospf_max_metric_router_lsa_shutdown,
unsigned int seconds;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc != 1)
{
vty_out (vty, "%% Must supply stub-router shutdown period");
@@ -6593,6 +7381,9 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown,
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
return CMD_SUCCESS;
@@ -6775,21 +7566,12 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
vty_out (vty, "%s", VTY_NEWLINE);
}
-DEFUN (show_ip_ospf_border_routers,
- show_ip_ospf_border_routers_cmd,
- "show ip ospf border-routers",
- SHOW_STR
- IP_STR
- "show all the ABR's and ASBR's\n"
- "for this area\n")
+static int
+show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf)
{
- struct ospf *ospf;
-
- if ((ospf = ospf_lookup ()) == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
if (ospf->new_table == NULL)
{
@@ -6803,24 +7585,52 @@ DEFUN (show_ip_ospf_border_routers,
/* Show Router routes. */
show_ip_ospf_route_router (vty, ospf->new_rtrs);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
-DEFUN (show_ip_ospf_route,
- show_ip_ospf_route_cmd,
- "show ip ospf route",
+DEFUN (show_ip_ospf_border_routers,
+ show_ip_ospf_border_routers_cmd,
+ "show ip ospf border-routers",
SHOW_STR
IP_STR
"OSPF information\n"
- "OSPF routing table\n")
+ "Show all the ABR's and ASBR's\n")
{
struct ospf *ospf;
if ((ospf = ospf_lookup ()) == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_border_routers_common(vty, ospf);
+}
+
+DEFUN (show_ip_ospf_instance_border_routers,
+ show_ip_ospf_instance_border_routers_cmd,
+ "show ip ospf <1-65535> border-routers",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Show all the ABR's and ASBR's\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_border_routers_common(vty, ospf);
+}
+
+static int
+show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf)
+{
+ if (ospf->instance)
+ vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
+ VTY_NEWLINE, VTY_NEWLINE);
if (ospf->new_table == NULL)
{
@@ -6837,9 +7647,45 @@ DEFUN (show_ip_ospf_route,
/* Show AS External routes. */
show_ip_ospf_route_external (vty, ospf->old_external_route);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
return CMD_SUCCESS;
}
+DEFUN (show_ip_ospf_route,
+ show_ip_ospf_route_cmd,
+ "show ip ospf route",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "OSPF routing table\n")
+{
+ struct ospf *ospf;
+
+ if ((ospf = ospf_lookup ()) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_route_common(vty, ospf);
+}
+
+DEFUN (show_ip_ospf_instance_route,
+ show_ip_ospf_instance_route_cmd,
+ "show ip ospf <1-65535> route",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "OSPF routing table\n")
+{
+ struct ospf *ospf;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
+
+ return show_ip_ospf_route_common(vty, ospf);
+}
const char *ospf_abr_type_str[] =
{
@@ -6891,6 +7737,7 @@ config_write_interface (struct vty *vty)
int write = 0;
struct route_node *rn = NULL;
struct ospf_if_params *params;
+ struct ospf *ospf = ospf_lookup();
for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
{
@@ -6972,7 +7819,7 @@ config_write_interface (struct vty *vty)
for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
{
vty_out (vty, " ip ospf message-digest-key %d md5 %s",
- ck->key_id, ck->auth_key);
+ ck->key_id, ck->auth_key);
if (params != IF_DEF_PARAMS (ifp))
vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
vty_out (vty, "%s", VTY_NEWLINE);
@@ -7050,8 +7897,12 @@ config_write_interface (struct vty *vty)
/* Area print. */
if (OSPF_IF_PARAM_CONFIGURED (params, if_area))
{
- vty_out (vty, " ip ospf area %s%s",
- inet_ntoa (params->if_area), VTY_NEWLINE);
+ if (ospf->instance)
+ vty_out (vty, " ip ospf %d area %s%s", ospf->instance,
+ inet_ntoa (params->if_area), VTY_NEWLINE);
+ else
+ vty_out (vty, " ip ospf area %s%s",
+ inet_ntoa (params->if_area), VTY_NEWLINE);
}
@@ -7323,20 +8174,33 @@ config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
/* redistribute print. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- if (type != zclient->redist_default && zclient->redist[type])
- {
- vty_out (vty, " redistribute %s", zebra_route_string(type));
- if (ospf->dmetric[type].value >= 0)
- vty_out (vty, " metric %d", ospf->dmetric[type].value);
-
- if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
- vty_out (vty, " metric-type 1");
+ {
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
- if (ROUTEMAP_NAME (ospf, type))
- vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
-
- vty_out (vty, "%s", VTY_NEWLINE);
- }
+ red_list = ospf->redist[type];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ vty_out (vty, " redistribute %s", zebra_route_string(type));
+ if (red->instance)
+ vty_out (vty, " %d", red->instance);
+
+ if (red->dmetric.value >= 0)
+ vty_out (vty, " metric %d", red->dmetric.value);
+
+ if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1)
+ vty_out (vty, " metric-type 1");
+
+ if (ROUTEMAP_NAME (red))
+ vty_out (vty, " route-map %s", ROUTEMAP_NAME (red));
+
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
+ }
return 0;
}
@@ -7354,6 +8218,7 @@ static int
config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
{
int type;
+ struct ospf_redist *red;
if (ospf)
{
@@ -7371,15 +8236,19 @@ config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
vty_out (vty, " always");
- if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
- vty_out (vty, " metric %d",
- ospf->dmetric[DEFAULT_ROUTE].value);
- if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
- vty_out (vty, " metric-type 1");
-
- if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
- vty_out (vty, " route-map %s",
- ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
+ red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
+ if (red)
+ {
+ if (red->dmetric.value >= 0)
+ vty_out (vty, " metric %d",
+ red->dmetric.value);
+ if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1)
+ vty_out (vty, " metric-type 1");
+
+ if (ROUTEMAP_NAME (red))
+ vty_out (vty, " route-map %s",
+ ROUTEMAP_NAME (red));
+ }
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7439,7 +8308,10 @@ ospf_config_write (struct vty *vty)
if (ospf != NULL)
{
/* `router ospf' print. */
- vty_out (vty, "router ospf%s", VTY_NEWLINE);
+ if (ospf->instance)
+ vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE);
+ else
+ vty_out (vty, "router ospf%s", VTY_NEWLINE);
write++;
@@ -7570,6 +8442,9 @@ ospf_vty_show_init (void)
install_element (VIEW_NODE, &show_ip_ospf_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_cmd);
+
/* "show ip ospf database" commands. */
install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
@@ -7586,10 +8461,28 @@ ospf_vty_show_init (void)
install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_self_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_self_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd);
+
/* "show ip ospf interface" commands. */
install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_interface_cmd);
+
/* "show ip ospf neighbor" commands. */
install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
@@ -7606,11 +8499,31 @@ ospf_vty_show_init (void)
install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_id_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_all_cmd);
+
/* "show ip ospf route" commands. */
install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
+
+ install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_route_cmd);
+ install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd);
+ install_element (ENABLE_NODE, &show_ip_ospf_instance_border_routers_cmd);
}
@@ -7708,6 +8621,8 @@ ospf_vty_if_init (void)
/* "ip ospf area" commands. */
install_element (INTERFACE_NODE, &ip_ospf_area_cmd);
install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd);
+ install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd);
+ install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd);
/* These commands are compatibitliy for previous version. */
install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
@@ -7741,6 +8656,8 @@ ospf_vty_zebra_init (void)
{
install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
+ install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd);
+ install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd);
install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
@@ -7828,6 +8745,9 @@ ospf_vty_init (void)
install_element (CONFIG_NODE, &router_ospf_cmd);
install_element (CONFIG_NODE, &no_router_ospf_cmd);
+ install_element (CONFIG_NODE, &router_ospf_instance_cmd);
+ install_element (CONFIG_NODE, &no_router_ospf_instance_cmd);
+
install_default (OSPF_NODE);
/* "ospf router-id" commands. */
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 9a3525379..ad7e98f09 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -386,8 +386,9 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
#ifdef HAVE_NETLINK
int ol_cnt = 0, not_ol_cnt = 0;
#endif /* HAVE_NETLINK */
+ struct ospf *ospf = ospf_lookup ();
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
{
message = 0;
flags = 0;
@@ -414,6 +415,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
/* Put command, type, flags, message. */
zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD);
stream_putc (s, ZEBRA_ROUTE_OSPF);
+ stream_putw (s, ospf->instance);
stream_putc (s, flags);
stream_putc (s, message);
stream_putw (s, SAFI_UNICAST);
@@ -529,8 +531,9 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
struct stream *s;
struct ospf_path *path;
struct listnode *node;
+ struct ospf *ospf = ospf_lookup ();
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
{
message = 0;
flags = 0;
@@ -543,6 +546,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
/* Put command, type, flags, message. */
zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE);
stream_putc (s, ZEBRA_ROUTE_OSPF);
+ stream_putw (s, ospf->instance);
stream_putc (s, flags);
stream_putc (s, message);
stream_putw (s, SAFI_UNICAST);
@@ -610,10 +614,12 @@ void
ospf_zebra_add_discard (struct prefix_ipv4 *p)
{
struct zapi_ipv4 api;
+ struct ospf *ospf = ospf_lookup ();
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
{
api.type = ZEBRA_ROUTE_OSPF;
+ api.instance = ospf->instance;
api.flags = ZEBRA_FLAG_BLACKHOLE;
api.message = 0;
api.safi = SAFI_UNICAST;
@@ -634,10 +640,12 @@ void
ospf_zebra_delete_discard (struct prefix_ipv4 *p)
{
struct zapi_ipv4 api;
+ struct ospf *ospf = ospf_lookup ();
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
{
api.type = ZEBRA_ROUTE_OSPF;
+ api.instance = ospf->instance;
api.flags = ZEBRA_FLAG_BLACKHOLE;
api.message = 0;
api.safi = SAFI_UNICAST;
@@ -655,50 +663,180 @@ ospf_zebra_delete_discard (struct prefix_ipv4 *p)
}
}
+struct ospf_external *
+ospf_external_lookup (u_char type, u_short instance)
+{
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ ext_list = om->external[type];
+ if (!ext_list)
+ return(NULL);
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ if (ext->instance == instance)
+ return ext;
+
+ return NULL;
+}
+
+struct ospf_external *
+ospf_external_add (u_char type, u_short instance)
+{
+ struct list *ext_list;
+ struct ospf_external *ext;
+
+ ext = ospf_external_lookup(type, instance);
+ if (ext)
+ return ext;
+
+ if (!om->external[type])
+ om->external[type] = list_new();
+
+ ext_list = om->external[type];
+ ext = (struct ospf_external *)calloc (1, sizeof(struct ospf_external));
+ ext->instance = instance;
+ EXTERNAL_INFO (ext) = route_table_init ();
+
+ listnode_add(ext_list, ext);
+
+ return ext;
+}
+
+void
+ospf_external_del (u_char type, u_short instance)
+{
+ struct ospf_external *ext;
+
+ ext = ospf_external_lookup(type, instance);
+
+ if (ext)
+ {
+ if (EXTERNAL_INFO (ext))
+ route_table_finish(EXTERNAL_INFO (ext));
+
+ listnode_delete(om->external[type], ext);
+ if (!om->external[type]->count)
+ {
+ list_free(om->external[type]);
+ om->external[type] = NULL;
+ }
+ }
+}
+
+struct ospf_redist *
+ospf_redist_lookup (struct ospf *ospf, u_char type, u_short instance)
+{
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[type];
+ if (!red_list)
+ return(NULL);
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ if (red->instance == instance)
+ return red;
+
+ return NULL;
+}
+
+struct ospf_redist *
+ospf_redist_add (struct ospf *ospf, u_char type, u_short instance)
+{
+ struct list *red_list;
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, type, instance);
+ if (red)
+ return red;
+
+ if (!ospf->redist[type])
+ ospf->redist[type] = list_new();
+
+ red_list = ospf->redist[type];
+ red = (struct ospf_redist *)calloc (1, sizeof(struct ospf_redist));
+ red->instance = instance;
+ red->dmetric.type = -1;
+ red->dmetric.value = -1;
+
+ listnode_add(red_list, red);
+
+ return red;
+}
+
+void
+ospf_redist_del (struct ospf *ospf, u_char type, u_short instance)
+{
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, type, instance);
+
+ if (red)
+ {
+ listnode_delete(ospf->redist[type], red);
+ if (!ospf->redist[type]->count)
+ {
+ list_free(ospf->redist[type]);
+ ospf->redist[type] = NULL;
+ }
+ }
+}
+
+
int
-ospf_is_type_redistributed (int type)
+ospf_is_type_redistributed (int type, u_short instance)
{
- return (DEFAULT_ROUTE_TYPE (type)) ?
- zclient->default_information : zclient->redist[type];
+ return (DEFAULT_ROUTE_TYPE (type) ?
+ zclient->default_information :
+ redist_check_instance(&zclient->redist[type], instance));
}
int
-ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue)
+ospf_redistribute_set (struct ospf *ospf, int type, u_short instance, int mtype,
+ int mvalue)
{
int force = 0;
+ struct ospf_redist *red;
- if (ospf_is_type_redistributed (type))
+ red = ospf_redist_lookup(ospf, type, instance);
+ if (ospf_is_type_redistributed (type, instance))
{
- if (mtype != ospf->dmetric[type].type)
+ if (mtype != red->dmetric.type)
{
- ospf->dmetric[type].type = mtype;
+ red->dmetric.type = mtype;
force = LSA_REFRESH_FORCE;
}
- if (mvalue != ospf->dmetric[type].value)
+ if (mvalue != red->dmetric.value)
{
- ospf->dmetric[type].value = mvalue;
+ red->dmetric.value = mvalue;
force = LSA_REFRESH_FORCE;
}
- ospf_external_lsa_refresh_type (ospf, type, force);
+ ospf_external_lsa_refresh_type (ospf, type, instance, force);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
- ospf_redist_string(type),
- metric_type (ospf, type), metric_value (ospf, type));
+ zlog_debug ("Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]",
+ ospf_redist_string(type), instance,
+ metric_type (ospf, type, instance),
+ metric_value (ospf, type, instance));
return CMD_SUCCESS;
}
- ospf->dmetric[type].type = mtype;
- ospf->dmetric[type].value = mvalue;
+ red->dmetric.type = mtype;
+ red->dmetric.value = mvalue;
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ ospf_external_add(type, instance);
+
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]",
- ospf_redist_string(type),
- metric_type (ospf, type), metric_value (ospf, type));
+ zlog_debug ("Redistribute[%s][%d]: Start Type[%d], Metric[%d]",
+ ospf_redist_string(type), instance,
+ metric_type (ospf, type, instance), metric_value (ospf, type, instance));
ospf_asbr_status_update (ospf, ++ospf->redistribute);
@@ -706,25 +844,26 @@ ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue)
}
int
-ospf_redistribute_unset (struct ospf *ospf, int type)
+ospf_redistribute_unset (struct ospf *ospf, int type, u_short instance)
{
- if (type == zclient->redist_default)
+ if (type == zclient->redist_default && instance == zclient->instance)
return CMD_SUCCESS;
- if (!ospf_is_type_redistributed (type))
+ if (!ospf_is_type_redistributed (type, instance))
return CMD_SUCCESS;
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug ("Redistribute[%s]: Stop",
- ospf_redist_string(type));
+ zlog_debug ("Redistribute[%s][%d]: Stop",
+ ospf_redist_string(type), instance);
- ospf->dmetric[type].type = -1;
- ospf->dmetric[type].value = -1;
+ ospf_redist_del (ospf, type, instance);
/* Remove the routes from OSPF table. */
- ospf_redistribute_withdraw (ospf, type);
+ ospf_redistribute_withdraw (ospf, type, instance);
+
+ ospf_external_del(type, instance);
ospf_asbr_status_update (ospf, --ospf->redistribute);
@@ -735,11 +874,17 @@ int
ospf_redistribute_default_set (struct ospf *ospf, int originate,
int mtype, int mvalue)
{
+ struct ospf_redist *red;
+
ospf->default_originate = originate;
- ospf->dmetric[DEFAULT_ROUTE].type = mtype;
- ospf->dmetric[DEFAULT_ROUTE].value = mvalue;
- if (ospf_is_type_redistributed (DEFAULT_ROUTE))
+ red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
+ red->dmetric.type = mtype;
+ red->dmetric.value = mvalue;
+
+ ospf_external_add(DEFAULT_ROUTE, 0);
+
+ if (ospf_is_type_redistributed (DEFAULT_ROUTE, 0))
{
/* if ospf->default_originate changes value, is calling
ospf_external_lsa_refresh_default sufficient to implement
@@ -749,8 +894,8 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
ospf_redist_string(DEFAULT_ROUTE),
- metric_type (ospf, DEFAULT_ROUTE),
- metric_value (ospf, DEFAULT_ROUTE));
+ metric_type (ospf, DEFAULT_ROUTE, 0),
+ metric_value (ospf, DEFAULT_ROUTE, 0));
return CMD_SUCCESS;
}
@@ -758,8 +903,8 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
- metric_type (ospf, DEFAULT_ROUTE),
- metric_value (ospf, DEFAULT_ROUTE));
+ metric_type (ospf, DEFAULT_ROUTE, 0),
+ metric_value (ospf, DEFAULT_ROUTE, 0));
if (ospf->router_id.s_addr == 0)
ospf->external_origin |= (1 << DEFAULT_ROUTE);
@@ -774,18 +919,19 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
int
ospf_redistribute_default_unset (struct ospf *ospf)
{
- if (!ospf_is_type_redistributed (DEFAULT_ROUTE))
+ if (!ospf_is_type_redistributed (DEFAULT_ROUTE, 0))
return CMD_SUCCESS;
ospf->default_originate = DEFAULT_ORIGINATE_NONE;
- ospf->dmetric[DEFAULT_ROUTE].type = -1;
- ospf->dmetric[DEFAULT_ROUTE].value = -1;
+ ospf_redist_del(ospf, DEFAULT_ROUTE, 0);
zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[DEFAULT]: Stop");
+ //Pending: how does the external_info cleanup work in this case?
+
ospf_asbr_status_update (ospf, --ospf->redistribute);
return CMD_SUCCESS;
@@ -836,7 +982,9 @@ ospf_redistribute_check (struct ospf *ospf,
{
struct route_map_set_values save_values;
struct prefix_ipv4 *p = &ei->p;
+ struct ospf_redist *red;
u_char type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
+ u_short instance = is_prefix_default (&ei->p) ? 0 : ei->instance;
if (changed)
*changed = 0;
@@ -865,11 +1013,12 @@ ospf_redistribute_check (struct ospf *ospf,
ospf_reset_route_map_set_values (&ei->route_map_set);
/* apply route-map if needed */
- if (ROUTEMAP_NAME (ospf, type))
+ red = ospf_redist_lookup (ospf, type, instance);
+ if (red && ROUTEMAP_NAME(red))
{
int ret;
- ret = route_map_apply (ROUTEMAP (ospf, type), (struct prefix *) p,
+ ret = route_map_apply (ROUTEMAP (red), (struct prefix *) p,
RMAP_OSPF, ei);
if (ret == RMAP_DENYMATCH)
@@ -893,23 +1042,23 @@ ospf_redistribute_check (struct ospf *ospf,
/* OSPF route-map set for redistribution */
void
-ospf_routemap_set (struct ospf *ospf, int type, const char *name)
+ospf_routemap_set (struct ospf_redist *red, const char *name)
{
- if (ROUTEMAP_NAME (ospf, type))
- free (ROUTEMAP_NAME (ospf, type));
+ if (ROUTEMAP_NAME (red))
+ free (ROUTEMAP_NAME (red));
- ROUTEMAP_NAME (ospf, type) = strdup (name);
- ROUTEMAP (ospf, type) = route_map_lookup_by_name (name);
+ ROUTEMAP_NAME (red) = strdup (name);
+ ROUTEMAP (red) = route_map_lookup_by_name (name);
}
void
-ospf_routemap_unset (struct ospf *ospf, int type)
+ospf_routemap_unset (struct ospf_redist *red)
{
- if (ROUTEMAP_NAME (ospf, type))
- free (ROUTEMAP_NAME (ospf, type));
+ if (ROUTEMAP_NAME (red))
+ free (ROUTEMAP_NAME (red));
- ROUTEMAP_NAME (ospf, type) = NULL;
- ROUTEMAP (ospf, type) = NULL;
+ ROUTEMAP_NAME (red) = NULL;
+ ROUTEMAP (red) = NULL;
}
/* Zebra route add and delete treatment. */
@@ -931,6 +1080,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
@@ -985,7 +1135,8 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
if (ospf->dtag[api.type] > 0)
api.tag = ospf->dtag[api.type];
- ei = ospf_external_info_add (api.type, p, ifindex, nexthop, api.tag);
+ ei = ospf_external_info_add (api.type, api.instance, p, ifindex,
+ nexthop, api.tag);
if (ospf->router_id.s_addr == 0)
/* Set flags to generate AS-external-LSA originate event
@@ -1016,7 +1167,7 @@ ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
}
else /* if (command == ZEBRA_IPV4_ROUTE_DELETE) */
{
- ospf_external_info_delete (api.type, p);
+ ospf_external_info_delete (api.type, api.instance, p);
if (is_prefix_default (&p))
ospf_external_lsa_refresh_default (ospf);
else
@@ -1042,7 +1193,7 @@ ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name)
/* If access-list have been set, schedule update timer. */
if (DISTRIBUTE_LIST (ospf, type))
- ospf_distribute_list_update (ospf, type);
+ ospf_distribute_list_update (ospf, type, 0);
return CMD_SUCCESS;
}
@@ -1052,7 +1203,7 @@ ospf_distribute_list_out_unset (struct ospf *ospf, int type, const char *name)
{
/* Schedule update timer. */
if (DISTRIBUTE_LIST (ospf, type))
- ospf_distribute_list_update (ospf, type);
+ ospf_distribute_list_update (ospf, type, 0);
/* Unset distribute-list. */
DISTRIBUTE_LIST (ospf, type) = NULL;
@@ -1088,19 +1239,30 @@ ospf_distribute_list_update_timer (struct thread *thread)
/* foreach all external info. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- rt = EXTERNAL_INFO (type);
- if (!rt)
- continue;
- for (rn = route_top (rt); rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- {
- if (is_prefix_default (&ei->p))
- default_refresh = 1;
- else if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
- ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_IF_CHANGED);
- else
- ospf_external_lsa_originate (ospf, ei);
- }
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ ext_list = om->external[type];
+ if (!ext_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ {
+ rt = ext->external_info;
+ if (!rt)
+ continue;
+ for (rn = route_top (rt); rn; rn = route_next (rn))
+ if ((ei = rn->info) != NULL)
+ {
+ if (is_prefix_default (&ei->p))
+ default_refresh = 1;
+ else if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
+ ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_IF_CHANGED);
+ else
+ ospf_external_lsa_originate (ospf, ei);
+ }
+ }
}
if (default_refresh)
ospf_external_lsa_refresh_default (ospf);
@@ -1111,12 +1273,15 @@ ospf_distribute_list_update_timer (struct thread *thread)
/* Update distribute-list and set timer to apply access-list. */
void
-ospf_distribute_list_update (struct ospf *ospf, uintptr_t type)
+ospf_distribute_list_update (struct ospf *ospf, uintptr_t type,
+ u_short instance)
{
struct route_table *rt;
+ struct ospf_external *ext;
/* External info does not exist. */
- if (!(rt = EXTERNAL_INFO (type)))
+ ext = ospf_external_lookup(type, instance);
+ if (!ext || !(rt = EXTERNAL_INFO (ext)))
return;
/* If exists previously invoked thread, then let it continue. */
@@ -1139,7 +1304,7 @@ ospf_filter_update (struct access_list *access)
struct ospf_area *area;
struct listnode *node;
- /* If OSPF instatnce does not exist, return right now. */
+ /* If OSPF instance does not exist, return right now. */
ospf = ospf_lookup ();
if (ospf == NULL)
return;
@@ -1147,12 +1312,20 @@ ospf_filter_update (struct access_list *access)
/* Update distribute-list, and apply filter. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP (ospf, type) != NULL)
- {
- /* if route-map is not NULL it may be using this access list */
- ospf_distribute_list_update (ospf, type);
- continue;
- }
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[type];
+ if (red_list)
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ if (ROUTEMAP (red))
+ {
+ /* if route-map is not NULL it may be using this access list */
+ ospf_distribute_list_update (ospf, type, red->instance);
+ }
+ }
/* There is place for route-map for default-information (ZEBRA_ROUTE_MAX),
* but no distribute list. */
@@ -1175,7 +1348,7 @@ ospf_filter_update (struct access_list *access)
/* Schedule distribute-list update timer. */
if (DISTRIBUTE_LIST (ospf, type) == NULL ||
strcmp (DISTRIBUTE_NAME (ospf, type), access->name) == 0)
- ospf_distribute_list_update (ospf, type);
+ ospf_distribute_list_update (ospf, type, 0);
}
}
@@ -1220,12 +1393,20 @@ ospf_prefix_list_update (struct prefix_list *plist)
*/
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP (ospf, type) != NULL)
- {
- /* If route-map is not NULL it may be using this prefix list */
- ospf_distribute_list_update (ospf, type);
- continue;
- }
+ struct list *red_list;
+ struct listnode *node;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[type];
+ if (red_list)
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ if (ROUTEMAP (red))
+ {
+ /* if route-map is not NULL it may be using this prefix list */
+ ospf_distribute_list_update (ospf, type, red->instance);
+ }
+ }
}
/* Update area filter-lists. */
@@ -1400,11 +1581,11 @@ ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
}
void
-ospf_zebra_init ()
+ospf_zebra_init (u_short instance)
{
/* Allocate zebra structure. */
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_OSPF);
+ zclient_init (zclient, ZEBRA_ROUTE_OSPF, instance);
zclient->router_id_update = ospf_router_id_update_zebra;
zclient->interface_add = ospf_interface_add;
zclient->interface_delete = ospf_interface_delete;
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index 148f6520f..1cebb3d6d 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -54,25 +54,32 @@ extern int ospf_redistribute_check (struct ospf *, struct external_info *,
int *);
extern int ospf_distribute_check_connected (struct ospf *,
struct external_info *);
-extern void ospf_distribute_list_update (struct ospf *, uintptr_t);
+extern void ospf_distribute_list_update (struct ospf *, uintptr_t, u_short);
-extern int ospf_is_type_redistributed (int);
+extern int ospf_is_type_redistributed (int, u_short);
extern void ospf_distance_reset (struct ospf *);
extern u_char ospf_distance_apply (struct prefix_ipv4 *, struct ospf_route *);
+extern struct ospf_external *ospf_external_lookup (u_char, u_short);
+extern struct ospf_external *ospf_external_add (u_char, u_short);
+extern void ospf_external_del (u_char, u_short);
+extern struct ospf_redist *ospf_redist_lookup (struct ospf *, u_char, u_short);
+extern struct ospf_redist *ospf_redist_add (struct ospf *, u_char, u_short);
+extern void ospf_redist_del (struct ospf *, u_char, u_short);
-extern int ospf_redistribute_set (struct ospf *, int, int, int);
-extern int ospf_redistribute_unset (struct ospf *, int);
+
+extern int ospf_redistribute_set (struct ospf *, int, u_short, int, int);
+extern int ospf_redistribute_unset (struct ospf *, int, u_short);
extern int ospf_redistribute_default_set (struct ospf *, int, int, int);
extern int ospf_redistribute_default_unset (struct ospf *);
extern int ospf_distribute_list_out_set (struct ospf *, int, const char *);
extern int ospf_distribute_list_out_unset (struct ospf *, int, const char *);
-extern void ospf_routemap_set (struct ospf *, int, const char *);
-extern void ospf_routemap_unset (struct ospf *, int);
+extern void ospf_routemap_set (struct ospf_redist *, const char *);
+extern void ospf_routemap_unset (struct ospf_redist *);
extern int ospf_distance_set (struct vty *, struct ospf *, const char *,
const char *, const char *);
extern int ospf_distance_unset (struct vty *, struct ospf *, const char *,
const char *, const char *);
-extern void ospf_zebra_init (void);
+extern void ospf_zebra_init (u_short);
#endif /* _ZEBRA_OSPF_ZEBRA_H */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index a69b5595d..e815c521c 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -153,12 +153,13 @@ ospf_area_id_cmp (struct ospf_area *a1, struct ospf_area *a2)
/* Allocate new ospf structure. */
static struct ospf *
-ospf_new (void)
+ospf_new (u_short instance)
{
int i;
struct ospf *new = XCALLOC (MTYPE_OSPF_TOP, sizeof (struct ospf));
+ new->instance = instance;
new->router_id.s_addr = htonl (0);
new->router_id_static.s_addr = htonl (0);
@@ -187,8 +188,6 @@ ospf_new (void)
/* Distribute parameter init. */
for (i = 0; i <= ZEBRA_ROUTE_MAX; i++)
{
- new->dmetric[i].type = -1;
- new->dmetric[i].value = -1;
new->dtag[i] = 0;
}
new->default_metric = -1;
@@ -248,6 +247,23 @@ ospf_lookup ()
return listgetdata (listhead (om->ospf));
}
+struct ospf *
+ospf_lookup_instance (u_short instance)
+{
+ struct ospf *ospf;
+ struct listnode *node, *nnode;
+
+ if (listcount (om->ospf) == 0)
+ return NULL;
+
+ for (ALL_LIST_ELEMENTS (om->ospf, node, nnode, ospf))
+ if ((ospf->instance == 0 && instance == 0)
+ || (ospf->instance && instance && ospf->instance == instance))
+ return ospf;
+
+ return NULL;
+}
+
static void
ospf_add (struct ospf *ospf)
{
@@ -268,7 +284,29 @@ ospf_get ()
ospf = ospf_lookup ();
if (ospf == NULL)
{
- ospf = ospf_new ();
+ ospf = ospf_new (0);
+ ospf_add (ospf);
+
+ if (ospf->router_id_static.s_addr == 0)
+ ospf_router_id_update (ospf);
+
+#ifdef HAVE_OPAQUE_LSA
+ ospf_opaque_type11_lsa_init (ospf);
+#endif /* HAVE_OPAQUE_LSA */
+ }
+
+ return ospf;
+}
+
+struct ospf *
+ospf_get_instance (u_short instance)
+{
+ struct ospf *ospf;
+
+ ospf = ospf_lookup_instance (instance);
+ if (ospf == NULL)
+ {
+ ospf = ospf_new (instance);
ospf_add (ospf);
if (ospf->router_id_static.s_addr == 0)
@@ -409,6 +447,7 @@ ospf_finish_final (struct ospf *ospf)
struct ospf_vl_data *vl_data;
struct listnode *node, *nnode;
int i;
+ u_short instance;
#ifdef HAVE_OPAQUE_LSA
ospf_opaque_type11_lsa_term (ospf);
@@ -419,7 +458,17 @@ ospf_finish_final (struct ospf *ospf)
/* Unregister redistribution */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- ospf_redistribute_unset (ospf, i);
+ {
+ struct list *red_list;
+ struct ospf_redist *red;
+
+ red_list = ospf->redist[i];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS(red_list, node, nnode, red))
+ ospf_redistribute_unset (ospf, i, red->instance);
+ }
ospf_redistribute_default_unset (ospf);
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
@@ -557,23 +606,43 @@ ospf_finish_final (struct ospf *ospf)
list_delete (ospf->areas);
for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++)
- if (EXTERNAL_INFO (i) != NULL)
- for (rn = route_top (EXTERNAL_INFO (i)); rn; rn = route_next (rn))
- {
- if (rn->info == NULL)
- continue;
-
- XFREE (MTYPE_OSPF_EXTERNAL_INFO, rn->info);
- rn->info = NULL;
- route_unlock_node (rn);
- }
+ {
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ ext_list = om->external[i];
+ if (!ext_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ {
+ if (ext->external_info)
+ for (rn = route_top (ext->external_info); rn; rn = route_next (rn))
+ {
+ if (rn->info == NULL)
+ continue;
+
+ XFREE (MTYPE_OSPF_EXTERNAL_INFO, rn->info);
+ rn->info = NULL;
+ route_unlock_node (rn);
+ }
+ }
+ }
ospf_distance_reset (ospf);
route_table_finish (ospf->distance_table);
+ if (!CHECK_FLAG (om->options, OSPF_MASTER_SHUTDOWN))
+ instance = ospf->instance;
+
ospf_delete (ospf);
XFREE (MTYPE_OSPF_TOP, ospf);
+
+ if (!CHECK_FLAG (om->options, OSPF_MASTER_SHUTDOWN))
+ ospf_get_instance(instance);
+
}
@@ -775,11 +844,13 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)
{
struct route_node *rn;
struct external_info *ei;
+ struct ospf_external *ext;
- if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
- if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
+ if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT, 0))
+ if ((ext = ospf_external_lookup(ZEBRA_ROUTE_CONNECT, 0)) &&
+ EXTERNAL_INFO (ext))
{
- for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
+ for (rn = route_top (EXTERNAL_INFO (ext));
rn; rn = route_next (rn))
{
if ((ei = rn->info) != NULL)
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 53c4099f2..7cbd85786 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -76,6 +76,12 @@
#define OSPF_LS_REFRESH_SHIFT (60 * 15)
#define OSPF_LS_REFRESH_JITTER 60
+struct ospf_external
+{
+ u_short instance;
+ struct route_table *external_info;
+};
+
/* OSPF master for system wide configuration and variables. */
struct ospf_master
{
@@ -89,8 +95,8 @@ struct ospf_master
struct list *iflist;
/* Redistributed external information. */
- struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
-#define EXTERNAL_INFO(T) om->external_info[T]
+ struct list *external[ZEBRA_ROUTE_MAX + 1];
+#define EXTERNAL_INFO(E) (E->external_info)
/* OSPF start time. */
time_t start_time;
@@ -100,9 +106,34 @@ struct ospf_master
#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
};
+struct ospf_redist
+{
+ u_short instance;
+
+ /* Redistribute metric info. */
+ struct
+ {
+ int type; /* External metric type (E1 or E2). */
+ int value; /* Value for static metric (24-bit).
+ -1 means metric value is not set. */
+ } dmetric;
+
+ /* For redistribute route map. */
+ struct
+ {
+ char *name;
+ struct route_map *map;
+ } route_map; /* +1 is for default-information */
+#define ROUTEMAP_NAME(R) (R->route_map.name)
+#define ROUTEMAP(R) (R->route_map.map)
+};
+
/* OSPF instance structure. */
struct ospf
{
+ /* OSPF instance ID */
+ u_short instance;
+
/* OSPF Router ID. */
struct in_addr router_id; /* Configured automatically. */
struct in_addr router_id_static; /* Configured manually. */
@@ -236,26 +267,12 @@ struct ospf
#define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
#define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
- /* Redistribute metric info. */
- struct
- {
- int type; /* External metric type (E1 or E2). */
- int value; /* Value for static metric (24-bit).
- -1 means metric value is not set. */
- } dmetric [ZEBRA_ROUTE_MAX + 1];
+ /* OSPF redistribute configuration */
+ struct list *redist[ZEBRA_ROUTE_MAX + 1];
/* Redistribute tag info. */
- u_short dtag [ZEBRA_ROUTE_MAX + 1];
+ u_short dtag[ZEBRA_ROUTE_MAX + 1]; //Pending: cant configure as of now
- /* For redistribute route map. */
- struct
- {
- char *name;
- struct route_map *map;
- } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
-#define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
-#define ROUTEMAP(O,T) (O)->route_map[T].map
-
int default_metric; /* Default metric for redistribute. */
#define OSPF_LSA_REFRESHER_GRANULARITY 10
@@ -514,7 +531,9 @@ extern int ospf_zlog;
/* Prototypes. */
extern const char *ospf_redist_string(u_int route_type);
extern struct ospf *ospf_lookup (void);
+extern struct ospf *ospf_lookup_instance (u_short);
extern struct ospf *ospf_get (void);
+extern struct ospf *ospf_get_instance (u_short);
extern void ospf_finish (struct ospf *);
extern void ospf_router_id_update (struct ospf *ospf);
extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,