summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-08-09 20:27:26 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-08-09 20:27:26 +0000
commit6aba2f99d36c0c95e63613146e8344d9256df609 (patch)
treeb76e2f7547be4cda6abcae160da591c9f51dc7bd /usr.sbin/bgpd
parent37d43a6ee9cff1651397a00f88f10a313035035f (diff)
Introduce new route decision tunable "rde med compare (always|strict)".
If set to always the med will also be compared between different AS. The default is strict which is the way the RFC specifies it. OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.conf.519
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/parse.y18
-rw-r--r--usr.sbin/bgpd/printconf.c5
-rw-r--r--usr.sbin/bgpd/rde_decide.c5
5 files changed, 43 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5
index 79629645efb..adfa3fe58bb 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.58 2005/07/28 20:32:33 henning Exp $
+.\" $OpenBSD: bgpd.conf.5,v 1.59 2005/08/09 20:27:25 claudio Exp $
.\"
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -242,6 +242,23 @@ section.
.Pp
.It Xo
.Ic rde
+.Ic med
+.Ic compare
+.Pq Ic always Ns \&| Ns Ic strict
+.Xc
+If set to
+.Ic always ,
+the
+.Em MED
+attributes will be comapared always.
+The default is
+.Ic strict
+where the
+.Em MED
+is only compared between peers belonging to the same AS.
+.Pp
+.It Xo
+.Ic rde
.Ic route-age
.Pq Ic ignore Ns \&| Ns Ic evaluate
.Xc
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 5bea6ba98ed..b4d330104d7 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.175 2005/07/04 09:37:24 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.176 2005/08/09 20:27:25 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -60,6 +60,7 @@
#define BGPD_FLAG_DECISION_MASK 0x0f00
#define BGPD_FLAG_DECISION_ROUTEAGE 0x0100
#define BGPD_FLAG_DECISION_TRANS_AS 0x0200
+#define BGPD_FLAG_DECISION_MED_ALWAYS 0x0400
#define BGPD_LOG_UPDATES 0x0001
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 8fe1c32ed9d..adb8f4a1115 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.170 2005/07/28 20:01:21 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.171 2005/08/09 20:27:25 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -142,7 +142,7 @@ typedef struct {
%}
%token AS ROUTERID HOLDTIME YMIN LISTEN ON FIBUPDATE
-%token RDE EVALUATE IGNORE
+%token RDE EVALUATE IGNORE COMPARE
%token GROUP NEIGHBOR NETWORK
%token REMOTEAS DESCR LOCALADDR MULTIHOP PASSIVE MAXPREFIX ANNOUNCE
%token ENFORCE NEIGHBORAS CAPABILITIES REFLECTOR DEPEND
@@ -415,6 +415,19 @@ conf_main : AS asnumber {
}
free($2);
}
+ | RDE MED COMPARE STRING {
+ if (!strcmp($4, "always"))
+ conf->flags |= BGPD_FLAG_DECISION_MED_ALWAYS;
+ else if (!strcmp($4, "strict"))
+ conf->flags &= ~BGPD_FLAG_DECISION_MED_ALWAYS;
+ else {
+ yyerror("rde med compare: "
+ "unknown setting \"%s\"", $4);
+ free($4);
+ YYERROR;
+ }
+ free($4);
+ }
;
mrtdump : DUMP STRING inout STRING optnumber {
@@ -1464,6 +1477,7 @@ lookup(char *s)
{ "blackhole", BLACKHOLE},
{ "capabilities", CAPABILITIES},
{ "community", COMMUNITY},
+ { "compare", COMPARE},
{ "connected", CONNECTED},
{ "deny", DENY},
{ "depend", DEPEND},
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index aa25203d42e..576991bc8db 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.46 2005/07/28 20:14:29 henning Exp $ */
+/* $OpenBSD: printconf.c,v 1.47 2005/08/09 20:27:25 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -165,6 +165,9 @@ print_mainconf(struct bgpd_config *conf)
if (conf->flags & BGPD_FLAG_DECISION_ROUTEAGE)
printf("rde route-age evaluate\n");
+ if (conf->flags & BGPD_FLAG_DECISION_MED_ALWAYS)
+ printf("rde med compare always\n");
+
if (conf->flags & BGPD_FLAG_DECISION_TRANS_AS)
printf("transparent-as yes\n");
diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c
index 98117ae4ae0..6ee960e78f1 100644
--- a/usr.sbin/bgpd/rde_decide.c
+++ b/usr.sbin/bgpd/rde_decide.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_decide.c,v 1.41 2005/04/12 14:32:01 claudio Exp $ */
+/* $OpenBSD: rde_decide.c,v 1.42 2005/08/09 20:27:25 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -137,7 +137,8 @@ prefix_cmp(struct prefix *p1, struct prefix *p2)
return (asp2->origin - asp1->origin);
/* 5. MED decision, only comparable between the same neighboring AS */
- if (aspath_neighbor(asp1->aspath) == aspath_neighbor(asp2->aspath))
+ if (rde_decisionflags() & BGPD_FLAG_DECISION_MED_ALWAYS ||
+ aspath_neighbor(asp1->aspath) == aspath_neighbor(asp2->aspath))
/* lowest value wins */
if ((asp2->med - asp1->med) != 0)
return (asp2->med - asp1->med);