+// SPDX-License-Identifier: GPL-2.0-or-later
/* zebra client
* Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "sockunion.h"
#include "zclient.h"
#include "routemap.h"
-#include "thread.h"
+#include "frrevent.h"
#include "queue.h"
#include "memory.h"
#include "lib/json.h"
peer->bgp->vrf_id);
}
+ /* Handle peerings via loopbacks. For instance, peer between
+ * 127.0.0.1 and 127.0.0.2. In short, allow peering with self
+ * via 127.0.0.0/8.
+ */
+ if (!ifp && cmd_allow_reserved_ranges_get())
+ ifp = if_get_vrf_loopback(peer->bgp->vrf_id);
+
if (!ifp) {
/*
* BGP views do not currently get proper data
return false;
}
-static struct thread *bgp_tm_thread_connect;
+static struct event *bgp_tm_thread_connect;
static bool bgp_tm_status_connected;
static bool bgp_tm_chunk_obtained;
#define BGP_FLOWSPEC_TABLE_CHUNK 100000
static uint32_t bgp_tm_min, bgp_tm_max, bgp_tm_chunk_size;
struct bgp *bgp_tm_bgp;
-static void bgp_zebra_tm_connect(struct thread *t)
+static void bgp_zebra_tm_connect(struct event *t)
{
struct zclient *zclient;
int delay = 10, ret = 0;
- zclient = THREAD_ARG(t);
+ zclient = EVENT_ARG(t);
if (bgp_tm_status_connected && zclient->sock > 0)
delay = 60;
else {
}
}
}
- thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
- &bgp_tm_thread_connect);
+ event_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+ &bgp_tm_thread_connect);
}
bool bgp_zebra_tm_chunk_obtained(void)
bgp_tm_min = bgp_tm_max = 0;
bgp_tm_chunk_size = BGP_FLOWSPEC_TABLE_CHUNK;
bgp_tm_bgp = bgp;
- thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
- &bgp_tm_thread_connect);
+ event_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+ &bgp_tm_thread_connect);
}
int bgp_zebra_get_table_range(uint32_t chunk_size,
uint32_t bos = 0;
uint32_t exp = 0;
+ /*
+ * BGP is installing this route and bgp has been configured
+ * to suppress announcements until the route has been installed
+ * let's set the fact that we expect this route to be installed
+ */
+ if (BGP_SUPPRESS_FIB_ENABLED(bgp))
+ SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
+
/* Don't try to install if we're not connected to Zebra or Zebra doesn't
* know of this instance.
*/
struct zapi_route api;
struct peer *peer;
+ /*
+ * If we are withdrawing the route, we don't need to have this
+ * flag set. So unset it.
+ */
+ UNSET_FLAG(info->net->flags, BGP_NODE_FIB_INSTALL_PENDING);
+
/* Don't try to install if we're not connected to Zebra or Zebra doesn't
* know of this instance.
*/
}
/* Find the bgp route node */
- dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p,
- &bgp->vrf_prd);
+ dest = bgp_safi_node_lookup(bgp->rib[afi][safi], safi, &p,
+ &bgp->vrf_prd);
if (!dest)
return -1;
hook_register_prio(if_del, 0, bgp_if_delete_hook);
}
-void bgp_zebra_init(struct thread_master *master, unsigned short instance)
+void bgp_zebra_init(struct event_loop *master, unsigned short instance)
{
zclient_num_connects = 0;
struct zapi_cap api;
int ret = BGP_GR_SUCCESS;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("%s: Sending %sable for %s", __func__,
+ disable ? "dis" : "en", bgp->name_pretty);
+
if (zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("zclient invalid");
+ zlog_debug("%s: %s zclient invalid", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("client not connected");
+ zlog_debug("%s: %s client not connected", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
== ZCLIENT_SEND_FAILURE) {
- zlog_err("error sending capability");
+ zlog_err("%s: %s error sending capability", __func__,
+ bgp->name_pretty);
ret = BGP_GR_FAILURE;
} else {
if (disable)
bgp->present_zebra_gr_state = ZEBRA_GR_ENABLE;
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("send capabilty success");
+ zlog_debug("%s: %s send capabilty success", __func__,
+ bgp->name_pretty);
ret = BGP_GR_SUCCESS;
}
return ret;
/* Send route update pesding or completed status to RIB for the
* specific AFI, SAFI
*/
-int bgp_zebra_update(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type)
+int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
+ enum zserv_client_capabilities type)
{
struct zapi_cap api = {0};
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("%s: %s afi: %u safi: %u Command %s", __func__,
+ bgp->name_pretty, afi, safi,
+ zserv_gr_client_cap_string(type));
+
if (zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("zclient == NULL, invalid");
+ zlog_debug("%s: %s zclient == NULL, invalid", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("client not connected");
+ zlog_debug("%s: %s client not connected", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
api.afi = afi;
api.safi = safi;
- api.vrf_id = vrf_id;
+ api.vrf_id = bgp->vrf_id;
api.cap = type;
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
== ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("error sending capability");
+ zlog_debug("%s: %s error sending capability", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
return BGP_GR_SUCCESS;
{
struct zapi_cap api;
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("%s: %s Timer Update to %u", __func__,
+ bgp->name_pretty, bgp->rib_stale_time);
+
if (zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("zclient invalid");
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("client not connected");
+ zlog_debug("%s: %s client not connected", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
== ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("error sending capability");
+ zlog_debug("%s: %s error sending capability", __func__,
+ bgp->name_pretty);
return BGP_GR_FAILURE;
}
- if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("send capabilty success");
+
return BGP_GR_SUCCESS;
}