bgpd: convert max prefix clis to transactional

Signed-off-by: Chirag Shah <chirag@nvidia.com>
This commit is contained in:
Chirag Shah 2020-10-22 13:43:14 -07:00
parent afe03f6094
commit 04261decb9
4 changed files with 555 additions and 145 deletions

View File

@ -2588,6 +2588,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -2915,6 +2916,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -3127,6 +3129,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -3339,6 +3342,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -3551,6 +3555,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -3763,6 +3768,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -3954,6 +3960,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -4145,6 +4152,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -4435,6 +4443,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -4762,6 +4771,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -5398,6 +5408,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -5610,6 +5621,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -5801,6 +5813,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -5992,6 +6005,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -6282,6 +6296,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -6609,6 +6624,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -6821,6 +6837,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -7039,6 +7056,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -7257,6 +7275,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -7469,6 +7488,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -7660,6 +7680,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {
@ -7851,6 +7872,7 @@ const struct frr_yang_module_info frr_bgp_info = {
.cbs = { .cbs = {
.create = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create, .create = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_create,
.destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy, .destroy = bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_direction_list_destroy,
.apply_finish = bgp_peer_group_afi_safi_prefix_limit_apply_finish,
} }
}, },
{ {

View File

@ -3665,6 +3665,12 @@ void bgp_peer_groups_peer_group_admin_shutdown_apply_finish(
struct nb_cb_apply_finish_args *args); struct nb_cb_apply_finish_args *args);
void bgp_peer_groups_peer_group_local_as_apply_finish( void bgp_peer_groups_peer_group_local_as_apply_finish(
struct nb_cb_apply_finish_args *args); struct nb_cb_apply_finish_args *args);
void bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args);
void bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args);
void bgp_peer_group_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args);
/* xpath macros */ /* xpath macros */
/* route-list */ /* route-list */

View File

