summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--babeld/babel_zebra.c25
-rw-r--r--babeld/babeld.c10
-rw-r--r--bgpd/bgp_vty.c30
-rw-r--r--bgpd/bgp_zebra.c40
-rw-r--r--bgpd/bgp_zebra.h2
-rw-r--r--isisd/isis_zebra.c9
-rw-r--r--lib/zclient.c46
-rw-r--r--lib/zclient.h6
-rw-r--r--ospf6d/ospf6_zebra.c32
-rw-r--r--ospf6d/ospf6_zebra.h2
-rw-r--r--ospfd/ospf_flood.c2
-rw-r--r--ospfd/ospf_zebra.c14
-rw-r--r--ripd/rip_zebra.c43
-rw-r--r--ripngd/ripng_zebra.c34
-rw-r--r--zebra/redistribute.c100
-rw-r--r--zebra/zserv.h2
16 files changed, 219 insertions, 178 deletions
diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c
index f584e0396e..c7236d3201 100644
--- a/babeld/babel_zebra.c
+++ b/babeld/babel_zebra.c
@@ -196,18 +196,23 @@ DEFUN (babel_redistribute_type,
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;
}
@@ -220,18 +225,23 @@ DEFUN (no_babel_redistribute_type,
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;
}
@@ -364,7 +374,8 @@ zebra_config_write (struct vty *vty)
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);
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 334f64c311..fff0f61313 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -95,6 +95,7 @@ babel_config_write (struct vty *vty)
{
int lines = 0;
int i;
+ afi_t afi;
/* list enabled debug modes */
lines += debug_babel_config_write (vty);
@@ -110,13 +111,14 @@ babel_config_write (struct vty *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;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 348687d38a..eb3c01e9f5 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -9681,7 +9681,7 @@ DEFUN (bgp_redistribute_ipv4,
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,
@@ -9704,7 +9704,7 @@ 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,
@@ -9729,7 +9729,7 @@ 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,
@@ -9757,7 +9757,7 @@ 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,
@@ -9785,7 +9785,7 @@ 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,
@@ -9806,7 +9806,7 @@ 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,
@@ -9830,7 +9830,7 @@ 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,
@@ -9857,7 +9857,7 @@ 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,
@@ -9887,7 +9887,7 @@ 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,
@@ -9917,7 +9917,7 @@ 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,
@@ -10059,7 +10059,7 @@ DEFUN (bgp_redistribute_ipv6,
}
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,
@@ -10082,7 +10082,7 @@ 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,
@@ -10107,7 +10107,7 @@ 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,
@@ -10135,7 +10135,7 @@ 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,
@@ -10163,7 +10163,7 @@ 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,
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 386de45ede..78735caded 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -944,7 +944,8 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp,
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)
@@ -1284,7 +1285,8 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
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;
@@ -1471,25 +1473,25 @@ bgp_redist_del (struct bgp *bgp, afi_t afi, u_char type, u_short instance)
/* 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;
}
@@ -1502,12 +1504,12 @@ bgp_redistribute_resend (struct bgp *bgp, afi_t afi, int type, u_short instance)
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;
}
@@ -1565,19 +1567,17 @@ bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type, u_short instance)
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. */
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index be94c5a016..2159d296e7 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -40,7 +40,7 @@ extern void bgp_zebra_withdraw (struct prefix *, struct bgp_info *, safi_t);
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);
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index dfedc624c9..8d457c462a 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -236,7 +236,7 @@ isis_zebra_route_add_ipv4 (struct prefix *prefix,
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;
@@ -303,7 +303,7 @@ isis_zebra_route_del_ipv4 (struct prefix *prefix,
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;
@@ -493,7 +493,8 @@ isis_zebra_route_update (struct prefix *prefix,
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))
@@ -577,7 +578,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
#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)
diff --git a/lib/zclient.c b/lib/zclient.c
index f2f910f6b6..29f568f2ad 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -139,7 +139,7 @@ redist_del_instance (struct redist_proto *red, u_short instance)
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;
@@ -148,14 +148,17 @@ zclient_init (struct zclient *zclient, int redist_default, u_short instance)
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;
@@ -400,6 +403,7 @@ int
zclient_start (struct zclient *zclient)
{
int i;
+ afi_t afi;
if (zclient_debug)
zlog_debug ("zclient_start is called");
@@ -445,16 +449,17 @@ zclient_start (struct zclient *zclient)
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)
@@ -694,7 +699,7 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,
* 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;
@@ -703,6 +708,7 @@ zebra_redistribute_send (int command, struct zclient *zclient, int type,
stream_reset(s);
zclient_create_header (s, command);
+ stream_putc (s, afi);
stream_putc (s, type);
stream_putw (s, instance);
@@ -1222,25 +1228,25 @@ zclient_read (struct thread *thread)
}
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);
}
diff --git a/lib/zclient.h b/lib/zclient.h
index 3c214d2785..f73145db00 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -72,7 +72,7 @@ struct zclient
/* 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;
@@ -156,10 +156,10 @@ 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, 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. */
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 78dd0f6d2b..f77ebd7f19 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -70,21 +70,21 @@ ospf6_router_id_update_zebra (int command, struct zclient *zclient,
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. */
@@ -297,7 +297,7 @@ DEFUN (show_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);
@@ -337,7 +337,7 @@ config_write_ospf6_zebra (struct vty *vty)
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);
@@ -472,7 +472,7 @@ ospf6_zebra_route_update (int type, struct ospf6_route *request)
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;
@@ -484,7 +484,7 @@ ospf6_zebra_route_update_add (struct ospf6_route *request)
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;
@@ -500,7 +500,7 @@ ospf6_zebra_add_discard (struct ospf6_route *request)
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))
{
@@ -544,7 +544,7 @@ ospf6_zebra_delete_discard (struct ospf6_route *request)
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))
{
@@ -587,10 +587,10 @@ DEFUN (redistribute_ospf6,
{
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;
@@ -615,10 +615,10 @@ DEFUN (no_redistribute_ospf6,
{
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;
diff --git a/ospf6d/ospf6_zebra.h b/ospf6d/ospf6_zebra.h
index b7a609d3ab..c2e92b67f2 100644
--- a/ospf6d/ospf6_zebra.h
+++ b/ospf6d/ospf6_zebra.h
@@ -42,7 +42,7 @@ extern void ospf6_zebra_route_update_remove (struct ospf6_route *request);
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);
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index 1d107ca0d0..bc41454287 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -95,7 +95,7 @@ ospf_external_info_check (struct ospf_lsa *lsa)
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;
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index ad7e98f099..1f04cc36bb 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -388,7 +388,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
#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;
@@ -533,7 +533,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
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;
@@ -616,7 +616,7 @@ ospf_zebra_add_discard (struct prefix_ipv4 *p)
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;
@@ -642,7 +642,7 @@ ospf_zebra_delete_discard (struct prefix_ipv4 *p)
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;
@@ -791,7 +791,7 @@ ospf_is_type_redistributed (int type, u_short 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
@@ -831,7 +831,7 @@ ospf_redistribute_set (struct ospf *ospf, int type, u_short instance, int mtype,
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]",
@@ -852,7 +852,7 @@ ospf_redistribute_unset (struct ospf *ospf, int type, u_short instance)
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",
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index d0ab21d2bf..22514d5fe7 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -41,7 +41,7 @@ rip_zebra_ipv4_add (struct prefix_ipv4 *p, struct in_addr *nexthop,
{
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;
@@ -73,7 +73,7 @@ rip_zebra_ipv4_delete (struct prefix_ipv4 *p, struct in_addr *nexthop,
{
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;
@@ -243,13 +243,13 @@ DEFUN (no_router_zebra,
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;
}
@@ -258,13 +258,13 @@ rip_redistribute_set (int type)
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);
@@ -275,7 +275,7 @@ rip_redistribute_unset (int type)
int
rip_redistribute_check (int type)
{
- return (zclient->redist[type].enabled);
+ return (zclient->redist[AFI_IP][type].enabled);
}
void
@@ -285,13 +285,13 @@ rip_redistribute_clean (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);
@@ -305,7 +305,7 @@ DEFUN (rip_redistribute_rip,
"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;
}
@@ -316,7 +316,7 @@ DEFUN (no_rip_redistribute_rip,
"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;
}
@@ -334,7 +334,7 @@ DEFUN (rip_redistribute_type,
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;
}
}
@@ -387,7 +387,8 @@ DEFUN (rip_redistribute_type_routemap,
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;
}
}
@@ -445,7 +446,8 @@ DEFUN (rip_redistribute_type_metric,
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;
}
}
@@ -506,7 +508,8 @@ DEFUN (rip_redistribute_type_metric_routemap,
{
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;
}
}
@@ -610,7 +613,7 @@ config_write_zebra (struct vty *vty)
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);
@@ -626,7 +629,7 @@ config_write_rip_redistribute (struct vty *vty, int config_mode)
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)
{
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index 92c8454183..09dd3390f4 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -48,7 +48,7 @@ ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop,
{
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;
@@ -74,7 +74,7 @@ ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop,
{
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;
@@ -156,13 +156,13 @@ ripng_zclient_reset (void)
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);
@@ -172,7 +172,7 @@ ripng_redistribute_unset (int type)
int
ripng_redistribute_check (int type)
{
- return (zclient->redist[type].enabled);
+ return (zclient->redist[AFI_IP6][type].enabled);
}
static void
@@ -232,13 +232,13 @@ ripng_redistribute_clean ()
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);
@@ -276,7 +276,7 @@ DEFUN (ripng_redistribute_ripng,
"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;
}
@@ -287,7 +287,7 @@ DEFUN (no_ripng_redistribute_ripng,
"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;
}
@@ -307,7 +307,7 @@ DEFUN (ripng_redistribute_type,
return CMD_WARNING;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, 0);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0);
return CMD_SUCCESS;
}
@@ -355,7 +355,7 @@ DEFUN (ripng_redistribute_type_metric,
}
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;
}
@@ -387,7 +387,7 @@ DEFUN (ripng_redistribute_type_routemap,
}
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;
}
@@ -424,7 +424,7 @@ DEFUN (ripng_redistribute_type_metric_routemap,
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;
}
@@ -444,7 +444,7 @@ ripng_redistribute_write (struct vty *vty, int config_mode)
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)
{
@@ -484,7 +484,7 @@ zebra_config_write (struct vty *vty)
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);
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 701b83493f..2ee5da5d94 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -208,36 +208,42 @@ redistribute_add (struct prefix *p, struct rib *rib)
{
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 */
}
}
@@ -257,26 +263,34 @@ redistribute_delete (struct prefix *p, struct rib *rib)
{
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 */
}
}
@@ -285,18 +299,20 @@ redistribute_delete (struct prefix *p, struct rib *rib)
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);
}
}
@@ -304,18 +320,20 @@ zebra_redistribute_add (int command, struct zserv *client, int length)
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?
}
}
diff --git a/zebra/zserv.h b/zebra/zserv.h
index 14c1bcabd1..22d150083a 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -60,7 +60,7 @@ struct zserv
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;