diff options
-rw-r--r-- | usr.sbin/bgpd/bgpd.conf.5 | 18 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 28 | ||||
-rw-r--r-- | usr.sbin/bgpd/printconf.c | 20 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_filter.c | 12 |
5 files changed, 75 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5 index 77527f1c430..21a5d2d7176 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.101 2009/10/28 21:38:03 jmc Exp $ +.\" $OpenBSD: bgpd.conf.5,v 1.102 2009/11/26 13:40:43 henning Exp $ .\" .\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> .\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -16,7 +16,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: October 28 2009 $ +.Dd $Mdocdate: November 26 2009 $ .Dt BGPD.CONF 5 .Os .Sh NAME @@ -1148,6 +1148,20 @@ otherwise it will be set to .Ar number . .Pp .It Xo +.Ic origin +.Sm off +.Po Ic igp \*(Ba +.Ic egp \*(Ba +.Ic incomplete Pc +.Sm on +.Xc +Set the +.Em ORIGIN +AS path attribute to mark the source of this +route as being injected from an igp protocol, an egp protocol +or being an aggregated route. +.Pp +.It Xo .Ic nexthop .Sm off .Po Ar address \*(Ba diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index c8f18e84e26..b26da83a39a 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.246 2009/11/02 20:38:15 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.247 2009/11/26 13:40:43 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -642,7 +642,8 @@ enum action_types { ACTION_PFTABLE, ACTION_PFTABLE_ID, ACTION_RTLABEL, - ACTION_RTLABEL_ID + ACTION_RTLABEL_ID, + ACTION_SET_ORIGIN }; struct filter_set { @@ -656,6 +657,7 @@ struct filter_set { struct filter_community community; char pftable[PFTABLE_LEN]; char rtlabel[RTLABEL_LEN]; + u_int8_t origin; } action; enum action_types type; }; diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index fe1c7361af5..3c1dd8d95c1 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.239 2009/11/11 13:48:34 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.240 2009/11/26 13:40:43 henning Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -173,7 +173,7 @@ typedef struct { %token CONNECTED STATIC %token PREFIX PREFIXLEN SOURCEAS TRANSITAS PEERAS COMMUNITY DELETE %token SET LOCALPREF MED METRIC NEXTHOP REJECT BLACKHOLE NOMODIFY SELF -%token PREPEND_SELF PREPEND_PEER PFTABLE WEIGHT RTLABEL +%token PREPEND_SELF PREPEND_PEER PFTABLE WEIGHT RTLABEL ORIGIN %token ERROR INCLUDE %token IPSEC ESP AH SPI IKE %token IPV4 IPV6 @@ -181,7 +181,7 @@ typedef struct { %token <v.string> STRING %token <v.number> NUMBER %type <v.number> asnumber as4number optnumber yesno inout -%type <v.number> espah family restart +%type <v.number> espah family restart origincode %type <v.string> string filter_rib %type <v.addr> address %type <v.prefix> prefix addrspec @@ -1846,8 +1846,29 @@ filter_set_opt : LOCALPREF NUMBER { } } } + | ORIGIN origincode { + if (($$ = calloc(1, sizeof(struct filter_set))) == NULL) + fatal(NULL); + $$->type = ACTION_SET_ORIGIN; + $$->action.origin = $2; + } ; +origincode : string { + if (!strcmp($1, "egp")) + $$ = ORIGIN_EGP; + else if (!strcmp($1, "igp")) + $$ = ORIGIN_IGP; + else if (!strcmp($1, "incomplete")) + $$ = ORIGIN_INCOMPLETE; + else { + yyerror("unknown origin \"%s\"", $1); + free($1); + YYERROR; + } + free($1); + }; + comma : "," | /* empty */ ; @@ -1951,6 +1972,7 @@ lookup(char *s) { "nexthop", NEXTHOP}, { "no-modify", NOMODIFY}, { "on", ON}, + { "origin", ORIGIN}, { "out", OUT}, { "passive", PASSIVE}, { "password", PASSWORD}, diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c index 346bcfe90ed..d1647aa1a96 100644 --- a/usr.sbin/bgpd/printconf.c +++ b/usr.sbin/bgpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.72 2009/10/13 11:41:32 claudio Exp $ */ +/* $OpenBSD: printconf.c,v 1.73 2009/11/26 13:40:43 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -27,6 +27,7 @@ void print_op(enum comp_ops); void print_community(int, int); +void print_origin(u_int8_t); void print_set(struct filter_set_head *); void print_mainconf(struct bgpd_config *); void print_network(struct network_config *); @@ -94,6 +95,19 @@ print_community(int as, int type) } void +print_origin(u_int8_t o) +{ + if (o == ORIGIN_IGP) + printf("igp "); + else if (o == ORIGIN_EGP) + printf("egp "); + else if (o == ORIGIN_INCOMPLETE) + printf("incomplete "); + else + printf("%u ", o); +} + +void print_set(struct filter_set_head *set) { struct filter_set *s; @@ -161,6 +175,10 @@ print_set(struct filter_set_head *set) case ACTION_RTLABEL: printf("rtlabel %s ", s->action.rtlabel); break; + case ACTION_SET_ORIGIN: + printf("origin "); + print_origin(s->action.origin); + break; case ACTION_RTLABEL_ID: case ACTION_PFTABLE_ID: /* not possible */ diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c index 6e758a12f94..60ccb313a6d 100644 --- a/usr.sbin/bgpd/rde_filter.c +++ b/usr.sbin/bgpd/rde_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_filter.c,v 1.57 2009/08/06 08:53:11 claudio Exp $ */ +/* $OpenBSD: rde_filter.c,v 1.58 2009/11/26 13:40:43 henning Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -250,6 +250,9 @@ rde_apply_set(struct rde_aspath *asp, struct filter_set_head *sh, asp->rtlabelid = set->action.id; rtlabel_ref(asp->rtlabelid); break; + case ACTION_SET_ORIGIN: + asp->origin = set->action.origin; + break; } } } @@ -581,6 +584,11 @@ filterset_equal(struct filter_set_head *ah, struct filter_set_head *bh) if (strcmp(as, bs) == 0) continue; break; + case ACTION_SET_ORIGIN: + if (a->type == b->type && + a->action.origin == b->action.origin) + continue; + break; } /* compare failed */ return (0); @@ -623,6 +631,8 @@ filterset_name(enum action_types type) case ACTION_RTLABEL: case ACTION_RTLABEL_ID: return ("rtlabel"); + case ACTION_SET_ORIGIN: + return ("origin"); } fatalx("filterset_name: got lost"); |