@ -13925,6 +13925,46 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_default_originate_opt
return NB_OK; return NB_OK;
} }
static int
bgp_neighbor_afi_safi_prefix_limit_list_destroy(struct nb_cb_destroy_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
int direction;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "neighbor");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./remote-address");
peer = bgp_neighbor_peer_lookup(bgp, peer_str, args->errmsg,
args->errmsg_len);
if (!peer)
return NB_ERR_INCONSISTENCY;
direction = yang_dnode_get_enum(args->dnode, "./direction");
switch (direction) {
case 1:
peer_maximum_prefix_unset(peer, afi, safi);
break;
case 2:
UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT);
peer->pmax_out[afi][safi] = 0;
break;
}
return NB_OK;
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list
@ -13951,14 +13991,101 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_limit_directio
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
} }
static void
bgp_peer_afi_safi_maximum_prefix_set(struct nb_cb_apply_finish_args *args,
struct peer *peer, afi_t afi, safi_t safi)
{
int direction;
uint32_t max;
uint8_t threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
uint16_t restart = 0;
bool warning = false;
bool force;
max = yang_dnode_get_uint32(args->dnode, "./max-prefixes");
direction = yang_dnode_get_enum(args->dnode, "./direction");
switch (direction) {
case 1:
force = yang_dnode_get_bool(args->dnode, "./force-check");
if (yang_dnode_exists(args->dnode,
"./options/shutdown-threshold-pct"))
threshold = yang_dnode_get_uint8(
args->dnode,
"./options/shutdown-threshold-pct");
if (yang_dnode_exists(args->dnode,
"./options/tw-shutdown-threshold-pct"))
threshold = yang_dnode_get_uint8(
args->dnode,
"./options/tw-shutdown-threshold-pct");
if (yang_dnode_exists(args->dnode,
"./options/tr-shutdown-threshold-pct"))
threshold = yang_dnode_get_uint8(
args->dnode,
"./options/tr-shutdown-threshold-pct");
if (yang_dnode_exists(args->dnode, "./options/warning-only"))
warning = yang_dnode_get_bool(args->dnode,
"./options/warning-only");
if (yang_dnode_exists(args->dnode, "./options/tw-warning-only"))
warning = yang_dnode_get_bool(
args->dnode, "./options/tw-warning-only");
if (yang_dnode_exists(args->dnode, "./options/restart-timer"))
restart = yang_dnode_get_uint16(
args->dnode, "./options/restart-timer");
if (yang_dnode_exists(args->dnode,
"./options/tr-restart-timer"))
restart = yang_dnode_get_uint16(
args->dnode, "./options/tr-restart-timer");
peer_maximum_prefix_set(peer, afi, safi, max, threshold,
warning, restart, force);
break;
case 2:
SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT);
peer->pmax_out[afi][safi] = max;
break;
}
}
void bgp_neighbors_neighbor_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "neighbor");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./remote-address");
peer = bgp_neighbor_peer_lookup(bgp, peer_str, args->errmsg,
args->errmsg_len);
if (!peer)
return;
bgp_peer_afi_safi_maximum_prefix_set(args, peer, afi, safi);
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes
@ -15447,9 +15574,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_limit_directio
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -16352,9 +16479,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_limit_direct
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -17257,9 +17384,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_limit_direct
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -18162,9 +18289,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_limit_
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -19067,9 +19194,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_limit_
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -19870,9 +19997,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limit_di
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -20673,9 +20800,9 @@ int bgp_neighbors_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limit_di
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_neighbor_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -21878,6 +22005,46 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_default_or
return NB_OK; return NB_OK;
} }
static int bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
struct nb_cb_destroy_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
int direction;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "unnumbered-neighbor");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./interface");
peer = bgp_unnumbered_neighbor_peer_lookup(bgp, peer_str, args->errmsg,
args->errmsg_len);
if (!peer)
return NB_ERR_INCONSISTENCY;
direction = yang_dnode_get_enum(args->dnode, "./direction");
switch (direction) {
case 1:
peer_maximum_prefix_unset(peer, afi, safi);
break;
case 2:
UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT);
peer->pmax_out[afi][safi] = 0;
break;
}
return NB_OK;
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list
@ -21904,14 +22071,42 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_unicast_prefix_lim
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
} }
void bgp_unnumbered_neighbor_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "unnumbered-neighbor");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./interface");
peer = bgp_unnumbered_neighbor_peer_lookup(bgp, peer_str, args->errmsg,
args->errmsg_len);
if (!peer)
return;
bgp_peer_afi_safi_maximum_prefix_set(args, peer, afi, safi);
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/neighbors/unnumbered-neighbor/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes
@ -23401,9 +23596,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_unicast_prefix_lim
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -24306,9 +24502,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_multicast_prefix_l
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -25211,9 +25408,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_multicast_prefix_l
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -26116,9 +26314,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv4_labeled_unicast_pr
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -27021,9 +27220,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_ipv6_labeled_unicast_pr
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -27824,9 +28024,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv4_unicast_pref
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -28627,9 +28828,10 @@ int bgp_neighbors_unnumbered_neighbor_afi_safis_afi_safi_l3vpn_ipv6_unicast_pref
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_unnumbered_neighbor_afi_safi_prefix_limit_list_destroy(
break; args);
} }
return NB_OK; return NB_OK;
@ -29829,6 +30031,44 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_default_originate
return NB_OK; return NB_OK;
} }
static int bgp_peer_group_afi_safi_prefix_limit_list_destroy(
struct nb_cb_destroy_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
int direction;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "peer-group");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./peer-group-name");
peer = bgp_peer_group_peer_lookup(bgp, peer_str);
if (!peer)
return NB_ERR_INCONSISTENCY;
direction = yang_dnode_get_enum(args->dnode, "./direction");
switch (direction) {
case 1:
peer_maximum_prefix_unset(peer, afi, safi);
break;
case 2:
UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT);
peer->pmax_out[afi][safi] = 0;
break;
}
return NB_OK;
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list
@ -29855,14 +30095,39 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_unicast_prefix_limit_dire
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
} }
void bgp_peer_group_afi_safi_prefix_limit_apply_finish(
struct nb_cb_apply_finish_args *args)
{
struct bgp *bgp;
const char *peer_str;
struct peer *peer;
const struct lyd_node *nbr_dnode;
const struct lyd_node *nbr_af_dnode;
const char *af_name;
afi_t afi;
safi_t safi;
nbr_af_dnode = yang_dnode_get_parent(args->dnode, "afi-safi");
af_name = yang_dnode_get_string(nbr_af_dnode, "./afi-safi-name");
yang_afi_safi_identity2value(af_name, &afi, &safi);
nbr_dnode = yang_dnode_get_parent(nbr_af_dnode, "peer-group");
bgp = nb_running_get_entry(nbr_dnode, NULL, true);
peer_str = yang_dnode_get_string(nbr_dnode, "./peer-group-name");
peer = bgp_peer_group_peer_lookup(bgp, peer_str);
if (!peer)
return;
bgp_peer_afi_safi_maximum_prefix_set(args, peer, afi, safi);
}
/* /*
* XPath: * XPath:
* /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/peer-groups/peer-group/afi-safis/afi-safi/ipv4-unicast/prefix-limit/direction-list/max-prefixes
@ -31349,9 +31614,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_unicast_prefix_limit_dire
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -32254,9 +32519,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_multicast_prefix_limit_di
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -33159,9 +33424,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_multicast_prefix_limit_di
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -34064,9 +34329,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv4_labeled_unicast_prefix_li
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -34969,9 +35234,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_labeled_unicast_prefix_li
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -35772,9 +36037,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv4_unicast_prefix_limi
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;
@ -36575,9 +36840,9 @@ int bgp_peer_groups_peer_group_afi_safis_afi_safi_l3vpn_ipv6_unicast_prefix_limi
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
return NB_OK;
case NB_EV_APPLY: case NB_EV_APPLY:
/* TODO: implement me. */ return bgp_peer_group_afi_safi_prefix_limit_list_destroy(args);
break;
} }
return NB_OK; return NB_OK;

