mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 01:38:24 +00:00
*: 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>
This commit is contained in:
parent
8a2ec9102f
commit
3eff8e2f44
@ -40,9 +40,6 @@ struct as_list_list {
|
|||||||
|
|
||||||
/* AS path filter master. */
|
/* AS path filter master. */
|
||||||
struct as_list_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. */
|
/* List of access_list which name is string. */
|
||||||
struct as_list_list str;
|
struct as_list_list str;
|
||||||
|
|
||||||
@ -71,8 +68,6 @@ struct as_filter {
|
|||||||
struct as_list {
|
struct as_list {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
enum access_type type;
|
|
||||||
|
|
||||||
struct as_list *next;
|
struct as_list *next;
|
||||||
struct as_list *prev;
|
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. */
|
/* as-path access-list 10 permit AS1. */
|
||||||
|
|
||||||
static struct as_list_master as_list_master = {{NULL, NULL},
|
static struct as_list_master as_list_master = {{NULL, NULL},
|
||||||
{NULL, NULL},
|
|
||||||
NULL,
|
NULL,
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
@ -237,10 +231,6 @@ struct as_list *as_list_lookup(const char *name)
|
|||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return 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)
|
for (aslist = as_list_master.str.head; aslist; aslist = aslist->next)
|
||||||
if (strcmp(aslist->name, name) == 0)
|
if (strcmp(aslist->name, name) == 0)
|
||||||
return aslist;
|
return aslist;
|
||||||
@ -263,8 +253,6 @@ static void as_list_free(struct as_list *aslist)
|
|||||||
the name. */
|
the name. */
|
||||||
static struct as_list *as_list_insert(const char *name)
|
static struct as_list *as_list_insert(const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
long number;
|
|
||||||
struct as_list *aslist;
|
struct as_list *aslist;
|
||||||
struct as_list *point;
|
struct as_list *point;
|
||||||
struct as_list_list *list;
|
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);
|
aslist->name = XSTRDUP(MTYPE_AS_STR, name);
|
||||||
assert(aslist->name);
|
assert(aslist->name);
|
||||||
|
|
||||||
/* If name is made by all digit character. We treat it as
|
/* Set access_list to string list. */
|
||||||
number. */
|
list = &as_list_master.str;
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
|
||||||
if (isdigit((unsigned char)name[i]))
|
/* Set point to insertion point. */
|
||||||
number = (number * 10) + (name[i] - '0');
|
for (point = list->head; point; point = point->next)
|
||||||
else
|
if (strcmp(point->name, name) >= 0)
|
||||||
break;
|
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 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. */
|
/* In case of this is the first element of master. */
|
||||||
if (list->head == NULL) {
|
if (list->head == NULL) {
|
||||||
@ -371,10 +336,7 @@ static void as_list_delete(struct as_list *aslist)
|
|||||||
as_filter_free(filter);
|
as_filter_free(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aslist->type == ACCESS_TYPE_NUMBER)
|
list = &as_list_master.str;
|
||||||
list = &as_list_master.num;
|
|
||||||
else
|
|
||||||
list = &as_list_master.str;
|
|
||||||
|
|
||||||
if (aslist->next)
|
if (aslist->next)
|
||||||
aslist->next->prev = aslist->prev;
|
aslist->next->prev = aslist->prev;
|
||||||
@ -667,17 +629,6 @@ static void as_list_show_all(struct vty *vty)
|
|||||||
struct as_list *aslist;
|
struct as_list *aslist;
|
||||||
struct as_filter *asfilter;
|
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) {
|
for (aslist = as_list_master.str.head; aslist; aslist = aslist->next) {
|
||||||
vty_out(vty, "AS path access list %s\n", aslist->name);
|
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;
|
struct as_filter *asfilter;
|
||||||
int write = 0;
|
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 (aslist = as_list_master.str.head; aslist; aslist = aslist->next)
|
||||||
for (asfilter = aslist->head; asfilter;
|
for (asfilter = aslist->head; asfilter;
|
||||||
asfilter = asfilter->next) {
|
asfilter = asfilter->next) {
|
||||||
@ -794,19 +733,11 @@ void bgp_filter_reset(void)
|
|||||||
struct as_list *aslist;
|
struct as_list *aslist;
|
||||||
struct as_list *next;
|
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) {
|
for (aslist = as_list_master.str.head; aslist; aslist = next) {
|
||||||
next = aslist->next;
|
next = aslist->next;
|
||||||
as_list_delete(aslist);
|
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.head == NULL);
|
||||||
assert(as_list_master.str.tail == NULL);
|
assert(as_list_master.str.tail == NULL);
|
||||||
}
|
}
|
||||||
|
@ -650,9 +650,8 @@ ldp_zebra_filter_update(struct access_list *access)
|
|||||||
|
|
||||||
if (access && access->name[0] != '\0') {
|
if (access && access->name[0] != '\0') {
|
||||||
strlcpy(laccess.name, access->name, sizeof(laccess.name));
|
strlcpy(laccess.name, access->name, sizeof(laccess.name));
|
||||||
laccess.type = access->type;
|
debug_evt("%s ACL update filter name %s", __func__,
|
||||||
debug_evt("%s ACL update filter name %s type %d", __func__,
|
access->name);
|
||||||
access->name, access->type);
|
|
||||||
|
|
||||||
main_imsg_compose_both(IMSG_FILTER_UPDATE, &laccess,
|
main_imsg_compose_both(IMSG_FILTER_UPDATE, &laccess,
|
||||||
sizeof(laccess));
|
sizeof(laccess));
|
||||||
|
@ -174,7 +174,6 @@ struct ldpd_init {
|
|||||||
|
|
||||||
struct ldp_access {
|
struct ldp_access {
|
||||||
char name[ACL_NAMSIZ];
|
char name[ACL_NAMSIZ];
|
||||||
enum access_type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union ldpd_addr {
|
union ldpd_addr {
|
||||||
|
117
lib/filter.c
117
lib/filter.c
@ -37,7 +37,6 @@ DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter");
|
|||||||
|
|
||||||
/* Static structure for mac access_list's master. */
|
/* Static structure for mac access_list's master. */
|
||||||
static struct access_master access_master_mac = {
|
static struct access_master access_master_mac = {
|
||||||
{NULL, NULL},
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -45,7 +44,6 @@ static struct access_master access_master_mac = {
|
|||||||
|
|
||||||
/* Static structure for IPv4 access_list's master. */
|
/* Static structure for IPv4 access_list's master. */
|
||||||
static struct access_master access_master_ipv4 = {
|
static struct access_master access_master_ipv4 = {
|
||||||
{NULL, NULL},
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -53,7 +51,6 @@ static struct access_master access_master_ipv4 = {
|
|||||||
|
|
||||||
/* Static structure for IPv6 access_list's master. */
|
/* Static structure for IPv6 access_list's master. */
|
||||||
static struct access_master access_master_ipv6 = {
|
static struct access_master access_master_ipv6 = {
|
||||||
{NULL, NULL},
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -166,10 +163,7 @@ void access_list_delete(struct access_list *access)
|
|||||||
|
|
||||||
master = access->master;
|
master = access->master;
|
||||||
|
|
||||||
if (access->type == ACCESS_TYPE_NUMBER)
|
list = &master->str;
|
||||||
list = &master->num;
|
|
||||||
else
|
|
||||||
list = &master->str;
|
|
||||||
|
|
||||||
if (access->next)
|
if (access->next)
|
||||||
access->next->prev = access->prev;
|
access->next->prev = access->prev;
|
||||||
@ -192,8 +186,6 @@ void access_list_delete(struct access_list *access)
|
|||||||
is sorted by the name. */
|
is sorted by the name. */
|
||||||
static struct access_list *access_list_insert(afi_t afi, const char *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 *access;
|
||||||
struct access_list *point;
|
struct access_list *point;
|
||||||
struct access_list_list *alist;
|
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->name = XSTRDUP(MTYPE_ACCESS_LIST_STR, name);
|
||||||
access->master = master;
|
access->master = master;
|
||||||
|
|
||||||
/* If name is made by all digit character. We treat it as
|
/* Set access_list to string list. */
|
||||||
number. */
|
alist = &master->str;
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
|
||||||
if (isdigit((unsigned char)name[i]))
|
/* Set point to insertion point. */
|
||||||
number = (number * 10) + (name[i] - '0');
|
for (point = alist->head; point; point = point->next)
|
||||||
else
|
if (strcmp(point->name, name) >= 0)
|
||||||
break;
|
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 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. */
|
/* In case of this is the first element of master. */
|
||||||
if (alist->head == NULL) {
|
if (alist->head == NULL) {
|
||||||
@ -285,10 +254,6 @@ struct access_list *access_list_lookup(afi_t afi, const char *name)
|
|||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
return 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)
|
for (access = master->str.head; access; access = access->next)
|
||||||
if (strcmp(access->name, name) == 0)
|
if (strcmp(access->name, name) == 0)
|
||||||
return access;
|
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 */
|
/* Print the name of the protocol */
|
||||||
vty_out(vty, "%s:\n", frr_protoname);
|
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) {
|
for (access = master->str.head; access; access = access->next) {
|
||||||
if (name && strcmp(access->name, name) != 0)
|
if (name && strcmp(access->name, name) != 0)
|
||||||
continue;
|
continue;
|
||||||
@ -734,18 +652,11 @@ static void access_list_reset_mac(void)
|
|||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (access = master->num.head; access; access = next) {
|
|
||||||
next = access->next;
|
|
||||||
access_list_delete(access);
|
|
||||||
}
|
|
||||||
for (access = master->str.head; access; access = next) {
|
for (access = master->str.head; access; access = next) {
|
||||||
next = access->next;
|
next = access->next;
|
||||||
access_list_delete(access);
|
access_list_delete(access);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(master->num.head == NULL);
|
|
||||||
assert(master->num.tail == NULL);
|
|
||||||
|
|
||||||
assert(master->str.head == NULL);
|
assert(master->str.head == NULL);
|
||||||
assert(master->str.tail == NULL);
|
assert(master->str.tail == NULL);
|
||||||
}
|
}
|
||||||
@ -792,18 +703,11 @@ static void access_list_reset_ipv4(void)
|
|||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (access = master->num.head; access; access = next) {
|
|
||||||
next = access->next;
|
|
||||||
access_list_delete(access);
|
|
||||||
}
|
|
||||||
for (access = master->str.head; access; access = next) {
|
for (access = master->str.head; access; access = next) {
|
||||||
next = access->next;
|
next = access->next;
|
||||||
access_list_delete(access);
|
access_list_delete(access);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(master->num.head == NULL);
|
|
||||||
assert(master->num.tail == NULL);
|
|
||||||
|
|
||||||
assert(master->str.head == NULL);
|
assert(master->str.head == NULL);
|
||||||
assert(master->str.tail == NULL);
|
assert(master->str.tail == NULL);
|
||||||
}
|
}
|
||||||
@ -833,18 +737,11 @@ static void access_list_reset_ipv6(void)
|
|||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (access = master->num.head; access; access = next) {
|
|
||||||
next = access->next;
|
|
||||||
access_list_delete(access);
|
|
||||||
}
|
|
||||||
for (access = master->str.head; access; access = next) {
|
for (access = master->str.head; access; access = next) {
|
||||||
next = access->next;
|
next = access->next;
|
||||||
access_list_delete(access);
|
access_list_delete(access);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(master->num.head == NULL);
|
|
||||||
assert(master->num.tail == NULL);
|
|
||||||
|
|
||||||
assert(master->str.head == NULL);
|
assert(master->str.head == NULL);
|
||||||
assert(master->str.tail == NULL);
|
assert(master->str.tail == NULL);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,6 @@ extern "C" {
|
|||||||
/* Filter type is made by `permit', `deny' and `dynamic'. */
|
/* Filter type is made by `permit', `deny' and `dynamic'. */
|
||||||
enum filter_type { FILTER_DENY, FILTER_PERMIT, FILTER_DYNAMIC };
|
enum filter_type { FILTER_DENY, FILTER_PERMIT, FILTER_DYNAMIC };
|
||||||
|
|
||||||
enum access_type { ACCESS_TYPE_STRING, ACCESS_TYPE_NUMBER };
|
|
||||||
|
|
||||||
struct filter_cisco {
|
struct filter_cisco {
|
||||||
/* Cisco access-list */
|
/* Cisco access-list */
|
||||||
int extended;
|
int extended;
|
||||||
@ -103,8 +101,6 @@ struct access_list {
|
|||||||
|
|
||||||
struct access_master *master;
|
struct access_master *master;
|
||||||
|
|
||||||
enum access_type type;
|
|
||||||
|
|
||||||
struct access_list *next;
|
struct access_list *next;
|
||||||
struct access_list *prev;
|
struct access_list *prev;
|
||||||
|
|
||||||
@ -120,9 +116,6 @@ struct access_list_list {
|
|||||||
|
|
||||||
/* Master structure of access_list. */
|
/* Master structure of access_list. */
|
||||||
struct access_master {
|
struct access_master {
|
||||||
/* List of access_list which name is number. */
|
|
||||||
struct access_list_list num;
|
|
||||||
|
|
||||||
/* List of access_list which name is string. */
|
/* List of access_list which name is string. */
|
||||||
struct access_list_list str;
|
struct access_list_list str;
|
||||||
|
|
||||||
|
75
lib/plist.c
75
lib/plist.c
@ -66,9 +66,6 @@ struct prefix_list_list {
|
|||||||
|
|
||||||
/* Master structure of prefix_list. */
|
/* Master structure of prefix_list. */
|
||||||
struct prefix_master {
|
struct prefix_master {
|
||||||
/* List of prefix_list which name is number. */
|
|
||||||
struct prefix_list_list num;
|
|
||||||
|
|
||||||
/* List of prefix_list which name is string. */
|
/* List of prefix_list which name is string. */
|
||||||
struct prefix_list_list str;
|
struct prefix_list_list str;
|
||||||
|
|
||||||
@ -87,22 +84,22 @@ struct prefix_master {
|
|||||||
|
|
||||||
/* Static structure of IPv4 prefix_list's master. */
|
/* Static structure of IPv4 prefix_list's master. */
|
||||||
static struct prefix_master prefix_master_ipv4 = {
|
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 structure of IPv6 prefix-list's master. */
|
||||||
static struct prefix_master prefix_master_ipv6 = {
|
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 structure of BGP ORF prefix_list's master. */
|
||||||
static struct prefix_master prefix_master_orf_v4 = {
|
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 structure of BGP ORF prefix_list's master. */
|
||||||
static struct prefix_master prefix_master_orf_v6 = {
|
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)
|
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)
|
if (master == NULL)
|
||||||
return 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)
|
for (plist = master->str.head; plist; plist = plist->next)
|
||||||
if (strcmp(plist->name, name) == 0)
|
if (strcmp(plist->name, name) == 0)
|
||||||
return plist;
|
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,
|
static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
long number;
|
|
||||||
struct prefix_list *plist;
|
struct prefix_list *plist;
|
||||||
struct prefix_list *point;
|
struct prefix_list *point;
|
||||||
struct prefix_list_list *list;
|
struct prefix_list_list *list;
|
||||||
@ -212,36 +203,13 @@ static struct prefix_list *prefix_list_insert(afi_t afi, int orf,
|
|||||||
plist->trie =
|
plist->trie =
|
||||||
XCALLOC(MTYPE_PREFIX_LIST_TRIE, sizeof(struct pltrie_table));
|
XCALLOC(MTYPE_PREFIX_LIST_TRIE, sizeof(struct pltrie_table));
|
||||||
|
|
||||||
/* If name is made by all digit character. We treat it as
|
/* Set prefix_list to string list. */
|
||||||
number. */
|
list = &master->str;
|
||||||
for (number = 0, i = 0; i < strlen(name); i++) {
|
|
||||||
if (isdigit((unsigned char)name[i]))
|
/* Set point to insertion point. */
|
||||||
number = (number * 10) + (name[i] - '0');
|
for (point = list->head; point; point = point->next)
|
||||||
else
|
if (strcmp(point->name, name) >= 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/* In case of name is all digit character */
|
|
||||||
if (i == strlen(name)) {
|
|
||||||
plist->type = PREFIX_TYPE_NUMBER;
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case of this is the first element of master. */
|
/* In case of this is the first element of master. */
|
||||||
if (list->head == NULL) {
|
if (list->head == NULL) {
|
||||||
@ -310,10 +278,7 @@ void prefix_list_delete(struct prefix_list *plist)
|
|||||||
|
|
||||||
master = plist->master;
|
master = plist->master;
|
||||||
|
|
||||||
if (plist->type == PREFIX_TYPE_NUMBER)
|
list = &master->str;
|
||||||
list = &master->num;
|
|
||||||
else
|
|
||||||
list = &master->str;
|
|
||||||
|
|
||||||
if (plist->next)
|
if (plist->next)
|
||||||
plist->next->prev = plist->prev;
|
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);
|
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)
|
for (plist = master->str.head; plist; plist = plist->next)
|
||||||
vty_show_prefix_entry(vty, afi, plist, master, dtype,
|
vty_show_prefix_entry(vty, afi, plist, master, dtype,
|
||||||
seqnum);
|
seqnum);
|
||||||
@ -1148,11 +1109,6 @@ static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name,
|
|||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
if (name == NULL && prefix == NULL) {
|
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 (plist = master->str.head; plist; plist = plist->next)
|
||||||
for (pentry = plist->head; pentry;
|
for (pentry = plist->head; pentry;
|
||||||
pentry = pentry->next)
|
pentry = pentry->next)
|
||||||
@ -1509,18 +1465,11 @@ static void prefix_list_reset_afi(afi_t afi, int orf)
|
|||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (plist = master->num.head; plist; plist = next) {
|
|
||||||
next = plist->next;
|
|
||||||
prefix_list_delete(plist);
|
|
||||||
}
|
|
||||||
for (plist = master->str.head; plist; plist = next) {
|
for (plist = master->str.head; plist; plist = next) {
|
||||||
next = plist->next;
|
next = plist->next;
|
||||||
prefix_list_delete(plist);
|
prefix_list_delete(plist);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(master->num.head == NULL);
|
|
||||||
assert(master->num.tail == NULL);
|
|
||||||
|
|
||||||
assert(master->str.head == NULL);
|
assert(master->str.head == NULL);
|
||||||
assert(master->str.tail == 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)
|
for (plist = master->str.head; plist; plist = plist->next)
|
||||||
vector_set(comps, XSTRDUP(MTYPE_COMPLETION, plist->name));
|
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)
|
static void plist_autocomplete(vector comps, struct cmd_token *token)
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum prefix_name_type { PREFIX_TYPE_STRING, PREFIX_TYPE_NUMBER };
|
|
||||||
|
|
||||||
struct pltrie_table;
|
struct pltrie_table;
|
||||||
|
|
||||||
struct prefix_list {
|
struct prefix_list {
|
||||||
@ -36,8 +34,6 @@ struct prefix_list {
|
|||||||
|
|
||||||
struct prefix_master *master;
|
struct prefix_master *master;
|
||||||
|
|
||||||
enum prefix_name_type type;
|
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
int rangecount;
|
int rangecount;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user