summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2007-03-03 15:26:47 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2007-03-03 15:26:47 +0000
commitee362f0290d5a1c5eb8d3aa726aa8147a7b9b9b8 (patch)
treeeecee982033b83f9db37487c28046fbe9338bee0
parent49a7e6a323545e9f1f5e8211e59186614edfc1aa (diff)
as-sets always begin with AS-, and aut-nums with AS[0-9], mandated by the
RPSL spec and enforced by the IRR databases. teach asset_get this fact. only send queries for the as-set members for as-sets. since we now always fake an as-set for aut-nums, we don't need to escape the recursive as-set resolution process when we run into aut-num members. complain about and then ignore unresolvable as-set members.
-rw-r--r--usr.sbin/bgpctl/irr_asset.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/usr.sbin/bgpctl/irr_asset.c b/usr.sbin/bgpctl/irr_asset.c
index 0cf54557a49..e6bc21d1871 100644
--- a/usr.sbin/bgpctl/irr_asset.c
+++ b/usr.sbin/bgpctl/irr_asset.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: irr_asset.c,v 1.1 2007/03/03 11:45:30 henning Exp $ */
+/* $OpenBSD: irr_asset.c,v 1.2 2007/03/03 15:26:46 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ctype.h>
#include "irrfilter.h"
@@ -75,23 +76,30 @@ asset_get(char *name)
err(1, "expand_as_set strdup");
RB_INSERT(as_set_h, &as_set_h, ass);
- curass = ass;
- if ((r = whois(name, QTYPE_ASSET)) == -1)
- errx(1, "whois error, asset_get %s", name);
- curass = NULL;
-
- /*
- * if there are no members, this is an aut-num.
- * if thsi was specified directly in the policy,
- * make a dummy as-set with the the AS as name
- * and its only member */
- if (ass->n_members == 0)
+ if (!strncasecmp(name, "AS", 2) &&
+ strlen(name) > 2 && isdigit(name[2])) {
+ /*
+ * this must be an aut-num
+ * make a dummy as-set with the the AS both as name
+ * and its only member
+ */
asset_add_as(ass, name);
+ return (ass);
+
+ } else if (!strncasecmp(name, "AS-", 3)) {
+ /* as-set */
+ curass = ass;
+ if ((r = whois(name, QTYPE_ASSET)) == -1)
+ errx(1, "whois error, asset_get %s", name);
+ curass = NULL;
+ } else
+ fprintf(stderr, "asset_get: %s: unknown object type\n", name);
for (i = 0; i < ass->n_members; i++) {
mas = asset_get(ass->members[i]);
- if (mas->n_members == 0)
- asset_add_as(ass, ass->members[i]);
+ if (mas->n_members == 0 && mas->n_as == 0)
+ fprintf(stderr, "%s: can't resolve member %s\n",
+ name, ass->members[i]);
else
asset_add_asset(ass, ass->members[i]);
}