From 4c1ee29116aff081f63b1fc7dad18cbfe1b8007f Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 30 Oct 2024 10:45:28 +0200 Subject: [PATCH] bgpd: Treat numbered community-list only if it's in a range 1-500 Before this patch, if we set something like: ``` bgp extcommunity-list expanded 1234 permit admin ``` In running config we have: ``` bgp extcommunity-list 1234 seq 5 permit admin ``` That leads to incorrect rendering, even more the line can't be deleted. With this fix we treat numbered community-list only if it's inside the range 1-500, otherwise it's a non-numbered clist. Signed-off-by: Donatas Abraitis --- bgpd/bgp_clist.c | 2 +- bgpd/bgp_clist.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index ad154e638b55..61ba527498ca 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -182,7 +182,7 @@ community_list_insert(struct community_list_handler *ch, const char *name, } /* In case of name is all digit character */ - if (i == strlen(name)) { + if (i == strlen(name) && number <= COMMUNITY_LIST_NUMBER_MAX) { new->sort = COMMUNITY_LIST_NUMBER; /* Set access_list to number list. */ diff --git a/bgpd/bgp_clist.h b/bgpd/bgp_clist.h index 29bd880c937e..7f35a6d53e4b 100644 --- a/bgpd/bgp_clist.h +++ b/bgpd/bgp_clist.h @@ -20,6 +20,10 @@ /* Number and string based community-list name. */ #define COMMUNITY_LIST_STRING 0 #define COMMUNITY_LIST_NUMBER 1 +/* The numbered community-list (including large/ext communities) + * have a range between 1-500. + */ +#define COMMUNITY_LIST_NUMBER_MAX 500 #define COMMUNITY_SEQ_NUMBER_AUTO -1