summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-07-01 13:38:15 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-07-01 13:38:15 +0000
commit1fc6d097ccbc2200c7554deb5e8890754a008d96 (patch)
tree12be2a282a9441c564c98d6da19e8048e3607f6b
parent363568c22a631871fa05861e45eede19bccf48d5 (diff)
Switch filter_sets form SIMPLEQ to TAILQ, needed for upcomming stuff.
-rw-r--r--usr.sbin/bgpd/bgpd.c4
-rw-r--r--usr.sbin/bgpd/bgpd.h6
-rw-r--r--usr.sbin/bgpd/parse.y93
-rw-r--r--usr.sbin/bgpd/printconf.c20
-rw-r--r--usr.sbin/bgpd/rde.c18
-rw-r--r--usr.sbin/bgpd/rde_filter.c8
-rw-r--r--usr.sbin/bgpd/session.c8
7 files changed, 74 insertions, 83 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 88463c90ead..258a20b0dad 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.122 2005/06/29 09:43:25 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.123 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -395,7 +395,7 @@ send_filterset(struct imsgbuf *i, struct filter_set_head *set, int id)
{
struct filter_set *s;
- SIMPLEQ_FOREACH(s, set, entry)
+ TAILQ_FOREACH(s, set, entry)
if (imsg_compose(i, IMSG_FILTER_SET, id, 0, -1, s,
sizeof(struct filter_set)) == -1)
return (-1);
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index b55b424c0b9..14666a29e19 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.173 2005/07/01 09:19:24 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.174 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -133,7 +133,7 @@ struct listen_addr {
};
TAILQ_HEAD(listen_addrs, listen_addr);
-SIMPLEQ_HEAD(filter_set_head, filter_set);
+TAILQ_HEAD(filter_set_head, filter_set);
struct bgpd_config {
struct filter_set_head connectset;
@@ -585,7 +585,7 @@ enum action_types {
};
struct filter_set {
- SIMPLEQ_ENTRY(filter_set) entry;
+ TAILQ_ENTRY(filter_set) entry;
union {
u_int8_t prepend;
u_int16_t id;
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 77feafffe5b..4d89a9b2f84 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.165 2005/06/29 09:43:25 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.166 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -95,6 +95,8 @@ int neighbor_consistent(struct peer *);
int merge_filterset(struct filter_set_head *, struct filter_set *);
void copy_filterset(struct filter_set_head *,
struct filter_set_head *);
+void move_filterset(struct filter_set_head *,
+ struct filter_set_head *);
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
struct sym {
@@ -331,11 +333,7 @@ conf_main : AS asnumber {
memcpy(&n->net.prefix, &$2.prefix,
sizeof(n->net.prefix));
n->net.prefixlen = $2.len;
- if ($3 == NULL || SIMPLEQ_EMPTY($3))
- SIMPLEQ_INIT(&n->net.attrset);
- else
- memcpy(&n->net.attrset, $3,
- sizeof(n->net.attrset));
+ move_filterset($3, &n->net.attrset);
free($3);
TAILQ_INSERT_TAIL(netconf, n, entry);
@@ -343,18 +341,10 @@ conf_main : AS asnumber {
| NETWORK STRING STATIC filter_set {
if (!strcmp($2, "inet")) {
conf->flags |= BGPD_FLAG_REDIST_STATIC;
- if ($4 == NULL || SIMPLEQ_EMPTY($4))
- SIMPLEQ_INIT(&conf->staticset);
- else
- memcpy(&conf->staticset, $4,
- sizeof(conf->staticset));
+ move_filterset($4, &conf->staticset);
} else if (!strcmp($2, "inet6")) {
conf->flags |= BGPD_FLAG_REDIST6_STATIC;
- if ($4 == NULL || SIMPLEQ_EMPTY($4))
- SIMPLEQ_INIT(&conf->staticset6);
- else
- memcpy(&conf->staticset6, $4,
- sizeof(conf->staticset6));
+ move_filterset($4, &conf->staticset6);
}
free($2);
free($4);
@@ -362,18 +352,10 @@ conf_main : AS asnumber {
| NETWORK STRING CONNECTED filter_set {
if (!strcmp($2, "inet")) {
conf->flags |= BGPD_FLAG_REDIST_CONNECTED;
- if ($4 == NULL || SIMPLEQ_EMPTY($4))
- SIMPLEQ_INIT(&conf->connectset);
- else
- memcpy(&conf->connectset, $4,
- sizeof(conf->connectset));
+ move_filterset($4, &conf->connectset);
} else if (!strcmp($2, "inet6")) {
conf->flags |= BGPD_FLAG_REDIST6_CONNECTED;
- if ($4 == NULL || SIMPLEQ_EMPTY($4))
- SIMPLEQ_INIT(&conf->connectset6);
- else
- memcpy(&conf->connectset6, $4,
- sizeof(conf->connectset6));
+ move_filterset($4, &conf->connectset6);
}
free($2);
free($4);
@@ -381,21 +363,13 @@ conf_main : AS asnumber {
| NETWORK STATIC filter_set {
/* keep for compatibility till after next release */
conf->flags |= BGPD_FLAG_REDIST_STATIC;
- if ($3 == NULL || SIMPLEQ_EMPTY($3))
- SIMPLEQ_INIT(&conf->staticset);
- else
- memcpy(&conf->staticset, $3,
- sizeof(conf->staticset));
+ move_filterset($3, &conf->staticset);
free($3);
}
| NETWORK CONNECTED filter_set {
/* keep for compatibility till after next release */
conf->flags |= BGPD_FLAG_REDIST_CONNECTED;
- if ($3 == NULL || SIMPLEQ_EMPTY($3))
- SIMPLEQ_INIT(&conf->connectset);
- else
- memcpy(&conf->connectset, $3,
- sizeof(conf->connectset));
+ move_filterset($3, &conf->connectset);
free($3);
}
| DUMP STRING STRING optnumber {
@@ -802,8 +776,8 @@ peeropts : REMOTEAS asnumber {
| SET optnl "{" optnl filter_set_l optnl "}" {
struct filter_set *s;
- while ((s = SIMPLEQ_FIRST($5)) != NULL) {
- SIMPLEQ_REMOVE_HEAD($5, entry);
+ while ((s = TAILQ_FIRST($5)) != NULL) {
+ TAILQ_REMOVE($5, s, entry);
if (merge_filterset(&curpeer->conf.attrset, s)
== -1)
YYERROR;
@@ -1167,8 +1141,8 @@ filter_set : /* empty */ { $$ = NULL; }
if (($$ = calloc(1, sizeof(struct filter_set_head))) ==
NULL)
fatal(NULL);
- SIMPLEQ_INIT($$);
- SIMPLEQ_INSERT_TAIL($$, $2, entry);
+ TAILQ_INIT($$);
+ TAILQ_INSERT_TAIL($$, $2, entry);
}
| SET optnl "{" optnl filter_set_l optnl "}" { $$ = $5; }
;
@@ -1182,8 +1156,8 @@ filter_set_l : filter_set_l comma filter_set_opt {
if (($$ = calloc(1, sizeof(struct filter_set_head))) ==
NULL)
fatal(NULL);
- SIMPLEQ_INIT($$);
- SIMPLEQ_INSERT_TAIL($$, $1, entry);
+ TAILQ_INIT($$);
+ TAILQ_INSERT_TAIL($$, $1, entry);
}
;
@@ -1993,7 +1967,7 @@ alloc_peer(void)
p->conf.capabilities.mp_v4 = SAFI_UNICAST;
p->conf.capabilities.mp_v6 = SAFI_NONE;
p->conf.capabilities.refresh = 1;
- SIMPLEQ_INIT(&p->conf.attrset);
+ TAILQ_INIT(&p->conf.attrset);
return (p);
}
@@ -2014,7 +1988,7 @@ new_peer(void)
sizeof(p->conf.descr)) >= sizeof(p->conf.descr))
fatalx("new_peer descr strlcpy");
p->conf.groupid = curgroup->conf.id;
- SIMPLEQ_INIT(&p->conf.attrset);
+ TAILQ_INIT(&p->conf.attrset);
copy_filterset(&curgroup->conf.attrset, &p->conf.attrset);
}
p->next = NULL;
@@ -2127,7 +2101,7 @@ expand_rule(struct filter_rule *rule, struct filter_peers_l *peer,
memcpy(r, rule, sizeof(struct filter_rule));
memcpy(&r->match, match,
sizeof(struct filter_match));
- SIMPLEQ_INIT(&r->set);
+ TAILQ_INIT(&r->set);
copy_filterset(set, &r->set);
if (p != NULL)
@@ -2172,8 +2146,8 @@ expand_rule(struct filter_rule *rule, struct filter_peers_l *peer,
}
if (set != NULL) {
- while ((s = SIMPLEQ_FIRST(set)) != NULL) {
- SIMPLEQ_REMOVE_HEAD(set, entry);
+ while ((s = TAILQ_FIRST(set)) != NULL) {
+ TAILQ_REMOVE(set, s, entry);
free(s);
}
free(set);
@@ -2272,7 +2246,7 @@ merge_filterset(struct filter_set_head *sh, struct filter_set *s)
{
struct filter_set *t;
- SIMPLEQ_FOREACH(t, sh, entry) {
+ TAILQ_FOREACH(t, sh, entry) {
if (s->type != t->type)
continue;
@@ -2294,7 +2268,7 @@ merge_filterset(struct filter_set_head *sh, struct filter_set *s)
return (-1);
}
}
- SIMPLEQ_INSERT_TAIL(sh, s, entry);
+ TAILQ_INSERT_TAIL(sh, s, entry);
return (0);
}
@@ -2307,10 +2281,27 @@ copy_filterset(struct filter_set_head *source, struct filter_set_head *dest)
if (source == NULL)
return;
- SIMPLEQ_FOREACH(s, source, entry) {
+ TAILQ_FOREACH(s, source, entry) {
if ((t = calloc(1, sizeof(struct filter_set))) == NULL)
fatal(NULL);
memcpy(t, s, sizeof(struct filter_set));
- SIMPLEQ_INSERT_TAIL(dest, t, entry);
+ TAILQ_INSERT_TAIL(dest, t, entry);
}
}
+
+void
+move_filterset(struct filter_set_head *source, struct filter_set_head *dest)
+{
+ struct filter_set *s;
+
+ TAILQ_INIT(dest);
+
+ if (source == NULL || TAILQ_EMPTY(source))
+ return;
+
+ while ((s = TAILQ_FIRST(source)) != NULL) {
+ TAILQ_REMOVE(source, s, entry);
+ TAILQ_INSERT_TAIL(dest, s, entry);
+ }
+}
+
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index 3b333b77718..08c2f2e4563 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.44 2005/07/01 09:19:24 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.45 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -77,11 +77,11 @@ print_set(struct filter_set_head *set)
{
struct filter_set *s;
- if (SIMPLEQ_EMPTY(set))
+ if (TAILQ_EMPTY(set))
return;
printf("set { ");
- SIMPLEQ_FOREACH(s, set, entry) {
+ TAILQ_FOREACH(s, set, entry) {
switch (s->type) {
case ACTION_SET_LOCALPREF:
printf("localpref %u ", s->action.metric);
@@ -176,28 +176,28 @@ print_mainconf(struct bgpd_config *conf)
if (conf->flags & BGPD_FLAG_REDIST_CONNECTED) {
printf("network inet connected");
- if (!SIMPLEQ_EMPTY(&conf->connectset))
+ if (!TAILQ_EMPTY(&conf->connectset))
printf(" ");
print_set(&conf->connectset);
printf("\n");
}
if (conf->flags & BGPD_FLAG_REDIST_STATIC) {
printf("network inet static");
- if (!SIMPLEQ_EMPTY(&conf->staticset))
+ if (!TAILQ_EMPTY(&conf->staticset))
printf(" ");
print_set(&conf->staticset);
printf("\n");
}
if (conf->flags & BGPD_FLAG_REDIST6_CONNECTED) {
printf("network inet6 connected");
- if (!SIMPLEQ_EMPTY(&conf->connectset6))
+ if (!TAILQ_EMPTY(&conf->connectset6))
printf(" ");
print_set(&conf->connectset6);
printf("\n");
}
if (conf->flags & BGPD_FLAG_REDIST_STATIC) {
printf("network inet6 static");
- if (!SIMPLEQ_EMPTY(&conf->staticset6))
+ if (!TAILQ_EMPTY(&conf->staticset6))
printf(" ");
print_set(&conf->staticset6);
printf("\n");
@@ -208,7 +208,7 @@ void
print_network(struct network_config *n)
{
printf("network %s/%u", log_addr(&n->prefix), n->prefixlen);
- if (!SIMPLEQ_EMPTY(&n->attrset))
+ if (!TAILQ_EMPTY(&n->attrset))
printf(" ");
print_set(&n->attrset);
printf("\n");
@@ -296,10 +296,10 @@ print_peer(struct peer_config *p, struct bgpd_config *conf, const char *c)
else if (p->auth.method == AUTH_IPSEC_IKE_ESP)
printf("%s\tipsec esp ike\n", c);
- if (!SIMPLEQ_EMPTY(&p->attrset))
+ if (!TAILQ_EMPTY(&p->attrset))
printf("%s\t", c);
print_set(&p->attrset);
- if (!SIMPLEQ_EMPTY(&p->attrset))
+ if (!TAILQ_EMPTY(&p->attrset))
printf("\n");
print_mrt(p->id, p->groupid, c, "\t");
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index f5cd16bafab..400289f1cd6 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.165 2005/07/01 12:10:20 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.166 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -331,7 +331,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf)
break;
}
memcpy(&netconf_s, imsg.data, sizeof(netconf_s));
- SIMPLEQ_INIT(&netconf_s.attrset);
+ TAILQ_INIT(&netconf_s.attrset);
session_set = &netconf_s.attrset;
break;
case IMSG_NETWORK_DONE:
@@ -349,7 +349,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf)
break;
}
memcpy(&netconf_s, imsg.data, sizeof(netconf_s));
- SIMPLEQ_INIT(&netconf_s.attrset);
+ TAILQ_INIT(&netconf_s.attrset);
network_delete(&netconf_s, 0);
break;
case IMSG_NETWORK_FLUSH:
@@ -373,7 +373,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf)
if ((s = malloc(sizeof(struct filter_set))) == NULL)
fatal(NULL);
memcpy(s, imsg.data, sizeof(struct filter_set));
- SIMPLEQ_INSERT_TAIL(session_set, s, entry);
+ TAILQ_INSERT_TAIL(session_set, s, entry);
break;
case IMSG_CTL_SHOW_NETWORK:
if (imsg.hdr.len != IMSG_HEADER_SIZE) {
@@ -475,7 +475,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
break;
case IMSG_NETWORK_ADD:
memcpy(&netconf_p, imsg.data, sizeof(netconf_p));
- SIMPLEQ_INIT(&netconf_p.attrset);
+ TAILQ_INIT(&netconf_p.attrset);
parent_set = &netconf_p.attrset;
break;
case IMSG_NETWORK_DONE:
@@ -489,7 +489,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
break;
}
memcpy(&netconf_p, imsg.data, sizeof(netconf_p));
- SIMPLEQ_INIT(&netconf_p.attrset);
+ TAILQ_INIT(&netconf_p.attrset);
network_delete(&netconf_p, 1);
break;
case IMSG_RECONF_FILTER:
@@ -499,7 +499,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
if ((r = malloc(sizeof(struct filter_rule))) == NULL)
fatal(NULL);
memcpy(r, imsg.data, sizeof(struct filter_rule));
- SIMPLEQ_INIT(&r->set);
+ TAILQ_INIT(&r->set);
parent_set = &r->set;
TAILQ_INSERT_TAIL(newrules, r, entry);
break;
@@ -541,7 +541,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
if ((s = malloc(sizeof(struct filter_set))) == NULL)
fatal(NULL);
memcpy(s, imsg.data, sizeof(struct filter_set));
- SIMPLEQ_INSERT_TAIL(parent_set, s, entry);
+ TAILQ_INSERT_TAIL(parent_set, s, entry);
break;
case IMSG_MRT_OPEN:
case IMSG_MRT_REOPEN:
@@ -1870,7 +1870,7 @@ peer_add(u_int32_t id, struct peer_config *p_conf)
LIST_INIT(&peer->path_h);
memcpy(&peer->conf, p_conf, sizeof(struct peer_config));
- SIMPLEQ_INIT(&peer->conf.attrset);
+ TAILQ_INIT(&peer->conf.attrset);
peer->remote_bgpid = 0;
peer->state = PEER_NONE;
up_init(peer);
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index 0c52caf13be..4287b5d9607 100644
--- a/usr.sbin/bgpd/rde_filter.c
+++ b/usr.sbin/bgpd/rde_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_filter.c,v 1.30 2005/07/01 12:10:21 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.31 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -71,7 +71,7 @@ rde_apply_set(struct rde_aspath *asp, struct filter_set_head *sh,
if (asp == NULL)
return;
- SIMPLEQ_FOREACH(set, sh, entry) {
+ TAILQ_FOREACH(set, sh, entry) {
/*
* default outgoing overrides are only allowed to
* set prepend-self and set nexthop no-modify
@@ -300,8 +300,8 @@ filterset_free(struct filter_set_head *sh)
{
struct filter_set *s;
- while ((s = SIMPLEQ_FIRST(sh)) != NULL) {
- SIMPLEQ_REMOVE_HEAD(sh, entry);
+ while ((s = TAILQ_FIRST(sh)) != NULL) {
+ TAILQ_REMOVE(sh, s, entry);
if (s->type == ACTION_RTLABEL_ID)
rtlabel_unref(s->action.id);
else if (s->type == ACTION_PFTABLE_ID)
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 54208f3a99e..5aa00eee3b6 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.228 2005/06/16 18:43:07 henning Exp $ */
+/* $OpenBSD: session.c,v 1.229 2005/07/01 13:38:14 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2124,7 +2124,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
reconf = RECONF_KEEP;
memcpy(&p->conf, pconf, sizeof(struct peer_config));
- SIMPLEQ_INIT(&p->conf.attrset);
+ TAILQ_INIT(&p->conf.attrset);
session_set = &p->conf.attrset;
p->conf.reconf_action = reconf;
break;
@@ -2225,7 +2225,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
if ((s = malloc(sizeof(struct filter_set))) == NULL)
fatal(NULL);
memcpy(s, imsg.data, sizeof(struct filter_set));
- SIMPLEQ_INSERT_TAIL(session_set, s, entry);
+ TAILQ_INSERT_TAIL(session_set, s, entry);
break;
case IMSG_IFINFO:
if (idx != PFD_PIPE_MAIN)
@@ -2579,7 +2579,7 @@ session_up(struct peer *p)
&p->conf, sizeof(p->conf)) == -1)
fatalx("imsg_compose error");
- SIMPLEQ_FOREACH(s, &p->conf.attrset, entry) {
+ TAILQ_FOREACH(s, &p->conf.attrset, entry) {
if (imsg_compose(ibuf_rde, IMSG_FILTER_SET, p->conf.id, 0, -1,
s, sizeof(struct filter_set)) == -1)
fatalx("imsg_compose error");