summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2009-09-08 16:11:37 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2009-09-08 16:11:37 +0000
commit202030fc169db12100b9f53a1b16bfb686d53034 (patch)
tree93e7dd1d7e8d374b7884622c56f0088e062567f8
parent8d8c0a2391f308d5be9d53997dd3b209abc4112d (diff)
Add -4 and -6 flags to irrfilter mode, allowing you to only fetch (you
guessed it) v4 or v6 from the IRR. Reduces size of the filter file (and thus router resource use) when you only speak IPv4 but you want to filter peers who announce lots of v6 space. ok claudio@
-rw-r--r--usr.sbin/bgpctl/bgpctl.88
-rw-r--r--usr.sbin/bgpctl/irr_prefix.c6
-rw-r--r--usr.sbin/bgpctl/irrfilter.h4
-rw-r--r--usr.sbin/bgpctl/parser.c11
4 files changed, 22 insertions, 7 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8
index 73fb8ea59bd..18c94fbbd6a 100644
--- a/usr.sbin/bgpctl/bgpctl.8
+++ b/usr.sbin/bgpctl/bgpctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bgpctl.8,v 1.49 2009/06/06 06:11:17 claudio Exp $
+.\" $OpenBSD: bgpctl.8,v 1.50 2009/09/08 16:11:36 sthen Exp $
.\"
.\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 6 2009 $
+.Dd $Mdocdate: September 8 2009 $
.Dt BGPCTL 8
.Os
.Sh NAME
@@ -79,6 +79,10 @@ The options are as follows:
Use
.Ar directory
to write the filter files to.
+.It Fl 4
+Fetch only IPv4 prefixes from the registry.
+.It Fl 6
+Fetch only IPv6 prefixes from the registry.
.El
.It Cm neighbor Ar peer Cm up
Take the BGP session to the specified neighbor up.
diff --git a/usr.sbin/bgpctl/irr_prefix.c b/usr.sbin/bgpctl/irr_prefix.c
index d8f5a708bdd..9f7d0aac042 100644
--- a/usr.sbin/bgpctl/irr_prefix.c
+++ b/usr.sbin/bgpctl/irr_prefix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: irr_prefix.c,v 1.16 2009/09/08 15:40:25 claudio Exp $ */
+/* $OpenBSD: irr_prefix.c,v 1.17 2009/09/08 16:11:36 sthen Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -64,7 +64,9 @@ prefixset_get(char *as)
fflush(stdout);
}
curpfxs = pfxs;
- if (whois(as, QTYPE_ROUTE) == -1)
+ if ((irrflags & F_IPV4) && whois(as, QTYPE_ROUTE) == -1)
+ errx(1, "whois error, prefixset_get %s", as);
+ if ((irrflags & F_IPV6) && whois(as, QTYPE_ROUTE6) == -1)
errx(1, "whois error, prefixset_get %s", as);
if (whois(as, QTYPE_ROUTE6) == -1)
errx(1, "whois error, prefixset_get %s", as);
diff --git a/usr.sbin/bgpctl/irrfilter.h b/usr.sbin/bgpctl/irrfilter.h
index 88370b47045..ddc4fc1312e 100644
--- a/usr.sbin/bgpctl/irrfilter.h
+++ b/usr.sbin/bgpctl/irrfilter.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: irrfilter.h,v 1.8 2009/09/08 15:40:25 claudio Exp $ */
+/* $OpenBSD: irrfilter.h,v 1.9 2009/09/08 16:11:36 sthen Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -21,6 +21,8 @@
#include <netinet/in.h>
#define F_IMPORTONLY 0x01 /* skip export: items */
+#define F_IPV4 0x02 /* use IPv4 items */
+#define F_IPV6 0x04 /* use IPv6 items */
int irrflags;
int irrverbose;
diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c
index 646f26a4598..423e997e7c4 100644
--- a/usr.sbin/bgpctl/parser.c
+++ b/usr.sbin/bgpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.55 2009/08/31 10:17:35 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.56 2009/09/08 16:11:36 sthen Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -336,6 +336,7 @@ parse(int argc, char *argv[])
bzero(&res, sizeof(res));
res.community.as = COMMUNITY_UNSET;
res.community.type = COMMUNITY_UNSET;
+ res.flags = (F_IPV4 | F_IPV6);
TAILQ_INIT(&res.set);
if ((res.irr_outdir = getcwd(NULL, 0)) == NULL) {
fprintf(stderr, "getcwd failed: %s", strerror(errno));
@@ -882,8 +883,14 @@ bgpctl_getopt(int *argc, char **argv[], int type)
int ch;
optind = optreset = 1;
- while ((ch = getopt((*argc) + 1, (*argv) - 1, "o:")) != -1) {
+ while ((ch = getopt((*argc) + 1, (*argv) - 1, "46o:")) != -1) {
switch (ch) {
+ case '4':
+ res.flags = (res.flags | F_IPV4) & ~F_IPV6;
+ break;
+ case '6':
+ res.flags = (res.flags | F_IPV6) & ~F_IPV4;
+ break;
case 'o':
res.irr_outdir = optarg;
break;