/* we must use a pointer because of zclient.c's functions (new, free). */
struct zclient *zclient;
-static int zebra_config_write (struct vty *vty);
/* Debug types */
static struct {
{0, 0, NULL}
};
-/* Zebra node structure. */
-struct cmd_node zebra_node =
-{
- ZEBRA_NODE,
- "%s(config-router)# ",
- 1 /* vtysh? yes */
-};
-
-
/* Zebra route add and delete treatment (ipv6). */
static int
babel_zebra_read_ipv6 (int command, struct zclient *zclient,
zclient->redistribute_route_ipv6_add = babel_zebra_read_ipv6;
zclient->redistribute_route_ipv6_del = babel_zebra_read_ipv6;
- install_node (&zebra_node, zebra_config_write);
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
install_element(ENABLE_NODE, &debug_babel_cmd);
install_element(ENABLE_NODE, &no_debug_babel_cmd);
install_element(VIEW_NODE, &show_debugging_babel_cmd);
}
-static int
-zebra_config_write (struct vty *vty)
-{
- if (! zclient->enable)
- {
- vty_out (vty, "no router zebra\n");
- return 1;
- }
- else if (! vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_BABEL], VRF_DEFAULT))
- {
- vty_out (vty, "router zebra\n");
- vty_out (vty, " no redistribute babel\n");
- return 1;
- }
- return 0;
-}
-
void
babel_zebra_close_connexion(void)
{
if (!bgp_install_info_to_zebra(bgp))
return;
- if ((p->family == AF_INET
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_BGP],
- bgp->vrf_id))
- || (p->family == AF_INET6
- && !vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_BGP],
- bgp->vrf_id)))
- return;
-
if (bgp->main_zebra_update_hold)
return;
if (!bgp_install_info_to_zebra(peer->bgp))
return;
- if ((p->family == AF_INET
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_BGP],
- peer->bgp->vrf_id))
- || (p->family == AF_INET6
- && !vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_BGP],
- peer->bgp->vrf_id)))
- return;
-
flags = 0;
if (peer->sort == BGP_PEER_IBGP) {
if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
return;
- if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT))
- return;
-
message = 0;
flags = 0;
UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
- if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT))
- return;
-
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_ISIS;
api.instance = 0;
if (zclient->sock < 0)
return;
- if ((prefix->family == AF_INET
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT))
- || (prefix->family == AF_INET6
- && !vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_ISIS],
- VRF_DEFAULT)))
- return;
-
if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) {
if (prefix->family == AF_INET)
isis_zebra_route_add_ipv4(prefix, route_info);
int i;
afi_t afi;
- /* zclient is disabled. */
- if (!zclient->enable)
- return;
-
/* If not connected to the zebra yet. */
if (zclient->sock < 0)
return;
int i;
afi_t afi;
- /* zclient is disabled. */
- if (!zclient->enable)
- return;
-
/* If not connected to the zebra yet. */
if (zclient->sock < 0)
return;
{
struct stream *s;
- /* zclient is disabled. */
- if (!zclient->enable)
- return;
-
/* If not connected to the zebra yet. */
if (zclient->sock < 0)
return;
if (zclient_debug)
zlog_info("zclient_start is called");
- /* zclient is disabled. */
- if (!zclient->enable)
- return 0;
-
/* If already connected to the zebra. */
if (zclient->sock >= 0)
return 0;
{
int afi, i;
- /* Enable zebra client connection by default. */
- zclient->enable = 1;
-
/* Set -1 to the default socket value. */
zclient->sock = -1;
/* Socket to zebra daemon. */
int sock;
- /* Flag of communication to zebra is enabled or not. Default is on.
- This flag is disabled by `no router zebra' statement. */
- int enable;
-
/* Connection failure count. */
int fail;
}
vty_out(vty, "Zebra Infomation\n");
- vty_out(vty, " enable: %d fail: %d\n", zclient->enable, zclient->fail);
+ vty_out(vty, " fail: %d\n", zclient->fail);
vty_out(vty, " redistribute default: %d\n",
vrf_bitmap_check(zclient->default_information, VRF_DEFAULT));
vty_out(vty, " redistribute:");
return CMD_SUCCESS;
}
-/* Zebra configuration write function. */
-static int config_write_ospf6_zebra(struct vty *vty)
-{
- if (!zclient->enable) {
- vty_out(vty, "no router zebra\n");
- vty_out(vty, "!\n");
- } else if (!vrf_bitmap_check(
- zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT)) {
- vty_out(vty, "router zebra\n");
- vty_out(vty, " no redistribute ospf6\n");
- vty_out(vty, "!\n");
- }
- return 0;
-}
-
-/* Zebra node structure. */
-static struct cmd_node zebra_node = {
- ZEBRA_NODE, "%s(config-zebra)# ",
-};
-
#define ADD 0
#define REM 1
static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
void ospf6_zebra_route_update_add(struct ospf6_route *request)
{
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT)) {
- ospf6->route_table->hook_add = NULL;
- ospf6->route_table->hook_remove = NULL;
- return;
- }
ospf6_zebra_route_update(ADD, request);
}
void ospf6_zebra_route_update_remove(struct ospf6_route *request)
{
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT)) {
- ospf6->route_table->hook_add = NULL;
- ospf6->route_table->hook_remove = NULL;
- return;
- }
ospf6_zebra_route_update(REM, request);
}
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT))
- return;
-
if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6;
char buf[INET6_ADDRSTRLEN];
struct prefix_ipv6 *dest;
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT))
- return;
-
if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF6;
}
}
-DEFUN (redistribute_ospf6,
- redistribute_ospf6_cmd,
- "redistribute ospf6",
- "Redistribute control\n"
- "OSPF6 route\n")
-{
- struct ospf6_route *route;
-
- if (vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT))
- return CMD_SUCCESS;
-
- vrf_bitmap_set(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT);
-
- if (ospf6 == NULL)
- return CMD_SUCCESS;
-
- /* send ospf6 route to zebra route table */
- for (route = ospf6_route_head(ospf6->route_table); route;
- route = ospf6_route_next(route))
- ospf6_zebra_route_update_add(route);
-
- ospf6->route_table->hook_add = ospf6_zebra_route_update_add;
- ospf6->route_table->hook_remove = ospf6_zebra_route_update_remove;
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_redistribute_ospf6,
- no_redistribute_ospf6_cmd,
- "no redistribute ospf6",
- NO_STR
- "Redistribute control\n"
- "OSPF6 route\n")
-{
- struct ospf6_route *route;
-
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT))
- return CMD_SUCCESS;
-
- vrf_bitmap_unset(zclient->redist[AFI_IP6][ZEBRA_ROUTE_OSPF6],
- VRF_DEFAULT);
-
- if (ospf6 == NULL)
- return CMD_SUCCESS;
-
- ospf6->route_table->hook_add = NULL;
- ospf6->route_table->hook_remove = NULL;
-
- /* withdraw ospf6 route from zebra route table */
- for (route = ospf6_route_head(ospf6->route_table); route;
- route = ospf6_route_next(route))
- ospf6_zebra_route_update_remove(route);
-
- return CMD_SUCCESS;
-}
-
static struct ospf6_distance *ospf6_distance_new(void)
{
return XCALLOC(MTYPE_OSPF6_DISTANCE, sizeof(struct ospf6_distance));
zclient->redistribute_route_ipv6_add = ospf6_zebra_read_ipv6;
zclient->redistribute_route_ipv6_del = ospf6_zebra_read_ipv6;
- /* redistribute connected route by default */
- /* ospf6_zebra_redistribute (ZEBRA_ROUTE_CONNECT); */
-
- /* Install zebra node. */
- install_node(&zebra_node, config_write_ospf6_zebra);
-
/* Install command element for zebra node. */
install_element(VIEW_NODE, &show_ospf6_zebra_cmd);
- install_default(ZEBRA_NODE);
- install_element(ZEBRA_NODE, &redistribute_ospf6_cmd);
- install_element(ZEBRA_NODE, &no_redistribute_ospf6_cmd);
-
- return;
}
/* Debug */
struct listnode *node;
struct ospf *ospf = ospf_lookup();
- if (!(ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT))
- return;
-
message = 0;
flags = 0;
struct listnode *node;
struct ospf *ospf = ospf_lookup();
- if (!(ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT))
- return;
-
message = 0;
flags = 0;
/* Distance value. */
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup();
- if (!(ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT))
- return;
-
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
struct zapi_ipv4 api;
struct ospf *ospf = ospf_lookup();
- if (!(ospf->instance
- && redist_check_instance(
- &zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- ospf->instance))
- && !vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF],
- VRF_DEFAULT))
- return;
-
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
struct rip_info *rinfo = NULL;
int count = 0;
- if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP],
- VRF_DEFAULT))
- return;
-
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIP;
api.instance = 0;
}
}
-DEFUN (rip_redistribute_rip,
- rip_redistribute_rip_cmd,
- "redistribute rip",
- "Redistribute information from another routing protocol\n"
- "Routing Information Protocol (RIP)\n")
-{
- vrf_bitmap_set(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_redistribute_rip,
- no_rip_redistribute_rip_cmd,
- "no redistribute rip",
- NO_STR
- "Redistribute information from another routing protocol\n"
- "Routing Information Protocol (RIP)\n")
-{
- vrf_bitmap_unset(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT);
- return CMD_SUCCESS;
-}
-
DEFUN (rip_redistribute_type,
rip_redistribute_type_cmd,
"redistribute " FRR_REDIST_STR_RIPD,
return CMD_SUCCESS;
}
-/* RIP configuration write function. */
-static int config_write_zebra(struct vty *vty)
-{
- if (!zclient->enable) {
- vty_out(vty, "no router zebra\n");
- return 1;
- } else if (!vrf_bitmap_check(zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP],
- VRF_DEFAULT)) {
- vty_out(vty, "router zebra\n");
- vty_out(vty, " no redistribute rip\n");
- return 1;
- }
- return 0;
-}
-
int config_write_rip_redistribute(struct vty *vty, int config_mode)
{
int i;
return 0;
}
-/* Zebra node structure. */
-static struct cmd_node zebra_node = {
- ZEBRA_NODE, "%s(config-router)# ",
-};
-
static void rip_zebra_connected(struct zclient *zclient)
{
zclient_send_reg_requests(zclient, VRF_DEFAULT);
zclient->redistribute_route_ipv4_add = rip_zebra_read_ipv4;
zclient->redistribute_route_ipv4_del = rip_zebra_read_ipv4;
- /* Install zebra node. */
- install_node(&zebra_node, config_write_zebra);
-
- /* Install command elements to zebra node. */
- install_default(ZEBRA_NODE);
- install_element(ZEBRA_NODE, &rip_redistribute_rip_cmd);
- install_element(ZEBRA_NODE, &no_rip_redistribute_rip_cmd);
-
/* Install command elements to rip node. */
install_element(RIP_NODE, &rip_redistribute_type_cmd);
install_element(RIP_NODE, &rip_redistribute_type_routemap_cmd);
struct ripng_info *rinfo = NULL;
int count = 0;
- if (!vrf_bitmap_check(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
- VRF_DEFAULT))
- return;
-
api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_RIPNG;
api.instance = 0;
}
}
-DEFUN (ripng_redistribute_ripng,
- ripng_redistribute_ripng_cmd,
- "redistribute ripng",
- "Redistribute information from another routing protocol\n"
- "RIPng route\n")
-{
- vrf_bitmap_set(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
- VRF_DEFAULT);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_ripng_redistribute_ripng,
- no_ripng_redistribute_ripng_cmd,
- "no redistribute ripng",
- NO_STR
- "Redistribute information from another routing protocol\n"
- "RIPng route\n")
-{
- vrf_bitmap_unset(zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
- VRF_DEFAULT);
- return CMD_SUCCESS;
-}
-
DEFUN (ripng_redistribute_type,
ripng_redistribute_type_cmd,
"redistribute " FRR_REDIST_STR_RIPNGD,
}
}
-/* RIPng configuration write function. */
-static int zebra_config_write(struct vty *vty)
-{
- if (!zclient->enable) {
- vty_out(vty, "no router zebra\n");
- return 1;
- } else if (!vrf_bitmap_check(
- zclient->redist[AFI_IP6][ZEBRA_ROUTE_RIPNG],
- VRF_DEFAULT)) {
- vty_out(vty, "router zebra\n");
- vty_out(vty, " no redistribute ripng\n");
- return 1;
- }
- return 0;
-}
-
-/* Zebra node structure. */
-static struct cmd_node zebra_node = {
- ZEBRA_NODE, "%s(config-router)# ",
-};
-
static void ripng_zebra_connected(struct zclient *zclient)
{
zclient_send_reg_requests(zclient, VRF_DEFAULT);
zclient->redistribute_route_ipv6_add = ripng_zebra_read_ipv6;
zclient->redistribute_route_ipv6_del = ripng_zebra_read_ipv6;
- /* Install zebra node. */
- install_node(&zebra_node, zebra_config_write);
-
- /* Install command element for zebra node. */
- install_default(ZEBRA_NODE);
- install_element(ZEBRA_NODE, &ripng_redistribute_ripng_cmd);
- install_element(ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd);
-
/* Install command elements to ripng node */
install_element(RIPNG_NODE, &ripng_redistribute_type_cmd);
install_element(RIPNG_NODE, &ripng_redistribute_type_routemap_cmd);