summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.c20
-rw-r--r--usr.sbin/bgpd/bgpd.conf.514
-rw-r--r--usr.sbin/bgpd/bgpd.h6
-rw-r--r--usr.sbin/bgpd/parse.y46
-rw-r--r--usr.sbin/bgpd/printconf.c20
5 files changed, 91 insertions, 15 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 8e74c059e1c..7ea56b8791d 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.120 2005/05/27 17:59:50 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.121 2005/06/09 15:32:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -49,7 +49,9 @@ int dispatch_imsg(struct imsgbuf *, int);
int rfd = -1;
int cflags = 0;
struct filter_set_head *connectset;
+struct filter_set_head *connectset6;
struct filter_set_head *staticset;
+struct filter_set_head *staticset6;
volatile sig_atomic_t mrtdump = 0;
volatile sig_atomic_t quit = 0;
volatile sig_atomic_t reconfig = 0;
@@ -171,6 +173,8 @@ main(int argc, char *argv[])
cflags = conf.flags;
connectset = &conf.connectset;
staticset = &conf.staticset;
+ connectset6 = &conf.connectset6;
+ staticset6 = &conf.staticset6;
if (geteuid())
errx(1, "need root privileges");
@@ -424,6 +428,8 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l,
cflags = conf->flags;
connectset = &conf->connectset;
staticset = &conf->staticset;
+ connectset6 = &conf->connectset6;
+ staticset6 = &conf->staticset6;
prepare_listeners(conf);
@@ -660,10 +666,18 @@ bgpd_redistribute(int type, struct kroute *kr, struct kroute6 *kr6)
struct network_config net;
struct filter_set_head *h;
- if ((cflags & BGPD_FLAG_REDIST_CONNECTED) && (kr->flags & F_CONNECTED))
+ if ((cflags & BGPD_FLAG_REDIST_CONNECTED) && kr &&
+ (kr->flags & F_CONNECTED))
h = connectset;
- else if ((cflags & BGPD_FLAG_REDIST_STATIC) && (kr->flags & F_STATIC))
+ else if ((cflags & BGPD_FLAG_REDIST_STATIC) && kr &&
+ (kr->flags & F_STATIC))
h = staticset;
+ else if ((cflags & BGPD_FLAG_REDIST6_CONNECTED) && kr6 &&
+ (kr6->flags & F_CONNECTED))
+ h = connectset6;
+ else if ((cflags & BGPD_FLAG_REDIST6_STATIC) && kr6 &&
+ (kr6->flags & F_STATIC))
+ h = staticset6;
else
return (0);
diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5
index a3dcb3462c8..e3288f1fed8 100644
--- a/usr.sbin/bgpd/bgpd.conf.5
+++ b/usr.sbin/bgpd/bgpd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bgpd.conf.5,v 1.55 2005/06/04 21:48:16 henning Exp $
+.\" $OpenBSD: bgpd.conf.5,v 1.56 2005/06/09 15:32:03 claudio Exp $
.\"
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -206,8 +206,16 @@ Log received and sent updates.
.Ar address Ns Li / Ns Ar prefix
.Op Ic set ...\&
.Xc
-.It Ic network static Op Ic set ...\&
-.It Ic network connected Op Ic set ...\&
+.It Xo
+.Ic network
+.Pq Ic inet Ns \&| Ns Ic inet6
+.Ic static Op Ic set ...\&
+.Xc
+.It Xo
+.Ic network
+.Pq Ic inet Ns \&| Ns Ic inet6
+.Ic connected Op Ic set ...\&
+.Xc
Announce the specified network as belonging to our AS.
If set to
.Ic connected ,
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 4c4ecccc9ca..9a685c9e73e 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.166 2005/05/27 17:52:11 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.167 2005/06/09 15:32:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -54,6 +54,8 @@
#define BGPD_FLAG_REFLECTOR 0x0004
#define BGPD_FLAG_REDIST_STATIC 0x0008
#define BGPD_FLAG_REDIST_CONNECTED 0x0010
+#define BGPD_FLAG_REDIST6_STATIC 0x0020
+#define BGPD_FLAG_REDIST6_CONNECTED 0x0040
#define BGPD_FLAG_DECISION_MASK 0x0f00
#define BGPD_FLAG_DECISION_ROUTEAGE 0x0100
#define BGPD_FLAG_DECISION_TRANS_AS 0x0200
@@ -133,7 +135,9 @@ SIMPLEQ_HEAD(filter_set_head, filter_set);
struct bgpd_config {
struct filter_set_head connectset;
+ struct filter_set_head connectset6;
struct filter_set_head staticset;
+ struct filter_set_head staticset6;
struct listen_addrs *listen_addrs;
int opts;
int flags;
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index f379ed13e69..b47d259100c 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.163 2005/05/24 17:41:13 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.164 2005/06/09 15:32:03 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -326,10 +326,6 @@ conf_main : AS asnumber {
| NETWORK prefix filter_set {
struct network *n;
- if ($2.prefix.af != AF_INET) {
- yyerror("king bula sez: AF_INET only for now");
- YYERROR;
- }
if ((n = calloc(1, sizeof(struct network))) == NULL)
fatal("new_network");
memcpy(&n->net.prefix, &$2.prefix,
@@ -344,7 +340,46 @@ conf_main : AS asnumber {
TAILQ_INSERT_TAIL(netconf, n, entry);
}
+ | NETWORK STRING STATIC filter_set {
+ if (!strcmp($2, "inet")) {
+ conf->flags |= BGPD_FLAG_REDIST_STATIC;
+ if ($4 == NULL || SIMPLEQ_EMPTY($4))
+ SIMPLEQ_INIT(&conf->staticset);
+ else
+ memcpy(&conf->staticset, $4,
+ sizeof(conf->staticset));
+ } else if (!strcmp($2, "inet6")) {
+ conf->flags |= BGPD_FLAG_REDIST6_STATIC;
+ if ($4 == NULL || SIMPLEQ_EMPTY($4))
+ SIMPLEQ_INIT(&conf->staticset6);
+ else
+ memcpy(&conf->staticset6, $4,
+ sizeof(conf->staticset6));
+ }
+ free($2);
+ free($4);
+ }
+ | NETWORK STRING CONNECTED filter_set {
+ if (!strcmp($2, "inet")) {
+ conf->flags |= BGPD_FLAG_REDIST_CONNECTED;
+ if ($4 == NULL || SIMPLEQ_EMPTY($4))
+ SIMPLEQ_INIT(&conf->connectset);
+ else
+ memcpy(&conf->connectset, $4,
+ sizeof(conf->connectset));
+ } else if (!strcmp($2, "inet6")) {
+ conf->flags |= BGPD_FLAG_REDIST6_CONNECTED;
+ if ($4 == NULL || SIMPLEQ_EMPTY($4))
+ SIMPLEQ_INIT(&conf->connectset6);
+ else
+ memcpy(&conf->connectset6, $4,
+ sizeof(conf->connectset6));
+ }
+ free($2);
+ free($4);
+ }
| NETWORK STATIC filter_set {
+ /* keep for compatibility till after next release */
conf->flags |= BGPD_FLAG_REDIST_STATIC;
if ($3 == NULL || SIMPLEQ_EMPTY($3))
SIMPLEQ_INIT(&conf->staticset);
@@ -354,6 +389,7 @@ conf_main : AS asnumber {
free($3);
}
| NETWORK CONNECTED filter_set {
+ /* keep for compatibility till after next release */
conf->flags |= BGPD_FLAG_REDIST_CONNECTED;
if ($3 == NULL || SIMPLEQ_EMPTY($3))
SIMPLEQ_INIT(&conf->connectset);
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index dc61d881ccf..51e4076a0ba 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.41 2005/04/28 13:54:45 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.42 2005/06/09 15:32:03 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -167,19 +167,33 @@ print_mainconf(struct bgpd_config *conf)
log_sockaddr((struct sockaddr *)&la->sa));
if (conf->flags & BGPD_FLAG_REDIST_CONNECTED) {
- printf("network connected");
+ printf("network inet connected");
if (!SIMPLEQ_EMPTY(&conf->connectset))
printf(" ");
print_set(&conf->connectset);
printf("\n");
}
if (conf->flags & BGPD_FLAG_REDIST_STATIC) {
- printf("network static");
+ printf("network inet static");
if (!SIMPLEQ_EMPTY(&conf->staticset))
printf(" ");
print_set(&conf->staticset);
printf("\n");
}
+ if (conf->flags & BGPD_FLAG_REDIST6_CONNECTED) {
+ printf("network inet6 connected");
+ if (!SIMPLEQ_EMPTY(&conf->connectset6))
+ printf(" ");
+ print_set(&conf->connectset6);
+ printf("\n");
+ }
+ if (conf->flags & BGPD_FLAG_REDIST_STATIC) {
+ printf("network inet6 static");
+ if (!SIMPLEQ_EMPTY(&conf->staticset6))
+ printf(" ");
+ print_set(&conf->staticset6);
+ printf("\n");
+ }
}
void