-/* $OpenBSD: aspa.c,v 1.28 2024/02/21 09:17:06 tb Exp $ */
+/* $OpenBSD: aspa.c,v 1.29 2024/04/05 16:05:15 job Exp $ */
/*
* Copyright (c) 2022 Job Snijders <job@fastly.com>
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Duplicated entries are merged.
*/
void
-aspa_insert_vaps(struct vap_tree *tree, struct aspa *aspa, struct repo *rp)
+aspa_insert_vaps(char *fn, struct vap_tree *tree, struct aspa *aspa,
+ struct repo *rp)
{
struct vap *v, *found;
size_t i, j;
v->expires = aspa->expires;
if ((found = RB_INSERT(vap_tree, tree, v)) != NULL) {
+ if (found->invalid) {
+ free(v);
+ return;
+ }
if (found->expires > v->expires) {
/* decrement found */
repo_stat_inc(repo_byid(found->repoid), found->talid,
} else
repo_stat_inc(rp, v->talid, RTYPE_ASPA, STYPE_UNIQUE);
+ if (v->providersz >= MAX_ASPA_PROVIDERS) {
+ v->invalid = 1;
+ repo_stat_inc(rp, v->talid, RTYPE_ASPA, STYPE_INVALID);
+ warnx("%s: too many providers for ASPA Customer ASID "
+ "(more than %d)", fn, MAX_ASPA_PROVIDERS);
+ return;
+ }
+
repo_stat_inc(rp, aspa->talid, RTYPE_ASPA, STYPE_TOTAL);
v->providers = reallocarray(v->providers,
-/* $OpenBSD: extern.h,v 1.213 2024/03/22 03:38:12 job Exp $ */
+/* $OpenBSD: extern.h,v 1.214 2024/04/05 16:05:15 job Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
time_t expires;
int talid;
unsigned int repoid;
+ int invalid;
};
/*
void aspa_buffer(struct ibuf *, const struct aspa *);
void aspa_free(struct aspa *);
-void aspa_insert_vaps(struct vap_tree *, struct aspa *,
+void aspa_insert_vaps(char *, struct vap_tree *, struct aspa *,
struct repo *);
struct aspa *aspa_parse(X509 **, const char *, int, const unsigned char *,
size_t);
-/* $OpenBSD: main.c,v 1.255 2024/03/22 03:38:12 job Exp $ */
+/* $OpenBSD: main.c,v 1.256 2024/04/05 16:05:15 job Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
}
aspa = aspa_read(b);
if (aspa->valid)
- aspa_insert_vaps(vaptree, aspa, rp);
+ aspa_insert_vaps(file, vaptree, aspa, rp);
else
repo_stat_inc(rp, talid, type, STYPE_INVALID);
aspa_free(aspa);
-/* $OpenBSD: output-bgpd.c,v 1.29 2024/02/22 12:49:42 job Exp $ */
+/* $OpenBSD: output-bgpd.c,v 1.30 2024/04/05 16:05:15 job Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
if (fprintf(out, "\naspa-set {\n") < 0)
return -1;
RB_FOREACH(vap, vap_tree, vaps) {
+ if (vap->invalid)
+ continue;
if (fprintf(out, "\tcustomer-as %d expires %lld "
"provider-as { ", vap->custasid,
(long long)vap->expires) < 0)
-/* $OpenBSD: output-json.c,v 1.46 2024/03/01 08:10:09 tb Exp $ */
+/* $OpenBSD: output-json.c,v 1.47 2024/04/05 16:05:15 job Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
*
{
size_t i;
+ if (v->invalid)
+ return;
+
json_do_object("aspa", 1);
json_do_int("customer_asid", v->custasid);
json_do_int("expires", v->expires);