QUAGGA_REDIST_HELP_STR_BABELD)
{
int type;
+ afi_t afi;
- type = proto_redistnum(AFI_IP6, argv[0]);
+ afi = AFI_IP6;
+ type = proto_redistnum(afi, argv[0]);
if (type < 0)
- type = proto_redistnum(AFI_IP, argv[0]);
+ {
+ afi = AFI_IP;
+ type = proto_redistnum(afi, argv[0]);
+ }
if (type < 0) {
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0);
return CMD_SUCCESS;
}
QUAGGA_REDIST_HELP_STR_BABELD)
{
int type;
+ afi_t afi;
- type = proto_redistnum(AFI_IP6, argv[0]);
+ afi = AFI_IP6;
+ type = proto_redistnum(afi, argv[0]);
if (type < 0)
- type = proto_redistnum(AFI_IP, argv[0]);
+ {
+ afi = AFI_IP;
+ type = proto_redistnum(afi, argv[0]);
+ }
if (type < 0) {
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0);
/* perhaps should we remove xroutes having the same type... */
return CMD_SUCCESS;
}
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
- else if (! zclient->redist[ZEBRA_ROUTE_BABEL].enabled)
+ else if (! (zclient->redist[AFI_IP][ZEBRA_ROUTE_BABEL].enabled ||
+ zclient->redist[AFI_IP6][ZEBRA_ROUTE_BABEL].enabled))
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute babel%s", VTY_NEWLINE);
{
int lines = 0;
int i;
+ afi_t afi;
/* list enabled debug modes */
lines += debug_babel_config_write (vty);
/* list enabled interfaces */
lines = 1 + babel_enable_if_config_write (vty);
/* list redistributed protocols */
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != zclient->redist_default &&
- zclient->redist[i].enabled)
- {
+ zclient->redist[afi][i].enabled)
+ {
vty_out (vty, " redistribute %s%s", zebra_route_string (i), VTY_NEWLINE);
lines++;
- }
+ }
return lines;
}
return CMD_WARNING;
}
bgp_redist_add(vty->index, AFI_IP, type, 0);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap,
red = bgp_redist_add(vty->index, AFI_IP, type, 0);
bgp_redistribute_rmap_set (red, argv[1]);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric,
red = bgp_redist_add(vty->index, AFI_IP, type, 0);
bgp_redistribute_metric_set (red, metric);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_rmap_metric,
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);
+ return bgp_redistribute_set (AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_metric_rmap,
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);
+ return bgp_redistribute_set (AFI_IP, type, 0);
}
DEFUN (bgp_redistribute_ipv4_ospf,
protocol = ZEBRA_ROUTE_TABLE;
bgp_redist_add(vty->index, AFI_IP, protocol, instance);
- return bgp_redistribute_set (protocol, instance);
+ return bgp_redistribute_set (AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_rmap,
VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
bgp_redistribute_rmap_set (red, argv[2]);
- return bgp_redistribute_set (protocol, instance);
+ return bgp_redistribute_set (AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_metric,
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
bgp_redistribute_metric_set (red, metric);
- return bgp_redistribute_set (protocol, instance);
+ return bgp_redistribute_set (AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
bgp_redistribute_rmap_set (red, argv[2]);
bgp_redistribute_metric_set (red, metric);
- return bgp_redistribute_set (protocol, instance);
+ return bgp_redistribute_set (AFI_IP, protocol, instance);
}
DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
bgp_redistribute_metric_set (red, metric);
bgp_redistribute_rmap_set (red, argv[3]);
- return bgp_redistribute_set (protocol, instance);
+ return bgp_redistribute_set (AFI_IP, protocol, instance);
}
DEFUN (no_bgp_redistribute_ipv4_ospf,
}
bgp_redist_add(vty->index, AFI_IP6, type, 0);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap,
red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
bgp_redistribute_rmap_set (red, argv[1]);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric,
red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
bgp_redistribute_metric_set (red, metric);
- return bgp_redistribute_set (type, 0);
+ return bgp_redistribute_set (AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_rmap_metric,
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);
+ return bgp_redistribute_set (AFI_IP6, type, 0);
}
DEFUN (bgp_redistribute_ipv6_metric_rmap,
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);
+ return bgp_redistribute_set (AFI_IP6, type, 0);
}
DEFUN (no_bgp_redistribute_ipv6,
if (zclient->sock < 0)
return;
- if (!zclient->redist[ZEBRA_ROUTE_BGP].enabled)
+ if ((p->family == AF_INET && !zclient->redist[AFI_IP][ZEBRA_ROUTE_BGP].enabled)
+ || (p->family == AF_INET6 && !zclient->redist[AFI_IP6][ZEBRA_ROUTE_BGP].enabled))
return;
if (bgp->main_zebra_update_hold)
if (zclient->sock < 0)
return;
- if (!zclient->redist[ZEBRA_ROUTE_BGP].enabled)
+ if ((p->family == AF_INET && !zclient->redist[AFI_IP][ZEBRA_ROUTE_BGP].enabled)
+ || (p->family == AF_INET6 && !zclient->redist[AFI_IP6][ZEBRA_ROUTE_BGP].enabled))
return;
peer = info->peer;
/* Other routes redistribution into BGP. */
int
-bgp_redistribute_set (int type, u_short instance)
+bgp_redistribute_set (afi_t afi, int type, u_short instance)
{
/* Return if already redistribute flag is set. */
- if (redist_check_instance(&zclient->redist[type], instance))
+ if (redist_check_instance(&zclient->redist[afi][type], instance))
return CMD_WARNING;
- redist_add_instance(&zclient->redist[type], instance);
+ redist_add_instance(&zclient->redist[afi][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 %d", zebra_route_string(type),
- instance);
+ zlog_debug("Zebra send: redistribute add afi %d %s %d", afi,
+ zebra_route_string(type), instance);
/* Send distribute add message to zebra. */
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, instance);
return CMD_SUCCESS;
}
return -1;
if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Zebra send: redistribute add %s %d", zebra_route_string(type),
- instance);
+ zlog_debug("Zebra send: redistribute delete/add afi %d %s %d", afi,
+ zebra_route_string(type), instance);
/* Send distribute add message to zebra. */
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, instance);
return 0;
}
bgp_redist_del(bgp, afi, type, instance);
/* Return if zebra connection is disabled. */
- if (!redist_check_instance(&zclient->redist[type], instance))
+ if (!redist_check_instance(&zclient->redist[afi][type], instance))
return CMD_WARNING;
- redist_del_instance(&zclient->redist[type], instance);
+ redist_del_instance(&zclient->redist[afi][type], instance);
- if (!bgp_redist_lookup(bgp, AFI_IP, type, instance)
- && !bgp_redist_lookup(bgp, AFI_IP6, type, instance)
- && zclient->sock >= 0)
+ if (zclient->sock >= 0)
{
/* Send distribute delete message to zebra. */
if (BGP_DEBUG (zebra, ZEBRA))
- zlog_debug("Zebra send: redistribute delete %s %d",
- zebra_route_string(type), instance);
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
+ zlog_debug("Zebra send: redistribute delete afi %d %s %d",
+ afi, zebra_route_string(type), instance);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, instance);
}
/* Withdraw redistributed routes from current BGP's routing table. */
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_set (afi_t, 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);
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
return;
- if (zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
+ if (zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS].enabled)
{
message = 0;
flags = 0;
struct zapi_ipv4 api;
struct prefix_ipv4 prefix4;
- if (zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
+ if (zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS].enabled)
{
api.type = ZEBRA_ROUTE_ISIS;
api.instance = 0;
if (zclient->sock < 0)
return;
- if (!zclient->redist[ZEBRA_ROUTE_ISIS].enabled)
+ if ((prefix->family == AF_INET && !zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS].enabled) ||
+ (prefix->family == AF_INET6 && !zclient->redist[AFI_IP6][ZEBRA_ROUTE_ISIS].enabled))
return;
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
#define ISIS_TYPE_IS_REDISTRIBUTED(T) \
T == ZEBRA_ROUTE_MAX ? zclient->default_information : \
-zclient->redist[type].enabled
+(zclient->redist[AFI_IP][type].enabled || client->redist[AFI_IP6][type].enabled)
int
isis_distribute_list_update (int routetype)
void
zclient_init (struct zclient *zclient, int redist_default, u_short instance)
{
- int i;
+ int afi, i;
/* Enable zebra client connection by default. */
zclient->enable = 1;
zclient->sock = -1;
/* Clear redistribution flags. */
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- memset(&zclient->redist[i], 0, sizeof(struct redist_proto));
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ memset(&zclient->redist[afi][i], 0, sizeof(struct redist_proto));
/* Set unwanted redistribute route. bgpd does not need BGP route
redistribution. */
zclient->redist_default = redist_default;
zclient->instance = instance;
- redist_add_instance (&zclient->redist[redist_default], instance);
+ /* Pending: make afi(s) an arg. */
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ redist_add_instance (&zclient->redist[afi][redist_default], instance);
/* Set default-information redistribute to zero. */
zclient->default_information = 0;
zclient_start (struct zclient *zclient)
{
int i;
+ afi_t afi;
if (zclient_debug)
zlog_debug ("zclient_start is called");
zebra_message_send (zclient, ZEBRA_INTERFACE_ADD);
/* Flush all redistribute request. */
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (zclient->redist[i].enabled)
- {
- struct listnode *node;
- u_short *id;
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ if (zclient->redist[afi][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);
- }
+ for (ALL_LIST_ELEMENTS_RO(zclient->redist[afi][i].instances, node, id))
+ if (!(i == zclient->redist_default && *id == zclient->instance))
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, i, *id);
+ }
/* If default information is needed. */
if (zclient->default_information)
* sending client
*/
int
-zebra_redistribute_send (int command, struct zclient *zclient, int type,
+zebra_redistribute_send (int command, struct zclient *zclient, afi_t afi, int type,
u_short instance)
{
struct stream *s;
stream_reset(s);
zclient_create_header (s, command);
+ stream_putc (s, afi);
stream_putc (s, type);
stream_putw (s, instance);
}
void
-zclient_redistribute (int command, struct zclient *zclient, int type,
+zclient_redistribute (int command, struct zclient *zclient, afi_t afi, int type,
u_short instance)
{
if (command == ZEBRA_REDISTRIBUTE_ADD)
{
- if (redist_check_instance(&zclient->redist[type], instance))
+ if (redist_check_instance(&zclient->redist[afi][type], instance))
return;
- redist_add_instance(&zclient->redist[type], instance);
+ redist_add_instance(&zclient->redist[afi][type], instance);
}
else
{
- if (!redist_check_instance(&zclient->redist[type], instance))
+ if (!redist_check_instance(&zclient->redist[afi][type], instance))
return;
- redist_del_instance(&zclient->redist[type], instance);
+ redist_del_instance(&zclient->redist[afi][type], instance);
}
if (zclient->sock > 0)
- zebra_redistribute_send (command, zclient, type, instance);
+ zebra_redistribute_send (command, zclient, afi, type, instance);
}
/* Redistribute information. */
u_char redist_default; /* clients protocol */
u_short instance;
- struct redist_proto redist[ZEBRA_ROUTE_MAX];
+ struct redist_proto redist[AFI_MAX][ZEBRA_ROUTE_MAX];
/* Redistribute defauilt. */
u_char default_information;
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, u_short instance);
+extern int zebra_redistribute_send (int command, struct zclient *, afi_t, 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 *, afi_t, int type,
u_short instance);
/* If state has changed, update state and send the command to zebra. */
void
ospf6_zebra_redistribute (int type)
{
- if (zclient->redist[type].enabled)
+ if (zclient->redist[AFI_IP6][type].enabled)
return;
- redist_add_instance(&zclient->redist[type], 0);
+ redist_add_instance(&zclient->redist[AFI_IP6][type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0);
}
void
ospf6_zebra_no_redistribute (int type)
{
- if (! zclient->redist[type].enabled)
+ if (! zclient->redist[AFI_IP6][type].enabled)
return;
- redist_del_instance(&zclient->redist[type], 0);
+ redist_del_instance(&zclient->redist[AFI_IP6][type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0);
}
/* Inteface addition message from zebra. */
vty_out (vty, " redistribute:");
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
- if (zclient->redist[i].enabled)
+ if (zclient->redist[AFI_IP6][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].enabled)
+ else if (! zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6].enabled)
{
vty_out (vty, "router zebra%s", VNL);
vty_out (vty, " no redistribute ospf6%s", VNL);
void
ospf6_zebra_route_update_add (struct ospf6_route *request)
{
- if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
+ if (! zclient->redist[AFI_IP6][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].enabled)
+ if (! zclient->redist[AFI_IP6][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].enabled)
+ if (zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6].enabled)
{
if (!CHECK_FLAG (request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED))
{
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
+ if (zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6].enabled)
{
if (CHECK_FLAG (request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED))
{
{
struct ospf6_route *route;
- if (zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
+ if (zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6].enabled)
return CMD_SUCCESS;
- redist_add_instance(&zclient->redist[ZEBRA_ROUTE_OSPF6], 0);
+ redist_add_instance(&zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6], 0);
if (ospf6 == NULL)
return CMD_SUCCESS;
{
struct ospf6_route *route;
- if (! zclient->redist[ZEBRA_ROUTE_OSPF6].enabled)
+ if (! zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6].enabled)
return CMD_SUCCESS;
- redist_del_instance(&zclient->redist[ZEBRA_ROUTE_OSPF6], 0);
+ redist_del_instance(&zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6], 0);
if (ospf6 == NULL)
return CMD_SUCCESS;
extern void ospf6_zebra_redistribute (int);
extern void ospf6_zebra_no_redistribute (int);
-#define ospf6_zebra_is_redistribute(type) (zclient->redist[type].enabled)
+#define ospf6_zebra_is_redistribute(type) (zclient->redist[AFI_IP6][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);
int redist_on = 0;
redist_on = is_prefix_default (&p) ? zclient->default_information :
- zclient->redist[type].enabled;
+ zclient->redist[AFI_IP][type].enabled;
if (redist_on)
{
struct list *ext_list;
#endif /* HAVE_NETLINK */
struct ospf *ospf = ospf_lookup ();
- if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
+ if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance))
{
message = 0;
flags = 0;
struct listnode *node;
struct ospf *ospf = ospf_lookup ();
- if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
+ if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance))
{
message = 0;
flags = 0;
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup ();
- if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
+ if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance))
{
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup ();
- if (redist_check_instance(&zclient->redist[ZEBRA_ROUTE_OSPF], ospf->instance))
+ if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance))
{
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
{
return (DEFAULT_ROUTE_TYPE (type) ?
zclient->default_information :
- redist_check_instance(&zclient->redist[type], instance));
+ redist_check_instance(&zclient->redist[AFI_IP][type], instance));
}
int
ospf_external_add(type, instance);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, instance);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, instance);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[%s][%d]: Start Type[%d], Metric[%d]",
if (!ospf_is_type_redistributed (type, instance))
return CMD_SUCCESS;
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, instance);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, instance);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[%s][%d]: Stop",
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_RIP].enabled)
+ if (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP].enabled)
{
api.type = ZEBRA_ROUTE_RIP;
api.instance = 0;
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_RIP].enabled)
+ if (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP].enabled)
{
api.type = ZEBRA_ROUTE_RIP;
api.instance = 0;
static int
rip_redistribute_set (int type)
{
- if (zclient->redist[type])
+ if (zclient->redist[AFI_IP][type])
return CMD_SUCCESS;
- zclient->redist[type] = 1;
+ zclient->redist[AFI_IP][type] = 1;
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type);
return CMD_SUCCESS;
}
static int
rip_redistribute_unset (int type)
{
- if (! zclient->redist[type].enabled)
+ if (! zclient->redist[AFI_IP][type].enabled)
return CMD_SUCCESS;
- redist_del_instance(&zclient->redist[type], 0);
+ redist_del_instance(&zclient->redist[AFI_IP][type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0);
/* Remove the routes from RIP table. */
rip_redistribute_withdraw (type);
int
rip_redistribute_check (int type)
{
- return (zclient->redist[type].enabled);
+ return (zclient->redist[AFI_IP][type].enabled);
}
void
for (i = 0; redist_type[i].str; i++)
{
- if (zclient->redist[redist_type[i].type].enabled)
+ if (zclient->redist[AFI_IP][redist_type[i].type].enabled)
{
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
- zclient, redist_type[i].type, 0);
+ zclient, AFI_IP, redist_type[i].type, 0);
- redist_del_instance(&zclient->redist[redist_type[i].type], 0);
+ redist_del_instance(&zclient->redist[AFI_IP][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")
{
- redist_add_instance(&zclient->redist[ZEBRA_ROUTE_RIP], 0);
+ redist_add_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], 0);
return CMD_SUCCESS;
}
"Redistribute information from another routing protocol\n"
"Routing Information Protocol (RIP)\n")
{
- redist_del_instance(&zclient->redist[ZEBRA_ROUTE_RIP], 0);
+ redist_del_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], 0);
return CMD_SUCCESS;
}
redist_type[i].str_min_len) == 0)
{
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient,
- redist_type[i].type, 0);
+ AFI_IP, 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, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
+ 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, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
+ 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, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
+ 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].enabled)
+ else if (! zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP].enabled)
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute rip%s", VTY_NEWLINE);
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != zclient->redist_default &&
- zclient->redist[i].enabled)
+ zclient->redist[AFI_IP][i].enabled)
{
if (config_mode)
{
{
struct zapi_ipv6 api;
- if (zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
+ if (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG].enabled)
{
api.type = ZEBRA_ROUTE_RIPNG;
api.instance = 0;
{
struct zapi_ipv6 api;
- if (zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
+ if (zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG].enabled)
{
api.type = ZEBRA_ROUTE_RIPNG;
api.instance = 0;
static int
ripng_redistribute_unset (int type)
{
- if (! zclient->redist[type].enabled)
+ if (! zclient->redist[AFI_IP6][type].enabled)
return CMD_SUCCESS;
- redist_del_instance(&zclient->redist[type], 0);
+ redist_del_instance(&zclient->redist[AFI_IP6][type], 0);
if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, 0);
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0);
ripng_redistribute_withdraw (type);
int
ripng_redistribute_check (int type)
{
- return (zclient->redist[type].enabled);
+ return (zclient->redist[AFI_IP6][type].enabled);
}
static void
for (i = 0; redist_type[i].str; i++)
{
- if (zclient->redist[redist_type[i].type].enabled)
+ if (zclient->redist[AFI_IP6][redist_type[i].type].enabled)
{
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
- zclient, redist_type[i].type, 0);
+ zclient, AFI_IP6, redist_type[i].type, 0);
- redist_del_instance(&zclient->redist[redist_type[i].type], 0);
+ redist_del_instance(&zclient->redist[AFI_IP6][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")
{
- redist_add_instance(&zclient->redist[ZEBRA_ROUTE_RIPNG], 0);
+ redist_add_instance(&zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], 0);
return CMD_SUCCESS;
}
"Redistribute information from another routing protocol\n"
"RIPng route\n")
{
- redist_del_instance(&zclient->redist[ZEBRA_ROUTE_RIPNG], 0);
+ redist_del_instance(&zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG], 0);
return CMD_SUCCESS;
}
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0);
return CMD_SUCCESS;
}
}
ripng_redistribute_metric_set (type, metric);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0);
return CMD_SUCCESS;
}
}
ripng_redistribute_routemap_set (type, argv[1]);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, 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, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0);
return CMD_SUCCESS;
}
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != zclient->redist_default &&
- zclient->redist[i].enabled)
+ zclient->redist[AFI_IP6][i].enabled)
{
if (config_mode)
{
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
- else if (! zclient->redist[ZEBRA_ROUTE_RIPNG].enabled)
+ else if (! zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG].enabled)
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute ripng%s", VTY_NEWLINE);
{
if (is_default (p))
{
- if (client->redist_default ||
- redist_check_instance(&client->redist[rib->type], rib->instance))
- {
- if (p->family == AF_INET)
- {
- client->redist_v4_add_cnt++;
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
- }
+ if ((p->family == AF_INET) &&
+ (client->redist_default ||
+ redist_check_instance(&client->redist[AFI_IP][rib->type],
+ rib->instance)))
+ {
+ client->redist_v4_add_cnt++;
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ }
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- {
- client->redist_v6_add_cnt++;
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
- }
+ if ((p->family == AF_INET6) &&
+ (client->redist_default ||
+ redist_check_instance(&client->redist[AFI_IP6][rib->type],
+ rib->instance)))
+ {
+ client->redist_v6_add_cnt++;
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ }
#endif /* HAVE_IPV6 */
- }
}
- else if (redist_check_instance(&client->redist[rib->type], rib->instance))
+ else
{
- if (p->family == AF_INET)
+ if ((p->family == AF_INET) &&
+ redist_check_instance(&client->redist[AFI_IP][rib->type],
+ rib->instance))
{
client->redist_v4_add_cnt++;
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
- }
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ }
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- {
- client->redist_v6_add_cnt++;
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
- }
+ if ((p->family == AF_INET6) &&
+ redist_check_instance(&client->redist[AFI_IP6][rib->type],
+ rib->instance))
+ {
+ client->redist_v6_add_cnt++;
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ }
#endif /* HAVE_IPV6 */
}
}
{
if (is_default (p))
{
- 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,
+ if ((p->family == AF_INET) &&
+ (client->redist_default ||
+ redist_check_instance(&client->redist[AFI_IP][rib->type],
+ rib->instance)))
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
+ if ((p->family == AF_INET6) &&
+ (client->redist_default ||
+ redist_check_instance(&client->redist[AFI_IP6][rib->type],
+ rib->instance)))
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
rib);
#endif /* HAVE_IPV6 */
- }
}
- 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);
+ else
+ {
+ if ((p->family == AF_INET) &&
+ redist_check_instance(&client->redist[AFI_IP][rib->type],
+ rib->instance))
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
+ rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
+ if ((p->family == AF_INET6) &&
+ redist_check_instance(&client->redist[AFI_IP6][rib->type],
+ rib->instance))
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
+ rib);
#endif /* HAVE_IPV6 */
}
}
void
zebra_redistribute_add (int command, struct zserv *client, int length)
{
+ afi_t afi;
int type;
u_short instance;
+ afi = stream_getc (client->ibuf);
type = stream_getc (client->ibuf);
instance = stream_getw (client->ibuf);
if (type == 0 || type >= ZEBRA_ROUTE_MAX)
return;
- if (!redist_check_instance(&client->redist[type], instance))
+ if (!redist_check_instance(&client->redist[afi][type], instance))
{
- redist_add_instance(&client->redist[type], instance);
+ redist_add_instance(&client->redist[afi][type], instance);
zebra_redistribute (client, type, instance);
}
}
void
zebra_redistribute_delete (int command, struct zserv *client, int length)
{
+ afi_t afi;
int type;
u_short instance;
+ afi = stream_getc (client->ibuf);
type = stream_getc (client->ibuf);
instance = stream_getw (client->ibuf);
if (type == 0 || type >= ZEBRA_ROUTE_MAX)
return;
- if (redist_check_instance(&client->redist[type], instance))
+ if (redist_check_instance(&client->redist[afi][type], instance))
{
- redist_del_instance(&client->redist[type], instance);
+ redist_del_instance(&client->redist[afi][type], instance);
//Pending: why no reaction here?
}
}
int rtm_table;
/* This client's redistribute flag. */
- struct redist_proto redist[ZEBRA_ROUTE_MAX];
+ struct redist_proto redist[AFI_MAX][ZEBRA_ROUTE_MAX];
/* Redistribute default route flag. */
u_char redist_default;