Merge pull request #14399 from opensourcerouting/fix/bgpd_handle_BGP_MAX_ATTR

bgpd: BGP_ATTR_MAX can be 255, allow using it for path attr
This commit is contained in:
Jafar Al-Gharaibeh 2023-09-12 15:12:15 -05:00 committed by GitHub
commit 7e43a5bf2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -5151,7 +5151,7 @@ void bgp_path_attribute_discard_vty(struct vty *vty, struct peer *peer,
* then flush all.
*/
if (!discard_attrs) {
for (i = 0; i < BGP_ATTR_MAX; i++)
for (i = 1; i <= BGP_ATTR_MAX; i++)
peer->discard_attrs[i] = false;
goto discard_soft_clear;
}
@ -5160,7 +5160,7 @@ void bgp_path_attribute_discard_vty(struct vty *vty, struct peer *peer,
frrstr_split(discard_attrs, " ", &attributes, &num_attributes);
if (set)
for (i = 0; i < BGP_ATTR_MAX; i++)
for (i = 1; i <= BGP_ATTR_MAX; i++)
peer->discard_attrs[i] = false;
for (i = 0; i < num_attributes; i++) {
@ -5220,7 +5220,7 @@ void bgp_path_attribute_withdraw_vty(struct vty *vty, struct peer *peer,
* then flush all.
*/
if (!withdraw_attrs) {
for (i = 0; i < BGP_ATTR_MAX; i++)
for (i = 1; i <= BGP_ATTR_MAX; i++)
peer->withdraw_attrs[i] = false;
goto withdraw_soft_clear;
}
@ -5229,7 +5229,7 @@ void bgp_path_attribute_withdraw_vty(struct vty *vty, struct peer *peer,
frrstr_split(withdraw_attrs, " ", &attributes, &num_attributes);
if (set)
for (i = 0; i < BGP_ATTR_MAX; i++)
for (i = 1; i <= BGP_ATTR_MAX; i++)
peer->withdraw_attrs[i] = false;
for (i = 0; i < num_attributes; i++) {

View File

@ -4337,7 +4337,7 @@ bool bgp_path_attribute_discard(struct peer *peer, char *buf, size_t size)
buf[0] = '\0';
for (unsigned int i = 0; i < BGP_ATTR_MAX; i++) {
for (unsigned int i = 1; i <= BGP_ATTR_MAX; i++) {
if (peer->discard_attrs[i])
snprintf(buf + strlen(buf), size - strlen(buf), "%s%d",
(strlen(buf) > 0) ? " " : "", i);
@ -4357,7 +4357,7 @@ bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf,
buf[0] = '\0';
for (unsigned int i = 0; i < BGP_ATTR_MAX; i++) {
for (unsigned int i = 1; i <= BGP_ATTR_MAX; i++) {
if (peer->withdraw_attrs[i])
snprintf(buf + strlen(buf), size - strlen(buf), "%s%d",
(strlen(buf) > 0) ? " " : "", i);

View File

@ -1809,10 +1809,10 @@ struct peer {
#define BGP_ATTR_MAX 255
/* Path attributes discard */
bool discard_attrs[BGP_ATTR_MAX];
bool discard_attrs[BGP_ATTR_MAX + 1];
/* Path attributes treat-as-withdraw */
bool withdraw_attrs[BGP_ATTR_MAX];
bool withdraw_attrs[BGP_ATTR_MAX + 1];
/* BGP Software Version Capability */
#define BGP_MAX_SOFT_VERSION 64