View File

@ -8000,55 +8000,6 @@ ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd,
"Route-map to selectively unsuppress suppressed routes\n" "Route-map to selectively unsuppress suppressed routes\n"
"Name of route map\n") "Name of route map\n")
static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *num_str,
const char *threshold_str, int warning,
const char *restart_str,
const char *force_str)
{
int ret;
struct peer *peer;
uint32_t max;
uint8_t threshold;
uint16_t restart;
peer = peer_and_group_lookup_vty(vty, ip_str);
if (!peer)
return CMD_WARNING_CONFIG_FAILED;
max = strtoul(num_str, NULL, 10);
if (threshold_str)
threshold = atoi(threshold_str);
else
threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
if (restart_str)
restart = atoi(restart_str);
else
restart = 0;
ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning,
restart, force_str ? true : false);
return bgp_vty_return(vty, ret);
}
static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi)
{
int ret;
struct peer *peer;
peer = peer_and_group_lookup_vty(vty, ip_str);
if (!peer)
return CMD_WARNING_CONFIG_FAILED;
ret = peer_maximum_prefix_unset(peer, afi, safi);
return bgp_vty_return(vty, ret);
}
/* Maximum number of prefix to be sent to the neighbor. */ /* Maximum number of prefix to be sent to the neighbor. */
DEFUN(neighbor_maximum_prefix_out, DEFUN(neighbor_maximum_prefix_out,
neighbor_maximum_prefix_out_cmd, neighbor_maximum_prefix_out_cmd,
@ -8058,23 +8009,32 @@ DEFUN(neighbor_maximum_prefix_out,
"Maximum number of prefixes to be sent to this peer\n" "Maximum number of prefixes to be sent to this peer\n"
"Maximum no. of prefix limit\n") "Maximum no. of prefix limit\n")
{ {
char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
int idx_peer = 1; int idx_peer = 1;
int idx_number = 3; int idx_number = 3;
struct peer *peer;
uint32_t max;
afi_t afi = bgp_node_afi(vty); afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty); safi_t safi = bgp_node_safi(vty);
peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
if (!peer) yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
max = strtoul(argv[idx_number]->arg, NULL, 10); snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='out']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
peer->pmax_out[afi][safi] = max;
return CMD_SUCCESS; nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
return nb_cli_apply_changes(vty, base_xpath);
} }
DEFUN(no_neighbor_maximum_prefix_out, DEFUN(no_neighbor_maximum_prefix_out,
@ -8085,19 +8045,28 @@ DEFUN(no_neighbor_maximum_prefix_out,
NEIGHBOR_ADDR_STR2 NEIGHBOR_ADDR_STR2
"Maximum number of prefixes to be sent to this peer\n") "Maximum number of prefixes to be sent to this peer\n")
{ {
char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
int idx_peer = 2; int idx_peer = 2;
struct peer *peer;
afi_t afi = bgp_node_afi(vty); afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty); safi_t safi = bgp_node_safi(vty);
peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
if (!peer) yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); snprintf(attr_xpath, sizeof(attr_xpath),
peer->pmax_out[afi][safi] = 0; "/%s/prefix-limit/direction-list[direction='out']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
return CMD_SUCCESS; nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, base_xpath);
} }
/* Maximum number of prefix configuration. Prefix count is different /* Maximum number of prefix configuration. Prefix count is different
@ -8115,14 +8084,33 @@ DEFUN (neighbor_maximum_prefix,
int idx_peer = 1; int idx_peer = 1;
int idx_number = 3; int idx_number = 3;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, NULL, 0, NULL, force);
} }
ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd,
@ -8146,14 +8134,37 @@ DEFUN (neighbor_maximum_prefix_threshold,
int idx_number = 3; int idx_number = 3;
int idx_number_2 = 4; int idx_number_2 = 4;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
nb_cli_enqueue_change(vty, "./options/shutdown-threshold-pct",
NB_OP_MODIFY, argv[idx_number_2]->arg);
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(
@ -8179,14 +8190,36 @@ DEFUN (neighbor_maximum_prefix_warning,
int idx_peer = 1; int idx_peer = 1;
int idx_number = 3; int idx_number = 3;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
nb_cli_enqueue_change(vty, "./options/warning-only", NB_OP_MODIFY,
"true");
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, NULL, 1, NULL, force);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(
@ -8214,14 +8247,37 @@ DEFUN (neighbor_maximum_prefix_threshold_warning,
int idx_number = 3; int idx_number = 3;
int idx_number_2 = 4; int idx_number_2 = 4;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
nb_cli_enqueue_change(vty, "./options/tw-shutdown-threshold-pct",
NB_OP_MODIFY, argv[idx_number_2]->arg);
nb_cli_enqueue_change(vty, "./options/tw-warning-only", NB_OP_MODIFY,
"true");
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(
@ -8250,14 +8306,35 @@ DEFUN (neighbor_maximum_prefix_restart,
int idx_number = 3; int idx_number = 3;
int idx_number_2 = 5; int idx_number_2 = 5;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
nb_cli_enqueue_change(vty, "./options/restart-timer", NB_OP_MODIFY,
argv[idx_number_2]->arg);
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(
@ -8288,15 +8365,37 @@ DEFUN (neighbor_maximum_prefix_threshold_restart,
int idx_number_2 = 4; int idx_number_2 = 4;
int idx_number_3 = 6; int idx_number_3 = 6;
int idx_force = 0; int idx_force = 0;
char *force = NULL; char base_xpath[XPATH_MAXLEN];
char af_xpath[XPATH_MAXLEN];
char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY,
argv[idx_number]->arg);
nb_cli_enqueue_change(vty, "./options/tr-shutdown-threshold-pct",
NB_OP_MODIFY, argv[idx_number_2]->arg);
nb_cli_enqueue_change(vty, "./options/tr-restart-timer", NB_OP_MODIFY,
argv[idx_number_3]->arg);
if (argv_find(argv, argc, "force", &idx_force)) if (argv_find(argv, argc, "force", &idx_force))
force = argv[idx_force]->arg; nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY,
"true");
return peer_maximum_prefix_set_vty( return nb_cli_apply_changes(vty, base_xpath);
vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty),
argv[idx_number]->arg, argv[idx_number_2]->arg, 0,
argv[idx_number_3]->arg, force);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(
@ -8326,9 +8425,27 @@ DEFUN (no_neighbor_maximum_prefix,
"Force checking all received routes not only accepted\n") "Force checking all received routes not only accepted\n")
{ {
int idx_peer = 2; int idx_peer = 2;
return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, char base_xpath[XPATH_MAXLEN];
bgp_node_afi(vty), char af_xpath[XPATH_MAXLEN];
bgp_node_safi(vty)); char attr_xpath[XPATH_MAXLEN];
afi_t afi = bgp_node_afi(vty);
safi_t safi = bgp_node_safi(vty);
snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH,
yang_afi_safi_value2identity(afi, safi));
if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath,
sizeof(base_xpath), af_xpath)
< 0)
return CMD_WARNING_CONFIG_FAILED;
snprintf(attr_xpath, sizeof(attr_xpath),
"/%s/prefix-limit/direction-list[direction='in']",
bgp_afi_safi_get_container_str(afi, safi));
strlcat(base_xpath, attr_xpath, sizeof(base_xpath));
nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, base_xpath);
} }
ALIAS_HIDDEN( ALIAS_HIDDEN(