-/* $OpenBSD: bgpd.c,v 1.248 2022/06/23 13:09:03 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.249 2022/07/20 12:43:27 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
reconfpending = 3; /* one per child */
- expand_networks(conf);
+ expand_networks(conf, &conf->networks);
+ SIMPLEQ_FOREACH(vpn, &conf->l3vpns, entry)
+ expand_networks(conf, &vpn->net_l);
cflags = conf->flags;
-/* $OpenBSD: bgpd.h,v 1.441 2022/07/11 17:08:21 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.442 2022/07/20 12:43:27 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
struct filter_set_head attrset;
char psname[SET_NAME_LEN];
uint64_t rd;
- uint16_t rtlabel;
enum network_type type;
+ uint16_t rtlabel;
uint8_t prefixlen;
uint8_t priority;
uint8_t old; /* used for reloading */
/* config.c */
struct bgpd_config *new_config(void);
void copy_config(struct bgpd_config *, struct bgpd_config *);
+void network_free(struct network *);
void free_l3vpns(struct l3vpn_head *);
void free_config(struct bgpd_config *);
void free_prefixsets(struct prefixset_head *);
void filterlist_free(struct filter_head *);
int host(const char *, struct bgpd_addr *, uint8_t *);
uint32_t get_bgpid(void);
-void expand_networks(struct bgpd_config *);
+void expand_networks(struct bgpd_config *, struct network_head *);
RB_PROTOTYPE(prefixset_tree, prefixset_item, entry, prefixset_cmp);
int roa_cmp(struct roa *, struct roa *);
RB_PROTOTYPE(roa_tree, roa, entry, roa_cmp);
-/* $OpenBSD: config.c,v 1.102 2022/06/05 12:43:13 claudio Exp $ */
+/* $OpenBSD: config.c,v 1.103 2022/07/20 12:43:27 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
to->fib_priority = from->fib_priority;
}
+void
+network_free(struct network *n)
+{
+ rtlabel_unref(n->net.rtlabel);
+ filterset_free(&n->net.attrset);
+ free(n);
+}
+
void
free_networks(struct network_head *networks)
{
while ((n = TAILQ_FIRST(networks)) != NULL) {
TAILQ_REMOVE(networks, n, entry);
- filterset_free(&n->net.attrset);
- free(n);
+ network_free(n);
}
}
sa2addr(res->ai_addr, h, NULL);
freeaddrinfo(res);
} else { /* ie. for 10/8 parsing */
- if ((bits = inet_net_pton(AF_INET, s, &h->v4, sizeof(h->v4))) == -1)
+ if ((bits = inet_net_pton(AF_INET, s, &h->v4,
+ sizeof(h->v4))) == -1)
return (0);
*len = bits;
h->aid = AID_INET;
}
void
-expand_networks(struct bgpd_config *c)
+expand_networks(struct bgpd_config *c, struct network_head *nw)
{
struct network *n, *m, *tmp;
- struct network_head *nw = &c->networks;
struct prefixset *ps;
struct prefixset_item *psi;
&m->net.attrset);
TAILQ_INSERT_TAIL(nw, m, entry);
}
- filterset_free(&n->net.attrset);
- free(n);
+ network_free(n);
}
}
}
-/* $OpenBSD: kroute.c,v 1.274 2022/07/19 10:26:19 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.275 2022/07/20 12:43:27 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
int kr6_delete(struct ktable *, struct kroute_full *);
int krVPN4_delete(struct ktable *, struct kroute_full *);
int krVPN6_delete(struct ktable *, struct kroute_full *);
-void kr_net_delete(struct network *);
int kr_net_match(struct ktable *, struct network_config *, uint16_t, int);
struct network *kr_net_find(struct ktable *, struct network *);
void kr_net_clear(struct ktable *);
}
}
-void
-kr_net_delete(struct network *n)
-{
- filterset_free(&n->net.attrset);
- free(n);
-}
-
static int
kr_net_redist_add(struct ktable *kt, struct network_config *net,
struct filter_set_head *attr, int dynamic)
TAILQ_FOREACH(xn, &kt->krn, entry) {
if (n->net.type != xn->net.type ||
n->net.prefixlen != xn->net.prefixlen ||
- n->net.rd != xn->net.rd)
+ n->net.rd != xn->net.rd ||
+ n->net.rtlabel != xn->net.rtlabel ||
+ n->net.priority != xn->net.priority)
continue;
if (memcmp(&n->net.prefix, &xn->net.prefix,
sizeof(n->net.prefix)) == 0)
xn->net.old = 0;
filterset_free(&xn->net.attrset);
filterset_move(&n->net.attrset, &xn->net.attrset);
- kr_net_delete(n);
+ network_free(n);
} else
TAILQ_INSERT_TAIL(&kt->krn, n, entry);
}
TAILQ_REMOVE(&kt->krn, n, entry);
if (n->net.type == NETWORK_DEFAULT)
kr_net_redist_del(kt, &n->net, 0);
- kr_net_delete(n);
+ network_free(n);
}
}
TAILQ_REMOVE(&kt->krn, n, entry);
if (n->net.type == NETWORK_DEFAULT)
kr_net_redist_del(kt, &n->net, 0);
- kr_net_delete(n);
+ network_free(n);
}
}
}