summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-04-14 16:15:35 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2021-04-14 16:18:13 +0200
commit3eff8e2f44b0810074e88ff2bc885f51b5f787d6 (patch)
tree9ae274bb0773022e148bf64ba7b3848998796a68
parentMerge pull request #8320 from idryzhov/prefix-list-seqnum (diff)
downloadfrr-3eff8e2f44b0810074e88ff2bc885f51b5f787d6.tar.xz
frr-3eff8e2f44b0810074e88ff2bc885f51b5f787d6.zip
*: 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>
-rw-r--r--bgpd/bgp_filter.c83
-rw-r--r--ldpd/ldp_zebra.c5
-rw-r--r--ldpd/ldpd.h1
-rw-r--r--lib/filter.c117
-rw-r--r--lib/filter.h7
-rw-r--r--lib/plist.c75
-rw-r--r--lib/plist_int.h4
7 files changed, 27 insertions, 265 deletions
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 5d1a7a98d..8d6691945 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);
}
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c
index ea86c2dc0..7a0e097db 100644
--- a/ldpd/ldp_zebra.c
+++ b/ldpd/ldp_zebra.c
@@ -650,9 +650,8 @@ ldp_zebra_filter_update(struct access_list *access)
if (access && access->name[0] != '\0') {
strlcpy(laccess.name, access->name, sizeof(laccess.name));
- laccess.type = access->type;
- debug_evt("%s ACL update filter name %s type %d", __func__,
- access->name, access->type);
+ debug_evt("%s ACL update filter name %s", __func__,
+ access->name);
main_imsg_compose_both(IMSG_FILTER_UPDATE, &laccess,
sizeof(laccess));
diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h
index 8fdc16fc7..df29d405e 100644
--- a/ldpd/ldpd.h
+++ b/ldpd/ldpd.h
@@ -174,7 +174,6 @@ struct ldpd_init {
struct ldp_access {
char name[ACL_NAMSIZ];
- enum access_type type;
};
union ldpd_addr {
diff --git a/lib/filter.c b/lib/filter.c
index ab62e95fb..5dbf30daa 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -38,7 +38,6 @@ DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter");
/* Static structure for mac access_list's master. */
static struct access_master access_master_mac = {
{NULL, NULL},
- {NULL, NULL},
NULL,
NULL,
};
@@ -46,7 +45,6 @@ static struct access_master access_master_mac = {
/* Static structure for IPv4 access_list's master. */
static struct access_master access_master_ipv4 = {
{NULL, NULL},
- {NULL, NULL},
NULL,
NULL,
};
@@ -54,7 +52,6 @@ static struct access_master access_master_ipv4 = {
/* Static structure for IPv6 access_list's master. */
static struct access_master access_master_ipv6 = {
{NULL, NULL},
- {NULL, NULL},
NULL,
NULL,
};
@@ -166,10 +163,7 @@ void access_list_delete(struct access_list *access)
master = access->master;
- if (access->type == ACCESS_TYPE_NUMBER)
- list = &master->num;
- else
- list = &master->str;
+ list = &master->str;
if (access->next)
access->next->prev = access->prev;
@@ -192,8 +186,6 @@ void access_list_delete(struct access_list *access)
is sorted by the name. */
static struct access_list *access_list_insert(afi_t afi, const char *name)
{
- unsigned int i;
- long number;
struct access_list *access;
struct access_list *point;
struct access_list_list *alist;
@@ -208,36 +200,13 @@ static struct access_list *access_list_insert(afi_t afi, const char *name)
access->name = XSTRDUP(MTYPE_ACCESS_LIST_STR, name);
access->master = master;
- /* 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)) {
- access->type = ACCESS_TYPE_NUMBER;
-
- /* Set access_list to number list. */
- alist = &master->num;
-
- for (point = alist->head; point; point = point->next)
- if (atol(point->name) >= number)
- break;
- } else {
- access->type = ACCESS_TYPE_STRING;
-
- /* Set access_list to string list. */
- alist = &master->str;
+ /* Set access_list to string list. */
+ alist = &master->str;
- /* Set point to insertion point. */
- for (point = alist->head; point; point = point->next)
- if (strcmp(point->name, name) >= 0)
- break;
- }
+ /* Set point to insertion point. */
+ for (point = alist->head; point; point = point->next)
+ if (strcmp(point->name, name) >= 0)
+ break;
/* In case of this is the first element of master. */
if (alist->head == NULL) {
@@ -285,10 +254,6 @@ struct access_list *access_list_lookup(afi_t afi, const char *name)
if (master == NULL)
return NULL;
- for (access = master->num.head; access; access = access->next)
- if (strcmp(access->name, name) == 0)
- return access;
-
for (access = master->str.head; access; access = access->next)
if (strcmp(access->name, name) == 0)
return access;
@@ -488,53 +453,6 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
/* Print the name of the protocol */
vty_out(vty, "%s:\n", frr_protoname);
- for (access = master->num.head; access; access = access->next) {
- if (name && strcmp(access->name, name) != 0)
- continue;
-
- write = 1;
-
- for (mfilter = access->head; mfilter; mfilter = mfilter->next) {
- filter = &mfilter->u.cfilter;
-
- if (write) {
- vty_out(vty, "%s %s access list %s\n",
- mfilter->cisco ? (filter->extended
- ? "Extended"
- : "Standard")
- : "Zebra",
- (afi == AFI_IP)
- ? ("IP")
- : ((afi == AFI_IP6) ? ("IPv6 ")
- : ("MAC ")),
- access->name);
- write = 0;
- }
-
- vty_out(vty, " seq %" PRId64, mfilter->seq);
- vty_out(vty, " %s%s", filter_type_str(mfilter),
- mfilter->type == FILTER_DENY ? " " : "");
-
- if (!mfilter->cisco)
- config_write_access_zebra(vty, mfilter);
- else if (filter->extended)
- config_write_access_cisco(vty, mfilter);
- else {
- if (filter->addr_mask.s_addr == 0xffffffff)
- vty_out(vty, " any\n");
- else {
- vty_out(vty, " %pI4", &filter->addr);
- if (filter->addr_mask.s_addr
- != INADDR_ANY)
- vty_out(vty,
- ", wildcard bits %pI4",
- &filter->addr_mask);
- vty_out(vty, "\n");
- }
- }
- }
- }
-
for (access = master->str.head; access; access = access->next) {
if (name && strcmp(access->name, name) != 0)
continue;
@@ -734,18 +652,11 @@ static void access_list_reset_mac(void)
if (master == NULL)
return;
- for (access = master->num.head; access; access = next) {
- next = access->next;
- access_list_delete(access);
- }
for (access = master->str.head; access; access = next) {
next = access->next;
access_list_delete(access);
}
- assert(master->num.head == NULL);
- assert(master->num.tail == NULL);
-
assert(master->str.head == NULL);
assert(master->str.tail == NULL);
}
@@ -792,18 +703,11 @@ static void access_list_reset_ipv4(void)
if (master == NULL)
return;
- for (access = master->num.head; access; access = next) {
- next = access->next;
- access_list_delete(access);
- }
for (access = master->str.head; access; access = next) {
next = access->next;
access_list_delete(access);
}
- assert(master->num.head == NULL);
- assert(master->num.tail == NULL);
-
assert(master->str.head == NULL);
assert(master->str.tail == NULL);
}
@@ -833,18 +737,11 @@ static void access_list_reset_ipv6(void)
if (master == NULL)
return;
- for (access = master->num.head; access; access = next) {
- next = access->next;
- access_list_delete(access);
- }
for (access = master->str.head; access; access = next) {
next = access->next;
access_list_delete(access);
}
- assert(master->num.head == NULL);
- assert(master->num.tail == NULL);
-
assert(master->str.head == NULL);
assert(master->str.tail == NULL);
}
diff --git a/lib/filter.h b/lib/filter.h
index ade68a456..941fabd38 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -50,8 +50,6 @@ extern "C" {
/* Filter type is made by `permit', `deny' and `dynamic'. */
enum filter_type { FILTER_DENY, FILTER_PERMIT, FILTER_DYNAMIC };
-enum access_type { ACCESS_TYPE_STRING, ACCESS_TYPE_NUMBER };
-
struct filter_cisco {
/* Cisco access-list */
int extended;
@@ -103,8 +101,6 @@ struct access_list {
struct access_master *master;
- enum access_type type;
-
struct access_list *next;
struct access_list *prev;
@@ -120,9 +116,6 @@ struct access_list_list {
/* Master structure of access_list. */
struct access_master {
- /* List of access_list which name is number. */
- struct access_list_list num;
-
/* List of access_list which name is string. */
struct access_list_list str;
diff --git a/lib/plist.c b/lib/plist.c
index 0663ac5ae..0ee02f8a0 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -66,9 +66,6 @@ struct prefix_list_list {
/* Master structure of prefix_list. */
struct prefix_master {
- /* List of prefix_list which name is number. */
- struct prefix_list_list num;
-
/* List of prefix_list which name is string. */
struct prefix_list_list str;
@@ -87,22 +84,22 @@ struct prefix_master {
/* Static structure of IPv4 prefix_list's master. */
static struct prefix_master prefix_master_ipv4 = {
- {NULL, NULL}, {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV4,
+ {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV4,
};
/* Static structure of IPv6 prefix-list's master. */
static struct prefix_master prefix_master_ipv6 = {
- {NULL, NULL}, {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV6,
+ {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV6,
};
/* Static structure of BGP ORF prefix_list's master. */
static struct prefix_master prefix_master_orf_v4 = {
- {NULL, NULL}, {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV4,
+ {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV4,
};
/* Static structure of BGP ORF prefix_list's master. */
static struct prefix_master prefix_master_orf_v6 = {
- {NULL, NULL}, {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV6,
+ {NULL, NULL}, NULL, NULL, NULL, PLC_MAXLEVELV6,
};
static struct prefix_master *prefix_master_get(afi_t afi, int orf)
@@ -141,10 +138,6 @@ static struct prefix_list *prefix_list_lookup_do(afi_t afi, int orf,
if (master == NULL)
return NULL;
- for (plist = master->num.head; plist; plist = plist->next)
- if (strcmp(plist->name, name) == 0)
- return plist;
-
for (plist = master->str.head; plist; plist = plist->next)
if (strcmp(plist->name, name) == 0)
return plist;
@@ -194,8 +187,6 @@ void prefix_list_entry_free(struct prefix_list_entry *pentry)
static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
const char *name)
{
- unsigned int i;
- long number;
struct prefix_list *plist;
struct prefix_list *point;
struct prefix_list_list *list;
@@ -212,36 +203,13 @@ static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
plist->trie =
XCALLOC(MTYPE_PREFIX_LIST_TRIE, sizeof(struct pltrie_table));
- /* 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)) {
- plist->type = PREFIX_TYPE_NUMBER;
+ /* Set prefix_list to string list. */
+ list = &master->str;
- /* Set prefix_list to number list. */
- list = &master->num;
-
- for (point = list->head; point; point = point->next)
- if (atol(point->name) >= number)
- break;
- } else {
- plist->type = PREFIX_TYPE_STRING;
-
- /* Set prefix_list to string list. */
- 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) {
@@ -310,10 +278,7 @@ void prefix_list_delete(struct prefix_list *plist)
master = plist->master;
- if (plist->type == PREFIX_TYPE_NUMBER)
- list = &master->num;
- else
- list = &master->str;
+ list = &master->str;
if (plist->next)
plist->next->prev = plist->prev;
@@ -1056,10 +1021,6 @@ static int vty_show_prefix_list(struct vty *vty, afi_t afi, const char *name,
master->recent->name);
}
- for (plist = master->num.head; plist; plist = plist->next)
- vty_show_prefix_entry(vty, afi, plist, master, dtype,
- seqnum);
-
for (plist = master->str.head; plist; plist = plist->next)
vty_show_prefix_entry(vty, afi, plist, master, dtype,
seqnum);
@@ -1148,11 +1109,6 @@ static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name,
return CMD_WARNING;
if (name == NULL && prefix == NULL) {
- for (plist = master->num.head; plist; plist = plist->next)
- for (pentry = plist->head; pentry;
- pentry = pentry->next)
- pentry->hitcnt = 0;
-
for (plist = master->str.head; plist; plist = plist->next)
for (pentry = plist->head; pentry;
pentry = pentry->next)
@@ -1509,18 +1465,11 @@ static void prefix_list_reset_afi(afi_t afi, int orf)
if (master == NULL)
return;
- for (plist = master->num.head; plist; plist = next) {
- next = plist->next;
- prefix_list_delete(plist);
- }
for (plist = master->str.head; plist; plist = next) {
next = plist->next;
prefix_list_delete(plist);
}
- assert(master->num.head == NULL);
- assert(master->num.tail == NULL);
-
assert(master->str.head == NULL);
assert(master->str.tail == NULL);
@@ -1546,8 +1495,6 @@ static void plist_autocomplete_afi(afi_t afi, vector comps,
for (plist = master->str.head; plist; plist = plist->next)
vector_set(comps, XSTRDUP(MTYPE_COMPLETION, plist->name));
- for (plist = master->num.head; plist; plist = plist->next)
- vector_set(comps, XSTRDUP(MTYPE_COMPLETION, plist->name));
}
static void plist_autocomplete(vector comps, struct cmd_token *token)
diff --git a/lib/plist_int.h b/lib/plist_int.h
index 5e0beabbc..571978a51 100644
--- a/lib/plist_int.h
+++ b/lib/plist_int.h
@@ -26,8 +26,6 @@
extern "C" {
#endif
-enum prefix_name_type { PREFIX_TYPE_STRING, PREFIX_TYPE_NUMBER };
-
struct pltrie_table;
struct prefix_list {
@@ -36,8 +34,6 @@ struct prefix_list {
struct prefix_master *master;
- enum prefix_name_type type;
-
int count;
int rangecount;