#include "buffer.h"
#include "linklist.h"
#include "stream.h"
-#include "thread.h"
+#include "frrevent.h"
#include "log.h"
#include "memory.h"
#include "lib_vty.h"
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) {
if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF)
continue;
- if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
- BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
- BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
- BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
- BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST],
+ if (CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_IP]
+ [SAFI_UNICAST],
+ BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_IP6]
+ [SAFI_UNICAST],
+ BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_IP]
+ [SAFI_UNICAST],
+ BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_IP6]
+ [SAFI_UNICAST],
+ BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) ||
+ CHECK_FLAG(tmp_bgp->af_flags[AFI_IP]
+ [SAFI_UNICAST],
BGP_CONFIG_VRF_TO_VRF_EXPORT) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST],
+ CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6]
+ [SAFI_UNICAST],
BGP_CONFIG_VRF_TO_VRF_EXPORT) ||
(bgp == bgp_get_evpn() &&
- (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
- BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
- BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
- BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) ||
- CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
- BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) ||
- (hashcount(tmp_bgp->vnihash))) {
+ (CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_L2VPN]
+ [SAFI_EVPN],
+ BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_L2VPN]
+ [SAFI_EVPN],
+ BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_L2VPN]
+ [SAFI_EVPN],
+ BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) ||
+ CHECK_FLAG(
+ tmp_bgp->af_flags[AFI_L2VPN]
+ [SAFI_EVPN],
+ BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) ||
+ (tmp_bgp->l3vni)) {
vty_out(vty,
"%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
return CMD_WARNING_CONFIG_FAILED;
/* Cancel max-med onstartup if its on */
if (bgp->t_maxmed_onstartup) {
- THREAD_OFF(bgp->t_maxmed_onstartup);
+ EVENT_OFF(bgp->t_maxmed_onstartup);
bgp->maxmed_onstartup_over = 1;
}
return CMD_SUCCESS;
}
+DEFPY(bgp_lu_uses_explicit_null, bgp_lu_uses_explicit_null_cmd,
+ "[no] bgp labeled-unicast <explicit-null|ipv4-explicit-null|ipv6-explicit-null>$value",
+ NO_STR BGP_STR
+ "BGP Labeled-unicast options\n"
+ "Use explicit-null label values for all local prefixes\n"
+ "Use the IPv4 explicit-null label value for IPv4 local prefixes\n"
+ "Use the IPv6 explicit-null label value for IPv6 local prefixes\n")
+{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ uint64_t label_mode;
+
+ if (strmatch(value, "ipv4-explicit-null"))
+ label_mode = BGP_FLAG_LU_IPV4_EXPLICIT_NULL;
+ else if (strmatch(value, "ipv6-explicit-null"))
+ label_mode = BGP_FLAG_LU_IPV6_EXPLICIT_NULL;
+ else
+ label_mode = BGP_FLAG_LU_IPV4_EXPLICIT_NULL |
+ BGP_FLAG_LU_IPV6_EXPLICIT_NULL;
+ if (no)
+ UNSET_FLAG(bgp->flags, label_mode);
+ else
+ SET_FLAG(bgp->flags, label_mode);
+ return CMD_SUCCESS;
+}
+
DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd,
"bgp suppress-duplicates",
BGP_STR
* fired.
*/
if (!rmap_delay_timer && bm->t_rmap_update) {
- THREAD_OFF(bm->t_rmap_update);
- thread_execute(bm->master, bgp_route_map_update_timer,
- NULL, 0);
+ EVENT_OFF(bm->t_rmap_update);
+ event_execute(bm->master, bgp_route_map_update_timer,
+ NULL, 0);
}
return CMD_SUCCESS;
} else {
return CMD_WARNING_CONFIG_FAILED;
if (!yes) {
- /* implement me */
- vty_out(vty, "It's not implemented\n");
- return CMD_WARNING_CONFIG_FAILED;
+ /* when SID is not set, do nothing */
+ if ((bgp->vpn_policy[afi].tovpn_sid_index == 0) &&
+ !CHECK_FLAG(bgp->vpn_policy[afi].flags,
+ BGP_VPN_POLICY_TOVPN_SID_AUTO))
+ return CMD_SUCCESS;
+
+ /* pre-change */
+ vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi,
+ bgp_get_default(), bgp);
+ bgp->vpn_policy[afi].tovpn_sid_index = 0;
+ UNSET_FLAG(bgp->vpn_policy[afi].flags,
+ BGP_VPN_POLICY_TOVPN_SID_AUTO);
+
+ /* post-change */
+ vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi,
+ bgp_get_default(), bgp);
+
+ return CMD_SUCCESS;
}
if (bgp->tovpn_sid_index != 0 ||
zlog_debug("%s: auto sid alloc.", __func__);
SET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_SID_AUTO);
- } else {
+ } else if (sid_idx != 0) {
/* SID allocation index-mode */
if (debug)
zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx);
{
static char stripped[BUFSIZ];
uint32_t i = 0;
- uint32_t last_space = 0;
+ uint32_t last_space = size;
while (i < size) {
- if (*(desc + i) == 0) {
+ if (*(desc + i) == '\0') {
stripped[i] = '\0';
return stripped;
}
i++;
}
- if (last_space > size)
- stripped[size + 1] = '\0';
- else
- stripped[last_space] = '\0';
+ stripped[last_space] = '\0';
return stripped;
}
if (peer->t_gr_stale != NULL) {
json_object_int_add(json_timer,
"stalePathTimerRemaining",
- thread_timer_remain_second(
+ event_timer_remain_second(
peer->t_gr_stale));
}
json_object_int_add(
json_timer,
"selectionDeferralTimerRemaining",
- thread_timer_remain_second(
+ event_timer_remain_second(
peer->bgp->gr_info[afi][safi]
.t_select_deferral));
}
if (peer->t_gr_stale != NULL)
vty_out(vty,
" Stale Path Remaining(sec): %ld\n",
- thread_timer_remain_second(
+ event_timer_remain_second(
peer->t_gr_stale));
/* Display Configured Selection
* Deferral only when when
NULL)
vty_out(vty,
" Selection Deferral Time Remaining(sec): %ld\n",
- thread_timer_remain_second(
+ event_timer_remain_second(
peer->bgp->gr_info[afi][safi]
.t_select_deferral));
}
if (p->t_gr_restart != NULL)
json_object_int_add(
json_timer, "restartTimerRemaining",
- thread_timer_remain_second(p->t_gr_restart));
+ event_timer_remain_second(p->t_gr_restart));
json_object_object_add(json, "timers", json_timer);
} else {
p->v_gr_restart);
if (p->t_gr_restart != NULL)
vty_out(vty, " Restart Time Remaining(sec): %ld\n",
- thread_timer_remain_second(p->t_gr_restart));
+ event_timer_remain_second(p->t_gr_restart));
if (p->t_gr_restart != NULL) {
vty_out(vty, " Restart Time Remaining(sec): %ld\n",
- thread_timer_remain_second(p->t_gr_restart));
+ event_timer_remain_second(p->t_gr_restart));
}
}
}
json_neigh,
"bgpTimerConfiguredConditionalAdvertisementsSec",
bgp->condition_check_period);
- if (thread_is_scheduled(bgp->t_condition_check))
+ if (event_is_scheduled(bgp->t_condition_check))
json_object_int_add(
json_neigh,
"bgpTimerUntilConditionalAdvertisementsSec",
- thread_timer_remain_second(
+ event_timer_remain_second(
bgp->t_condition_check));
} else {
/* Administrative shutdown. */
vty_out(vty,
" Configured conditional advertisements interval is %d seconds\n",
bgp->condition_check_period);
- if (thread_is_scheduled(bgp->t_condition_check))
+ if (event_is_scheduled(bgp->t_condition_check))
vty_out(vty,
" Time until conditional advertisements begin is %lu seconds\n",
- thread_timer_remain_second(
+ event_timer_remain_second(
bgp->t_condition_check));
}
/* Capability. */
if (p->t_gr_restart)
json_object_int_add(
json_grace, "gracefulRestartTimerMsecs",
- thread_timer_remain_second(p->t_gr_restart) *
+ event_timer_remain_second(p->t_gr_restart) *
1000);
if (p->t_gr_stale)
json_object_int_add(
json_grace, "gracefulStalepathTimerMsecs",
- thread_timer_remain_second(p->t_gr_stale) *
+ event_timer_remain_second(p->t_gr_stale) *
1000);
/* more gr info in new format */
BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace);
if (p->t_gr_restart)
vty_out(vty,
" The remaining time of restart timer is %ld\n",
- thread_timer_remain_second(p->t_gr_restart));
+ event_timer_remain_second(p->t_gr_restart));
if (p->t_gr_stale)
vty_out(vty,
" The remaining time of stalepath timer is %ld\n",
- thread_timer_remain_second(p->t_gr_stale));
+ event_timer_remain_second(p->t_gr_stale));
/* more gr info in new format */
BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL);
json_neigh, "reducePrefixNumFrom");
json_object_int_add(json_neigh,
"restartInTimerMsec",
- thread_timer_remain_second(
- p->t_pmax_restart)
- * 1000);
+ event_timer_remain_second(
+ p->t_pmax_restart) *
+ 1000);
} else
vty_out(vty,
" Reduce the no. of prefix from %s, will restart in %ld seconds\n",
- p->host, thread_timer_remain_second(
- p->t_pmax_restart));
+ p->host,
+ event_timer_remain_second(
+ p->t_pmax_restart));
} else {
if (use_json)
json_object_boolean_true_add(
if (p->t_start)
json_object_int_add(
json_neigh, "nextStartTimerDueInMsecs",
- thread_timer_remain_second(p->t_start) * 1000);
+ event_timer_remain_second(p->t_start) * 1000);
if (p->t_connect)
json_object_int_add(
json_neigh, "nextConnectTimerDueInMsecs",
- thread_timer_remain_second(p->t_connect)
- * 1000);
+ event_timer_remain_second(p->t_connect) * 1000);
if (p->t_routeadv) {
json_object_int_add(json_neigh, "mraiInterval",
p->v_routeadv);
json_object_int_add(
json_neigh, "mraiTimerExpireInMsecs",
- thread_timer_remain_second(p->t_routeadv)
- * 1000);
+ event_timer_remain_second(p->t_routeadv) *
+ 1000);
}
if (p->password)
json_object_int_add(json_neigh, "authenticationEnabled",
}
if (p->t_start)
vty_out(vty, "Next start timer due in %ld seconds\n",
- thread_timer_remain_second(p->t_start));
+ event_timer_remain_second(p->t_start));
if (p->t_connect)
vty_out(vty, "Next connect timer due in %ld seconds\n",
- thread_timer_remain_second(p->t_connect));
+ event_timer_remain_second(p->t_connect));
if (p->t_routeadv)
vty_out(vty,
"MRAI (interval %u) timer expires in %ld seconds\n",
p->v_routeadv,
- thread_timer_remain_second(p->t_routeadv));
+ event_timer_remain_second(p->t_routeadv));
if (p->password)
vty_out(vty, "Peer Authentication Enabled\n");
? ""
: "no ");
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV4_EXPLICIT_NULL) &&
+ !!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV6_EXPLICIT_NULL))
+ vty_out(vty, " bgp labeled-unicast explicit-null\n");
+ else if (!!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_LU_IPV4_EXPLICIT_NULL))
+ vty_out(vty,
+ " bgp labeled-unicast ipv4-explicit-null\n");
+ else if (!!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_LU_IPV6_EXPLICIT_NULL))
+ vty_out(vty,
+ " bgp labeled-unicast ipv6-explicit-null\n");
+
/* draft-ietf-idr-deprecate-as-set-confed-set */
if (bgp->reject_as_sets)
vty_out(vty, " bgp reject-as-sets\n");
DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp));
-static struct thread *t_bgp_cfg;
+static struct event *t_bgp_cfg;
bool bgp_config_inprocess(void)
{
- return thread_is_scheduled(t_bgp_cfg);
+ return event_is_scheduled(t_bgp_cfg);
}
-static void bgp_config_finish(struct thread *t)
+static void bgp_config_finish(struct event *t)
{
struct listnode *node;
struct bgp *bgp;
static void bgp_config_start(void)
{
#define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
- THREAD_OFF(t_bgp_cfg);
- thread_add_timer(bm->master, bgp_config_finish, NULL,
- BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg);
+ EVENT_OFF(t_bgp_cfg);
+ event_add_timer(bm->master, bgp_config_finish, NULL,
+ BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg);
}
/* When we receive a hook the configuration is read,
{
#define BGP_POST_CONFIG_DELAY_SECONDS 1
uint32_t bgp_post_config_delay =
- thread_is_scheduled(bm->t_rmap_update)
- ? thread_timer_remain_second(bm->t_rmap_update)
+ event_is_scheduled(bm->t_rmap_update)
+ ? event_timer_remain_second(bm->t_rmap_update)
: BGP_POST_CONFIG_DELAY_SECONDS;
/* If BGP config processing thread isn't running, then
if (!bgp_config_inprocess())
return;
- THREAD_OFF(t_bgp_cfg);
+ EVENT_OFF(t_bgp_cfg);
/* Start a new timer to make sure we don't send EoR
* before route-maps are processed.
*/
- thread_add_timer(bm->master, bgp_config_finish, NULL,
- bgp_post_config_delay, &t_bgp_cfg);
+ event_add_timer(bm->master, bgp_config_finish, NULL,
+ bgp_post_config_delay, &t_bgp_cfg);
}
static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd);
install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd);
+ /* bgp labeled-unicast explicit-null */
+ install_element(BGP_NODE, &bgp_lu_uses_explicit_null_cmd);
+
/* bgp suppress-duplicates */
install_element(BGP_NODE, &bgp_suppress_duplicates_cmd);
install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd);