bgp->vrf_id = vrf_id;
if (BGP_DEBUG (zebra, ZEBRA) && vrf)
- zlog_debug("zclient_send_requests %u", vrf_id);
+ zlog_debug("zclient_send_reg_requests %u", vrf_id);
- zclient_send_requests (zclient, vrf_id);
+ zclient_send_reg_requests (zclient, vrf_id);
bgp_instance_up (bgp);
//Pending: See if the following can be moved inside bgp_instance_up ()
bgp->vrf_id = vrf->vrf_id;
}
- zclient_send_requests (zclient, bgp->vrf_id);
+ zclient_send_reg_requests (zclient, bgp->vrf_id);
bgp_nht_register_all (bgp->vrf_id);
}
return 0;
}
-/* Send requests to zebra daemon for the information in a VRF. */
+/* Send register requests to zebra daemon for the information in a VRF. */
void
-zclient_send_requests (struct zclient *zclient, vrf_id_t vrf_id)
+zclient_send_reg_requests (struct zclient *zclient, vrf_id_t vrf_id)
{
int i;
afi_t afi;
return;
if (zclient_debug)
- zlog_debug ("%s: send messages for VRF %u", __func__, vrf_id);
+ zlog_debug ("%s: send register messages for VRF %u", __func__, vrf_id);
/* We need router-id information. */
zebra_message_send (zclient, ZEBRA_ROUTER_ID_ADD, vrf_id);
zebra_message_send (zclient, ZEBRA_REDISTRIBUTE_DEFAULT_ADD, vrf_id);
}
+/* Send unregister requests to zebra daemon for the information in a VRF. */
+void
+zclient_send_dereg_requests (struct zclient *zclient, vrf_id_t vrf_id)
+{
+ int i;
+ afi_t afi;
+
+ /* zclient is disabled. */
+ if (! zclient->enable)
+ return;
+
+ /* If not connected to the zebra yet. */
+ if (zclient->sock < 0)
+ return;
+
+ if (zclient_debug)
+ zlog_debug ("%s: send deregister messages for VRF %u", __func__, vrf_id);
+
+ /* We need router-id information. */
+ zebra_message_send (zclient, ZEBRA_ROUTER_ID_DELETE, vrf_id);
+
+ /* We need interface information. */
+ zebra_message_send (zclient, ZEBRA_INTERFACE_DELETE, vrf_id);
+
+ /* Set unwanted redistribute route. */
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ vrf_bitmap_set (zclient->redist[afi][zclient->redist_default], vrf_id);
+
+ /* Flush all redistribute request. */
+ if (vrf_id == VRF_DEFAULT)
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ if (zclient->mi_redist[afi][i].enabled)
+ {
+ struct listnode *node;
+ u_short *id;
+
+ for (ALL_LIST_ELEMENTS_RO(zclient->mi_redist[afi][i].instances, node, id))
+ if (!(i == zclient->redist_default && *id == zclient->instance))
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, i,
+ *id, VRF_DEFAULT);
+ }
+
+ /* Flush all redistribute request. */
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ if (i != zclient->redist_default &&
+ vrf_bitmap_check (zclient->redist[afi][i], vrf_id))
+ zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, i, 0, vrf_id);
+
+ /* If default information is needed. */
+ if (vrf_bitmap_check (zclient->default_information, VRF_DEFAULT))
+ zebra_message_send (zclient, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, vrf_id);
+}
+
/* Make connection to zebra daemon. */
int
zclient_start (struct zclient *zclient)
extern void redist_add_instance (struct redist_proto *, u_short);
extern void redist_del_instance (struct redist_proto *, u_short);
-extern void zclient_send_requests (struct zclient *, vrf_id_t);
+extern void zclient_send_reg_requests (struct zclient *, vrf_id_t);
+extern void zclient_send_dereg_requests (struct zclient *, vrf_id_t);
/* Send redistribute command to zebra daemon. Do not update zclient state. */
extern int zebra_redistribute_send (int command, struct zclient *, afi_t, int type, u_short instance, vrf_id_t vrf_id);