From cf15ea6afd9afb2f756e819126b4db8ed244adf9 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Tue, 12 Apr 2005 14:32:02 +0000 Subject: Introduce a per prefix weight. The weight is used to tip prefixes with equal long AS pathes in one or the other direction. It weights a prefix at a very late stage in the decision process. This is a nice bgpd feature to traffic engineer networks where most AS pathes are equally long. OK henning@ --- usr.sbin/bgpd/parse.y | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'usr.sbin/bgpd/parse.y') diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 0eddbd03158..a2d47a30084 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.157 2005/04/12 14:26:58 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.158 2005/04/12 14:32:00 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -152,7 +152,7 @@ typedef struct { %token FROM TO ANY %token PREFIX PREFIXLEN SOURCEAS TRANSITAS COMMUNITY %token SET LOCALPREF MED METRIC NEXTHOP REJECT BLACKHOLE NOMODIFY -%token PREPEND_SELF PREPEND_PEER PFTABLE +%token PREPEND_SELF PREPEND_PEER PFTABLE WEIGHT %token ERROR %token IPSEC ESP AH SPI IKE %token STRING @@ -1206,6 +1206,32 @@ filter_set_opt : LOCALPREF number { $$->type = ACTION_SET_RELATIVE_MED; $$->action.relative = -$3; } + | WEIGHT number { + if (($$ = calloc(1, sizeof(struct filter_set))) == NULL) + fatal(NULL); + $$->type = ACTION_SET_WEIGHT; + $$->action.metric = $2; + } + | WEIGHT '+' number { + if ($3 > INT_MAX) { + yyerror("weight to big: max %u", INT_MAX); + YYERROR; + } + if (($$ = calloc(1, sizeof(struct filter_set))) == NULL) + fatal(NULL); + $$->type = ACTION_SET_RELATIVE_WEIGHT; + $$->action.metric = $3; + } + | WEIGHT '-' number { + if ($3 > INT_MAX) { + yyerror("weight to small: min -%u", INT_MAX); + YYERROR; + } + if (($$ = calloc(1, sizeof(struct filter_set))) == NULL) + fatal(NULL); + $$->type = ACTION_SET_RELATIVE_WEIGHT; + $$->action.relative = -$3; + } | NEXTHOP address { if (($$ = calloc(1, sizeof(struct filter_set))) == NULL) fatal(NULL); @@ -1417,7 +1443,8 @@ lookup(char *s) { "tcp", TCP}, { "to", TO}, { "transit-as", TRANSITAS}, - { "transparent-as", TRANSPARENT} + { "transparent-as", TRANSPARENT}, + { "weight", WEIGHT} }; const struct keywords *p; -- cgit v1.2.3