summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2011-05-01 12:56:05 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2011-05-01 12:56:05 +0000
commita98e9bb7b03360436119edd88230330b78dac64f (patch)
treea33009802145f1f4131308ed682d5bed829f9d92 /usr.sbin/bgpd
parentea51f26a9ea20a6a28bf9c568c913175d6989102 (diff)
On reload the filtersets attached to a network need to be moved to the
existing network element. First free the old filterset and then move the new on top of it. This solves the reload issue with changing network statements. OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.h4
-rw-r--r--usr.sbin/bgpd/kroute.c4
-rw-r--r--usr.sbin/bgpd/parse.y24
-rw-r--r--usr.sbin/bgpd/rde_filter.c18
4 files changed, 26 insertions, 24 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 827b9f4cbe9..96374e903ec 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.263 2010/10/24 17:20:08 deraadt Exp $ */
+/* $OpenBSD: bgpd.h,v 1.264 2011/05/01 12:56:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -931,6 +931,8 @@ void pftable_ref(u_int16_t);
/* rde_filter.c */
void filterset_free(struct filter_set_head *);
int filterset_cmp(struct filter_set *, struct filter_set *);
+void filterset_move(struct filter_set_head *,
+ struct filter_set_head *);
const char *filterset_name(enum action_types);
/* util.c */
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 9fc68355ac7..666f437624b 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.187 2011/03/07 07:43:02 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.188 2011/05/01 12:56:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1155,6 +1155,8 @@ kr_net_reload(u_int rtableid, struct network_head *nh)
xn = kr_net_find(kt, n);
if (xn) {
xn->net.old = 0;
+ filterset_free(&xn->net.attrset);
+ filterset_move(&n->net.attrset, &xn->net.attrset);
kr_net_delete(n);
} else
TAILQ_INSERT_TAIL(&kt->krn, n, entry);
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index eecd9a7a134..75798d892f4 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.258 2010/09/02 14:03:21 sobrado Exp $ */
+/* $OpenBSD: parse.y,v 1.259 2011/05/01 12:56:04 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -126,8 +126,6 @@ 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 *);
struct filter_rule *get_rule(enum action_types);
int getcommunity(char *);
@@ -608,7 +606,7 @@ network : NETWORK prefix filter_set {
memcpy(&n->net.prefix, &$2.prefix,
sizeof(n->net.prefix));
n->net.prefixlen = $2.len;
- move_filterset($3, &n->net.attrset);
+ filterset_move($3, &n->net.attrset);
free($3);
TAILQ_INSERT_TAIL(netconf, n, entry);
@@ -626,7 +624,7 @@ network : NETWORK prefix filter_set {
YYERROR;
}
n->net.type = $3 ? NETWORK_STATIC : NETWORK_CONNECTED;
- move_filterset($4, &n->net.attrset);
+ filterset_move($4, &n->net.attrset);
free($4);
TAILQ_INSERT_TAIL(netconf, n, entry);
@@ -3465,22 +3463,6 @@ copy_filterset(struct filter_set_head *source, struct filter_set_head *dest)
}
}
-void
-move_filterset(struct filter_set_head *source, struct filter_set_head *dest)
-{
- struct filter_set *s;
-
- TAILQ_INIT(dest);
-
- if (source == NULL)
- return;
-
- while ((s = TAILQ_FIRST(source)) != NULL) {
- TAILQ_REMOVE(source, s, entry);
- TAILQ_INSERT_TAIL(dest, s, entry);
- }
-}
-
struct filter_rule *
get_rule(enum action_types type)
{
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index d641e68596f..24d97cc6946 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.65 2010/11/29 17:02:41 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.66 2011/05/01 12:56:04 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -516,6 +516,22 @@ filterset_cmp(struct filter_set *a, struct filter_set *b)
return (0);
}
+void
+filterset_move(struct filter_set_head *source, struct filter_set_head *dest)
+{
+ struct filter_set *s;
+
+ TAILQ_INIT(dest);
+
+ if (source == NULL)
+ return;
+
+ while ((s = TAILQ_FIRST(source)) != NULL) {
+ TAILQ_REMOVE(source, s, entry);
+ TAILQ_INSERT_TAIL(dest, s, entry);
+ }
+}
+
int
filterset_equal(struct filter_set_head *ah, struct filter_set_head *bh)
{