summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_zebra.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_zebra.c')
-rw-r--r--ospfd/ospf_zebra.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index bdb5193a..fe1f45db 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -59,7 +59,7 @@ struct in_addr router_id_zebra;
/* Router-id update message from zebra. */
static int
ospf_router_id_update_zebra (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct ospf *ospf;
struct prefix router_id;
@@ -84,11 +84,12 @@ ospf_router_id_update_zebra (int command, struct zclient *zclient,
/* Inteface addition message from zebra. */
static int
-ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
+ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length,
+ vrf_id_t vrf_id)
{
struct interface *ifp;
- ifp = zebra_interface_add_read (zclient->ibuf);
+ ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
zlog_debug ("Zebra: interface add %s index %d flags %llx metric %d mtu %d",
@@ -114,7 +115,7 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length)
static int
ospf_interface_delete (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct interface *ifp;
struct stream *s;
@@ -122,7 +123,7 @@ ospf_interface_delete (int command, struct zclient *zclient,
s = zclient->ibuf;
/* zebra_interface_state_read() updates interface structure in iflist */
- ifp = zebra_interface_state_read (s);
+ ifp = zebra_interface_state_read (s, vrf_id);
if (ifp == NULL)
return 0;
@@ -149,7 +150,7 @@ ospf_interface_delete (int command, struct zclient *zclient,
}
static struct interface *
-zebra_interface_if_lookup (struct stream *s)
+zebra_interface_if_lookup (struct stream *s, vrf_id_t vrf_id)
{
char ifname_tmp[INTERFACE_NAMSIZ];
@@ -163,13 +164,13 @@ zebra_interface_if_lookup (struct stream *s)
static int
ospf_interface_state_up (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct interface *ifp;
struct ospf_interface *oi;
struct route_node *rn;
- ifp = zebra_interface_if_lookup (zclient->ibuf);
+ ifp = zebra_interface_if_lookup (zclient->ibuf, vrf_id);
if (ifp == NULL)
return 0;
@@ -225,13 +226,13 @@ ospf_interface_state_up (int command, struct zclient *zclient,
static int
ospf_interface_state_down (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct interface *ifp;
struct ospf_interface *oi;
struct route_node *node;
- ifp = zebra_interface_state_read (zclient->ibuf);
+ ifp = zebra_interface_state_read (zclient->ibuf, vrf_id);
if (ifp == NULL)
return 0;
@@ -251,11 +252,11 @@ ospf_interface_state_down (int command, struct zclient *zclient,
static int
ospf_interface_address_add (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct connected *c;
- c = zebra_interface_address_read (command, zclient->ibuf);
+ c = zebra_interface_address_read (command, zclient->ibuf, vrf_id);
if (c == NULL)
return 0;
@@ -278,7 +279,7 @@ ospf_interface_address_add (int command, struct zclient *zclient,
static int
ospf_interface_address_delete (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct connected *c;
struct interface *ifp;
@@ -286,7 +287,7 @@ ospf_interface_address_delete (int command, struct zclient *zclient,
struct route_node *rn;
struct prefix p;
- c = zebra_interface_address_read (command, zclient->ibuf);
+ c = zebra_interface_address_read (command, zclient->ibuf, vrf_id);
if (c == NULL)
return 0;
@@ -335,7 +336,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
struct ospf_path *path;
struct listnode *node;
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
{
message = 0;
flags = 0;
@@ -354,7 +355,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
stream_reset (s);
/* Put command, type, flags, message. */
- zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD);
+ zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
stream_putc (s, ZEBRA_ROUTE_OSPF);
stream_putc (s, flags);
stream_putc (s, message);
@@ -433,7 +434,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
struct ospf_path *path;
struct listnode *node;
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
{
message = 0;
flags = 0;
@@ -444,7 +445,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
stream_reset (s);
/* Put command, type, flags, message. */
- zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE);
+ zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT);
stream_putc (s, ZEBRA_ROUTE_OSPF);
stream_putc (s, flags);
stream_putc (s, message);
@@ -514,8 +515,9 @@ ospf_zebra_add_discard (struct prefix_ipv4 *p)
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
{
+ api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF;
api.flags = ZEBRA_FLAG_BLACKHOLE;
api.message = 0;
@@ -537,8 +539,9 @@ ospf_zebra_delete_discard (struct prefix_ipv4 *p)
{
struct zapi_ipv4 api;
- if (zclient->redist[ZEBRA_ROUTE_OSPF])
+ if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
{
+ api.vrf_id = VRF_DEFAULT;
api.type = ZEBRA_ROUTE_OSPF;
api.flags = ZEBRA_FLAG_BLACKHOLE;
api.message = 0;
@@ -560,7 +563,8 @@ int
ospf_is_type_redistributed (int type)
{
return (DEFAULT_ROUTE_TYPE (type)) ?
- zclient->default_information : zclient->redist[type];
+ vrf_bitmap_check (zclient->default_information, VRF_DEFAULT) : \
+ vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT);
}
int
@@ -594,7 +598,7 @@ ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue)
ospf->dmetric[type].type = mtype;
ospf->dmetric[type].value = mvalue;
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, VRF_DEFAULT);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]",
@@ -615,7 +619,7 @@ ospf_redistribute_unset (struct ospf *ospf, int type)
if (!ospf_is_type_redistributed (type))
return CMD_SUCCESS;
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, VRF_DEFAULT);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[%s]: Stop",
@@ -655,7 +659,8 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
return CMD_SUCCESS;
}
- zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient);
+ zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient,
+ VRF_DEFAULT);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
@@ -682,7 +687,8 @@ ospf_redistribute_default_unset (struct ospf *ospf)
ospf->dmetric[DEFAULT_ROUTE].type = -1;
ospf->dmetric[DEFAULT_ROUTE].value = -1;
- zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient);
+ zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient,
+ VRF_DEFAULT);
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
zlog_debug ("Redistribute[DEFAULT]: Stop");
@@ -816,7 +822,7 @@ ospf_routemap_unset (struct ospf *ospf, int type)
/* Zebra route add and delete treatment. */
static int
ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
- zebra_size_t length)
+ zebra_size_t length, vrf_id_t vrf_id)
{
struct stream *s;
struct zapi_ipv4 api;
@@ -1292,12 +1298,19 @@ ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
return 0;
}
+static void
+ospf_zebra_connected (struct zclient *zclient)
+{
+ zclient_send_requests (zclient, VRF_DEFAULT);
+}
+
void
ospf_zebra_init ()
{
/* Allocate zebra structure. */
zclient = zclient_new ();
zclient_init (zclient, ZEBRA_ROUTE_OSPF);
+ zclient->zebra_connected = ospf_zebra_connected;
zclient->router_id_update = ospf_router_id_update_zebra;
zclient->interface_add = ospf_interface_add;
zclient->interface_delete = ospf_interface_delete;