Move and rename copy_filterset to rde_filter.c as filterset_copy.
This way it matches the other filterset_* functions.
OK?
--
:wq Claudio
Index: bgpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.400
diff -u -p -r1.400 bgpd.h
--- bgpd.h 12 Feb 2020 10:33:56 -0000 1.400
+++ bgpd.h 14 Feb 2020 12:16:43 -0000
@@ -1182,8 +1182,6 @@ void free_prefixtree(struct prefixset_t
void filterlist_free(struct filter_head *);
int host(const char *, struct bgpd_addr *, u_int8_t *);
u_int32_t get_bgpid(void);
-void copy_filterset(struct filter_set_head *,
- struct filter_set_head *);
void expand_networks(struct bgpd_config *);
int prefixset_cmp(struct prefixset_item *, struct prefixset_item *);
RB_PROTOTYPE(prefixset_tree, prefixset_item, entry, prefixset_cmp);
@@ -1261,10 +1259,10 @@ int pftable_addr_remove(struct pftable_m
int pftable_commit(void);
/* 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 *);
+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 *);
+void filterset_copy(struct filter_set_head *, struct filter_set_head *);
const char *filterset_name(enum action_types);
/* rde_sets.c */
Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/config.c,v
retrieving revision 1.94
diff -u -p -r1.94 config.c
--- config.c 28 Jan 2020 15:45:46 -0000 1.94
+++ config.c 14 Feb 2020 12:21:44 -0000
@@ -496,22 +496,6 @@ prepare_listeners(struct bgpd_config *co
}
void
-copy_filterset(struct filter_set_head *source, struct filter_set_head *dest)
-{
- struct filter_set *s, *t;
-
- if (source == NULL)
- return;
-
- TAILQ_FOREACH(s, source, entry) {
- if ((t = malloc(sizeof(struct filter_set))) == NULL)
- fatal(NULL);
- memcpy(t, s, sizeof(struct filter_set));
- TAILQ_INSERT_TAIL(dest, t, entry);
- }
-}
-
-void
expand_networks(struct bgpd_config *c)
{
struct network *n, *m, *tmp;
@@ -533,8 +517,7 @@ expand_networks(struct bgpd_config *c)
memcpy(&m->net.prefix, &psi->p.addr,
sizeof(m->net.prefix));
m->net.prefixlen = psi->p.len;
- TAILQ_INIT(&m->net.attrset);
- copy_filterset(&n->net.attrset,
+ filterset_copy(&n->net.attrset,
&m->net.attrset);
TAILQ_INSERT_TAIL(nw, m, entry);
}
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.403
diff -u -p -r1.403 parse.y
--- parse.y 24 Jan 2020 05:44:05 -0000 1.403
+++ parse.y 14 Feb 2020 12:21:59 -0000
@@ -4076,8 +4076,7 @@ expand_rule(struct filter_rule *rule, st
memcpy(r, rule, sizeof(struct
filter_rule));
memcpy(&r->match, match,
sizeof(struct filter_match));
- TAILQ_INIT(&r->set);
- copy_filterset(set, &r->set);
+ filterset_copy(set, &r->set);
if (rb != NULL)
strlcpy(r->rib, rb->name,
Index: rde_filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
retrieving revision 1.122
diff -u -p -r1.122 rde_filter.c
--- rde_filter.c 13 Aug 2019 12:16:20 -0000 1.122
+++ rde_filter.c 14 Feb 2020 12:21:28 -0000
@@ -502,6 +502,10 @@ filterset_cmp(struct filter_set *a, stru
return (0);
}
+/*
+ * move filterset from source to dest. dest will be initialized first.
+ * After the move source is an empty list.
+ */
void
filterset_move(struct filter_set_head *source, struct filter_set_head *dest)
{
@@ -509,6 +513,26 @@ filterset_move(struct filter_set_head *s
if (source == NULL)
return;
TAILQ_CONCAT(dest, source, entry);
+}
+
+/*
+ * copy filterset from source to dest. dest will be initialized first.
+ */
+void
+filterset_copy(struct filter_set_head *source, struct filter_set_head *dest)
+{
+ struct filter_set *s, *t;
+
+ TAILQ_INIT(dest);
+ if (source == NULL)
+ return;
+
+ TAILQ_FOREACH(s, source, entry) {
+ if ((t = malloc(sizeof(struct filter_set))) == NULL)
+ fatal(NULL);
+ memcpy(t, s, sizeof(struct filter_set));
+ TAILQ_INSERT_TAIL(dest, t, entry);
+ }
}
int