progname = babel_get_progname(argv[0]);
/* set default log (lib/log.h) */
- zlog_default = openzlog(progname, ZLOG_BABEL,
+ zlog_default = openzlog(progname, ZLOG_BABEL, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* set log destination as stdout until the config file is read */
zlog_set_level(NULL, ZLOG_DEST_STDOUT, LOG_WARNING);
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
return CMD_SUCCESS;
}
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
/* perhaps should we remove xroutes having the same type... */
return CMD_SUCCESS;
}
void babelz_zebra_init(void)
{
zclient = zclient_new();
- zclient_init(zclient, ZEBRA_ROUTE_BABEL);
+ zclient_init(zclient, ZEBRA_ROUTE_BABEL, 0);
zclient->interface_add = babel_interface_add;
zclient->interface_delete = babel_interface_delete;
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
- else if (! zclient->redist[ZEBRA_ROUTE_BABEL])
+ else if (! zclient->redist[ZEBRA_ROUTE_BABEL].enabled)
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute babel%s", VTY_NEWLINE);
lines = 1 + babel_enable_if_config_write (vty);
/* list redistributed protocols */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default && zclient->redist[i])
+ if (i != zclient->redist_default &&
+ zclient->redist[i].enabled)
{
vty_out (vty, " redistribute %s%s", zebra_route_string (i), VTY_NEWLINE);
lines++;
/* Preserve name of myself. */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_BGP,
+ zlog_default = openzlog (progname, ZLOG_BGP, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* BGP master init. */
}
static struct bgp_info *
-info_make (int type, int sub_type, struct peer *peer, struct attr *attr,
+info_make (int type, int sub_type, u_short instance, struct peer *peer, struct attr *attr,
struct bgp_node *rn)
{
struct bgp_info *new;
/* Make new BGP info. */
new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
new->type = type;
+ new->instance = instance;
new->sub_type = sub_type;
new->peer = peer;
new->attr = attr;
p->prefixlen, rsclient->host);
}
- new = info_make(type, sub_type, peer, attr_new, rn);
+ new = info_make(type, sub_type, 0, peer, attr_new, rn);
/* Update MPLS tag. */
if (safi == SAFI_MPLS_VPN)
}
/* Make new BGP info. */
- new = info_make(type, sub_type, peer, attr_new, rn);
+ new = info_make(type, sub_type, 0, peer, attr_new, rn);
/* Update MPLS tag. */
if (safi == SAFI_MPLS_VPN)
}
/* Make new BGP info. */
- new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
+ new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self,
attr_new, rn);
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
}
/* Make new BGP info. */
- new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new,
+ new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new,
rn);
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
/* Make new BGP info. */
- new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
+ new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self,
bgp_attr_default_intern(BGP_ORIGIN_IGP), rn);
SET_FLAG (new->flags, BGP_INFO_VALID);
if (aggregate->count > 0)
{
rn = bgp_node_get (table, p);
- new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
+ new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self,
bgp_attr_aggregate_intern(bgp, origin, aspath, community,
aggregate->as_set,
atomic_aggregate), rn);
if (aggregate->count)
{
rn = bgp_node_get (table, p);
- new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
+ new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0, bgp->peer_self,
bgp_attr_aggregate_intern(bgp, origin, aspath, community,
aggregate->as_set,
atomic_aggregate), rn);
void
bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
const struct in6_addr *nexthop6, unsigned int ifindex,
- u_int32_t metric, u_char type, u_short tag)
+ u_int32_t metric, u_char type, u_short instance, u_short tag)
{
struct bgp *bgp;
struct listnode *node, *nnode;
struct attr *new_attr;
afi_t afi;
int ret;
+ struct bgp_redist *red;
/* Make default attribute. */
bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
{
afi = family2afi (p->family);
- if (bgp->redist[afi][type])
+ red = bgp_redist_lookup(bgp, afi, type, instance);
+ if (red)
{
struct attr attr_new;
struct attr_extra extra_new;
attr_new.extra = &extra_new;
bgp_attr_dup (&attr_new, &attr);
- if (bgp->redist_metric_flag[afi][type])
- attr_new.med = bgp->redist_metric[afi][type];
+ if (red->redist_metric_flag)
+ attr_new.med = red->redist_metric;
/* Apply route-map. */
- if (bgp->rmap[afi][type].map)
+ if (red->rmap.map)
{
info.peer = bgp->peer_self;
info.attr = &attr_new;
SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
- ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
- &info);
+ ret = route_map_apply (red->rmap.map, p, RMAP_BGP, &info);
bgp->peer_self->rmap_type = 0;
/* Unintern original. */
aspath_unintern (&attr.aspath);
bgp_attr_extra_free (&attr);
- bgp_redistribute_delete (p, type);
+ bgp_redistribute_delete (p, type, instance);
return;
}
}
}
}
- new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self,
+ new = info_make(type, BGP_ROUTE_REDISTRIBUTE, instance, bgp->peer_self,
new_attr, bn);
SET_FLAG (new->flags, BGP_INFO_VALID);
}
void
-bgp_redistribute_delete (struct prefix *p, u_char type)
+bgp_redistribute_delete (struct prefix *p, u_char type, u_short instance)
{
struct bgp *bgp;
struct listnode *node, *nnode;
afi_t afi;
struct bgp_node *rn;
struct bgp_info *ri;
+ struct bgp_redist *red;
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
afi = family2afi (p->family);
- if (bgp->redist[afi][type])
+ red = bgp_redist_lookup(bgp, afi, type, instance);
+ if (red)
{
rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
/* Withdraw specified route type's route. */
void
-bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
+bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type, u_short instance)
{
struct bgp_node *rn;
struct bgp_info *ri;
{
for (ri = rn->info; ri; ri = ri->next)
if (ri->peer == bgp->peer_self
- && ri->type == type)
+ && ri->type == type
+ && ri->instance == instance)
break;
if (ri)
#define BGP_ROUTE_STATIC 1
#define BGP_ROUTE_AGGREGATE 2
#define BGP_ROUTE_REDISTRIBUTE 3
+
+ u_short instance;
+
};
/* BGP static route configuration. */
extern void bgp_redistribute_add (struct prefix *, const struct in_addr *,
const struct in6_addr *, unsigned int ifindex,
- u_int32_t, u_char, u_short);
-extern void bgp_redistribute_delete (struct prefix *, u_char);
-extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
+ u_int32_t, u_char, u_short, u_short);
+extern void bgp_redistribute_delete (struct prefix *, u_char, u_short);
+extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int, u_short);
extern void bgp_static_delete (struct bgp *);
extern void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
char buf[INET6_ADDRSTRLEN];
if (!bgp)
- return;
+ return (-1);
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
- if (bgp->rmap[afi][i].name &&
- (strcmp(rmap_name, bgp->rmap[afi][i].name) == 0))
- {
- bgp->rmap[afi][i].map =
- route_map_lookup_by_name (bgp->rmap[afi][i].name);
-
- if (bgp->redist[afi][i] && route_update)
- {
- if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Processing route_map %s update on "
- "redistributed routes", rmap_name);
-
- bgp_redistribute_resend (bgp, afi, i);
- }
+ struct list *red_list;
+ struct listnode *node;
+ struct bgp_redist *red;
+
+ red_list = bgp->redist[afi][i];
+ if (!red_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ if (red->rmap.name &&
+ (strcmp(rmap_name, red->rmap.name) == 0))
+ {
+ red->rmap.map =
+ route_map_lookup_by_name (red->rmap.name);
+
+ if (route_update)
+ {
+ if (bgp_debug_update(peer, NULL, 0))
+ zlog_debug("Processing route_map %s update on "
+ "redistributed routes", rmap_name);
+
+ bgp_redistribute_resend (bgp, afi, i, red->instance);
+ }
+ }
}
}
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_redistribute_set (vty->index, AFI_IP, type);
+ bgp_redist_add(vty->index, AFI_IP, type, 0);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap,
"Pointer to route-map entries\n")
{
int type;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
return CMD_WARNING;
}
- bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
- return bgp_redistribute_set (vty->index, AFI_IP, type);
+ red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, type);
+ red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap_metric,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[2]);
- bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP, type);
+ red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric_rmap,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
- bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
- return bgp_redistribute_set (vty->index, AFI_IP, type);
+ red = bgp_redist_add(vty->index, AFI_IP, type, 0);
+ bgp_redistribute_metric_set (red, metric);
+ bgp_redistribute_rmap_set (red, argv[2]);
+ return bgp_redistribute_set (type, 0);
}
+DEFUN (bgp_redistribute_ipv4_ospf,
+ bgp_redistribute_ipv4_ospf_cmd,
+ "redistribute ospf <1-65535>",
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n")
+{
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ bgp_redist_add(vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+ return bgp_redistribute_set (ZEBRA_ROUTE_OSPF, instance);
+}
+
+DEFUN (bgp_redistribute_ipv4_ospf_rmap,
+ bgp_redistribute_ipv4_ospf_rmap_cmd,
+ "redistribute ospf <1-65535> route-map WORD",
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+{
+ struct bgp_redist *red;
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ red = bgp_redist_add(vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ return bgp_redistribute_set (ZEBRA_ROUTE_OSPF, instance);
+}
+
+DEFUN (bgp_redistribute_ipv4_ospf_metric,
+ bgp_redistribute_ipv4_ospf_metric_cmd,
+ "redistribute ospf <1-65535> metric <0-4294967295>",
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n")
+{
+ u_int32_t metric;
+ struct bgp_redist *red;
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ VTY_GET_INTEGER ("metric", metric, argv[1]);
+
+ red = bgp_redist_add(vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (ZEBRA_ROUTE_OSPF, instance);
+}
+
+DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
+ bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
+ "redistribute ospf <1-65535> route-map WORD metric <0-4294967295>",
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n")
+{
+ u_int32_t metric;
+ struct bgp_redist *red;
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ VTY_GET_INTEGER ("metric", metric, argv[2]);
+
+ red = bgp_redist_add(vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (ZEBRA_ROUTE_OSPF, instance);
+}
+
+DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
+ bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
+ "redistribute ospf <1-65535> metric <0-4294967295> route-map WORD",
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+{
+ u_int32_t metric;
+ struct bgp_redist *red;
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ VTY_GET_INTEGER ("metric", metric, argv[1]);
+
+ red = bgp_redist_add(vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+ bgp_redistribute_metric_set (red, metric);
+ bgp_redistribute_rmap_set (red, argv[2]);
+ return bgp_redistribute_set (ZEBRA_ROUTE_OSPF, instance);
+}
+
+DEFUN (no_bgp_redistribute_ipv4_ospf,
+ no_bgp_redistribute_ipv4_ospf_cmd,
+ "no redistribute ospf <1-65535>",
+ NO_STR
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n")
+{
+ u_short instance;
+
+ VTY_GET_INTEGER ("Instance ID", instance, argv[0]);
+ return bgp_redistribute_unset (vty->index, AFI_IP, ZEBRA_ROUTE_OSPF, instance);
+}
+
+ALIAS (no_bgp_redistribute_ipv4_ospf,
+ no_bgp_redistribute_ipv4_ospf_rmap_cmd,
+ "no redistribute ospf <1-65535> route-map WORD",
+ NO_STR
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+
+ALIAS (no_bgp_redistribute_ipv4_ospf,
+ no_bgp_redistribute_ipv4_ospf_metric_cmd,
+ "no redistribute ospf <1-65535> metric <0-4294967295>",
+ NO_STR
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n")
+
+ALIAS (no_bgp_redistribute_ipv4_ospf,
+ no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
+ "no redistribute ospf <1-65535> route-map WORD metric <0-4294967295>",
+ NO_STR
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n")
+
+ALIAS (no_bgp_redistribute_ipv4_ospf,
+ no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
+ "no redistribute ospf <1-65535> metric <0-4294967295> route-map WORD",
+ NO_STR
+ "Redistribute information from another routing protocol\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n"
+ "Metric for redistributed routes\n"
+ "Default metric\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
+
DEFUN (no_bgp_redistribute_ipv4,
no_bgp_redistribute_ipv4_cmd,
"no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
-
- return bgp_redistribute_unset (vty->index, AFI_IP, type);
+ return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
}
ALIAS (no_bgp_redistribute_ipv4,
return CMD_WARNING;
}
- return bgp_redistribute_set (vty->index, AFI_IP6, type);
+ bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap,
"Pointer to route-map entries\n")
{
int type;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP6, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
return CMD_WARNING;
}
- bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
- return bgp_redistribute_set (vty->index, AFI_IP6, type);
+ red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP6, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP6, type);
+ red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap_metric,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP6, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[2]);
- bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
- return bgp_redistribute_set (vty->index, AFI_IP6, type);
+ red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ bgp_redistribute_rmap_set (red, argv[1]);
+ bgp_redistribute_metric_set (red, metric);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric_rmap,
{
int type;
u_int32_t metric;
+ struct bgp_redist *red;
type = proto_redistnum (AFI_IP6, argv[0]);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
}
VTY_GET_INTEGER ("metric", metric, argv[1]);
- bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
- bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
- return bgp_redistribute_set (vty->index, AFI_IP6, type);
+ red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
+ bgp_redistribute_metric_set (red, metric);
+ bgp_redistribute_rmap_set (red, argv[2]);
+ return bgp_redistribute_set (type, 0);
}
DEFUN (no_bgp_redistribute_ipv6,
return CMD_WARNING;
}
- return bgp_redistribute_unset (vty->index, AFI_IP6, type);
+ return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
}
ALIAS (no_bgp_redistribute_ipv6,
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
/* Redistribute BGP does not make sense. */
- if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
+ if (i != ZEBRA_ROUTE_BGP)
{
- /* Display "address-family" when it is not yet diplayed. */
- bgp_config_write_family_header (vty, afi, safi, write);
-
- /* "redistribute" configuration. */
- vty_out (vty, " redistribute %s", zebra_route_string(i));
-
- if (bgp->redist_metric_flag[afi][i])
- vty_out (vty, " metric %u", bgp->redist_metric[afi][i]);
+ struct list *red_list;
+ struct listnode *node;
+ struct bgp_redist *red;
- if (bgp->rmap[afi][i].name)
- vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
+ red_list = bgp->redist[afi][i];
+ if (!red_list)
+ continue;
- vty_out (vty, "%s", VTY_NEWLINE);
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ {
+ /* Display "address-family" when it is not yet diplayed. */
+ bgp_config_write_family_header (vty, afi, safi, write);
+
+ /* "redistribute" configuration. */
+ vty_out (vty, " redistribute %s", zebra_route_string(i));
+ if (red->instance)
+ vty_out (vty, " %d", red->instance);
+ if (red->redist_metric_flag)
+ vty_out (vty, " metric %u", red->redist_metric);
+ if (red->rmap.name)
+ vty_out (vty, " route-map %s", red->rmap.name);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
}
}
return *write;
install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
+ install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
+ install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
+ install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
+ install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
+ install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
+ install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
+ install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
+ install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
+ install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
+ install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
#ifdef HAVE_IPV6
install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
if (bgp_debug_zebra(&p))
{
char buf[2][INET_ADDRSTRLEN];
- zlog_debug("Zebra rcvd: IPv4 route add %s %s/%d nexthop %s metric %u tag %d",
- zebra_route_string(api.type),
+ zlog_debug("Zebra rcvd: IPv4 route add %s[%d] %s/%d nexthop %s metric %u tag %d",
+ zebra_route_string(api.type), api.instance,
inet_ntop(AF_INET, &p.prefix, buf[0], sizeof(buf[0])),
p.prefixlen,
inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
api.tag);
}
bgp_redistribute_add((struct prefix *)&p, &nexthop, NULL, ifindex,
- api.metric, api.type, api.tag);
+ api.metric, api.type, api.instance, api.tag);
}
else
{
if (bgp_debug_zebra(&p))
{
char buf[2][INET_ADDRSTRLEN];
- zlog_debug("Zebra rcvd: IPv4 route delete %s %s/%d "
+ zlog_debug("Zebra rcvd: IPv4 route delete %s[%d] %s/%d "
"nexthop %s metric %u tag %d",
- zebra_route_string(api.type),
+ zebra_route_string(api.type), api.instance,
inet_ntop(AF_INET, &p.prefix, buf[0], sizeof(buf[0])),
p.prefixlen,
inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
api.metric,
api.tag);
}
- bgp_redistribute_delete((struct prefix *)&p, api.type);
+ bgp_redistribute_delete((struct prefix *)&p, api.type, api.instance);
}
return 0;
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
if (bgp_debug_zebra(&p))
{
char buf[2][INET6_ADDRSTRLEN];
- zlog_debug("Zebra rcvd: IPv6 route add %s %s/%d nexthop %s metric %u tag %d",
- zebra_route_string(api.type),
+ zlog_debug("Zebra rcvd: IPv6 route add %s[%d] %s/%d nexthop %s metric %u tag %d",
+ zebra_route_string(api.type), api.instance,
inet_ntop(AF_INET6, &p.prefix, buf[0], sizeof(buf[0])),
p.prefixlen,
inet_ntop(AF_INET, &nexthop, buf[1], sizeof(buf[1])),
api.tag);
}
bgp_redistribute_add ((struct prefix *)&p, NULL, &nexthop, ifindex,
- api.metric, api.type, api.tag);
+ api.metric, api.type, api.instance, api.tag);
}
else
{
if (bgp_debug_zebra(&p))
{
char buf[2][INET6_ADDRSTRLEN];
- zlog_debug("Zebra rcvd: IPv6 route delete %s %s/%d "
+ zlog_debug("Zebra rcvd: IPv6 route delete %s[%d] %s/%d "
"nexthop %s metric %u tag %d",
- zebra_route_string(api.type),
+ zebra_route_string(api.type), api.instance,
inet_ntop(AF_INET6, &p.prefix, buf[0], sizeof(buf[0])),
p.prefixlen,
inet_ntop(AF_INET6, &nexthop, buf[1], sizeof(buf[1])),
api.metric,
api.tag);
}
- bgp_redistribute_delete ((struct prefix *) &p, api.type);
+ bgp_redistribute_delete ((struct prefix *) &p, api.type, api.instance);
}
return 0;
if (zclient->sock < 0)
return;
- if (! zclient->redist[ZEBRA_ROUTE_BGP])
+ if (!zclient->redist[ZEBRA_ROUTE_BGP].enabled)
return;
if (bgp->main_zebra_update_hold)
api.flags = flags;
api.type = ZEBRA_ROUTE_BGP;
+ api.instance = 0;
api.message = 0;
api.safi = safi;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
/* Make Zebra API structure. */
api.flags = flags;
api.type = ZEBRA_ROUTE_BGP;
+ api.instance = 0;
api.message = 0;
api.safi = safi;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
if (zclient->sock < 0)
return;
- if (! zclient->redist[ZEBRA_ROUTE_BGP])
+ if (!zclient->redist[ZEBRA_ROUTE_BGP].enabled)
return;
peer = info->peer;
nexthop = &info->attr->nexthop;
api.type = ZEBRA_ROUTE_BGP;
+ api.instance = 0;
api.message = 0;
api.safi = safi;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
api.flags = flags;
api.type = ZEBRA_ROUTE_BGP;
+ api.instance = 0;
api.message = 0;
api.safi = safi;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
}
#endif /* HAVE_IPV6 */
}
+struct bgp_redist *
+bgp_redist_lookup (struct bgp *bgp, afi_t afi, u_char type, u_short instance)
+{
+ struct list *red_list;
+ struct listnode *node;
+ struct bgp_redist *red;
+
+ red_list = bgp->redist[afi][type];
+ if (!red_list)
+ return(NULL);
+
+ for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
+ if (red->instance == instance)
+ return red;
+
+ return NULL;
+}
+
+struct bgp_redist *
+bgp_redist_add (struct bgp *bgp, afi_t afi, u_char type, u_short instance)
+{
+ struct list *red_list;
+ struct bgp_redist *red;
+
+ red = bgp_redist_lookup(bgp, afi, type, instance);
+ if (red)
+ return red;
+
+ if (!bgp->redist[afi][type])
+ bgp->redist[afi][type] = list_new();
+
+ red_list = bgp->redist[afi][type];
+ red = (struct bgp_redist *)calloc (1, sizeof(struct bgp_redist));
+ red->instance = instance;
+
+ listnode_add(red_list, red);
+
+ return red;
+}
+
+static void
+bgp_redist_del (struct bgp *bgp, afi_t afi, u_char type, u_short instance)
+{
+ struct bgp_redist *red;
+
+ red = bgp_redist_lookup(bgp, afi, type, instance);
+
+ if (red)
+ {
+ listnode_delete(bgp->redist[afi][type], red);
+ if (!bgp->redist[afi][type]->count)
+ {
+ list_free(bgp->redist[afi][type]);
+ bgp->redist[afi][type] = NULL;
+ }
+ }
+}
/* Other routes redistribution into BGP. */
int
-bgp_redistribute_set (struct bgp *bgp, afi_t afi, int type)
+bgp_redistribute_set (int type, u_short instance)
{
- /* Set flag to BGP instance. */
- bgp->redist[afi][type] = 1;
/* Return if already redistribute flag is set. */
- if (zclient->redist[type])
+ if (redist_check_instance(&zclient->redist[type], instance))
return CMD_WARNING;
- zclient->redist[type] = 1;
+ redist_add_instance(&zclient->redist[type], instance);
/* Return if zebra connection is not established. */
if (zclient->sock < 0)
return CMD_WARNING;
if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Zebra send: redistribute add %s", zebra_route_string(type));
+ zlog_debug("Zebra send: redistribute add %s %d", zebra_route_string(type),
+ instance);
/* Send distribute add message to zebra. */
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
return CMD_SUCCESS;
}
int
-bgp_redistribute_resend (struct bgp *bgp, afi_t afi, int type)
+bgp_redistribute_resend (struct bgp *bgp, afi_t afi, int type, u_short instance)
{
/* Return if zebra connection is not established. */
if (zclient->sock < 0)
return -1;
if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Zebra send: redistribute add %s", zebra_route_string(type));
+ zlog_debug("Zebra send: redistribute add %s %d", zebra_route_string(type),
+ instance);
/* Send distribute add message to zebra. */
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
return 0;
}
/* Redistribute with route-map specification. */
int
-bgp_redistribute_rmap_set (struct bgp *bgp, afi_t afi, int type,
- const char *name)
+bgp_redistribute_rmap_set (struct bgp_redist *red, const char *name)
{
- if (bgp->rmap[afi][type].name
- && (strcmp (bgp->rmap[afi][type].name, name) == 0))
+ if (red->rmap.name
+ && (strcmp (red->rmap.name, name) == 0))
return 0;
- if (bgp->rmap[afi][type].name)
- free (bgp->rmap[afi][type].name);
- bgp->rmap[afi][type].name = strdup (name);
- bgp->rmap[afi][type].map = route_map_lookup_by_name (name);
+ if (red->rmap.name)
+ free (red->rmap.name);
+ red->rmap.name = strdup (name);
+ red->rmap.map = route_map_lookup_by_name (name);
return 1;
}
/* Redistribute with metric specification. */
int
-bgp_redistribute_metric_set (struct bgp *bgp, afi_t afi, int type,
- u_int32_t metric)
+bgp_redistribute_metric_set (struct bgp_redist *red, u_int32_t metric)
{
- if (bgp->redist_metric_flag[afi][type]
- && bgp->redist_metric[afi][type] == metric)
+ if (red->redist_metric_flag
+ && red->redist_metric == metric)
return 0;
- bgp->redist_metric_flag[afi][type] = 1;
- bgp->redist_metric[afi][type] = metric;
+ red->redist_metric_flag = 1;
+ red->redist_metric = metric;
return 1;
}
/* Unset redistribution. */
int
-bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type)
+bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type, u_short instance)
{
- /* Unset flag from BGP instance. */
- bgp->redist[afi][type] = 0;
+ struct bgp_redist *red;
+
+ red = bgp_redist_lookup(bgp, afi, type, instance);
+ if (!red)
+ return CMD_SUCCESS;
/* Unset route-map. */
- if (bgp->rmap[afi][type].name)
- free (bgp->rmap[afi][type].name);
- bgp->rmap[afi][type].name = NULL;
- bgp->rmap[afi][type].map = NULL;
+ if (red->rmap.name)
+ free (red->rmap.name);
+ red->rmap.name = NULL;
+ red->rmap.map = NULL;
/* Unset metric. */
- bgp->redist_metric_flag[afi][type] = 0;
- bgp->redist_metric[afi][type] = 0;
+ red->redist_metric_flag = 0;
+ red->redist_metric = 0;
+
+ bgp_redist_del(bgp, afi, type, instance);
/* Return if zebra connection is disabled. */
- if (! zclient->redist[type])
+ if (!redist_check_instance(&zclient->redist[type], instance))
return CMD_WARNING;
- zclient->redist[type] = 0;
+ redist_del_instance(&zclient->redist[type], instance);
- if (bgp->redist[AFI_IP][type] == 0
- && bgp->redist[AFI_IP6][type] == 0
+ if (!bgp_redist_lookup(bgp, AFI_IP, type, instance)
+ && !bgp_redist_lookup(bgp, AFI_IP6, type, instance)
&& zclient->sock >= 0)
{
/* Send distribute delete message to zebra. */
if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Zebra send: redistribute delete %s",
- zebra_route_string(type));
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zlog_debug("Zebra send: redistribute delete %s %d",
+ zebra_route_string(type), instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
}
/* Withdraw redistributed routes from current BGP's routing table. */
- bgp_redistribute_withdraw (bgp, afi, type);
+ bgp_redistribute_withdraw (bgp, afi, type, instance);
return CMD_SUCCESS;
}
{
/* Set default values. */
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_BGP);
+ zclient_init (zclient, ZEBRA_ROUTE_BGP, 0);
zclient->router_id_update = bgp_router_id_update;
zclient->interface_add = bgp_interface_add;
zclient->interface_delete = bgp_interface_delete;
extern void bgp_zebra_announce_table (struct bgp *, afi_t, safi_t);
extern void bgp_zebra_withdraw (struct prefix *, struct bgp_info *, safi_t);
-extern int bgp_redistribute_set (struct bgp *, afi_t, int);
-extern int bgp_redistribute_resend (struct bgp *, afi_t, int);
-extern int bgp_redistribute_rmap_set (struct bgp *, afi_t, int, const char *);
-extern int bgp_redistribute_metric_set (struct bgp *, afi_t, int, u_int32_t);
-extern int bgp_redistribute_unset (struct bgp *, afi_t, int);
+extern struct bgp_redist *bgp_redist_lookup (struct bgp *, afi_t, u_char, u_short);
+extern struct bgp_redist *bgp_redist_add (struct bgp *, afi_t, u_char, u_short);
+extern int bgp_redistribute_set (int, u_short);
+extern int bgp_redistribute_resend (struct bgp *, afi_t, int, u_short);
+extern int bgp_redistribute_rmap_set (struct bgp_redist *, const char *);
+extern int bgp_redistribute_metric_set (struct bgp_redist *, u_int32_t);
+extern int bgp_redistribute_unset (struct bgp *, afi_t, int, u_short);
extern struct interface *if_lookup_by_ipv4 (struct in_addr *);
extern struct interface *if_lookup_by_ipv4_exact (struct in_addr *);
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != ZEBRA_ROUTE_BGP)
- bgp_redistribute_unset (bgp, afi, i);
+ bgp_redistribute_unset (bgp, afi, i, 0);
for (ALL_LIST_ELEMENTS (bgp->group, node, next, group))
{
struct route_map *map;
};
+struct bgp_redist
+{
+ u_short instance;
+
+ /* BGP redistribute metric configuration. */
+ u_char redist_metric_flag;
+ u_int32_t redist_metric;
+
+ /* BGP redistribute route-map. */
+ struct bgp_rmap rmap;
+};
+
/* BGP instance structure. */
struct bgp
{
struct bgp_rmap table_map[AFI_MAX][SAFI_MAX];
/* BGP redistribute configuration. */
- u_char redist[AFI_MAX][ZEBRA_ROUTE_MAX];
-
- /* BGP redistribute metric configuration. */
- u_char redist_metric_flag[AFI_MAX][ZEBRA_ROUTE_MAX];
- u_int32_t redist_metric[AFI_MAX][ZEBRA_ROUTE_MAX];
-
- /* BGP redistribute route-map. */
- struct bgp_rmap rmap[AFI_MAX][ZEBRA_ROUTE_MAX];
+ struct list *redist[AFI_MAX][ZEBRA_ROUTE_MAX];
/* timer to dampen route map changes */
struct thread *t_rmap_update; /* Handle route map updates */
/* Get the programname without the preceding path. */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_ISIS,
+ zlog_default = openzlog (progname, ZLOG_ISIS, 0,
LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
/* for reload */
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
return;
- if (zclient->redist[ZEBRA_ROUTE_ISIS])
+ if (zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
{
message = 0;
flags = 0;
zclient_create_header (stream, ZEBRA_IPV4_ROUTE_ADD);
/* type */
stream_putc (stream, ZEBRA_ROUTE_ISIS);
+ /* instance */
+ stream_putw (stream, 0);
/* flags */
stream_putc (stream, flags);
/* message */
struct zapi_ipv4 api;
struct prefix_ipv4 prefix4;
- if (zclient->redist[ZEBRA_ROUTE_ISIS])
+ if (zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
{
api.type = ZEBRA_ROUTE_ISIS;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
return;
api.type = ZEBRA_ROUTE_ISIS;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
return;
api.type = ZEBRA_ROUTE_ISIS;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
if (zclient->sock < 0)
return;
- if (!zclient->redist[ZEBRA_ROUTE_ISIS])
+ if (!zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
return;
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
ifindex = 0;
api.type = stream_getc (stream);
+ api.instance = stream_getw (stream);
api.flags = stream_getc (stream);
api.message = stream_getc (stream);
#endif
#define ISIS_TYPE_IS_REDISTRIBUTED(T) \
-T == ZEBRA_ROUTE_MAX ? zclient->default_information : zclient->redist[type]
+T == ZEBRA_ROUTE_MAX ? zclient->default_information : \
+zclient->redist[type].enabled
int
isis_distribute_list_update (int routetype)
isis_zebra_init ()
{
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_ISIS);
+ zclient_init (zclient, ZEBRA_ROUTE_ISIS, 0);
zclient->router_id_update = isis_router_id_update_zebra;
zclient->interface_add = isis_zebra_if_add;
zclient->interface_delete = isis_zebra_if_del;
static void
vzlog (struct zlog *zl, int priority, const char *format, va_list args)
{
+ char proto_str[32];
struct timestamp_control tsctl;
tsctl.already_rendered = 0;
va_end(ac);
}
+ if (zl->instance)
+ sprintf (proto_str, "%s[%d]: ", zlog_proto_names[zl->protocol], zl->instance);
+ else
+ sprintf (proto_str, "%s: ", zlog_proto_names[zl->protocol]);
+
/* File output. */
if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
{
time_print (zl->fp, &tsctl);
if (zl->record_priority)
fprintf (zl->fp, "%s: ", zlog_priority[priority]);
- fprintf (zl->fp, "%s: ", zlog_proto_names[zl->protocol]);
+ fprintf (zl->fp, "%s", proto_str);
va_copy(ac, args);
vfprintf (zl->fp, format, ac);
va_end(ac);
time_print (stdout, &tsctl);
if (zl->record_priority)
fprintf (stdout, "%s: ", zlog_priority[priority]);
- fprintf (stdout, "%s: ", zlog_proto_names[zl->protocol]);
+ fprintf (stdout, "%s", proto_str);
va_copy(ac, args);
vfprintf (stdout, format, ac);
va_end(ac);
/* Terminal monitor. */
if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
vty_log ((zl->record_priority ? zlog_priority[priority] : NULL),
- zlog_proto_names[zl->protocol], format, &tsctl, args);
+ proto_str, format, &tsctl, args);
}
static char *
/* Open log stream */
struct zlog *
-openzlog (const char *progname, zlog_proto_t protocol,
+openzlog (const char *progname, zlog_proto_t protocol, u_short instance,
int syslog_flags, int syslog_facility)
{
struct zlog *zl;
zl->ident = progname;
zl->protocol = protocol;
+ zl->instance = instance;
zl->facility = syslog_facility;
zl->syslog_options = syslog_flags;
{
const char *ident; /* daemon name (first arg to openlog) */
zlog_proto_t protocol;
+ u_short instance;
int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated
logging destination */
int default_lvl; /* maxlvl to use if none is specified */
/* Open zlog function */
extern struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
- int syslog_options, int syslog_facility);
+ u_short instance, int syslog_options, int syslog_facility);
/* Close zlog function. */
extern void closezlog (struct zlog *zl);
/* Print the name of the protocol */
if (zlog_default)
- vty_out (vty, "%s:%s", zlog_proto_names[zlog_default->protocol],
- VTY_NEWLINE);
+ vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
+ if (zlog_default->instance)
+ vty_out (vty, " %d", zlog_default->instance);
+ vty_out (vty, ":%s", VTY_NEWLINE);
for (index = map->head; index; index = index->next)
{
XFREE (MTYPE_ZCLIENT, zclient);
}
+int
+redist_check_instance (struct redist_proto *red, u_short instance)
+{
+ struct listnode *node;
+ u_short *id;
+
+ if (!red->instances)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS_RO (red->instances, node, id))
+ if (*id == instance)
+ return 1;
+
+ return 0;
+}
+
+void
+redist_add_instance (struct redist_proto *red, u_short instance)
+{
+ u_short *in;
+
+ red->enabled = 1;
+
+ if (!red->instances)
+ red->instances = list_new();
+
+ in = (u_short *)calloc(1, sizeof(u_short));
+ *in = instance;
+ listnode_add (red->instances, in);
+}
+
+void
+redist_del_instance (struct redist_proto *red, u_short instance)
+{
+ struct listnode *node;
+ u_short *id = NULL;
+
+ if (!red->instances)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS_RO (red->instances, node, id))
+ if (*id == instance)
+ break;
+
+ if (id)
+ {
+ listnode_delete(red->instances, id);
+ if (!red->instances->count)
+ {
+ red->enabled = 0;
+ list_free(red->instances);
+ red->instances = NULL;
+ }
+ }
+}
+
/* Initialize zebra client. Argument redist_default is unwanted
redistribute route type. */
void
-zclient_init (struct zclient *zclient, int redist_default)
+zclient_init (struct zclient *zclient, int redist_default, u_short instance)
{
int i;
/* Clear redistribution flags. */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- zclient->redist[i] = 0;
+ memset(&zclient->redist[i], 0, sizeof(struct redist_proto));
/* Set unwanted redistribute route. bgpd does not need BGP route
redistribution. */
zclient->redist_default = redist_default;
- zclient->redist[redist_default] = 1;
+ zclient->instance = instance;
+ redist_add_instance (&zclient->redist[redist_default], instance);
/* Set default-information redistribute to zero. */
zclient->default_information = 0;
zclient_reset (struct zclient *zclient)
{
zclient_stop (zclient);
- zclient_init (zclient, zclient->redist_default);
+ zclient_init (zclient, zclient->redist_default, zclient->instance);
}
#ifdef HAVE_TCP_ZEBRA
zclient_create_header (s, ZEBRA_HELLO);
stream_putc (s, zclient->redist_default);
+ stream_putw (s, zclient->instance);
stream_putw_at (s, 0, stream_get_endp (s));
return zclient_send_message(zclient);
}
/* Flush all redistribute request. */
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default && zclient->redist[i])
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, i);
+ if (zclient->redist[i].enabled)
+ {
+ struct listnode *node;
+ u_short *id;
+
+ for (ALL_LIST_ELEMENTS_RO(zclient->redist[i].instances, node, id))
+ if (!(i == zclient->redist_default && *id == zclient->instance))
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, i, *id);
+ }
/* If default information is needed. */
if (zclient->default_information)
/* Put type and nexthop. */
stream_putc (s, api->type);
+ stream_putw (s, api->instance);
stream_putc (s, api->flags);
stream_putc (s, api->message);
stream_putw (s, api->safi);
/* Put type and nexthop. */
stream_putc (s, api->type);
+ stream_putw (s, api->instance);
stream_putc (s, api->flags);
stream_putc (s, api->message);
stream_putw (s, api->safi);
* sending client
*/
int
-zebra_redistribute_send (int command, struct zclient *zclient, int type)
+zebra_redistribute_send (int command, struct zclient *zclient, int type,
+ u_short instance)
{
struct stream *s;
zclient_create_header (s, command);
stream_putc (s, type);
+ stream_putw (s, instance);
stream_putw_at (s, 0, stream_get_endp (s));
}
void
-zclient_redistribute (int command, struct zclient *zclient, int type)
+zclient_redistribute (int command, struct zclient *zclient, int type,
+ u_short instance)
{
if (command == ZEBRA_REDISTRIBUTE_ADD)
{
- if (zclient->redist[type])
+ if (redist_check_instance(&zclient->redist[type], instance))
return;
- zclient->redist[type] = 1;
+ redist_add_instance(&zclient->redist[type], instance);
}
else
{
- if (!zclient->redist[type])
+ if (!redist_check_instance(&zclient->redist[type], instance))
return;
- zclient->redist[type] = 0;
+ redist_del_instance(&zclient->redist[type], instance);
}
if (zclient->sock > 0)
- zebra_redistribute_send (command, zclient, type);
+ zebra_redistribute_send (command, zclient, type, instance);
}
/* Zebra header size. */
#define ZEBRA_HEADER_SIZE 6
+struct redist_proto
+{
+ u_char enabled;
+ struct list *instances;
+};
+
/* Structure for the zebra client. */
struct zclient
{
struct thread *t_write;
/* Redistribute information. */
- u_char redist_default;
- u_char redist[ZEBRA_ROUTE_MAX];
+ u_char redist_default; /* clients protocol */
+ u_short instance;
+ struct redist_proto redist[ZEBRA_ROUTE_MAX];
/* Redistribute defauilt. */
u_char default_information;
struct zapi_ipv4
{
u_char type;
+ u_short instance;
u_char flags;
/* Prototypes of zebra client service functions. */
extern struct zclient *zclient_new (void);
-extern void zclient_init (struct zclient *, int);
+extern void zclient_init (struct zclient *, int, u_short);
extern int zclient_start (struct zclient *);
extern void zclient_stop (struct zclient *);
extern void zclient_reset (struct zclient *);
extern int zclient_socket_connect (struct zclient *);
extern void zclient_serv_path_set (char *path);
+extern int redist_check_instance (struct redist_proto *, u_short);
+extern void redist_add_instance (struct redist_proto *, u_short);
+extern void redist_del_instance (struct redist_proto *, u_short);
+
/* Send redistribute command to zebra daemon. Do not update zclient state. */
-extern int zebra_redistribute_send (int command, struct zclient *, int type);
+extern int zebra_redistribute_send (int command, struct zclient *, int type, u_short instance);
/* If state has changed, update state and call zebra_redistribute_send. */
-extern void zclient_redistribute (int command, struct zclient *, int type);
+extern void zclient_redistribute (int command, struct zclient *, int type,
+ u_short instance);
/* If state has changed, update state and send the command to zebra. */
extern void zclient_redistribute_default (int command, struct zclient *);
struct zapi_ipv6
{
u_char type;
+ u_short instance;
u_char flags;
master = thread_master_create ();
/* Initializations. */
- zlog_default = openzlog (progname, ZLOG_OSPF6,
+ zlog_default = openzlog (progname, ZLOG_OSPF6, 0,
LOG_CONS|LOG_NDELAY|LOG_PID,
LOG_DAEMON);
zprivs_init (&ospf6d_privs);
void
ospf6_zebra_redistribute (int type)
{
- if (zclient->redist[type])
+ if (zclient->redist[type].enabled)
return;
- zclient->redist[type] = 1;
+ redist_add_instance(&zclient->redist[type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
}
void
ospf6_zebra_no_redistribute (int type)
{
- if (! zclient->redist[type])
+ if (! zclient->redist[type].enabled)
return;
- zclient->redist[type] = 0;
+ redist_del_instance(&zclient->redist[type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
}
/* Inteface addition message from zebra. */
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
vty_out (vty, " redistribute:");
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
- if (zclient->redist[i])
+ if (zclient->redist[i].enabled)
vty_out (vty, " %s", zebra_route_string(i));
}
vty_out (vty, "%s", VNL);
vty_out (vty, "no router zebra%s", VNL);
vty_out (vty, "!%s", VNL);
}
- else if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
+ else if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
{
vty_out (vty, "router zebra%s", VNL);
vty_out (vty, " no redistribute ospf6%s", VNL);
ospf6_route_zebra_copy_nexthops (request, ifindexes, nexthops, nhcount);
api.type = ZEBRA_ROUTE_OSPF6;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
void
ospf6_zebra_route_update_add (struct ospf6_route *request)
{
- if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
{
ospf6->route_table->hook_add = NULL;
ospf6->route_table->hook_remove = NULL;
void
ospf6_zebra_route_update_remove (struct ospf6_route *request)
{
- if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
{
ospf6->route_table->hook_add = NULL;
ospf6->route_table->hook_remove = NULL;
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
{
if (!CHECK_FLAG (request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED))
{
api.type = ZEBRA_ROUTE_OSPF6;
api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.instance = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
{
if (CHECK_FLAG (request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED))
{
api.type = ZEBRA_ROUTE_OSPF6;
api.flags = ZEBRA_FLAG_BLACKHOLE;
+ api.instance = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
{
struct ospf6_route *route;
- if (zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
return CMD_SUCCESS;
- zclient->redist[ZEBRA_ROUTE_OSPF6] = 1;
+ redist_add_instance(&zclient->redist[ZEBRA_ROUTE_OSPF6], 0);
if (ospf6 == NULL)
return CMD_SUCCESS;
{
struct ospf6_route *route;
- if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
+ if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
return CMD_SUCCESS;
- zclient->redist[ZEBRA_ROUTE_OSPF6] = 0;
+ redist_del_instance(&zclient->redist[ZEBRA_ROUTE_OSPF6], 0);
if (ospf6 == NULL)
return CMD_SUCCESS;
{
/* Allocate zebra structure. */
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_OSPF6);
+ zclient_init (zclient, ZEBRA_ROUTE_OSPF6, 0);
zclient->router_id_update = ospf6_router_id_update_zebra;
zclient->interface_add = ospf6_zebra_if_add;
zclient->interface_delete = ospf6_zebra_if_del;
extern void ospf6_zebra_redistribute (int);
extern void ospf6_zebra_no_redistribute (int);
-#define ospf6_zebra_is_redistribute(type) (zclient->redist[type])
+#define ospf6_zebra_is_redistribute(type) (zclient->redist[type].enabled)
extern void ospf6_zebra_init (void);
extern void ospf6_zebra_add_discard (struct ospf6_route *request);
extern void ospf6_zebra_delete_discard (struct ospf6_route *request);
/* 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;
/* 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;
}
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);
}
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);
}
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))
{
/* Type of source protocol. */
u_char type;
+ u_short instance;
+
/* Prefix. */
struct prefix_ipv4 p;
#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 *);
/*
- [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++)
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)",
"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"
"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 (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++)
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)",
"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);
}
}
/* 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)",
"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)",
"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);
}
}
/* 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)",
"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);
}
}
/* 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)",
"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);
}
}
/* 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)",
"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);
}
}
/* 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)",
"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);
}
}
/* 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)",
"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);
}
}
/* 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)",
"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",
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",
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. */
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 =
{
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;
}
/* 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;
}
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;
}
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;
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;
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);
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);
}
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;
#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)
{
return ospf->default_metric;
}
- return ospf->dmetric[src].value;
+ return red->dmetric.value;
}
/* Set AS-external-LSA body. */
u_int32_t mvalue;
int mtype;
int type;
+ u_short instance;
/* Put Network Mask. */
masklen2ip (p->prefixlen, &mask);
/* 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));
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;
}
/* 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;
}
/* 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)))
}
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))
{
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 *,
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 *);
};
/* 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'},
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;
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\
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;
{
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':
vty_addr = optarg;
break;
case 'i':
- pid_file = optarg;
+ strcpy(pid_file,optarg);
break;
case 'z':
zclient_serv_path_set (optarg);
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. */
/* OSPFd inits. */
ospf_if_init ();
- ospf_zebra_init ();
+ ospf_zebra_init (instance);
/* OSPF vty inits. */
ospf_vty_init ();
/* 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 */
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))
/* 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
{
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))
{
{
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))
{
{
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);
{
struct ospf *ospf;
int type;
+ u_short instance; // PENDING
/* If OSPF instatnce does not exist, return right now. */
ospf = ospf_lookup ();
/* 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);
+ }
+ }
}
}
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);
+ }
}
}
}
{
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;
{
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;
{
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))
{
"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",
"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",
struct in_addr router_id;
int ret;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ret = inet_aton (argv[0], &router_id);
if (!ret)
{
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->router_id_static.s_addr = 0;
ospf_router_id_update (ospf);
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);
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);
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",
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]);
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]);
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]);
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]);
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]);
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]);
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 */
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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)
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);
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);
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);
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)
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)
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
return CMD_SUCCESS;
}
{
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;
{
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;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
return CMD_SUCCESS;
}
{
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);
{
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);
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->spf_delay = delay;
ospf->spf_holdtime = hold;
ospf->spf_max_holdtime = max;
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)
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)
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);
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;
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);
struct listnode *node;
struct interface *ifp;
+ if (!ospf)
+ return CMD_SUCCESS;
+
refbw = strtol (argv[0], NULL, 10);
if (refbw < 1 || refbw > 4294967)
{
struct listnode *node, *nnode;
struct interface *ifp;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
return CMD_SUCCESS;
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)
{
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
return CMD_SUCCESS;
}
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",
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,
}
}
-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)
{
}
}
-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 = ospf_lookup ();
- struct listnode *node;
- struct ospf_interface *oi;
+ struct ospf *ospf;
- if (ospf == NULL)
- {
- vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
- show_ip_ospf_neighbour_header (vty);
-
- for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
- {
+ 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 listnode *node;
+ struct ospf_interface *oi;
+
+ 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;
struct ospf_nbr_nbma *nbr_nbma;
}
}
+ 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);
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)
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);
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))
{
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))
{
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))
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
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;
}
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)",
"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)
- adv_router = ospf->router_id;
- else
- {
- ret = inet_aton (argv[1], &adv_router);
- if (!ret)
- return CMD_WARNING;
- }
+ /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
+ if (strncmp (argv[arg_base + 1], "s", 1) == 0)
+ adv_router = ospf->router_id;
+ else
+ {
+ ret = inet_aton (argv[arg_base + 1], &adv_router);
+ if (!ret)
+ return CMD_WARNING;
+ }
+
+ show_lsa_detail_adv_router (vty, ospf, 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|)",
+ SHOW_STR
+ IP_STR
+ "OSPF information\n"
+ "Database summary\n"
+ 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]);
- show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
+ if ((ospf = ospf_lookup_instance (instance)) == NULL)
+ return CMD_SUCCESS;
- return CMD_SUCCESS;
+ return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, 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|)",
+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,
"ip ospf authentication (null|message-digest) A.B.C.D",
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",
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",
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))
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
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)
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,
{
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,
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)
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;
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 */
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))
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);
{
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);
}
struct ospf *ospf = vty->index;
int metric = -1;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (!str2metric (argv[0], &metric))
return CMD_WARNING;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->default_metric = -1;
return CMD_SUCCESS;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->distance_all = atoi (argv[0]);
return CMD_SUCCESS;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->distance_all = 0;
return CMD_SUCCESS;
if (argc < 3)
return CMD_WARNING;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argv[0] != NULL)
ospf->distance_intra = 0;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
return CMD_SUCCESS;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
return CMD_SUCCESS;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
return CMD_SUCCESS;
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
return CMD_SUCCESS;
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);
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);
unsigned int seconds;
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
if (argc != 1)
{
vty_out (vty, "%% Must supply stub-router period");
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))
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");
{
struct ospf *ospf = vty->index;
+ if (!ospf)
+ return CMD_SUCCESS;
+
ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
return CMD_SUCCESS;
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)
{
/* 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)
{
/* 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[] =
{
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))
{
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);
/* 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);
}
/* 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;
}
config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
{
int type;
+ struct ospf_redist *red;
if (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);
}
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++;
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);
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);
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);
}
/* "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);
{
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);
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. */
#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;
/* 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);
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;
/* 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);
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;
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;
}
}
+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);
}
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);
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
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;
}
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);
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;
{
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;
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)
/* 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. */
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
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
}
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
/* 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;
}
{
/* 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;
/* 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);
/* 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. */
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;
/* 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. */
/* 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);
}
}
*/
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. */
}
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;
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 */
/* 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);
/* 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;
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)
{
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)
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);
/* 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))
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);
+
}
{
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)
#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
{
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;
#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. */
#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
/* 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 *,
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
/* First of all we need logging init. */
- zlog_default = openzlog (progname, ZLOG_RIP,
+ zlog_default = openzlog (progname, ZLOG_RIP, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* Command line option parse. */
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_RIP])
+ if (zclient->redist[ZEBRA_ROUTE_RIP].enabled)
{
api.type = ZEBRA_ROUTE_RIP;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_RIP])
+ if (zclient->redist[ZEBRA_ROUTE_RIP].enabled)
{
api.type = ZEBRA_ROUTE_RIP;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
static int
rip_redistribute_unset (int type)
{
- if (! zclient->redist[type])
+ if (! zclient->redist[type].enabled)
return CMD_SUCCESS;
- zclient->redist[type] = 0;
+ redist_del_instance(&zclient->redist[type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
/* Remove the routes from RIP table. */
rip_redistribute_withdraw (type);
int
rip_redistribute_check (int type)
{
- return (zclient->redist[type]);
+ return (zclient->redist[type].enabled);
}
void
for (i = 0; redist_type[i].str; i++)
{
- if (zclient->redist[redist_type[i].type])
+ if (zclient->redist[redist_type[i].type].enabled)
{
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
- zclient, redist_type[i].type);
+ zclient, redist_type[i].type, 0);
- zclient->redist[redist_type[i].type] = 0;
+ redist_del_instance(&zclient->redist[redist_type[i].type], 0);
/* Remove the routes from RIP table. */
rip_redistribute_withdraw (redist_type[i].type);
"Redistribute information from another routing protocol\n"
"Routing Information Protocol (RIP)\n")
{
- zclient->redist[ZEBRA_ROUTE_RIP] = 1;
+ redist_add_instance(&zclient->redist[ZEBRA_ROUTE_RIP], 0);
return CMD_SUCCESS;
}
"Redistribute information from another routing protocol\n"
"Routing Information Protocol (RIP)\n")
{
- zclient->redist[ZEBRA_ROUTE_RIP] = 0;
+ redist_del_instance(&zclient->redist[ZEBRA_ROUTE_RIP], 0);
return CMD_SUCCESS;
}
redist_type[i].str_min_len) == 0)
{
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient,
- redist_type[i].type);
+ redist_type[i].type, 0);
return CMD_SUCCESS;
}
}
redist_type[i].str_min_len) == 0)
{
rip_routemap_set (redist_type[i].type, argv[1]);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type, 0);
return CMD_SUCCESS;
}
}
redist_type[i].str_min_len) == 0)
{
rip_redistribute_metric_set (redist_type[i].type, metric);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type, 0);
return CMD_SUCCESS;
}
}
{
rip_redistribute_metric_set (redist_type[i].type, metric);
rip_routemap_set (redist_type[i].type, argv[2]);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type, 0);
return CMD_SUCCESS;
}
}
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
- else if (! zclient->redist[ZEBRA_ROUTE_RIP])
+ else if (! zclient->redist[ZEBRA_ROUTE_RIP].enabled)
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute rip%s", VTY_NEWLINE);
int i;
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default && zclient->redist[i])
+ if (i != zclient->redist_default &&
+ zclient->redist[i].enabled)
{
if (config_mode)
{
{
/* Set default value to the zebra client structure. */
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_RIP);
+ zclient_init (zclient, ZEBRA_ROUTE_RIP, 0);
zclient->interface_add = rip_interface_add;
zclient->interface_delete = rip_interface_delete;
zclient->interface_address_add = rip_interface_address_add;
/* get program name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog(progname, ZLOG_RIPNG,
+ zlog_default = openzlog(progname, ZLOG_RIPNG, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
while (1)
{
struct zapi_ipv6 api;
- if (zclient->redist[ZEBRA_ROUTE_RIPNG])
+ if (zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
{
api.type = ZEBRA_ROUTE_RIPNG;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
{
struct zapi_ipv6 api;
- if (zclient->redist[ZEBRA_ROUTE_RIPNG])
+ if (zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
{
api.type = ZEBRA_ROUTE_RIPNG;
+ api.instance = 0;
api.flags = 0;
api.message = 0;
api.safi = SAFI_UNICAST;
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
static int
ripng_redistribute_unset (int type)
{
- if (! zclient->redist[type])
+ if (! zclient->redist[type].enabled)
return CMD_SUCCESS;
- zclient->redist[type] = 0;
+ redist_del_instance(&zclient->redist[type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
ripng_redistribute_withdraw (type);
int
ripng_redistribute_check (int type)
{
- return (zclient->redist[type]);
+ return (zclient->redist[type].enabled);
}
static void
for (i = 0; redist_type[i].str; i++)
{
- if (zclient->redist[redist_type[i].type])
+ if (zclient->redist[redist_type[i].type].enabled)
{
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
- zclient, redist_type[i].type);
+ zclient, redist_type[i].type, 0);
- zclient->redist[redist_type[i].type] = 0;
+ redist_del_instance(&zclient->redist[redist_type[i].type], 0);
/* Remove the routes from RIPng table. */
ripng_redistribute_withdraw (redist_type[i].type);
"Redistribute information from another routing protocol\n"
"RIPng route\n")
{
- zclient->redist[ZEBRA_ROUTE_RIPNG] = 1;
+ redist_add_instance(&zclient->redist[ZEBRA_ROUTE_RIPNG], 0);
return CMD_SUCCESS;
}
"Redistribute information from another routing protocol\n"
"RIPng route\n")
{
- zclient->redist[ZEBRA_ROUTE_RIPNG] = 0;
+ redist_del_instance(&zclient->redist[ZEBRA_ROUTE_RIPNG], 0);
return CMD_SUCCESS;
}
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
return CMD_SUCCESS;
}
}
ripng_redistribute_metric_set (type, metric);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
return CMD_SUCCESS;
}
}
ripng_redistribute_routemap_set (type, argv[1]);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
return CMD_SUCCESS;
}
ripng_redistribute_metric_set (type, metric);
ripng_redistribute_routemap_set (type, argv[2]);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
return CMD_SUCCESS;
}
int i;
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default && zclient->redist[i])
+ if (i != zclient->redist_default &&
+ zclient->redist[i].enabled)
{
if (config_mode)
{
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
- else if (! zclient->redist[ZEBRA_ROUTE_RIPNG])
+ else if (! zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute ripng%s", VTY_NEWLINE);
{
/* Allocate zebra structure. */
zclient = zclient_new ();
- zclient_init (zclient, ZEBRA_ROUTE_RIPNG);
+ zclient_init (zclient, ZEBRA_ROUTE_RIPNG, 0);
zclient->interface_up = ripng_interface_up;
zclient->interface_down = ripng_interface_down;
master = thread_master_create ();
signal_init (master, array_size(sigs), sigs);
- zlog_default = openzlog("testsig", ZLOG_NONE,
+ zlog_default = openzlog("testsig", ZLOG_NONE, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
$ignore{'"router rip"'} = "ignore";
$ignore{'"router ripng"'} = "ignore";
$ignore{'"router ospf"'} = "ignore";
-$ignore{'"router ospf <0-65535>"'} = "ignore";
+$ignore{'"router ospf <1-65535>"'} = "ignore";
$ignore{'"router ospf6"'} = "ignore";
$ignore{'"router babel"'} = "ignore";
$ignore{'"router bgp " "<1-4294967295>"'} = "ignore";
#include <readline/readline.h>
#include <readline/history.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <string.h>
+
#include "command.h"
#include "memory.h"
#include "vtysh/vtysh.h"
struct vtysh_client
{
int fd;
- const char *name;
+ char *name;
int flag;
- const char *path;
-} vtysh_client[] =
-{
- { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH},
- { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH},
- { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH},
- { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH},
- { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH},
- { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH},
- { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH},
- { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH},
+ char *path;
+ struct vtysh_client *next;
+};
+
+struct vtysh_client vtysh_client[] =
+{
+ { .fd = -1, .name = "zebra", .flag = VTYSH_ZEBRA, .path = ZEBRA_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "ripd", .flag = VTYSH_RIPD, .path = RIP_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "ripngd", .flag = VTYSH_RIPNGD, .path = RIPNG_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "ospfd", .flag = VTYSH_OSPFD, .path = OSPF_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "ospf6d", .flag = VTYSH_OSPF6D, .path = OSPF6_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH, .next = NULL},
+ { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH, .next = NULL},
};
* under load - it SHOULD handle it. */
#define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
static int
-vtysh_client_config (struct vtysh_client *vclient, char *line)
+vtysh_client_config_one (struct vtysh_client *vclient, char *line)
{
int ret;
char *buf;
}
static int
-vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
+vtysh_client_config (struct vtysh_client *head_client, char *line)
+{
+ struct vtysh_client *client;
+ int rc;
+
+ rc = vtysh_client_config_one(head_client, line);
+ if (rc != CMD_SUCCESS)
+ return rc;
+
+ client = head_client->next;
+ while (client)
+ {
+ rc = vtysh_client_config_one(client, line);
+ if (rc != CMD_SUCCESS)
+ return rc;
+ client = client->next;
+ }
+ return CMD_SUCCESS;
+}
+
+static int
+vtysh_client_execute_one (struct vtysh_client *vclient, const char *line, FILE *fp)
{
int ret;
char buf[1001];
}
}
+static int
+vtysh_client_execute (struct vtysh_client *head_client, const char *line, FILE *fp)
+{
+ struct vtysh_client *client;
+ int rc;
+
+ rc = vtysh_client_execute_one(head_client, line, fp);
+ if (rc != CMD_SUCCESS)
+ return rc;
+
+ client = head_client->next;
+ while (client)
+ {
+ rc = vtysh_client_execute_one(client, line, fp);
+ if (rc != CMD_SUCCESS)
+ return rc;
+ client = client->next;
+ }
+ return CMD_SUCCESS;
+}
+
void
vtysh_exit_ripd_only (void)
{
return CMD_SUCCESS;
}
+ALIAS_SH (VTYSH_OSPFD,
+ router_ospf,
+ router_ospf_instance_cmd,
+ "router ospf <1-65535>",
+ "Enable a routing process\n"
+ "Start OSPF configuration\n"
+ "Instance ID\n")
+
DEFUNSH (VTYSH_OSPF6D,
router_ospf6,
router_ospf6_cmd,
return 0;
}
+/* Return true if str begins with prefix, else return false */
+static int
+begins_with(const char *str, const char *prefix)
+{
+ if (!str || !prefix)
+ return 0;
+ size_t lenstr = strlen(str);
+ size_t lenprefix = strlen(prefix);
+ if (lenprefix > lenstr)
+ return 0;
+ return strncmp(str, prefix, lenprefix) == 0;
+}
+
+/* Return true if str ends with suffix, else return false */
+static int
+ends_with(const char *str, const char *suffix)
+{
+ if (!str || !suffix)
+ return 0;
+ size_t lenstr = strlen(str);
+ size_t lensuffix = strlen(suffix);
+ if (lensuffix > lenstr)
+ return 0;
+ return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0;
+}
+
+static void
+vtysh_client_sorted_insert (struct vtysh_client *head_client,
+ struct vtysh_client *client)
+{
+ struct vtysh_client *prev_node, *current_node;
+
+ prev_node = head_client;
+ current_node = head_client->next;
+ while (current_node)
+ {
+ if (strcmp(current_node->path, client->path) > 0)
+ break;
+
+ prev_node = current_node;
+ current_node = current_node->next;
+ }
+ client->next = current_node;
+ prev_node->next = client;
+}
+
+#define MAXIMUM_INSTANCES 10
+
+static void
+vtysh_update_all_insances(struct vtysh_client * head_client)
+{
+ struct vtysh_client *client;
+ char *path;
+ DIR *dir;
+ struct dirent *file;
+ int n = 0;
+
+ if (head_client->flag != VTYSH_OSPFD) return;
+
+ /* ls /var/run/quagga/ and look for all files ending in .vty */
+ dir = opendir("/var/run/quagga/");
+ if (dir)
+ {
+ while ((file = readdir(dir)) != NULL)
+ {
+ if (begins_with(file->d_name, "ospfd-") && ends_with(file->d_name, ".vty"))
+ {
+ if (n == MAXIMUM_INSTANCES)
+ {
+ fprintf(stderr,
+ "Parsing /var/run/quagga/, client limit(%d) reached!\n", n);
+ break;
+ }
+ client = (struct vtysh_client *) malloc(sizeof(struct vtysh_client));
+ client->fd = -1;
+ client->name = (char *) malloc(10);
+ strcpy(client->name, "ospfd");
+ client->flag = VTYSH_OSPFD;
+ client->path = (char *) malloc(100);
+ sprintf(client->path, "/var/run/quagga/%s", file->d_name);
+ client->next = NULL;
+ vtysh_client_sorted_insert(head_client, client);
+ n++;
+ }
+ }
+ closedir(dir);
+ }
+}
+
+int
+vtysh_connect_all_instances (struct vtysh_client *head_client)
+{
+ struct vtysh_client *client;
+ int rc = 0;
+
+ vtysh_update_all_insances(head_client);
+
+ client = head_client->next;
+ while (client)
+ {
+ if (vtysh_connect(client) == 0)
+ rc++;
+ client = client->next;
+ }
+
+ return rc;
+}
+
int
vtysh_connect_all(const char *daemon_name)
{
/* We need direct access to ripd in vtysh_exit_ripd_only. */
if (vtysh_client[i].flag == VTYSH_RIPD)
ripd_client = &vtysh_client[i];
- }
+
+ rc += vtysh_connect_all_instances(&vtysh_client[i]);
+ }
}
if (!matches)
fprintf(stderr, "Error: no daemons match name %s!\n", daemon_name);
install_element (CONFIG_NODE, &router_ripng_cmd);
#endif
install_element (CONFIG_NODE, &router_ospf_cmd);
+ install_element (CONFIG_NODE, &router_ospf_instance_cmd);
#ifdef HAVE_IPV6
install_element (CONFIG_NODE, &router_ospf6_cmd);
#endif
return usage(progname,1);
}
- zlog_default = openzlog(progname, ZLOG_NONE,
+ zlog_default = openzlog(progname, ZLOG_NONE, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
zlog_set_level(NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
if (daemon_mode)
if (prefix_ipv4_any (&p))
return;
- rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
+ rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, NULL, ifp->ifindex,
RT_TABLE_MAIN, ifp->metric, 0, SAFI_UNICAST);
- rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex,
+ rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, NULL, ifp->ifindex,
RT_TABLE_MAIN, ifp->metric, 0, SAFI_MULTICAST);
rib_update ();
return;
/* Same logic as for connected_up_ipv4(): push the changes into the head. */
- rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
+ rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
- rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_MULTICAST);
+ rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, 0, SAFI_MULTICAST);
rib_update ();
}
return;
#endif
- rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
+ rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
ifp->metric, 0, SAFI_UNICAST);
rib_update ();
if (IN6_IS_ADDR_UNSPECIFIED (&p.prefix))
return;
- rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
+ rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, 0, &p, NULL, ifp->ifindex, 0, SAFI_UNICAST);
rib_update ();
}
* to specify the route really
*/
if (rtm->rtm_type == RTM_CHANGE)
- rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p,
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p,
NULL, 0, 0, SAFI_UNICAST);
if (rtm->rtm_type == RTM_GET
|| rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags,
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags,
&p, &gate.sin.sin_addr, NULL, 0, 0, 0, 0, SAFI_UNICAST);
else
- rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags,
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0 zebra_flags,
&p, &gate.sin.sin_addr, 0, 0, SAFI_UNICAST);
}
#ifdef HAVE_IPV6
* to specify the route really
*/
if (rtm->rtm_type == RTM_CHANGE)
- rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p,
+ rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p,
NULL, 0, 0, SAFI_UNICAST);
if (rtm->rtm_type == RTM_GET
|| rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
- rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags,
+ rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags,
&p, &gate.sin6.sin6_addr, ifindex, 0, 0, 0, SAFI_UNICAST);
else
- rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags,
+ rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags,
&p, &gate.sin6.sin6_addr, ifindex, 0, SAFI_UNICAST);
}
#endif /* HAVE_IPV6 */
/* preserve my name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_ZEBRA,
+ zlog_default = openzlog (progname, ZLOG_ZEBRA, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
while (1)
/* Redistribute routes. */
static void
-zebra_redistribute (struct zserv *client, int type)
+zebra_redistribute (struct zserv *client, int type, u_short instance)
{
struct rib *newrib;
struct route_table *table;
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
- && newrib->type == type
+ && newrib->type == type
+ && newrib->instance == instance
&& newrib->distance != DISTANCE_INFINITY
&& zebra_check_addr (&rn->p))
{
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
- && newrib->type == type
+ && newrib->type == type
+ && newrib->instance == instance
&& newrib->distance != DISTANCE_INFINITY
&& zebra_check_addr (&rn->p))
{
{
if (is_default (p))
{
- if (client->redist_default || client->redist[rib->type])
+ if (client->redist_default ||
+ redist_check_instance(&client->redist[rib->type], rib->instance))
{
if (p->family == AF_INET)
{
#endif /* HAVE_IPV6 */
}
}
- else if (client->redist[rib->type])
+ else if (redist_check_instance(&client->redist[rib->type], rib->instance))
{
if (p->family == AF_INET)
{
{
if (is_default (p))
{
- if (client->redist_default || client->redist[rib->type])
+ if (client->redist_default ||
+ redist_check_instance(&client->redist[rib->type], rib->instance))
{
if (p->family == AF_INET)
zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
#endif /* HAVE_IPV6 */
}
}
- else if (client->redist[rib->type])
- {
+ else if (redist_check_instance(&client->redist[rib->type], rib->instance))
+ {
if (p->family == AF_INET)
zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
#ifdef HAVE_IPV6
zebra_redistribute_add (int command, struct zserv *client, int length)
{
int type;
+ u_short instance;
type = stream_getc (client->ibuf);
+ instance = stream_getw (client->ibuf);
if (type == 0 || type >= ZEBRA_ROUTE_MAX)
return;
- if (! client->redist[type])
+ if (!redist_check_instance(&client->redist[type], instance))
{
- client->redist[type] = 1;
- zebra_redistribute (client, type);
+ redist_add_instance(&client->redist[type], instance);
+ zebra_redistribute (client, type, instance);
}
}
zebra_redistribute_delete (int command, struct zserv *client, int length)
{
int type;
+ u_short instance;
type = stream_getc (client->ibuf);
+ instance = stream_getw (client->ibuf);
if (type == 0 || type >= ZEBRA_ROUTE_MAX)
return;
- client->redist[type] = 0;
+ if (redist_check_instance(&client->redist[type], instance))
+ {
+ redist_del_instance(&client->redist[type], instance);
+ //Pending: why no reaction here?
+ }
}
void
/* Type fo this route. */
int type;
+ /* Source protocol instance */
+ u_short instance;
+
/* Which routing table */
int table;
/* NOTE:
* All rib_add_ipv[46]* functions will not just add prefix into RIB, but
* also implicitly withdraw equal prefix of same type. */
-extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+extern int rib_add_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
unsigned int ifindex, u_int32_t vrf_id,
u_int32_t, u_char, safi_t);
extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *, safi_t);
-extern int rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+extern int rib_delete_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex,
u_int32_t, safi_t safi);
extern void rib_sweep_route (void);
extern void rib_close (void);
extern void rib_init (void);
-extern unsigned long rib_score_proto (u_char proto);
+extern unsigned long rib_score_proto (u_char proto, u_short instance);
struct zebra_t;
extern void rib_queue_add (struct zebra_t *zebra, struct route_node *rn);
#ifdef HAVE_IPV6
extern int
-rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
+rib_add_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p,
struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id,
u_int32_t metric, u_char distance, safi_t safi);
extern int
-rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
+rib_delete_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p,
struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi);
extern struct rib *rib_lookup_ipv6 (struct in6_addr *);
p.prefixlen = rtm->rtm_dst_len;
if (!tb[RTA_MULTIPATH])
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index,
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, flags, &p, gate, src, index,
table, metric, 0, SAFI_UNICAST);
else
{
memcpy (&p.prefix, dest, 16);
p.prefixlen = rtm->rtm_dst_len;
- rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, index, table,
+ rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, flags, &p, gate, index, table,
metric, 0, SAFI_UNICAST);
}
#endif /* HAVE_IPV6 */
if (h->nlmsg_type == RTM_NEWROUTE)
{
if (!tb[RTA_MULTIPATH])
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table,
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, 0, &p, gate, src, index, table,
metric, 0, SAFI_UNICAST);
else
{
}
}
else
- rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, gate, index,
+ rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, gate, index,
table, SAFI_UNICAST);
}
}
if (h->nlmsg_type == RTM_NEWROUTE)
- rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, metric, 0, SAFI_UNICAST);
+ rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, 0, &p, gate, index, table, metric, 0, SAFI_UNICAST);
else
- rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, gate, index,
+ rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, gate, index,
table, SAFI_UNICAST);
}
#endif /* HAVE_IPV6 */
gateway.s_addr = routeEntry->ipRouteNextHop;
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &prefix,
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &prefix,
&gateway, NULL, 0, 0, 0, 0, SAFI_UNICAST);
}
p.prefixlen = ip_masklen (tmpmask);
sscanf (gate, "%lX", (unsigned long *)&gateway);
- rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, zebra_flags, &p, &gateway, NULL, 0, 0, 0, 0, SAFI_UNICAST);
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, &gateway, NULL, 0, 0, 0, 0, SAFI_UNICAST);
}
fclose (fp);
/* preserve my name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_ZEBRA,
+ zlog_default = openzlog (progname, ZLOG_ZEBRA, 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
while (1)
}
int
-rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+rib_add_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, struct in_addr *src,
unsigned int ifindex, u_int32_t vrf_id,
u_int32_t metric, u_char distance, safi_t safi)
if (rib->type != type)
continue;
+ if (rib->instance != instance)
+ continue;
if (rib->type != ZEBRA_ROUTE_CONNECT)
{
same = rib;
/* Allocate new rib structure. */
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
rib->type = type;
+ rib->instance = instance;
rib->distance = distance;
rib->flags = flags;
rib->metric = metric;
zlog_debug ("%s: dumping RIB entry %p for %s/%d", func, rib, straddr, p->prefixlen);
zlog_debug
(
- "%s: refcnt == %lu, uptime == %lu, type == %u, table == %d",
+ "%s: refcnt == %lu, uptime == %lu, type == %u, instance == %d, table == %d",
func,
rib->refcnt,
(unsigned long) rib->uptime,
rib->type,
+ rib->instance,
rib->table
);
zlog_debug
if (CHECK_FLAG (same->status, RIB_ENTRY_REMOVED))
continue;
- if (same->type == rib->type && same->table == rib->table
+ if (same->type == rib->type && same->instance == rib->instance
+ && same->table == rib->table
&& same->type != ZEBRA_ROUTE_CONNECT)
break;
}
/* XXX factor with rib_delete_ipv6 */
int
-rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+rib_delete_ipv4 (int type, u_short instance, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi)
{
struct route_table *table;
if (rib->type != type)
continue;
+ if (rib->instance != instance)
+ continue;
if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX)
{
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
rib->type = ZEBRA_ROUTE_STATIC;
+ rib->instance = 0;
rib->distance = si->distance;
rib->metric = 0;
rib->table = zebrad.rtm_table_default;
}
int
-rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p,
+rib_add_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p,
struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id,
u_int32_t metric, u_char distance, safi_t safi)
{
if (rib->type != type)
continue;
+ if (rib->instance != instance)
+ continue;
if (rib->type != ZEBRA_ROUTE_CONNECT)
{
same = rib;
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
rib->type = type;
+ rib->instance = instance;
rib->distance = distance;
rib->flags = flags;
rib->metric = metric;
continue;
}
+ if (same->instance != rib->instance) {
+ continue;
+ }
+
if (same->table != rib->table) {
continue;
}
/* XXX factor with rib_delete_ipv6 */
int
-rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
+rib_delete_ipv6 (int type, u_short instance, int flags, struct prefix_ipv6 *p,
struct in6_addr *gate, unsigned int ifindex, u_int32_t vrf_id, safi_t safi)
{
struct route_table *table;
if (rib->type != type)
continue;
+ if (rib->instance != instance)
+ continue;
if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
nexthop->type == NEXTHOP_TYPE_IFINDEX)
{
rib = XCALLOC (MTYPE_RIB, sizeof (struct rib));
rib->type = ZEBRA_ROUTE_STATIC;
+ rib->instance = 0;
rib->distance = si->distance;
rib->metric = 0;
rib->table = zebrad.rtm_table_default;
/* Remove specific by protocol routes from 'table'. */
static unsigned long
-rib_score_proto_table (u_char proto, struct route_table *table)
+rib_score_proto_table (u_char proto, u_short instance, struct route_table *table)
{
struct route_node *rn;
struct rib *rib;
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
continue;
- if (rib->type == proto)
+ if (rib->type == proto && rib->instance == instance)
{
rib_delnode (rn, rib);
n++;
/* Remove specific by protocol routes. */
unsigned long
-rib_score_proto (u_char proto)
+rib_score_proto (u_char proto, u_short instance)
{
- return rib_score_proto_table (proto, vrf_table (AFI_IP, SAFI_UNICAST, 0))
- +rib_score_proto_table (proto, vrf_table (AFI_IP6, SAFI_UNICAST, 0));
+ return rib_score_proto_table (proto, instance, vrf_table (AFI_IP, SAFI_UNICAST, 0))
+ +rib_score_proto_table (proto, instance, vrf_table (AFI_IP6, SAFI_UNICAST, 0));
}
/* Close RIB and clean up kernel routes. */
vty_out (vty, "Routing entry for %s/%d%s",
inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
VTY_NEWLINE);
- vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
+ vty_out (vty, " Known via \"%s", zebra_route_string (rib->type));
+ if (rib->instance)
+ vty_out (vty, "[%d]", rib->instance);
+ vty_out (vty, "\"");
vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
if (rib->tag)
vty_out (vty, ", tag %d", rib->tag);
if (nexthop == rib->nexthop)
{
/* Prefix information. */
- len = vty_out (vty, "%c%c%c %s/%d",
- zebra_route_char (rib->type),
+ len = vty_out (vty, "%c", zebra_route_char (rib->type));
+ if (rib->instance)
+ len += vty_out (vty, "[%d]", rib->instance);
+ len += vty_out (vty, "%c%c %s/%d",
CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
? '>' : ' ',
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
? '*' : ' ',
inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ),
rn->p.prefixlen);
-
+
/* Distance and metric display. */
if (rib->type != ZEBRA_ROUTE_CONNECT
&& rib->type != ZEBRA_ROUTE_KERNEL)
return CMD_SUCCESS;
}
+DEFUN (show_ip_route_ospf_instance,
+ show_ip_route_ospf_instance_cmd,
+ "show ip route ospf <1-65535>",
+ SHOW_STR
+ IP_STR
+ "IP routing table\n"
+ "Open Shortest Path First (OSPFv2)\n"
+ "Instance ID\n")
+{
+ struct route_table *table;
+ struct route_node *rn;
+ struct rib *rib;
+ int first = 1;
+ u_short instance = 0;
+
+ VTY_GET_INTEGER ("Instance", instance, argv[0]);
+
+ table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
+ if (! table)
+ return CMD_SUCCESS;
+
+ /* Show matched type IPv4 routes. */
+ for (rn = route_top (table); rn; rn = route_next (rn))
+ RNODE_FOREACH_RIB (rn, rib)
+ if (rib->type == ZEBRA_ROUTE_OSPF && rib->instance == instance)
+ {
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V4_HEADER);
+ first = 0;
+ }
+ vty_show_ip_route (vty, rn, rib);
+ }
+ return CMD_SUCCESS;
+}
+
DEFUN (show_ip_route_addr,
show_ip_route_addr_cmd,
"show ip route A.B.C.D",
install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_cmd);
install_element (VIEW_NODE, &show_ip_route_cmd);
+ install_element (VIEW_NODE, &show_ip_route_ospf_instance_cmd);
install_element (VIEW_NODE, &show_ip_route_tag_cmd);
install_element (VIEW_NODE, &show_ip_nht_cmd);
install_element (VIEW_NODE, &show_ipv6_nht_cmd);
install_element (VIEW_NODE, &show_ip_route_summary_cmd);
install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
install_element (ENABLE_NODE, &show_ip_route_cmd);
+ install_element (ENABLE_NODE, &show_ip_route_ospf_instance_cmd);
install_element (ENABLE_NODE, &show_ip_route_tag_cmd);
install_element (ENABLE_NODE, &show_ip_nht_cmd);
install_element (ENABLE_NODE, &show_ipv6_nht_cmd);
return 0;
}
-/* When client connects, it sends hello message
- * with promise to send zebra routes of specific type.
- * Zebra stores a socket fd of the client into
- * this array. And use it to clean up routes that
- * client didn't remove for some reasons after closing
- * connection.
- */
-static int route_type_oaths[ZEBRA_ROUTE_MAX];
-
static int
zserv_flush_data(struct thread *thread)
{
/* Put type and nexthop. */
stream_putc (s, rib->type);
+ stream_putw (s, rib->instance);
stream_putc (s, rib->flags);
/* marker for message flags field */
/* Type, flags, message. */
rib->type = stream_getc (s);
+ rib->instance = stream_getw (s);
rib->flags = stream_getc (s);
message = stream_getc (s);
safi = stream_getw (s);
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
api.safi = stream_getw (s);
else
api.tag = 0;
- rib_delete_ipv4 (api.type, api.flags, &p, nexthop_p, ifindex,
+ rib_delete_ipv4 (api.type, api.instance, api.flags, &p, nexthop_p, ifindex,
client->rtm_table, api.safi);
client->v4_route_del_cnt++;
return 0;
/* Type, flags, message. */
rib->type = stream_getc (s);
+ rib->instance = stream_getw (s);
rib->flags = stream_getc (s);
message = stream_getc (s);
safi = stream_getw (s);
/* Type, flags, message. */
api.type = stream_getc (s);
+ api.instance = stream_getw (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
api.safi = stream_getw (s);
api.tag = 0;
if (IN6_IS_ADDR_UNSPECIFIED (&nexthop))
- rib_delete_ipv6 (api.type, api.flags, &p, NULL, ifindex, client->rtm_table, api.safi);
+ rib_delete_ipv6 (api.type, api.instance, api.flags, &p, NULL, ifindex, client->rtm_table, api.safi);
else
- rib_delete_ipv6 (api.type, api.flags, &p, &nexthop, ifindex, client->rtm_table, api.safi);
+ rib_delete_ipv6 (api.type, api.instance, api.flags, &p, &nexthop, ifindex, client->rtm_table, api.safi);
client->v6_route_del_cnt++;
return 0;
{
/* type of protocol (lib/zebra.h) */
u_char proto;
+ u_short instance;
+
proto = stream_getc (client->ibuf);
+ instance = stream_getw (client->ibuf);
/* accept only dynamic routing protocols */
if ((proto < ZEBRA_ROUTE_MAX)
{
zlog_notice ("client %d says hello and bids fair to announce only %s routes",
client->sock, zebra_route_string(proto));
+ if (instance)
+ zlog_notice ("client protocol instance %d", instance);
- /* if route-type was binded by other client */
- if (route_type_oaths[proto])
- zlog_warn ("sender of %s routes changed %c->%c",
- zebra_route_string(proto), route_type_oaths[proto],
- client->sock);
-
- route_type_oaths[proto] = client->sock;
client->proto = proto;
+ client->instance = instance;
}
}
-/* If client sent routes of specific type, zebra removes it
- * and returns number of deleted routes.
- */
-static void
-zebra_score_rib (int client_sock)
-{
- int i;
-
- for (i = ZEBRA_ROUTE_RIP; i < ZEBRA_ROUTE_MAX; i++)
- if (client_sock == route_type_oaths[i])
- {
- zlog_notice ("client %d disconnected. %lu %s routes removed from the rib",
- client_sock, rib_score_proto (i), zebra_route_string (i));
- route_type_oaths[i] = 0;
- break;
- }
-}
-
/* Close zebra client. */
static void
zebra_client_close (struct zserv *client)
/* Close file descriptor. */
if (client->sock)
{
+ unsigned long nroutes;
+
close (client->sock);
- zebra_score_rib (client->sock);
+ nroutes = rib_score_proto (client->proto, client->instance);
+ zlog_notice ("client %d disconnected. %lu %s routes removed from the rib",
+ client->sock, nroutes, zebra_route_string (client->proto));
client->sock = -1;
}
return;
}
- memset (&route_type_oaths, 0, sizeof (route_type_oaths));
memset (&addr, 0, sizeof (struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_port = htons (ZEBRA_PORT);
return;
}
- memset (&route_type_oaths, 0, sizeof (route_type_oaths));
-
/* Make server socket. */
memset (&serv, 0, sizeof (struct sockaddr_un));
serv.sun_family = AF_UNIX;
char cbuf[ZEBRA_TIME_BUF], rbuf[ZEBRA_TIME_BUF];
char wbuf[ZEBRA_TIME_BUF], nhbuf[ZEBRA_TIME_BUF], mbuf[ZEBRA_TIME_BUF];
- vty_out (vty, "Client: %s %s",
- zebra_route_string(client->proto), VTY_NEWLINE);
+ vty_out (vty, "Client: %s", zebra_route_string(client->proto));
+ if (client->instance)
+ vty_out (vty, " Instance: %d", client->instance);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
vty_out (vty, "------------------------ %s", VTY_NEWLINE);
vty_out (vty, "FD: %d %s", client->sock, VTY_NEWLINE);
vty_out (vty, "Route Table ID: %d %s", client->rtm_table, VTY_NEWLINE);
#include "if.h"
#include "workqueue.h"
#include "routemap.h"
+#include "zclient.h"
/* Default port information. */
#define ZEBRA_VTY_PORT 2601
int rtm_table;
/* This client's redistribute flag. */
- u_char redist[ZEBRA_ROUTE_MAX];
+ struct redist_proto redist[ZEBRA_ROUTE_MAX];
/* Redistribute default route flag. */
u_char redist_default;
/* client's protocol */
u_char proto;
+ u_short instance;
/* Statistics */
u_int32_t redist_v4_add_cnt;