summaryrefslogtreecommitdiff
path: root/bgpd/bgp_filter.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-04-14 17:15:35 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-04-14 17:18:13 +0300
commit3eff8e2f44b0810074e88ff2bc885f51b5f787d6 (patch)
tree9ae274bb0773022e148bf64ba7b3848998796a68 /bgpd/bgp_filter.c
parent8a2ec9102f82c8f6f2bddec4a244ec9666d4624f (diff)
*: cleanup number-named access-lists and prefix-lists
A long time ago there was a difference between number-named and string-named access/prefix-lists. Currently we always treat the name as a string and there is no need for a separate list for number-named lists. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'bgpd/bgp_filter.c')
-rw-r--r--bgpd/bgp_filter.c83
1 files changed, 7 insertions, 76 deletions
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 5d1a7a98d7..8d6691945f 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -40,9 +40,6 @@ struct as_list_list {
/* AS path filter master. */
struct as_list_master {
- /* List of access_list which name is number. */
- struct as_list_list num;
-
/* List of access_list which name is string. */
struct as_list_list str;
@@ -71,8 +68,6 @@ struct as_filter {
struct as_list {
char *name;
- enum access_type type;
-
struct as_list *next;
struct as_list *prev;
@@ -115,7 +110,6 @@ static struct as_filter *bgp_aslist_seq_check(struct as_list *list, int64_t seq)
/* as-path access-list 10 permit AS1. */
static struct as_list_master as_list_master = {{NULL, NULL},
- {NULL, NULL},
NULL,
NULL};
@@ -237,10 +231,6 @@ struct as_list *as_list_lookup(const char *name)
if (name == NULL)
return NULL;
- for (aslist = as_list_master.num.head; aslist; aslist = aslist->next)
- if (strcmp(aslist->name, name) == 0)
- return aslist;
-
for (aslist = as_list_master.str.head; aslist; aslist = aslist->next)
if (strcmp(aslist->name, name) == 0)
return aslist;
@@ -263,8 +253,6 @@ static void as_list_free(struct as_list *aslist)
the name. */
static struct as_list *as_list_insert(const char *name)
{
- size_t i;
- long number;
struct as_list *aslist;
struct as_list *point;
struct as_list_list *list;
@@ -274,36 +262,13 @@ static struct as_list *as_list_insert(const char *name)
aslist->name = XSTRDUP(MTYPE_AS_STR, name);
assert(aslist->name);
- /* If name is made by all digit character. We treat it as
- number. */
- for (number = 0, i = 0; i < strlen(name); i++) {
- if (isdigit((unsigned char)name[i]))
- number = (number * 10) + (name[i] - '0');
- else
- break;
- }
-
- /* In case of name is all digit character */
- if (i == strlen(name)) {
- aslist->type = ACCESS_TYPE_NUMBER;
-
- /* Set access_list to number list. */
- list = &as_list_master.num;
-
- for (point = list->head; point; point = point->next)
- if (atol(point->name) >= number)
- break;
- } else {
- aslist->type = ACCESS_TYPE_STRING;
-
- /* Set access_list to string list. */
- list = &as_list_master.str;
+ /* Set access_list to string list. */
+ list = &as_list_master.str;
- /* Set point to insertion point. */
- for (point = list->head; point; point = point->next)
- if (strcmp(point->name, name) >= 0)
- break;
- }
+ /* Set point to insertion point. */
+ for (point = list->head; point; point = point->next)
+ if (strcmp(point->name, name) >= 0)
+ break;
/* In case of this is the first element of master. */
if (list->head == NULL) {
@@ -371,10 +336,7 @@ static void as_list_delete(struct as_list *aslist)
as_filter_free(filter);
}
- if (aslist->type == ACCESS_TYPE_NUMBER)
- list = &as_list_master.num;
- else
- list = &as_list_master.str;
+ list = &as_list_master.str;
if (aslist->next)
aslist->next->prev = aslist->prev;
@@ -667,17 +629,6 @@ static void as_list_show_all(struct vty *vty)
struct as_list *aslist;
struct as_filter *asfilter;
- for (aslist = as_list_master.num.head; aslist; aslist = aslist->next) {
- vty_out(vty, "AS path access list %s\n", aslist->name);
-
- for (asfilter = aslist->head; asfilter;
- asfilter = asfilter->next) {
- vty_out(vty, " %s %s\n",
- filter_type_str(asfilter->type),
- asfilter->reg_str);
- }
- }
-
for (aslist = as_list_master.str.head; aslist; aslist = aslist->next) {
vty_out(vty, "AS path access list %s\n", aslist->name);
@@ -740,18 +691,6 @@ static int config_write_as_list(struct vty *vty)
struct as_filter *asfilter;
int write = 0;
- for (aslist = as_list_master.num.head; aslist; aslist = aslist->next)
- for (asfilter = aslist->head; asfilter;
- asfilter = asfilter->next) {
- vty_out(vty,
- "bgp as-path access-list %s seq %" PRId64
- " %s %s\n",
- aslist->name, asfilter->seq,
- filter_type_str(asfilter->type),
- asfilter->reg_str);
- write++;
- }
-
for (aslist = as_list_master.str.head; aslist; aslist = aslist->next)
for (asfilter = aslist->head; asfilter;
asfilter = asfilter->next) {
@@ -794,19 +733,11 @@ void bgp_filter_reset(void)
struct as_list *aslist;
struct as_list *next;
- for (aslist = as_list_master.num.head; aslist; aslist = next) {
- next = aslist->next;
- as_list_delete(aslist);
- }
-
for (aslist = as_list_master.str.head; aslist; aslist = next) {
next = aslist->next;
as_list_delete(aslist);
}
- assert(as_list_master.num.head == NULL);
- assert(as_list_master.num.tail == NULL);
-
assert(as_list_master.str.head == NULL);
assert(as_list_master.str.tail == NULL);
}