diff options
author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2024-12-10 18:36:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-10 18:36:50 +0100 |
commit | ccb57ad10f81af33256761d18adaf37eb776e9d2 (patch) | |
tree | c4e0fef9acfc6d18a4586e8f530896b6961a2c9a /pimd | |
parent | Merge pull request #17575 from opensourcerouting/fix/outgoing_rmap_supressed (diff) | |
parent | doc: document new SA limit command (diff) | |
download | frr-ccb57ad10f81af33256761d18adaf37eb776e9d2.tar.xz frr-ccb57ad10f81af33256761d18adaf37eb776e9d2.zip |
Merge pull request #17521 from opensourcerouting/msdp-sa-limit
pimd: MSDP per peer SA limit
Diffstat (limited to 'pimd')
-rw-r--r-- | pimd/pim_cmd.c | 24 | ||||
-rw-r--r-- | pimd/pim_msdp.c | 12 | ||||
-rw-r--r-- | pimd/pim_msdp.h | 3 | ||||
-rw-r--r-- | pimd/pim_nb.c | 7 | ||||
-rw-r--r-- | pimd/pim_nb.h | 2 | ||||
-rw-r--r-- | pimd/pim_nb_config.c | 42 |
6 files changed, 90 insertions, 0 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index bac964575..3fabe1706 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -7593,6 +7593,29 @@ DEFPY(msdp_shutdown, return nb_cli_apply_changes(vty, NULL); } +DEFPY(msdp_peer_sa_limit, msdp_peer_sa_limit_cmd, + "[no] msdp peer A.B.C.D$peer sa-limit ![(1-4294967294)$sa_limit]", + NO_STR + CFG_MSDP_STR + "Configure MSDP peer\n" + "MSDP peer address\n" + "Limit amount of SA\n" + "Maximum number of SA\n") +{ + const struct lyd_node *peer_node; + char xpath[XPATH_MAXLEN + 24]; + + snprintf(xpath, sizeof(xpath), "%s/msdp-peer[peer-ip='%s']", VTY_CURR_XPATH, peer_str); + peer_node = yang_dnode_get(vty->candidate_config->dnode, xpath); + if (peer_node == NULL) { + vty_out(vty, "%% MSDP peer %s not yet configured\n", peer_str); + return CMD_SUCCESS; + } + + nb_cli_enqueue_change(vty, "./sa-limit", NB_OP_MODIFY, sa_limit_str); + return nb_cli_apply_changes(vty, "%s", xpath); +} + static void ip_msdp_show_mesh_group(struct vty *vty, struct pim_msdp_mg *mg, struct json_object *json) { @@ -8988,6 +9011,7 @@ void pim_cmd_init(void) install_element(PIM_NODE, &msdp_log_neighbor_changes_cmd); install_element(PIM_NODE, &msdp_log_sa_changes_cmd); install_element(PIM_NODE, &msdp_shutdown_cmd); + install_element(PIM_NODE, &msdp_peer_sa_limit_cmd); install_element(PIM_NODE, &pim_bsr_candidate_rp_cmd); install_element(PIM_NODE, &pim_bsr_candidate_rp_group_cmd); diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c index ae887b248..bd86ca502 100644 --- a/pimd/pim_msdp.c +++ b/pimd/pim_msdp.c @@ -359,6 +359,15 @@ void pim_msdp_sa_ref(struct pim_instance *pim, struct pim_msdp_peer *mp, struct rp_info *rp_info; struct prefix grp; + /* Check peer SA limit. */ + if (mp && mp->sa_limit && mp->sa_cnt >= mp->sa_limit) { + if (pim_msdp_log_sa_events(pim)) + zlog_debug("MSDP peer %pI4 reject SA (%pI4, %pI4): SA limit %u of %u", + &mp->peer, &sg->src, &sg->grp, mp->sa_cnt, mp->sa_limit); + + return; + } + sa = pim_msdp_sa_add(pim, sg, rp); if (!sa) { return; @@ -1316,6 +1325,9 @@ bool pim_msdp_peer_config_write(struct vty *vty, struct pim_instance *pim) vty_out(vty, " msdp peer %pI4 sa-filter %s out\n", &mp->peer, mp->acl_out); + if (mp->sa_limit) + vty_out(vty, " msdp peer %pI4 sa-limit %u\n", &mp->peer, mp->sa_limit); + written = true; } diff --git a/pimd/pim_msdp.h b/pimd/pim_msdp.h index d0aa83d99..15ed685b3 100644 --- a/pimd/pim_msdp.h +++ b/pimd/pim_msdp.h @@ -152,6 +152,9 @@ struct pim_msdp_peer { char *acl_in; /** SA output access list name. */ char *acl_out; + + /** SA maximum amount. */ + uint32_t sa_limit; }; struct pim_msdp_mg_mbr { diff --git a/pimd/pim_nb.c b/pimd/pim_nb.c index 2b39f2dcb..b5d20419d 100644 --- a/pimd/pim_nb.c +++ b/pimd/pim_nb.c @@ -209,6 +209,13 @@ const struct frr_yang_module_info frr_pim_info = { } }, { + .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp-peer/sa-limit", + .cbs = { + .modify = pim_msdp_peer_sa_limit_modify, + .destroy = pim_msdp_peer_sa_limit_destroy, + } + }, + { .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/mlag", .cbs = { .create = routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_create, diff --git a/pimd/pim_nb.h b/pimd/pim_nb.h index f27b86680..7d30db04b 100644 --- a/pimd/pim_nb.h +++ b/pimd/pim_nb.h @@ -76,6 +76,8 @@ int pim_msdp_peer_sa_filter_out_destroy(struct nb_cb_destroy_args *args); int pim_msdp_peer_authentication_type_modify(struct nb_cb_modify_args *args); int pim_msdp_peer_authentication_key_modify(struct nb_cb_modify_args *args); int pim_msdp_peer_authentication_key_destroy(struct nb_cb_destroy_args *args); +int pim_msdp_peer_sa_limit_modify(struct nb_cb_modify_args *args); +int pim_msdp_peer_sa_limit_destroy(struct nb_cb_destroy_args *args); int routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_create( struct nb_cb_create_args *args); int routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_destroy( diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 41457ffba..4f79a890d 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -1580,6 +1580,48 @@ int pim_msdp_peer_sa_filter_out_destroy(struct nb_cb_destroy_args *args) } /* + * XPath: + * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/msdp-peer/sa-limit + */ +int pim_msdp_peer_sa_limit_modify(struct nb_cb_modify_args *args) +{ + struct pim_msdp_peer *mp; + + switch (args->event) { + case NB_EV_VALIDATE: + case NB_EV_PREPARE: + case NB_EV_ABORT: + /* NOTHING */ + break; + case NB_EV_APPLY: + mp = nb_running_get_entry(args->dnode, NULL, true); + mp->sa_limit = yang_dnode_get_uint32(args->dnode, NULL); + break; + } + + return NB_OK; +} + +int pim_msdp_peer_sa_limit_destroy(struct nb_cb_destroy_args *args) +{ + struct pim_msdp_peer *mp; + + switch (args->event) { + case NB_EV_VALIDATE: + case NB_EV_PREPARE: + case NB_EV_ABORT: + /* NOTHING */ + break; + case NB_EV_APPLY: + mp = nb_running_get_entry(args->dnode, NULL, true); + mp->sa_limit = 0; + break; + } + + return NB_OK; +} + +/* * XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-pim:pim/address-family/mlag */ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_mlag_create( |