summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2007-03-06 00:27:34 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2007-03-06 00:27:34 +0000
commit37c07d65ff47c5ffaa3c9d9a52c8d7ff4c038b98 (patch)
treeed8e5d7c178234d91ca743f099527f7106108dbe /usr.sbin
parent0b8e4a2a36e9bfcfb00ff7e53775b9f7f8a88898 (diff)
another completely bogus route entry, this time openface in their own RR:
route: 198.73.251.0 no prefixlen... overhaul error handling in prefixset_addmember(). for prefixes without prefixlen or ones where inet_net_pton reports an invalid format, complain and ignore the prefix, but don't err out completely.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpctl/irr_prefix.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.sbin/bgpctl/irr_prefix.c b/usr.sbin/bgpctl/irr_prefix.c
index 5e586abf703..64cf616a635 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.12 2007/03/05 22:10:50 henning Exp $ */
+/* $OpenBSD: irr_prefix.c,v 1.13 2007/03/06 00:27:33 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -20,6 +20,7 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -75,16 +76,25 @@ prefixset_addmember(char *s)
struct irr_prefix *pfx;
int len;
- if (strchr(s, '/') == NULL)
- errx(1, "prefix %s does not have the len specified", s);
+ if (strchr(s, '/') == NULL) {
+ fprintf(stderr, "%s: prefix %s does not have the len "
+ "specified, ignoring\n", curpfxs->as, s);
+ return (0);
+ }
if ((pfx = calloc(1, sizeof(*pfx))) == NULL)
err(1, "prefixset_addmember calloc");
if ((len = inet_net_pton(AF_INET, s, &pfx->addr.in,
- sizeof(pfx->addr.in))) == -1)
- err(1, "prefixset_addmember %s inet_net_pton \"%s\"",
- curpfxs->as, s);
+ sizeof(pfx->addr.in))) == -1) {
+ if (errno == ENOENT) {
+ fprintf(stderr, "%s: prefix \"%s\": parse error\n",
+ curpfxs->as, s);
+ return (0);
+ } else
+ err(1, "prefixset_addmember %s inet_net_pton \"%s\"",
+ curpfxs->as, s);
+ }
pfx->af = AF_INET;
pfx->len = len;