#include "bgpd/bgp_nb.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_vty.h"
-#include "bgpd/bgp_mplsvpn.h"
-#include "bgpd/bgp_fsm.h"
-#include "bgpd/bgp_addpath.h"
-#include "bgpd/bgp_updgrp.h"
-#include "bgpd/bgp_io.h"
-
-DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp));
-
-FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY,
- { .val_ulong = 10, .match_profile = "datacenter", },
- { .val_ulong = 120 },
-);
-FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME,
- { .val_ulong = 9, .match_profile = "datacenter", },
- { .val_ulong = 180 },
-);
-FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE,
- { .val_ulong = 3, .match_profile = "datacenter", },
- { .val_ulong = 60 },
-);
/*
* XPath:
int routing_control_plane_protocols_control_plane_protocol_bgp_global_create(
struct nb_cb_create_args *args)
{
-
- const struct lyd_node *vrf_dnode;
- struct bgp *bgp;
- struct vrf *vrf;
- const char *name = NULL;
- as_t as;
- enum bgp_instance_type inst_type;
- bool is_view_inst = false;
- int ret;
- int is_new_bgp = 0;
-
- inst_type = BGP_INSTANCE_TYPE_DEFAULT;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- vrf_dnode = yang_dnode_get_parent(args->dnode,
- "control-plane-protocol");
- vrf = nb_running_get_entry(vrf_dnode, NULL, true);
-
- if (strmatch(vrf->name, VRF_DEFAULT_NAME)) {
- name = NULL;
- } else {
- name = vrf->name;
- inst_type = BGP_INSTANCE_TYPE_VRF;
- }
-
- as = yang_dnode_get_uint32(args->dnode, "./local-as");
-
- is_view_inst = yang_dnode_get_bool(args->dnode,
- "./instance-type-view");
- if (is_view_inst)
- inst_type = BGP_INSTANCE_TYPE_VIEW;
-
- if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
- is_new_bgp = (bgp_lookup(as, name) == NULL);
-
- ret = bgp_get_vty(&bgp, &as, name, inst_type);
- if (ret == BGP_ERR_INSTANCE_MISMATCH) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "BGP instance name and AS number mismatch\nBGP instance is already running; AS is %u",
- as);
-
- return NB_ERR_INCONSISTENCY;
- }
- /*
- * If we just instantiated the default instance, complete
- * any pending VRF-VPN leaking that was configured via
- * earlier "router bgp X vrf FOO" blocks.
- */
- if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
- vpn_leak_postchange_all();
-
- if (inst_type == BGP_INSTANCE_TYPE_VRF)
- bgp_vpn_leak_export(bgp);
-
- UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
-
- nb_running_set_entry(args->dnode, bgp);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_destroy(
struct nb_cb_destroy_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
- bgp = nb_running_get_entry(args->dnode, NULL, false);
-
- if (bgp->l3vni) {
- snprintf(args->errmsg, args->errmsg_len,
- "Please unconfigure l3vni %u", bgp->l3vni);
- return NB_ERR_VALIDATION;
- }
-
- /* Cannot delete default instance if vrf instances exist */
- if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
- struct listnode *node;
- struct bgp *tmp_bgp;
-
- for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) {
- if (tmp_bgp->inst_type
- == BGP_INSTANCE_TYPE_VRF) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "Cannot delete default BGP instance. Dependent VRF instances exist\n");
- return NB_ERR_VALIDATION;
- }
- }
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_unset_entry(args->dnode);
-
- bgp_delete(bgp);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_local_as_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- as_t as;
-
switch (args->event) {
case NB_EV_VALIDATE:
- as = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp = nb_running_get_entry_non_rec(args->dnode, NULL, false);
- if (bgp && bgp->as != as) {
- snprintf(args->errmsg, args->errmsg_len,
- "BGP instance is already running; AS is %u",
- bgp->as);
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- /* NOTE: handled in bgp_global_create callback, the as change
- * will be rejected in validate phase.
- */
- as = yang_dnode_get_uint32(args->dnode, NULL);
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- if (bgp->as != as) {
- snprintf(args->errmsg, args->errmsg_len,
- "BGP instance is already running; AS is %u",
- bgp->as);
- return NB_ERR_INCONSISTENCY;
- }
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_router_id_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- struct in_addr router_id;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- yang_dnode_get_ipv4(&router_id, args->dnode, NULL);
- bgp_router_id_static_set(bgp, router_id);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_router_id_destroy(
struct nb_cb_destroy_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- struct in_addr router_id;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- router_id.s_addr = INADDR_ANY;
- bgp_router_id_static_set(bgp, router_id);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_confederation_identifier_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- as_t as;
-
switch (args->event) {
case NB_EV_VALIDATE:
- as = yang_dnode_get_uint32(args->dnode, NULL);
- if (!as) {
- snprintf(args->errmsg, args->errmsg_len, "Invalid AS.");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- as = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp_confederation_id_set(bgp, as);
-
+ /* TODO: implement me. */
break;
}
- as = yang_dnode_get_uint32(args->dnode, NULL);
-
-
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_confederation_identifier_destroy(
struct nb_cb_destroy_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp_confederation_id_unset(bgp);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_confederation_member_as_create(
struct nb_cb_create_args *args)
{
- as_t my_as, as;
- struct bgp *bgp;
- int ret;
-
switch (args->event) {
case NB_EV_VALIDATE:
- my_as = yang_dnode_get_uint32(args->dnode,
- "../../../global/local-as");
- as = yang_dnode_get_uint32(args->dnode, NULL);
- if (my_as == as) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "Local member-AS %u not allowed in confed peer list",
- my_as);
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- as = yang_dnode_get_uint32(args->dnode, NULL);
-
- ret = bgp_confederation_peers_add(bgp, as);
- if (ret == BGP_ERR_INVALID_AS) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "Local member-AS not alloed in confed peer list");
- return NB_ERR_INCONSISTENCY;
- }
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_confederation_member_as_destroy(
struct nb_cb_destroy_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- as_t as;
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- as = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp_confederation_peers_remove(bgp, as);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
-/*
- * XPath:
- * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global/med-config
- */
-void routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_apply_finish(
- struct nb_cb_apply_finish_args *args)
-{
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp_maxmed_update(bgp);
-}
-
/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global/med-config/enable-med-admin
int routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_enable_med_admin_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp->v_maxmed_admin = yang_dnode_get_bool(args->dnode, NULL);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_max_med_admin_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- uint32_t med_admin_val;
-
switch (args->event) {
case NB_EV_VALIDATE:
- med_admin_val = yang_dnode_get_uint32(args->dnode, NULL);
-
- /* enable_med_admin is required to be enabled for max-med-admin
- * non default value.
- */
- if (med_admin_val != BGP_MAXMED_VALUE_DEFAULT
- && !yang_dnode_get_bool(args->dnode,
- "../enable-med-admin")) {
- snprintf(args->errmsg, args->errmsg_len,
- "enable med admin is not set");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- med_admin_val = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp->maxmed_admin_value = med_admin_val;
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_max_med_onstart_up_time_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp->v_maxmed_onstartup =
- yang_dnode_get_uint32(args->dnode, NULL);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_max_med_onstart_up_time_destroy(
struct nb_cb_destroy_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- /* Cancel max-med onstartup if its on */
- if (bgp->t_maxmed_onstartup) {
- THREAD_OFF(bgp->t_maxmed_onstartup);
- bgp->maxmed_onstartup_over = 1;
- }
-
- bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
- /* Resetting onstartup value as part of dependent node is
- * detroyed.
- */
- bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_med_config_max_med_onstart_up_value_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- uint32_t onstartup_val;
-
switch (args->event) {
case NB_EV_VALIDATE:
- onstartup_val = yang_dnode_get_uint32(args->dnode, NULL);
-
- if (!yang_dnode_exists(args->dnode,
- "../max-med-onstart-up-time")
- && onstartup_val != BGP_MAXMED_VALUE_DEFAULT) {
- snprintf(args->errmsg, args->errmsg_len,
- "max-med-onstart-up-time is not set.");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp->maxmed_onstartup_value =
- yang_dnode_get_uint32(args->dnode, NULL);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_reflector_route_reflector_cluster_id_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- struct in_addr cluster_id;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- /* cluster-id is either dotted-quad or a uint32 */
- (void)inet_aton(lyd_get_value(args->dnode), &cluster_id);
- bgp_cluster_id_set(bgp, &cluster_id);
-
- if (bgp_clear_star_soft_out(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_reflector_route_reflector_cluster_id_destroy(
struct nb_cb_destroy_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp_cluster_id_unset(bgp);
-
- if (bgp_clear_star_soft_out(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_reflector_no_client_reflect_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
-
- if (bgp_clear_star_soft_out(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_reflector_allow_outbound_policy_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
-
- update_group_announce_rrclients(bgp);
-
- if (bgp_clear_star_soft_out(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
-/*
- * XPath:
- * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global/route-selection-options
- */
-void routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_apply_finish(
- struct nb_cb_apply_finish_args *args)
-{
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp_recalculate_all_bestpaths(bgp);
-}
-
/*
* XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global/route-selection-options/always-compare-med
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_always_compare_med_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
-
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_deterministic_med_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- int bestpath_per_as_used;
- afi_t afi;
- safi_t safi;
- struct peer *peer;
- struct listnode *node;
-
switch (args->event) {
case NB_EV_VALIDATE:
- bgp = nb_running_get_entry(args->dnode, NULL, false);
-
- if (!bgp)
- return NB_OK;
-
- /* for deconfiguring deterministic-med case */
- if (!yang_dnode_get_bool(args->dnode, NULL)
- && CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
- bestpath_per_as_used = 0;
-
- for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
- FOREACH_AFI_SAFI (afi, safi)
- if (bgp_addpath_dmed_required(
- peer->addpath_type[afi]
- [safi])) {
- bestpath_per_as_used = 1;
- break;
- }
-
- if (bestpath_per_as_used)
- break;
- }
-
- if (bestpath_per_as_used) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use");
- return NB_ERR_VALIDATION;
- }
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_confed_med_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_missing_as_worst_med_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_ignore_as_path_length_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_external_compare_router_id_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_allow_multiple_as_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL)) {
- SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
- if (yang_dnode_get_bool(args->dnode,
- "../multi-path-as-set")) {
- SET_FLAG(bgp->flags,
- BGP_FLAG_MULTIPATH_RELAX_AS_SET);
- }
- } else {
- UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
- /* unset as-set */
- UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
- }
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_multi_path_as_set_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (!CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
- SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
-
- } else
- zlog_debug(
- "%s multi-path-as-set as part of allow-multiple-as modify cb.",
- __func__);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_route_selection_options_multi_path_as_set_destroy(
struct nb_cb_destroy_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- /* Only unset if it set, it is possible allow_multiple_as_modify
- * unset this.
- */
- if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
- UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
-
- bgp_recalculate_all_bestpaths(bgp);
- }
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_neighbor_config_dynamic_neighbors_limit_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- uint32_t listen_limit;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- listen_limit = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp_listen_limit_set(bgp, listen_limit);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_neighbor_config_dynamic_neighbors_limit_destroy(
struct nb_cb_destroy_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- bgp_listen_limit_unset(bgp);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_neighbor_config_log_neighbor_changes_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_neighbor_config_packet_quanta_config_wpkt_quanta_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- uint32_t quanta;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- quanta = yang_dnode_get_uint32(args->dnode, NULL);
-
- if (atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed)
- == BGP_WRITE_PACKET_MAX)
- bgp_wpkt_quanta_config_vty(bgp, quanta, true);
- else
- bgp_wpkt_quanta_config_vty(bgp, quanta, false);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_neighbor_config_packet_quanta_config_rpkt_quanta_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- uint32_t quanta;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- quanta = yang_dnode_get_uint32(args->dnode, NULL);
-
- if (atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed)
- == BGP_READ_PACKET_MAX)
- bgp_rpkt_quanta_config_vty(bgp, quanta, true);
- else
- bgp_rpkt_quanta_config_vty(bgp, quanta, false);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_update_group_config_subgroup_pkt_queue_size_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- uint32_t max_size;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- max_size = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp_default_subgroup_pkt_queue_max_set(bgp, max_size);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_update_group_config_coalesce_time_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
- uint32_t coalesce_time;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- coalesce_time = yang_dnode_get_uint32(args->dnode, NULL);
-
- if (coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) {
- bgp->heuristic_coalesce = false;
- bgp->coalesce_time = coalesce_time;
- } else {
- bgp->heuristic_coalesce = true;
- bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
}
return NB_OK;
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_config_timers_hold_time_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- unsigned long keepalive = 0;
- unsigned long holdtime = 0;
-
switch (args->event) {
case NB_EV_VALIDATE:
- keepalive = yang_dnode_get_uint16(args->dnode, "../keepalive");
- holdtime = yang_dnode_get_uint16(args->dnode, NULL);
- /* Holdtime value check. */
- if (holdtime < 3 && holdtime != 0) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "hold time value must be either 0 or greater than 3");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- keepalive = yang_dnode_get_uint16(args->dnode, "../keepalive");
- holdtime = yang_dnode_get_uint16(args->dnode, NULL);
-
- bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,
- BGP_DEFAULT_DELAYOPEN);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_global_config_timers_keepalive_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
- unsigned long keepalive = 0;
- unsigned long holdtime = 0;
-
switch (args->event) {
case NB_EV_VALIDATE:
- keepalive = yang_dnode_get_uint16(args->dnode, NULL);
- holdtime = yang_dnode_get_uint16(args->dnode, "../hold-time");
- /* Holdtime value check. */
- if (holdtime < 3 && holdtime != 0) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "hold time value must be either 0 or greater than 3");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- keepalive = yang_dnode_get_uint16(args->dnode, NULL);
- holdtime = yang_dnode_get_uint16(args->dnode, "../hold-time");
-
- bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,
- BGP_DEFAULT_DELAYOPEN);
-
+ /* TODO: implement me. */
break;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_ebgp_multihop_connected_route_check_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
-
- if (bgp_clear_star_soft_in(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_fast_external_failover_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- if (!yang_dnode_get_bool(args->dnode, NULL)) {
- SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
- } else
- UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_local_pref_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
- struct bgp *bgp;
- uint32_t local_pref;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- local_pref = yang_dnode_get_uint32(args->dnode, NULL);
-
- bgp_default_local_preference_set(bgp, local_pref);
-
- if (bgp_clear_star_soft_in(bgp->name, args->errmsg, args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_default_shutdown_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
- bgp->autoshutdown = yang_dnode_get_bool(args->dnode, NULL);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_ebgp_requires_policy_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_show_hostname_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_show_nexthop_hostname_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_import_check_modify(
struct nb_cb_modify_args *args)
{
- if (args->event != NB_EV_APPLY)
- return NB_OK;
-
- struct bgp *bgp;
-
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
-
- bgp_static_redo_import_check(bgp);
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ case NB_EV_APPLY:
+ /* TODO: implement me. */
+ break;
+ }
return NB_OK;
}
int routing_control_plane_protocols_control_plane_protocol_bgp_global_graceful_shutdown_enable_modify(
struct nb_cb_modify_args *args)
{
- struct bgp *bgp;
-
switch (args->event) {
case NB_EV_VALIDATE:
- if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) {
- snprintf(
- args->errmsg, args->errmsg_len,
- "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown");
- return NB_ERR_VALIDATION;
- }
-
- break;
case NB_EV_PREPARE:
case NB_EV_ABORT:
- return NB_OK;
case NB_EV_APPLY:
- bgp = nb_running_get_entry(args->dnode, NULL, true);
-
- if (yang_dnode_get_bool(args->dnode, NULL))
- SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
- else
- UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
-
- bgp_static_redo_import_check(bgp);
- bgp_redistribute_redo(bgp);
-
- if (bgp_clear_star_soft_out(bgp->name, args->errmsg,
- args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
-
- if (bgp_clear_star_soft_in(bgp->name, args->errmsg,
- args->errmsg_len))
- return NB_ERR_INCONSISTENCY;
-
+ /* TODO: implement me. */
break;
}
#include "bgpd/rfapi/bgp_rfapi_cfg.h"
#endif
-#include "northbound.h"
-#include "northbound_cli.h"
-#include "bgpd/bgp_nb.h"
-
-
FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK,
{
.val_bool = false,
(struct bgp *bgp, struct vty *vty),
(bgp, vty));
DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp));
+DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp));
static struct peer_group *listen_range_exists(struct bgp *bgp,
struct prefix *range, int exact);
clear_as
};
-static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi,
- int error, char *errmsg, size_t errmsg_len)
+static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi,
+ safi_t safi, int error)
{
switch (error) {
case BGP_ERR_AF_UNCONFIGURED:
- snprintf(errmsg, errmsg_len,
- "%%BGP: Enable %s address family for the neighbor %s",
- get_afi_safi_str(afi, safi, false), peer->host);
+ vty_out(vty,
+ "%%BGP: Enable %s address family for the neighbor %s\n",
+ get_afi_safi_str(afi, safi, false), peer->host);
break;
case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
- snprintf(
- errmsg, errmsg_len,
- "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
+ vty_out(vty,
+ "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
peer->host);
break;
default:
}
/* `clear ip bgp' functions. */
-static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi,
+static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
enum clear_sort sort, enum bgp_clear_type stype,
- const char *arg, char *errmsg, size_t errmsg_len)
+ const char *arg)
{
int ret = 0;
bool found = false;
stype);
if (ret < 0)
- bgp_clear_vty_error(peer, afi, safi, ret,
- errmsg, errmsg_len);
+ bgp_clear_vty_error(vty, peer, afi, safi, ret);
}
if (gr_router_detected
if (!peer) {
peer = peer_lookup_by_hostname(bgp, arg);
if (!peer) {
- snprintf(
- errmsg, errmsg_len,
- "Malformed address or name: %s",
+ vty_out(vty,
+ "Malformed address or name: %s\n",
arg);
return CMD_WARNING;
}
} else {
peer = peer_lookup(bgp, &su);
if (!peer) {
- snprintf(errmsg, errmsg_len,
- "%%BGP: Unknown neighbor - \"%s\"",
- arg);
+ vty_out(vty,
+ "%%BGP: Unknown neighbor - \"%s\"\n",
+ arg);
return CMD_WARNING;
}
}
ret = BGP_ERR_AF_UNCONFIGURED;
if (ret < 0)
- bgp_clear_vty_error(peer, afi, safi, ret, errmsg,
- errmsg_len);
+ bgp_clear_vty_error(vty, peer, afi, safi, ret);
return CMD_SUCCESS;
}
group = peer_group_lookup(bgp, arg);
if (!group) {
- snprintf(errmsg, errmsg_len,
- "%%BGP: No such peer-group %s", arg);
+ vty_out(vty, "%%BGP: No such peer-group %s\n", arg);
return CMD_WARNING;
}
ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
- bgp_clear_vty_error(peer, afi, safi, ret,
- errmsg, errmsg_len);
+ bgp_clear_vty_error(vty, peer, afi, safi, ret);
else
found = true;
}
if (!found)
- snprintf(
- errmsg, errmsg_len,
- "%%BGP: No %s peer belonging to peer-group %s is configured",
+ vty_out(vty,
+ "%%BGP: No %s peer belonging to peer-group %s is configured\n",
get_afi_safi_str(afi, safi, false), arg);
return CMD_SUCCESS;
ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
- bgp_clear_vty_error(peer, afi, safi, ret,
- errmsg, errmsg_len);
+ bgp_clear_vty_error(vty, peer, afi, safi, ret);
else
found = true;
}
}
if (!found)
- snprintf(errmsg, errmsg_len,
- "%%BGP: No external %s peer is configured",
- get_afi_safi_str(afi, safi, false));
+ vty_out(vty,
+ "%%BGP: No external %s peer is configured\n",
+ get_afi_safi_str(afi, safi, false));
return CMD_SUCCESS;
}
ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);
if (ret < 0)
- bgp_clear_vty_error(peer, afi, safi, ret,
- errmsg, errmsg_len);
+ bgp_clear_vty_error(vty, peer, afi, safi, ret);
else
found = true;
}
}
if (!found)
- snprintf(errmsg, errmsg_len,
- "%%BGP: No %s peer is configured with AS %s",
- get_afi_safi_str(afi, safi, false), arg);
+ vty_out(vty,
+ "%%BGP: No %s peer is configured with AS %s\n",
+ get_afi_safi_str(afi, safi, false), arg);
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
-static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi,
- enum clear_sort sort, enum bgp_clear_type stype,
- const char *arg, char *errmsg, size_t errmsg_len)
+static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi,
+ safi_t safi, enum clear_sort sort,
+ enum bgp_clear_type stype, const char *arg)
{
struct bgp *bgp;
if (name) {
bgp = bgp_lookup_by_name(name);
if (bgp == NULL) {
- snprintf(errmsg, errmsg_len,
- "Can't find BGP instance %s", name);
+ vty_out(vty, "Can't find BGP instance %s\n", name);
return CMD_WARNING;
}
} else {
bgp = bgp_get_default();
if (bgp == NULL) {
- snprintf(errmsg, errmsg_len,
- "No BGP process is configured");
+ vty_out(vty, "No BGP process is configured\n");
return CMD_WARNING;
}
}
- return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len);
+ return bgp_clear(vty, bgp, afi, safi, sort, stype, arg);
}
/* clear soft inbound */
-int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len)
+static void bgp_clear_star_soft_in(struct vty *vty, const char *name)
{
afi_t afi;
safi_t safi;
- int ret;
-
- FOREACH_AFI_SAFI (afi, safi) {
- ret = bgp_clear_vty(name, afi, safi, clear_all,
- BGP_CLEAR_SOFT_IN, NULL, errmsg,
- errmsg_len);
- if (ret != CMD_SUCCESS)
- return -1;
- }
- return 0;
+ FOREACH_AFI_SAFI (afi, safi)
+ bgp_clear_vty(vty, name, afi, safi, clear_all,
+ BGP_CLEAR_SOFT_IN, NULL);
}
/* clear soft outbound */
-int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len)
+static void bgp_clear_star_soft_out(struct vty *vty, const char *name)
{
afi_t afi;
safi_t safi;
- int ret;
-
- FOREACH_AFI_SAFI (afi, safi) {
- ret = bgp_clear_vty(name, afi, safi, clear_all,
- BGP_CLEAR_SOFT_OUT, NULL, errmsg,
- errmsg_len);
- if (ret != CMD_SUCCESS)
- return -1;
- }
- return 0;
+ FOREACH_AFI_SAFI (afi, safi)
+ bgp_clear_vty(vty, name, afi, safi, clear_all,
+ BGP_CLEAR_SOFT_OUT, NULL);
}
}
/* "router bgp" commands. */
-DEFUN_YANG_NOSH(router_bgp,
- router_bgp_cmd,
- "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
- ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR)
+DEFUN_NOSH (router_bgp,
+ router_bgp_cmd,
+ "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
+ ROUTER_STR
+ BGP_STR
+ AS_STR
+ BGP_INSTANCE_HELP_STR)
{
int idx_asn = 2;
int idx_view_vrf = 3;
int idx_vrf = 4;
- int ret = CMD_SUCCESS;
+ int is_new_bgp = 0;
+ int ret;
as_t as;
struct bgp *bgp;
const char *name = NULL;
- char as_str[12] = {'\0'};
enum bgp_instance_type inst_type;
- char base_xpath[XPATH_MAXLEN];
// "router bgp" without an ASN
if (argc == 2) {
vty_out(vty, "%% Please specify ASN and VRF\n");
return CMD_WARNING_CONFIG_FAILED;
}
- /* unset the auto created flag as the user config is now present
- */
- UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
-
- snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
- "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME);
-
- nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
- snprintf(as_str, 12, "%d", bgp->as);
- nb_cli_enqueue_change(vty, "./local-as", NB_OP_MODIFY, as_str);
- if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) {
- nb_cli_enqueue_change(vty, "./instance-type-view",
- NB_OP_MODIFY, "true");
- }
-
- ret = nb_cli_apply_changes(vty, base_xpath);
- if (ret == CMD_SUCCESS) {
- VTY_PUSH_XPATH(BGP_NODE, base_xpath);
-
- /*
- * For backward compatibility with old commands we still
- * need to use the qobj infrastructure.
- */
- VTY_PUSH_CONTEXT(BGP_NODE, bgp);
- }
- return ret;
}
// "router bgp X"
else {
-
as = strtoul(argv[idx_asn]->arg, NULL, 10);
+
inst_type = BGP_INSTANCE_TYPE_DEFAULT;
if (argc > 3) {
name = argv[idx_vrf]->arg;
name = NULL;
else
inst_type = BGP_INSTANCE_TYPE_VRF;
- } else if (!strcmp(argv[idx_view_vrf]->text, "view")) {
+ } else if (!strcmp(argv[idx_view_vrf]->text, "view"))
inst_type = BGP_INSTANCE_TYPE_VIEW;
- }
- }
- snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
- "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME);
-
- nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
- nb_cli_enqueue_change(vty, "./local-as", NB_OP_MODIFY,
- argv[idx_asn]->arg);
- if (inst_type == BGP_INSTANCE_TYPE_VIEW) {
- nb_cli_enqueue_change(vty, "./instance-type-view",
- NB_OP_MODIFY, "true");
}
- nb_cli_pending_commit_check(vty);
- ret = nb_cli_apply_changes(vty, base_xpath);
- if (ret == CMD_SUCCESS) {
- VTY_PUSH_XPATH(BGP_NODE, base_xpath);
+ if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ is_new_bgp = (bgp_lookup(as, name) == NULL);
- /*
- * For backward compatibility with old commands we still
- * need to use the qobj infrastructure.
- */
- bgp = bgp_lookup(as, name);
- if (bgp)
- VTY_PUSH_CONTEXT(BGP_NODE, bgp);
+ ret = bgp_get_vty(&bgp, &as, name, inst_type);
+ switch (ret) {
+ case BGP_ERR_AS_MISMATCH:
+ vty_out(vty, "BGP is already running; AS is %u\n", as);
+ return CMD_WARNING_CONFIG_FAILED;
+ case BGP_ERR_INSTANCE_MISMATCH:
+ vty_out(vty,
+ "BGP instance name and AS number mismatch\n");
+ vty_out(vty,
+ "BGP instance is already running; AS is %u\n",
+ as);
+ return CMD_WARNING_CONFIG_FAILED;
}
+
+ /*
+ * If we just instantiated the default instance, complete
+ * any pending VRF-VPN leaking that was configured via
+ * earlier "router bgp X vrf FOO" blocks.
+ */
+ if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ vpn_leak_postchange_all();
+
+ if (inst_type == BGP_INSTANCE_TYPE_VRF)
+ bgp_vpn_leak_export(bgp);
+ /* Pending: handle when user tries to change a view to vrf n vv.
+ */
}
- return ret;
+ /* unset the auto created flag as the user config is now present */
+ UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO);
+ VTY_PUSH_CONTEXT(BGP_NODE, bgp);
+
+ return CMD_SUCCESS;
}
/* "no router bgp" commands. */
-DEFUN_YANG(no_router_bgp,
- no_router_bgp_cmd,
- "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
- NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR)
+DEFUN (no_router_bgp,
+ no_router_bgp_cmd,
+ "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
+ NO_STR
+ ROUTER_STR
+ BGP_STR
+ AS_STR
+ BGP_INSTANCE_HELP_STR)
{
int idx_asn = 3;
int idx_vrf = 5;
- as_t as = 0;
+ as_t as;
struct bgp *bgp;
const char *name = NULL;
- char base_xpath[XPATH_MAXLEN];
// "no router bgp" without an ASN
if (argc == 3) {
}
}
}
- snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
- "frr-bgp:bgp", "bgp",
- bgp->name ? bgp->name : VRF_DEFAULT_NAME);
- nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
+ bgp_delete(bgp);
- return nb_cli_apply_changes(vty, base_xpath);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
-{
- const struct lyd_node *vrf_dnode;
- const char *vrf_name;
- as_t as;
-
- vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol");
- vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf");
- as = yang_dnode_get_uint32(dnode, "./local-as");
-
- vty_out(vty, "!\n");
- vty_out(vty, "router bgp %u", as);
- if (!strmatch(vrf_name, VRF_DEFAULT_NAME))
- vty_out(vty, " vrf %s", vrf_name);
- vty_out(vty, "\n");
-}
/* BGP router-id. */
-DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D",
- BGP_STR
- "Override configured router identifier\n"
- "Manually configured router identifier\n")
+DEFPY (bgp_router_id,
+ bgp_router_id_cmd,
+ "bgp router-id A.B.C.D",
+ BGP_STR
+ "Override configured router identifier\n"
+ "Manually configured router identifier\n")
{
- nb_cli_enqueue_change(vty, "./router-id", NB_OP_MODIFY, router_id_str);
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_router_id_static_set(bgp, router_id);
+ return CMD_SUCCESS;
}
-DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]",
- NO_STR BGP_STR
- "Override configured router identifier\n"
- "Manually configured router identifier\n")
+DEFPY (no_bgp_router_id,
+ no_bgp_router_id_cmd,
+ "no bgp router-id [A.B.C.D]",
+ NO_STR
+ BGP_STR
+ "Override configured router identifier\n"
+ "Manually configured router identifier\n")
{
- nb_cli_enqueue_change(vty, "./router-id", NB_OP_DESTROY,
- router_id_str ? router_id_str : NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
-}
+ if (router_id_str) {
+ if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) {
+ vty_out(vty, "%% BGP router-id doesn't match\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ }
-void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
-{
- vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL));
+ router_id.s_addr = 0;
+ bgp_router_id_static_set(bgp, router_id);
+
+ return CMD_SUCCESS;
}
DEFPY(bgp_community_alias, bgp_community_alias_cmd,
/* BGP Cluster ID. */
-DEFUN_YANG(bgp_cluster_id,
- bgp_cluster_id_cmd,
- "bgp cluster-id <A.B.C.D|(1-4294967295)>",
- BGP_STR
- "Configure Route-Reflector Cluster-id\n"
- "Route-Reflector Cluster-id in IP address format\n"
- "Route-Reflector Cluster-id as 32 bit quantity\n")
+DEFUN (bgp_cluster_id,
+ bgp_cluster_id_cmd,
+ "bgp cluster-id <A.B.C.D|(1-4294967295)>",
+ BGP_STR
+ "Configure Route-Reflector Cluster-id\n"
+ "Route-Reflector Cluster-id in IP address format\n"
+ "Route-Reflector Cluster-id as 32 bit quantity\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_ipv4 = 2;
+ int ret;
+ struct in_addr cluster;
+
+ ret = inet_aton(argv[idx_ipv4]->arg, &cluster);
+ if (!ret) {
+ vty_out(vty, "%% Malformed bgp cluster identifier\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
- nb_cli_enqueue_change(vty,
- "./route-reflector/route-reflector-cluster-id",
- NB_OP_MODIFY, argv[idx_ipv4]->arg);
+ bgp_cluster_id_set(bgp, &cluster);
+ bgp_clear_star_soft_out(vty, bgp->name);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_cluster_id,
- no_bgp_cluster_id_cmd,
- "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
- NO_STR BGP_STR
- "Configure Route-Reflector Cluster-id\n"
- "Route-Reflector Cluster-id in IP address format\n"
- "Route-Reflector Cluster-id as 32 bit quantity\n")
+DEFUN (no_bgp_cluster_id,
+ no_bgp_cluster_id_cmd,
+ "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
+ NO_STR
+ BGP_STR
+ "Configure Route-Reflector Cluster-id\n"
+ "Route-Reflector Cluster-id in IP address format\n"
+ "Route-Reflector Cluster-id as 32 bit quantity\n")
{
- nb_cli_enqueue_change(vty,
- "./route-reflector/route-reflector-cluster-id",
- NB_OP_DESTROY, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_cluster_id_unset(bgp);
+ bgp_clear_star_soft_out(vty, bgp->name);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
DEFPY (bgp_norib,
return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_confederation_identifier,
- bgp_confederation_identifier_cmd,
- "bgp confederation identifier (1-4294967295)",
- "BGP specific commands\n"
- "AS confederation parameters\n"
- "AS number\n"
- "Set routing domain confederation AS\n")
+DEFUN (bgp_confederation_identifier,
+ bgp_confederation_identifier_cmd,
+ "bgp confederation identifier (1-4294967295)",
+ "BGP specific commands\n"
+ "AS confederation parameters\n"
+ "AS number\n"
+ "Set routing domain confederation AS\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
+ as_t as;
- nb_cli_enqueue_change(vty, "./confederation/identifier", NB_OP_MODIFY,
- argv[idx_number]->arg);
-
- return nb_cli_apply_changes(vty, NULL);
-}
+ as = strtoul(argv[idx_number]->arg, NULL, 10);
-DEFUN_YANG(no_bgp_confederation_identifier,
- no_bgp_confederation_identifier_cmd,
- "no bgp confederation identifier [(1-4294967295)]",
- NO_STR
- "BGP specific commands\n"
- "AS confederation parameters\n"
- "AS number\n"
- "Set routing domain confederation AS\n")
-{
- nb_cli_enqueue_change(vty, "./confederation/identifier", NB_OP_DESTROY,
- NULL);
+ bgp_confederation_id_set(bgp, as);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_confederation_identifier(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_confederation_identifier,
+ no_bgp_confederation_identifier_cmd,
+ "no bgp confederation identifier [(1-4294967295)]",
+ NO_STR
+ "BGP specific commands\n"
+ "AS confederation parameters\n"
+ "AS number\n"
+ "Set routing domain confederation AS\n")
{
- vty_out(vty, " bgp confederation identifier %u\n",
- yang_dnode_get_uint32(dnode, NULL));
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_confederation_id_unset(bgp);
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_confederation_peers,
- bgp_confederation_peers_cmd,
- "bgp confederation peers (1-4294967295)...",
- "BGP specific commands\n"
- "AS confederation parameters\n"
- "Peer ASs in BGP confederation\n" AS_STR)
+DEFUN (bgp_confederation_peers,
+ bgp_confederation_peers_cmd,
+ "bgp confederation peers (1-4294967295)...",
+ "BGP specific commands\n"
+ "AS confederation parameters\n"
+ "Peer ASs in BGP confederation\n"
+ AS_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_asn = 3;
+ as_t as;
int i;
- for (i = idx_asn; i < argc; i++)
- nb_cli_enqueue_change(vty, "./confederation/member-as",
- NB_OP_CREATE, argv[i]->arg);
+ for (i = idx_asn; i < argc; i++) {
+ as = strtoul(argv[i]->arg, NULL, 10);
+
+ if (bgp->as == as) {
+ vty_out(vty,
+ "%% Local member-AS not allowed in confed peer list\n");
+ continue;
+ }
- return nb_cli_apply_changes(vty, NULL);
+ bgp_confederation_peers_add(bgp, as);
+ }
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_confederation_peers,
- no_bgp_confederation_peers_cmd,
- "no bgp confederation peers (1-4294967295)...",
- NO_STR
- "BGP specific commands\n"
- "AS confederation parameters\n"
- "Peer ASs in BGP confederation\n" AS_STR)
+DEFUN (no_bgp_confederation_peers,
+ no_bgp_confederation_peers_cmd,
+ "no bgp confederation peers (1-4294967295)...",
+ NO_STR
+ "BGP specific commands\n"
+ "AS confederation parameters\n"
+ "Peer ASs in BGP confederation\n"
+ AS_STR)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_asn = 4;
+ as_t as;
int i;
- for (i = idx_asn; i < argc; i++)
- nb_cli_enqueue_change(vty, "./confederation/member-as",
- NB_OP_DESTROY, argv[i]->arg);
-
- return nb_cli_apply_changes(vty, NULL);
-}
+ for (i = idx_asn; i < argc; i++) {
+ as = strtoul(argv[i]->arg, NULL, 10);
-void cli_show_router_bgp_confederation_member_as(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
-{
- vty_out(vty, " bgp confederation peers %u \n",
- yang_dnode_get_uint32(dnode, NULL));
+ bgp_confederation_peers_remove(bgp, as);
+ }
+ return CMD_SUCCESS;
}
/**
return CMD_SUCCESS;
}
-void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (bgp_maxmed_admin,
+ bgp_maxmed_admin_cmd,
+ "bgp max-med administrative ",
+ BGP_STR
+ "Advertise routes with max-med\n"
+ "Administratively applied, for an indefinite period\n")
{
- if (yang_dnode_get_bool(dnode, "./enable-med-admin")) {
- uint32_t med_admin_val;
-
- vty_out(vty, " bgp max-med administrative");
- if ((med_admin_val =
- yang_dnode_get_uint32(dnode, "./max-med-admin"))
- != BGP_MAXMED_VALUE_DEFAULT)
- vty_out(vty, " %u", med_admin_val);
- vty_out(vty, "\n");
- }
-
- if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) {
- uint32_t onstartup_val;
-
- vty_out(vty, " bgp max-med on-startup %u",
- yang_dnode_get_uint32(dnode,
- "./max-med-onstart-up-time"));
- onstartup_val = yang_dnode_get_uint32(
- dnode, "./max-med-onstart-up-value");
- if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT)
- vty_out(vty, " %u", onstartup_val);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- vty_out(vty, "\n");
- }
-}
+ bgp->v_maxmed_admin = 1;
+ bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
-DEFUN_YANG(bgp_maxmed_admin,
- bgp_maxmed_admin_cmd,
- "bgp max-med administrative ",
- BGP_STR
- "Advertise routes with max-med\n"
- "Administratively applied, for an indefinite period\n")
-{
- nb_cli_enqueue_change(vty, "./med-config/enable-med-admin",
- NB_OP_MODIFY, "true");
+ bgp_maxmed_update(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_maxmed_admin_medv,
- bgp_maxmed_admin_medv_cmd,
- "bgp max-med administrative (0-4294967295)",
- BGP_STR
- "Advertise routes with max-med\n"
- "Administratively applied, for an indefinite period\n"
- "Max MED value to be used\n")
+DEFUN (bgp_maxmed_admin_medv,
+ bgp_maxmed_admin_medv_cmd,
+ "bgp max-med administrative (0-4294967295)",
+ BGP_STR
+ "Advertise routes with max-med\n"
+ "Administratively applied, for an indefinite period\n"
+ "Max MED value to be used\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
- nb_cli_enqueue_change(vty, "./med-config/enable-med-admin",
- NB_OP_MODIFY, "true");
+ bgp->v_maxmed_admin = 1;
+ bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10);
- nb_cli_enqueue_change(vty, "./med-config/max-med-admin", NB_OP_MODIFY,
- argv[idx_number]->arg);
+ bgp_maxmed_update(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_maxmed_admin,
- no_bgp_maxmed_admin_cmd,
- "no bgp max-med administrative [(0-4294967295)]",
- NO_STR BGP_STR
- "Advertise routes with max-med\n"
- "Administratively applied, for an indefinite period\n"
- "Max MED value to be used\n")
+DEFUN (no_bgp_maxmed_admin,
+ no_bgp_maxmed_admin_cmd,
+ "no bgp max-med administrative [(0-4294967295)]",
+ NO_STR
+ BGP_STR
+ "Advertise routes with max-med\n"
+ "Administratively applied, for an indefinite period\n"
+ "Max MED value to be used\n")
{
- nb_cli_enqueue_change(vty, "./med-config/enable-med-admin",
- NB_OP_MODIFY, "false");
-
- nb_cli_enqueue_change(vty, "./med-config/max-med-admin", NB_OP_MODIFY,
- NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
+ bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
+ bgp_maxmed_update(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_maxmed_onstartup,
- bgp_maxmed_onstartup_cmd,
- "bgp max-med on-startup (5-86400) [(0-4294967295)]",
- BGP_STR
- "Advertise routes with max-med\n"
- "Effective on a startup\n"
- "Time (seconds) period for max-med\n"
- "Max MED value to be used\n")
+DEFUN (bgp_maxmed_onstartup,
+ bgp_maxmed_onstartup_cmd,
+ "bgp max-med on-startup (5-86400) [(0-4294967295)]",
+ BGP_STR
+ "Advertise routes with max-med\n"
+ "Effective on a startup\n"
+ "Time (seconds) period for max-med\n"
+ "Max MED value to be used\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
argv_find(argv, argc, "(5-86400)", &idx);
- nb_cli_enqueue_change(vty, "./med-config/max-med-onstart-up-time",
- NB_OP_MODIFY, argv[idx]->arg);
-
+ bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10);
if (argv_find(argv, argc, "(0-4294967295)", &idx))
- nb_cli_enqueue_change(vty,
- "./med-config/max-med-onstart-up-value",
- NB_OP_MODIFY, argv[idx]->arg);
+ bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10);
else
- nb_cli_enqueue_change(vty,
- "./med-config/max-med-onstart-up-value",
- NB_OP_MODIFY, NULL);
+ bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
- return nb_cli_apply_changes(vty, NULL);
+ bgp_maxmed_update(bgp);
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_maxmed_onstartup,
- no_bgp_maxmed_onstartup_cmd,
- "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
- NO_STR BGP_STR
- "Advertise routes with max-med\n"
- "Effective on a startup\n"
- "Time (seconds) period for max-med\n"
- "Max MED value to be used\n")
+DEFUN (no_bgp_maxmed_onstartup,
+ no_bgp_maxmed_onstartup_cmd,
+ "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
+ NO_STR
+ BGP_STR
+ "Advertise routes with max-med\n"
+ "Effective on a startup\n"
+ "Time (seconds) period for max-med\n"
+ "Max MED value to be used\n")
{
- nb_cli_enqueue_change(vty, "./med-config/max-med-onstart-up-time",
- NB_OP_DESTROY, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+
+ /* Cancel max-med onstartup if its on */
+ if (bgp->t_maxmed_onstartup) {
+ thread_cancel(&bgp->t_maxmed_onstartup);
+ bgp->maxmed_onstartup_over = 1;
+ }
+
+ bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
+ bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
- nb_cli_enqueue_change(vty, "./med-config/max-med-onstart-up-value",
- NB_OP_MODIFY, NULL);
+ bgp_maxmed_update(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
static int bgp_global_update_delay_config_vty(struct vty *vty,
}
-int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set)
+static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta,
+ bool set)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+
quanta = set ? quanta : BGP_WRITE_PACKET_MAX;
atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed);
return CMD_SUCCESS;
}
-int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set)
+static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta,
+ bool set)
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+
quanta = set ? quanta : BGP_READ_PACKET_MAX;
atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed);
* Furthermore, the maximums used here should correspond to
* BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
*/
-DEFPY_YANG(bgp_wpkt_quanta,
- bgp_wpkt_quanta_cmd,
- "[no] write-quanta (1-64)$quanta",
- NO_STR
- "How many packets to write to peer socket per run\n"
- "Number of packets\n")
-{
- if (!no)
- nb_cli_enqueue_change(
- vty,
- "./global-neighbor-config/packet-quanta-config/wpkt-quanta",
- NB_OP_MODIFY, quanta_str);
- else
- nb_cli_enqueue_change(
- vty,
- "./global-neighbor-config/packet-quanta-config/wpkt-quanta",
- NB_OP_MODIFY, NULL);
-
- return nb_cli_apply_changes(vty, NULL);
-}
-
-DEFPY_YANG(bgp_rpkt_quanta,
- bgp_rpkt_quanta_cmd,
- "[no] read-quanta (1-10)$quanta",
- NO_STR
- "How many packets to read from peer socket per I/O cycle\n"
- "Number of packets\n")
-{
- if (!no)
- nb_cli_enqueue_change(
- vty,
- "./global-neighbor-config/packet-quanta-config/rpkt-quanta",
- NB_OP_MODIFY, quanta_str);
- else
- nb_cli_enqueue_change(
- vty,
- "./global-neighbor-config/packet-quanta-config/rpkt-quanta",
- NB_OP_MODIFY, NULL);
+DEFPY (bgp_wpkt_quanta,
+ bgp_wpkt_quanta_cmd,
+ "[no] write-quanta (1-64)$quanta",
+ NO_STR
+ "How many packets to write to peer socket per run\n"
+ "Number of packets\n")
+{
+ return bgp_wpkt_quanta_config_vty(vty, quanta, !no);
+}
- return nb_cli_apply_changes(vty, NULL);
+DEFPY (bgp_rpkt_quanta,
+ bgp_rpkt_quanta_cmd,
+ "[no] read-quanta (1-10)$quanta",
+ NO_STR
+ "How many packets to read from peer socket per I/O cycle\n"
+ "Number of packets\n")
+{
+ return bgp_rpkt_quanta_config_vty(vty, quanta, !no);
}
void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp)
vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time);
}
-void cli_show_router_global_update_group_config_coalesce_time(
- struct vty *vty, struct lyd_node *dnode, bool show_defaults)
-{
- vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL));
-}
-
-DEFUN_YANG(bgp_coalesce_time,
- bgp_coalesce_time_cmd,
- "coalesce-time (0-4294967295)",
- "Subgroup coalesce timer\n"
- "Subgroup coalesce timer value (in ms)\n")
+DEFUN (bgp_coalesce_time,
+ bgp_coalesce_time_cmd,
+ "coalesce-time (0-4294967295)",
+ "Subgroup coalesce timer\n"
+ "Subgroup coalesce timer value (in ms)\n")
{
- int idx = 0;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int idx = 0;
argv_find(argv, argc, "(0-4294967295)", &idx);
- nb_cli_enqueue_change(vty, "./global-update-group-config/coalesce-time",
- NB_OP_MODIFY, argv[idx]->arg);
-
- return nb_cli_apply_changes(vty, NULL);
+ bgp->heuristic_coalesce = false;
+ bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_coalesce_time,
- no_bgp_coalesce_time_cmd,
- "no coalesce-time (0-4294967295)",
- NO_STR
- "Subgroup coalesce timer\n"
- "Subgroup coalesce timer value (in ms)\n")
+DEFUN (no_bgp_coalesce_time,
+ no_bgp_coalesce_time_cmd,
+ "no coalesce-time (0-4294967295)",
+ NO_STR
+ "Subgroup coalesce timer\n"
+ "Subgroup coalesce timer value (in ms)\n")
{
- nb_cli_enqueue_change(vty, "./global-update-group-config/coalesce-time",
- NB_OP_MODIFY, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
+ bgp->heuristic_coalesce = true;
+ bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
+ return CMD_SUCCESS;
}
/* Maximum-paths configuration */
/* BGP timers. */
-DEFUN_YANG(bgp_timers,
- bgp_timers_cmd,
- "timers bgp (0-65535) (0-65535)",
- "Adjust routing timers\n"
- "BGP timers\n"
- "Keepalive interval\n"
- "Holdtime\n")
+DEFUN (bgp_timers,
+ bgp_timers_cmd,
+ "timers bgp (0-65535) (0-65535)",
+ "Adjust routing timers\n"
+ "BGP timers\n"
+ "Keepalive interval\n"
+ "Holdtime\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 2;
int idx_number_2 = 3;
+ unsigned long keepalive = 0;
+ unsigned long holdtime = 0;
- nb_cli_enqueue_change(vty, "./global-config-timers/keepalive",
- NB_OP_MODIFY, argv[idx_number]->arg);
- nb_cli_enqueue_change(vty, "./global-config-timers/hold-time",
- NB_OP_MODIFY, argv[idx_number_2]->arg);
+ keepalive = strtoul(argv[idx_number]->arg, NULL, 10);
+ holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10);
- return nb_cli_apply_changes(vty, NULL);
-}
+ /* Holdtime value check. */
+ if (holdtime < 3 && holdtime != 0) {
+ vty_out(vty,
+ "%% hold time value must be either 0 or greater than 3\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
-DEFUN_YANG(no_bgp_timers,
- no_bgp_timers_cmd,
- "no timers bgp [(0-65535) (0-65535)]",
- NO_STR
- "Adjust routing timers\n"
- "BGP timers\n"
- "Keepalive interval\n"
- "Holdtime\n")
-{
- nb_cli_enqueue_change(vty, "./global-config-timers/keepalive",
- NB_OP_DESTROY, NULL);
- nb_cli_enqueue_change(vty, "./global-config-timers/hold-time",
- NB_OP_DESTROY, NULL);
+ bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,
+ BGP_DEFAULT_DELAYOPEN);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_route_reflector(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_timers,
+ no_bgp_timers_cmd,
+ "no timers bgp [(0-65535) (0-65535)]",
+ NO_STR
+ "Adjust routing timers\n"
+ "BGP timers\n"
+ "Keepalive interval\n"
+ "Holdtime\n")
{
- if (yang_dnode_get_bool(dnode, "./no-client-reflect"))
- vty_out(vty, " no bgp client-to-client reflection\n");
-
- if (yang_dnode_get_bool(dnode, "./allow-outbound-policy"))
- vty_out(vty, " bgp route-reflector allow-outbound-policy\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,
+ DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN);
- if (yang_dnode_exists(dnode, "./route-reflector-cluster-id"))
- vty_out(vty, " bgp cluster-id %s\n",
- yang_dnode_get_string(dnode,
- "./route-reflector-cluster-id"));
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_client_to_client_reflection,
- bgp_client_to_client_reflection_cmd,
- "bgp client-to-client reflection",
- "BGP specific commands\n"
- "Configure client to client route reflection\n"
- "reflection of routes allowed\n")
-{
- nb_cli_enqueue_change(vty, "./route-reflector/no-client-reflect",
- NB_OP_MODIFY, "false");
-
- return nb_cli_apply_changes(vty, NULL);
-}
-DEFUN_YANG(no_bgp_client_to_client_reflection,
- no_bgp_client_to_client_reflection_cmd,
- "no bgp client-to-client reflection",
- NO_STR
- "BGP specific commands\n"
- "Configure client to client route reflection\n"
- "reflection of routes allowed\n")
+DEFUN (bgp_client_to_client_reflection,
+ bgp_client_to_client_reflection_cmd,
+ "bgp client-to-client reflection",
+ "BGP specific commands\n"
+ "Configure client to client route reflection\n"
+ "reflection of routes allowed\n")
{
- nb_cli_enqueue_change(vty, "./route-reflector/no-client-reflect",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+ bgp_clear_star_soft_out(vty, bgp->name);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_route_selection(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_client_to_client_reflection,
+ no_bgp_client_to_client_reflection_cmd,
+ "no bgp client-to-client reflection",
+ NO_STR
+ "BGP specific commands\n"
+ "Configure client to client route reflection\n"
+ "reflection of routes allowed\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT);
+ bgp_clear_star_soft_out(vty, bgp->name);
- if (yang_dnode_get_bool(dnode, "./always-compare-med"))
- vty_out(vty, " bgp always-compare-med\n");
-
- if (yang_dnode_get_bool(dnode, "./ignore-as-path-length"))
- vty_out(vty, " bgp bestpath as-path ignore\n");
-
- if (yang_dnode_get_bool(dnode, "./aspath-confed"))
- vty_out(vty, " bgp bestpath as-path confed\n");
-
- if (yang_dnode_get_bool(dnode, "./external-compare-router-id"))
- vty_out(vty, " bgp bestpath compare-routerid\n");
-
- if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) {
- if (yang_dnode_get_bool(dnode, "./multi-path-as-set"))
- vty_out(vty,
- " bgp bestpath as-path multipath-relax as-set\n");
- else
- vty_out(vty, " bgp bestpath as-path multipath-relax\n");
- }
-
- if (yang_dnode_get_bool(dnode, "./deterministic-med"))
- vty_out(vty, " bgp deterministic-med\n");
-
- if (yang_dnode_get_bool(dnode, "./confed-med")
- || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) {
- vty_out(vty, " bgp bestpath med");
- if (yang_dnode_get_bool(dnode, "./confed-med"))
- vty_out(vty, " confed");
- if (yang_dnode_get_bool(dnode, "./missing-as-worst-med"))
- vty_out(vty, " missing-as-worst");
- vty_out(vty, "\n");
- }
+ return CMD_SUCCESS;
}
/* "bgp always-compare-med" configuration. */
-DEFUN_YANG(bgp_always_compare_med,
- bgp_always_compare_med_cmd,
- "bgp always-compare-med",
- "BGP specific commands\n"
- "Allow comparing MED from different neighbors\n")
+DEFUN (bgp_always_compare_med,
+ bgp_always_compare_med_cmd,
+ "bgp always-compare-med",
+ "BGP specific commands\n"
+ "Allow comparing MED from different neighbors\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/always-compare-med",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_always_compare_med,
- no_bgp_always_compare_med_cmd,
- "no bgp always-compare-med",
- NO_STR
- "BGP specific commands\n"
- "Allow comparing MED from different neighbors\n")
+DEFUN (no_bgp_always_compare_med,
+ no_bgp_always_compare_med_cmd,
+ "no bgp always-compare-med",
+ NO_STR
+ "BGP specific commands\n"
+ "Allow comparing MED from different neighbors\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/always-compare-med",
- NB_OP_MODIFY, "false");
-
- return nb_cli_apply_changes(vty, NULL);
-}
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED);
+ bgp_recalculate_all_bestpaths(bgp);
-DEFUN_YANG(bgp_suppress_duplicates,
- bgp_suppress_duplicates_cmd,
- "bgp suppress-duplicates",
- "BGP specific commands\n"
- "Suppress duplicate updates if the route actually not changed\n")
-{
- nb_cli_enqueue_change(vty, "./global/suppress-duplicates",
- NB_OP_MODIFY, "true");
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_suppress_duplicates,
- no_bgp_suppress_duplicates_cmd,
- "no bgp suppress-duplicates",
- NO_STR
- "BGP specific commands\n"
- "Suppress duplicate updates if the route actually not changed\n")
-{
- nb_cli_enqueue_change(vty, "./global/suppress-duplicates",
- NB_OP_MODIFY, "false");
- return nb_cli_apply_changes(vty, NULL);
-}
-void cli_show_router_bgp_suppress_duplicates(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd,
+ "bgp ebgp-requires-policy",
+ "BGP specific commands\n"
+ "Require in and out policy for eBGP peers (RFC8212)\n")
{
- if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SUPPRESS_DUPLICATES)
- vty_out(vty, " bgp suppress-duplicates\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_ebgp_requires_policy,
- bgp_ebgp_requires_policy_cmd,
- "bgp ebgp-requires-policy",
- "BGP specific commands\n"
- "Require in and out policy for eBGP peers (RFC8212)\n")
+DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd,
+ "no bgp ebgp-requires-policy",
+ NO_STR
+ "BGP specific commands\n"
+ "Require in and out policy for eBGP peers (RFC8212)\n")
{
- nb_cli_enqueue_change(vty, "./ebgp-requires-policy", NB_OP_MODIFY,
- "true");
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_ebgp_requires_policy,
- no_bgp_ebgp_requires_policy_cmd,
- "no bgp ebgp-requires-policy",
- NO_STR
- "BGP specific commands\n"
- "Require in and out policy for eBGP peers (RFC8212)\n")
+DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd,
+ "bgp suppress-duplicates",
+ "BGP specific commands\n"
+ "Suppress duplicate updates if the route actually not changed\n")
{
- nb_cli_enqueue_change(vty, "./ebgp-requires-policy", NB_OP_MODIFY,
- "false");
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd,
+ "no bgp suppress-duplicates",
+ NO_STR
+ "BGP specific commands\n"
+ "Suppress duplicate updates if the route actually not changed\n")
{
- if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY)
- vty_out(vty, " bgp ebgp-requires-policy\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES);
+ return CMD_SUCCESS;
}
DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd,
}
/* "bgp deterministic-med" configuration. */
-DEFUN_YANG (bgp_deterministic_med,
+DEFUN (bgp_deterministic_med,
bgp_deterministic_med_cmd,
"bgp deterministic-med",
"BGP specific commands\n"
"Pick the best-MED path among paths advertised from the neighboring AS\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/deterministic-med",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
+ bgp_recalculate_all_bestpaths(bgp);
+ }
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_deterministic_med,
+DEFUN (no_bgp_deterministic_med,
no_bgp_deterministic_med_cmd,
"no bgp deterministic-med",
NO_STR
"BGP specific commands\n"
"Pick the best-MED path among paths advertised from the neighboring AS\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/deterministic-med",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int bestpath_per_as_used;
+ afi_t afi;
+ safi_t safi;
+ struct peer *peer;
+ struct listnode *node, *nnode;
- return nb_cli_apply_changes(vty, NULL);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
+ bestpath_per_as_used = 0;
+
+ for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+ FOREACH_AFI_SAFI (afi, safi)
+ if (bgp_addpath_dmed_required(
+ peer->addpath_type[afi][safi])) {
+ bestpath_per_as_used = 1;
+ break;
+ }
+
+ if (bestpath_per_as_used)
+ break;
+ }
+
+ if (bestpath_per_as_used) {
+ vty_out(vty,
+ "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ } else {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED);
+ bgp_recalculate_all_bestpaths(bgp);
+ }
+ }
+
+ return CMD_SUCCESS;
}
/* "bgp graceful-restart mode" configuration. */
return CMD_SUCCESS;
}
-static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp,
- char *errmsg,
- size_t errmsg_len)
+static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty,
+ struct bgp *bgp)
{
bgp_static_redo_import_check(bgp);
bgp_redistribute_redo(bgp);
- if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0)
- return -1;
- if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0)
- return -1;
-
- return 0;
+ bgp_clear_star_soft_out(vty, bgp->name);
+ bgp_clear_star_soft_in(vty, bgp->name);
}
static int bgp_global_graceful_shutdown_config_vty(struct vty *vty)
struct listnode *node, *nnode;
struct bgp *bgp;
bool vrf_cfg = false;
- char errmsg[BUFSIZ] = {'\0'};
if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN))
return CMD_SUCCESS;
SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN);
/* Initiate processing for all BGP instances. */
- for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
- if (bgp_initiate_graceful_shut_unshut(bgp, errmsg,
- sizeof(errmsg))
- < 0)
- if (strlen(errmsg))
- vty_out(vty, "%s\n", errmsg);
- }
+ for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
+ bgp_initiate_graceful_shut_unshut(vty, bgp);
return CMD_SUCCESS;
}
{
struct listnode *node, *nnode;
struct bgp *bgp;
- char errmsg[BUFSIZ] = {'\0'};
if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN))
return CMD_SUCCESS;
UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN);
/* Initiate processing for all BGP instances. */
- for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
- if (bgp_initiate_graceful_shut_unshut(bgp, errmsg,
- sizeof(errmsg))
- < 0)
- if (strlen(errmsg))
- vty_out(vty, "%s\n", errmsg);
- }
+ for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
+ bgp_initiate_graceful_shut_unshut(vty, bgp);
return CMD_SUCCESS;
}
if (vty->node == CONFIG_NODE)
return bgp_global_graceful_shutdown_config_vty(vty);
- nb_cli_enqueue_change(vty, "./graceful-shutdown/enable", NB_OP_MODIFY,
- "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
+ /* if configured globally, per-instance config is not allowed */
+ if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) {
+ vty_out(vty,
+ "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
+ bgp_initiate_graceful_shut_unshut(vty, bgp);
+ }
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_graceful_shutdown,
+DEFUN (no_bgp_graceful_shutdown,
no_bgp_graceful_shutdown_cmd,
"no bgp graceful-shutdown",
NO_STR
if (vty->node == CONFIG_NODE)
return bgp_global_graceful_shutdown_deconfig_vty(vty);
- nb_cli_enqueue_change(vty, "./graceful-shutdown/enable", NB_OP_MODIFY,
- "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
-}
+ /* If configured globally, cannot remove from one bgp instance */
+ if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) {
+ vty_out(vty,
+ "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
-void cli_show_router_bgp_graceful_shutdown(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
-{
- if (yang_dnode_get_bool(dnode, NULL))
- vty_out(vty, " bgp graceful-shutdown\n");
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN);
+ bgp_initiate_graceful_shut_unshut(vty, bgp);
+ }
+
+ return CMD_SUCCESS;
}
/* "bgp fast-external-failover" configuration. */
-DEFUN_YANG (bgp_fast_external_failover,
+DEFUN (bgp_fast_external_failover,
bgp_fast_external_failover_cmd,
"bgp fast-external-failover",
BGP_STR
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
- nb_cli_enqueue_change(vty, "./fast-external-failover", NB_OP_MODIFY,
- "false");
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_fast_external_failover,
+DEFUN (no_bgp_fast_external_failover,
no_bgp_fast_external_failover_cmd,
"no bgp fast-external-failover",
NO_STR
BGP_STR
"Immediately reset session if a link to a directly connected external peer goes down\n")
{
- nb_cli_enqueue_change(vty, "./fast-external-failover", NB_OP_MODIFY,
- "true");
-
- return nb_cli_apply_changes(vty, NULL);
-}
-
-void cli_show_router_bgp_fast_external_failover(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
-{
- if (!yang_dnode_get_bool(dnode, NULL))
- vty_out(vty, " no bgp fast-external-failover\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER);
+ return CMD_SUCCESS;
}
/* "bgp bestpath compare-routerid" configuration. */
-DEFUN_YANG(bgp_bestpath_compare_router_id,
- bgp_bestpath_compare_router_id_cmd,
- "bgp bestpath compare-routerid",
- "BGP specific commands\n"
- "Change the default bestpath selection\n"
- "Compare router-id for identical EBGP paths\n")
+DEFUN (bgp_bestpath_compare_router_id,
+ bgp_bestpath_compare_router_id_cmd,
+ "bgp bestpath compare-routerid",
+ "BGP specific commands\n"
+ "Change the default bestpath selection\n"
+ "Compare router-id for identical EBGP paths\n")
{
- nb_cli_enqueue_change(
- vty, "./route-selection-options/external-compare-router-id",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_bestpath_compare_router_id,
- no_bgp_bestpath_compare_router_id_cmd,
- "no bgp bestpath compare-routerid",
- NO_STR
- "BGP specific commands\n"
- "Change the default bestpath selection\n"
- "Compare router-id for identical EBGP paths\n")
+DEFUN (no_bgp_bestpath_compare_router_id,
+ no_bgp_bestpath_compare_router_id_cmd,
+ "no bgp bestpath compare-routerid",
+ NO_STR
+ "BGP specific commands\n"
+ "Change the default bestpath selection\n"
+ "Compare router-id for identical EBGP paths\n")
{
- nb_cli_enqueue_change(
- vty, "./route-selection-options/external-compare-router-id",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
/* "bgp bestpath as-path ignore" configuration. */
-DEFUN_YANG(bgp_bestpath_aspath_ignore,
- bgp_bestpath_aspath_ignore_cmd,
- "bgp bestpath as-path ignore",
- "BGP specific commands\n"
- "Change the default bestpath selection\n"
- "AS-path attribute\n"
- "Ignore as-path length in selecting a route\n")
+DEFUN (bgp_bestpath_aspath_ignore,
+ bgp_bestpath_aspath_ignore_cmd,
+ "bgp bestpath as-path ignore",
+ "BGP specific commands\n"
+ "Change the default bestpath selection\n"
+ "AS-path attribute\n"
+ "Ignore as-path length in selecting a route\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/ignore-as-path-length",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_bestpath_aspath_ignore,
- no_bgp_bestpath_aspath_ignore_cmd,
- "no bgp bestpath as-path ignore",
- NO_STR
- "BGP specific commands\n"
- "Change the default bestpath selection\n"
- "AS-path attribute\n"
- "Ignore as-path length in selecting a route\n")
+DEFUN (no_bgp_bestpath_aspath_ignore,
+ no_bgp_bestpath_aspath_ignore_cmd,
+ "no bgp bestpath as-path ignore",
+ NO_STR
+ "BGP specific commands\n"
+ "Change the default bestpath selection\n"
+ "AS-path attribute\n"
+ "Ignore as-path length in selecting a route\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/ignore-as-path-length",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
/* "bgp bestpath as-path confed" configuration. */
-DEFUN_YANG (bgp_bestpath_aspath_confed,
+DEFUN (bgp_bestpath_aspath_confed,
bgp_bestpath_aspath_confed_cmd,
"bgp bestpath as-path confed",
"BGP specific commands\n"
"AS-path attribute\n"
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
- nb_cli_enqueue_change(vty, "./route-selection-options/aspath-confed",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_bestpath_aspath_confed,
+DEFUN (no_bgp_bestpath_aspath_confed,
no_bgp_bestpath_aspath_confed_cmd,
"no bgp bestpath as-path confed",
NO_STR
"AS-path attribute\n"
"Compare path lengths including confederation sets & sequences in selecting a route\n")
{
- nb_cli_enqueue_change(vty, "./route-selection-options/aspath-confed",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
/* "bgp bestpath as-path multipath-relax" configuration. */
-DEFUN_YANG (bgp_bestpath_aspath_multipath_relax,
+DEFUN (bgp_bestpath_aspath_multipath_relax,
bgp_bestpath_aspath_multipath_relax_cmd,
"bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
"BGP specific commands\n"
"Generate an AS_SET\n"
"Do not generate an AS_SET\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx = 0;
+ SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
- nb_cli_enqueue_change(vty,
- "./route-selection-options/allow-multiple-as",
- NB_OP_MODIFY, "true");
+ /* no-as-set is now the default behavior so we can silently
+ * ignore it */
if (argv_find(argv, argc, "as-set", &idx))
- nb_cli_enqueue_change(
- vty, "./route-selection-options/multi-path-as-set",
- NB_OP_MODIFY, "true");
+ SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
else
- nb_cli_enqueue_change(
- vty, "./route-selection-options/multi-path-as-set",
- NB_OP_MODIFY, "false");
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax,
+DEFUN (no_bgp_bestpath_aspath_multipath_relax,
no_bgp_bestpath_aspath_multipath_relax_cmd,
"no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
NO_STR
"Generate an AS_SET\n"
"Do not generate an AS_SET\n")
{
- nb_cli_enqueue_change(vty,
- "./route-selection-options/allow-multiple-as",
- NB_OP_MODIFY, "false");
- nb_cli_enqueue_change(vty,
- "./route-selection-options/multi-path-as-set",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
/* "bgp bestpath peer-type multipath-relax" configuration. */
}
/* "bgp log-neighbor-changes" configuration. */
-DEFUN_YANG(bgp_log_neighbor_changes,
- bgp_log_neighbor_changes_cmd,
- "bgp log-neighbor-changes",
- "BGP specific commands\n"
- "Log neighbor up/down and reset reason\n")
+DEFUN (bgp_log_neighbor_changes,
+ bgp_log_neighbor_changes_cmd,
+ "bgp log-neighbor-changes",
+ "BGP specific commands\n"
+ "Log neighbor up/down and reset reason\n")
{
- nb_cli_enqueue_change(vty,
- "./global-neighbor-config/log-neighbor-changes",
- NB_OP_MODIFY, "true");
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_log_neighbor_changes,
- no_bgp_log_neighbor_changes_cmd,
- "no bgp log-neighbor-changes",
- NO_STR
- "BGP specific commands\n"
- "Log neighbor up/down and reset reason\n")
+DEFUN (no_bgp_log_neighbor_changes,
+ no_bgp_log_neighbor_changes_cmd,
+ "no bgp log-neighbor-changes",
+ NO_STR
+ "BGP specific commands\n"
+ "Log neighbor up/down and reset reason\n")
{
- nb_cli_enqueue_change(vty,
- "./global-neighbor-config/log-neighbor-changes",
- NB_OP_MODIFY, "false");
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+ return CMD_SUCCESS;
}
/* "bgp bestpath med" configuration. */
-DEFUN_YANG (bgp_bestpath_med,
+DEFUN (bgp_bestpath_med,
bgp_bestpath_med_cmd,
"bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
"BGP specific commands\n"
"Treat missing MED as the least preferred one\n"
"Compare MED among confederation paths\n")
{
- int idx = 0;
- bool confed = false;
- bool worst_med = false;
-
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int idx = 0;
if (argv_find(argv, argc, "confed", &idx))
- confed = true;
-
- nb_cli_enqueue_change(vty, "./route-selection-options/confed-med",
- NB_OP_MODIFY, confed ? "true" : "false");
-
+ SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
idx = 0;
if (argv_find(argv, argc, "missing-as-worst", &idx))
- worst_med = true;
+ SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
- nb_cli_enqueue_change(vty,
- "./route-selection-options/missing-as-worst-med",
- NB_OP_MODIFY, worst_med ? "true" : "false");
+ bgp_recalculate_all_bestpaths(bgp);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG (no_bgp_bestpath_med,
+DEFUN (no_bgp_bestpath_med,
no_bgp_bestpath_med_cmd,
"no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
NO_STR
"Treat missing MED as the least preferred one\n"
"Compare MED among confederation paths\n")
{
- int idx = 0;
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int idx = 0;
if (argv_find(argv, argc, "confed", &idx))
- nb_cli_enqueue_change(vty,
- "./route-selection-options/confed-med",
- NB_OP_MODIFY, "false");
-
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED);
idx = 0;
if (argv_find(argv, argc, "missing-as-worst", &idx))
- nb_cli_enqueue_change(
- vty, "./route-selection-options/missing-as-worst-med",
- NB_OP_MODIFY, "false");
+ UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST);
- return nb_cli_apply_changes(vty, NULL);
+ bgp_recalculate_all_bestpaths(bgp);
+
+ return CMD_SUCCESS;
}
/* "bgp bestpath bandwidth" configuration. */
}
/* Display hostname in certain command outputs */
-DEFUN_YANG (bgp_default_show_hostname,
+DEFUN (bgp_default_show_hostname,
bgp_default_show_hostname_cmd,
"bgp default show-hostname",
"BGP specific commands\n"
"Configure BGP defaults\n"
"Show hostname in certain command outputs\n")
{
- nb_cli_enqueue_change(vty, "./show-hostname", NB_OP_MODIFY, "true");
-
- return nb_cli_apply_changes(vty, NULL);
-}
-
-DEFUN_YANG(no_bgp_default_show_hostname,
- no_bgp_default_show_hostname_cmd,
- "no bgp default show-hostname",
- NO_STR
- "BGP specific commands\n"
- "Configure BGP defaults\n"
- "Show hostname in certain command outputs\n")
-{
- nb_cli_enqueue_change(vty, "./show-hostname", NB_OP_MODIFY, "false");
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_default_show_hostname,
+ no_bgp_default_show_hostname_cmd,
+ "no bgp default show-hostname",
+ NO_STR
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "Show hostname in certain command outputs\n")
{
- if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME)
- vty_out(vty, " bgp default show-hostname\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME);
+ return CMD_SUCCESS;
}
/* Display hostname in certain command outputs */
"Configure BGP defaults\n"
"Show hostname for nexthop in certain command outputs\n")
{
- nb_cli_enqueue_change(vty, "./show-nexthop-hostname", NB_OP_MODIFY,
- "true");
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
+ return CMD_SUCCESS;
}
DEFUN (no_bgp_default_show_nexthop_hostname,
"Configure BGP defaults\n"
"Show hostname for nexthop in certain command outputs\n")
{
- nb_cli_enqueue_change(vty, "./show-nexthop-hostname", NB_OP_MODIFY,
- "false");
-
- return nb_cli_apply_changes(vty, NULL);
-}
-
-void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
-{
- if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME)
- vty_out(vty, " bgp default show-nexthop-hostname\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
+ return CMD_SUCCESS;
}
/* "bgp network import-check" configuration. */
-DEFUN_YANG(bgp_network_import_check,
- bgp_network_import_check_cmd,
- "bgp network import-check",
- "BGP specific commands\n"
- "BGP network command\n"
- "Check BGP network route exists in IGP\n")
+DEFUN (bgp_network_import_check,
+ bgp_network_import_check_cmd,
+ "bgp network import-check",
+ "BGP specific commands\n"
+ "BGP network command\n"
+ "Check BGP network route exists in IGP\n")
{
- nb_cli_enqueue_change(vty, "./import-check", NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
+ bgp_static_redo_import_check(bgp);
+ }
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd,
"Check BGP network route exists in IGP\n"
"Match route precisely\n")
-DEFUN_YANG(no_bgp_network_import_check,
- no_bgp_network_import_check_cmd,
- "no bgp network import-check",
- NO_STR
- "BGP specific commands\n"
- "BGP network command\n"
- "Check BGP network route exists in IGP\n")
+DEFUN (no_bgp_network_import_check,
+ no_bgp_network_import_check_cmd,
+ "no bgp network import-check",
+ NO_STR
+ "BGP specific commands\n"
+ "BGP network command\n"
+ "Check BGP network route exists in IGP\n")
{
- nb_cli_enqueue_change(vty, "./import-check", NB_OP_MODIFY, "false");
-
- return nb_cli_apply_changes(vty, NULL);
-}
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK);
+ bgp_static_redo_import_check(bgp);
+ }
-void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
-{
- if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK)
- vty_out(vty, " bgp network import-check\n");
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_default_local_preference,
- bgp_default_local_preference_cmd,
- "bgp default local-preference (0-4294967295)",
- "BGP specific commands\n"
- "Configure BGP defaults\n"
- "local preference (higher=more preferred)\n"
- "Configure default local preference value\n")
+DEFUN (bgp_default_local_preference,
+ bgp_default_local_preference_cmd,
+ "bgp default local-preference (0-4294967295)",
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "local preference (higher=more preferred)\n"
+ "Configure default local preference value\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
+ uint32_t local_pref;
- nb_cli_enqueue_change(vty, "./local-pref", NB_OP_MODIFY,
- argv[idx_number]->arg);
+ local_pref = strtoul(argv[idx_number]->arg, NULL, 10);
- return nb_cli_apply_changes(vty, NULL);
-}
+ bgp_default_local_preference_set(bgp, local_pref);
+ bgp_clear_star_soft_in(vty, bgp->name);
-DEFUN_YANG(no_bgp_default_local_preference,
- no_bgp_default_local_preference_cmd,
- "no bgp default local-preference [(0-4294967295)]",
- NO_STR
- "BGP specific commands\n"
- "Configure BGP defaults\n"
- "local preference (higher=more preferred)\n"
- "Configure default local preference value\n")
-{
- nb_cli_enqueue_change(vty, "./local-pref", NB_OP_MODIFY, NULL);
-
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_default_local_preference,
+ no_bgp_default_local_preference_cmd,
+ "no bgp default local-preference [(0-4294967295)]",
+ NO_STR
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "local preference (higher=more preferred)\n"
+ "Configure default local preference value\n")
{
- vty_out(vty, " bgp default local-preference %u\n",
- yang_dnode_get_uint32(dnode, NULL));
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_default_local_preference_unset(bgp);
+ bgp_clear_star_soft_in(vty, bgp->name);
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_default_subgroup_pkt_queue_max,
- bgp_default_subgroup_pkt_queue_max_cmd,
- "bgp default subgroup-pkt-queue-max (20-100)",
- "BGP specific commands\n"
- "Configure BGP defaults\n"
- "subgroup-pkt-queue-max\n"
- "Configure subgroup packet queue max\n")
+DEFUN (bgp_default_subgroup_pkt_queue_max,
+ bgp_default_subgroup_pkt_queue_max_cmd,
+ "bgp default subgroup-pkt-queue-max (20-100)",
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "subgroup-pkt-queue-max\n"
+ "Configure subgroup packet queue max\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
+ uint32_t max_size;
- nb_cli_enqueue_change(
- vty, "./global-update-group-config/subgroup-pkt-queue-size",
- NB_OP_MODIFY, argv[idx_number]->arg);
-
- return nb_cli_apply_changes(vty, NULL);
-}
+ max_size = strtoul(argv[idx_number]->arg, NULL, 10);
-DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max,
- no_bgp_default_subgroup_pkt_queue_max_cmd,
- "no bgp default subgroup-pkt-queue-max [(20-100)]",
- NO_STR
- "BGP specific commands\n"
- "Configure BGP defaults\n"
- "subgroup-pkt-queue-max\n"
- "Configure subgroup packet queue max\n")
-{
- nb_cli_enqueue_change(
- vty, "./global-update-group-config/subgroup-pkt-queue-size",
- NB_OP_MODIFY, NULL);
+ bgp_default_subgroup_pkt_queue_max_set(bgp, max_size);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
- struct vty *vty, struct lyd_node *dnode, bool show_defaults)
+DEFUN (no_bgp_default_subgroup_pkt_queue_max,
+ no_bgp_default_subgroup_pkt_queue_max_cmd,
+ "no bgp default subgroup-pkt-queue-max [(20-100)]",
+ NO_STR
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "subgroup-pkt-queue-max\n"
+ "Configure subgroup packet queue max\n")
{
- vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n",
- yang_dnode_get_uint32(dnode, NULL));
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_default_subgroup_pkt_queue_max_unset(bgp);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_rr_allow_outbound_policy,
- bgp_rr_allow_outbound_policy_cmd,
- "bgp route-reflector allow-outbound-policy",
- "BGP specific commands\n"
- "Allow modifications made by out route-map\n"
- "on ibgp neighbors\n")
-{
- nb_cli_enqueue_change(vty, "./route-reflector/allow-outbound-policy",
- NB_OP_MODIFY, "true");
- return nb_cli_apply_changes(vty, NULL);
-}
-
-DEFUN_YANG(no_bgp_rr_allow_outbound_policy,
- no_bgp_rr_allow_outbound_policy_cmd,
- "no bgp route-reflector allow-outbound-policy",
- NO_STR
- "BGP specific commands\n"
- "Allow modifications made by out route-map\n"
- "on ibgp neighbors\n")
+DEFUN (bgp_rr_allow_outbound_policy,
+ bgp_rr_allow_outbound_policy_cmd,
+ "bgp route-reflector allow-outbound-policy",
+ "BGP specific commands\n"
+ "Allow modifications made by out route-map\n"
+ "on ibgp neighbors\n")
{
- nb_cli_enqueue_change(vty, "./route-reflector/allow-outbound-policy",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- return nb_cli_apply_changes(vty, NULL);
-}
+ if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+ update_group_announce_rrclients(bgp);
+ bgp_clear_star_soft_out(vty, bgp->name);
+ }
+ return CMD_SUCCESS;
+}
-void cli_show_router_global_neighbor_config(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (no_bgp_rr_allow_outbound_policy,
+ no_bgp_rr_allow_outbound_policy_cmd,
+ "no bgp route-reflector allow-outbound-policy",
+ NO_STR
+ "BGP specific commands\n"
+ "Allow modifications made by out route-map\n"
+ "on ibgp neighbors\n")
{
- uint32_t write_quanta, read_quanta;
-
- if (yang_dnode_get_bool(dnode, "./log-neighbor-changes"))
- vty_out(vty, " bgp log-neighbor-changes\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) {
- uint32_t listen_limit = yang_dnode_get_uint32(
- dnode, "./dynamic-neighbors-limit");
- vty_out(vty, " bgp listen limit %u\n", listen_limit);
+ if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {
+ UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
+ update_group_announce_rrclients(bgp);
+ bgp_clear_star_soft_out(vty, bgp->name);
}
- write_quanta = yang_dnode_get_uint32(
- dnode, "./packet-quanta-config/wpkt-quanta");
- if (write_quanta != BGP_WRITE_PACKET_MAX)
- vty_out(vty, " write-quanta %d\n", write_quanta);
-
- read_quanta = yang_dnode_get_uint32(
- dnode, "./packet-quanta-config/rpkt-quanta");
-
- if (read_quanta != BGP_READ_PACKET_MAX)
- vty_out(vty, " read-quanta %d\n", read_quanta);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(bgp_listen_limit,
- bgp_listen_limit_cmd,
- "bgp listen limit (1-65535)",
- "BGP specific commands\n"
- "BGP Dynamic Neighbors listen commands\n"
- "Maximum number of BGP Dynamic Neighbors that can be created\n"
- "Configure Dynamic Neighbors listen limit value\n")
+DEFUN (bgp_listen_limit,
+ bgp_listen_limit_cmd,
+ "bgp listen limit (1-65535)",
+ "BGP specific commands\n"
+ "BGP Dynamic Neighbors listen commands\n"
+ "Maximum number of BGP Dynamic Neighbors that can be created\n"
+ "Configure Dynamic Neighbors listen limit value\n")
{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_number = 3;
+ int listen_limit;
- nb_cli_enqueue_change(
- vty, "./global-neighbor-config/dynamic-neighbors-limit",
- NB_OP_MODIFY, argv[idx_number]->arg);
+ listen_limit = strtoul(argv[idx_number]->arg, NULL, 10);
- return nb_cli_apply_changes(vty, NULL);
+ bgp_listen_limit_set(bgp, listen_limit);
+
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_listen_limit,
- no_bgp_listen_limit_cmd,
- "no bgp listen limit [(1-65535)]",
- NO_STR
- "BGP specific commands\n"
- "BGP Dynamic Neighbors listen commands\n"
- "Maximum number of BGP Dynamic Neighbors that can be created\n"
- "Configure Dynamic Neighbors listen limit value\n")
+DEFUN (no_bgp_listen_limit,
+ no_bgp_listen_limit_cmd,
+ "no bgp listen limit [(1-65535)]",
+ NO_STR
+ "BGP specific commands\n"
+ "BGP Dynamic Neighbors listen commands\n"
+ "Maximum number of BGP Dynamic Neighbors that can be created\n"
+ "Configure Dynamic Neighbors listen limit value\n")
{
- nb_cli_enqueue_change(
- vty, "./global-neighbor-config/dynamic-neighbors-limit",
- NB_OP_DESTROY, NULL);
-
- return nb_cli_apply_changes(vty, NULL);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp_listen_limit_unset(bgp);
+ return CMD_SUCCESS;
}
}
-DEFUN_YANG(bgp_disable_connected_route_check,
- bgp_disable_connected_route_check_cmd,
- "bgp disable-ebgp-connected-route-check",
- "BGP specific commands\n"
- "Disable checking if nexthop is connected on ebgp sessions\n")
+DEFUN (bgp_disable_connected_route_check,
+ bgp_disable_connected_route_check_cmd,
+ "bgp disable-ebgp-connected-route-check",
+ "BGP specific commands\n"
+ "Disable checking if nexthop is connected on ebgp sessions\n")
{
- nb_cli_enqueue_change(vty, "./ebgp-multihop-connected-route-check",
- NB_OP_MODIFY, "true");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+ bgp_clear_star_soft_in(vty, bgp->name);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-DEFUN_YANG(no_bgp_disable_connected_route_check,
- no_bgp_disable_connected_route_check_cmd,
- "no bgp disable-ebgp-connected-route-check",
- NO_STR
- "BGP specific commands\n"
- "Disable checking if nexthop is connected on ebgp sessions\n")
+DEFUN (no_bgp_disable_connected_route_check,
+ no_bgp_disable_connected_route_check_cmd,
+ "no bgp disable-ebgp-connected-route-check",
+ NO_STR
+ "BGP specific commands\n"
+ "Disable checking if nexthop is connected on ebgp sessions\n")
{
- nb_cli_enqueue_change(vty, "./ebgp-multihop-connected-route-check",
- NB_OP_MODIFY, "false");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
+ bgp_clear_star_soft_in(vty, bgp->name);
- return nb_cli_apply_changes(vty, NULL);
+ return CMD_SUCCESS;
}
-void cli_show_router_global_ebgp_multihop_connected_route_check(
- struct vty *vty, struct lyd_node *dnode, bool show_defaults)
-{
- if (yang_dnode_get_bool(dnode, NULL))
- vty_out(vty, " bgp disable-ebgp-connected-route-check\n");
-}
static int peer_remote_as_vty(struct vty *vty, const char *peer_str,
const char *as_str)
return bgp_vty_return(vty, ret);
}
-DEFUN_YANG(bgp_default_shutdown,
- bgp_default_shutdown_cmd,
- "[no] bgp default shutdown",
- NO_STR BGP_STR
- "Configure BGP defaults\n"
- "Apply administrative shutdown to newly configured peers\n")
-{
- nb_cli_enqueue_change(vty, "./default-shutdown", NB_OP_MODIFY,
- strmatch(argv[0]->text, "no") ? "false" : "true");
-
- return nb_cli_apply_changes(vty, NULL);
-}
-
-void cli_show_router_bgp_default_shutdown(struct vty *vty,
- struct lyd_node *dnode,
- bool show_defaults)
+DEFUN (bgp_default_shutdown,
+ bgp_default_shutdown_cmd,
+ "[no] bgp default shutdown",
+ NO_STR
+ BGP_STR
+ "Configure BGP defaults\n"
+ "Apply administrative shutdown to newly configured peers\n")
{
- if (yang_dnode_get_bool(dnode, NULL))
- vty_out(vty, " bgp default shutdown\n");
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ bgp->autoshutdown = !strmatch(argv[0]->text, "no");
+ return CMD_SUCCESS;
}
DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...",
UNSET_FLAG(bgp->af_flags[afi][safi], flag);
}
+ hook_call(bgp_snmp_init_stats, bgp);
+
return CMD_SUCCESS;
}
char *clr_arg = NULL;
int idx = 0;
- char errmsg[BUFSIZ] = {'\0'};
- int ret;
/* clear [ip] bgp */
if (argv_find(argv, argc, "ip", &idx))
} else
clr_type = BGP_CLEAR_SOFT_NONE;
- ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg,
- sizeof(errmsg));
- if (ret != NB_OK)
- vty_out(vty, "Error description: %s\n", errmsg);
-
- return ret;
+ return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg);
}
DEFUN (clear_ip_bgp_prefix,