diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2007-05-28 17:26:34 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2007-05-28 17:26:34 +0000 |
commit | 36c39afaad2c7b0623942a2dfd1de71415e8f152 (patch) | |
tree | e9efb7384e5689abb9439e047984f8487a15ccd6 | |
parent | a9414e98d077bb8e241d60f0c3c02855f006ac95 (diff) |
allow matching on communities using 0 in the AS part, that is in use.
that unfortunately means we cannot use 0 for "unset".
ok claudio
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 18 | ||||
-rw-r--r-- | usr.sbin/bgpd/printconf.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_filter.c | 4 |
4 files changed, 16 insertions, 13 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 1de46da0585..e68859c11ac 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.217 2007/05/15 14:35:30 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.218 2007/05/28 17:26:33 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -594,6 +594,7 @@ struct filter_peers { #define COMMUNITY_ERROR -1 #define COMMUNITY_ANY -2 #define COMMUNITY_NEIGHBOR_AS -3 +#define COMMUNITY_UNSET -4 #define COMMUNITY_WELLKNOWN 0xffff #define COMMUNITY_NO_EXPORT 0xff01 #define COMMUNITY_NO_ADVERTISE 0xff02 diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 45bddeef586..d786fc19092 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.204 2007/04/23 13:04:24 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.205 2007/05/28 17:26:33 henning Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1267,8 +1267,14 @@ filter_as : as4number { } ; -filter_match_h : /* empty */ { bzero(&$$, sizeof($$)); } - | { bzero(&fmopts, sizeof(fmopts)); } +filter_match_h : /* empty */ { + bzero(&$$, sizeof($$)); + $$.m.community.as = COMMUNITY_UNSET; + } + | { + bzero(&fmopts, sizeof(fmopts)); + fmopts.m.community.as = COMMUNITY_UNSET; + } filter_match { memcpy(&$$, &fmopts, sizeof($$)); } @@ -1307,7 +1313,7 @@ filter_elm : filter_prefix_h { fmopts.as_l = $1; } | COMMUNITY STRING { - if (fmopts.m.community.as) { + if (fmopts.m.community.as != COMMUNITY_UNSET) { yyerror("\"community\" already specified"); free($2); YYERROR; @@ -2264,10 +2270,6 @@ parsecommunity(char *s, int *as, int *type) if ((i = getcommunity(s)) == COMMUNITY_ERROR) return (-1); - if (i == 0 || i == USHRT_MAX) { - yyerror("Bad community AS number"); - return (-1); - } *as = i; if ((i = getcommunity(p)) == COMMUNITY_ERROR) diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c index fcfbd76429b..fe5231fad6a 100644 --- a/usr.sbin/bgpd/printconf.c +++ b/usr.sbin/bgpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.63 2007/05/15 11:07:46 henning Exp $ */ +/* $OpenBSD: printconf.c,v 1.64 2007/05/28 17:26:33 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -484,7 +484,7 @@ print_rule(struct peer *peer_l, struct filter_rule *r) printf("unfluffy-as %s ", log_as(r->match.as.as)); } - if (r->match.community.as != 0) { + if (r->match.community.as != COMMUNITY_UNSET) { printf("community "); print_community(r->match.community.as, r->match.community.type); diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c index 1e0e1c32e56..2593f98bdb6 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.52 2007/05/11 11:27:59 claudio Exp $ */ +/* $OpenBSD: rde_filter.c,v 1.53 2007/05/28 17:26:33 henning Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -256,7 +256,7 @@ rde_filter_match(struct filter_rule *f, struct rde_aspath *asp, f->match.as.as) == 0) return (0); - if (asp != NULL && f->match.community.as != 0) { + if (asp != NULL && f->match.community.as != COMMUNITY_UNSET) { switch (f->match.community.as) { case COMMUNITY_ERROR: fatalx("rde_apply_set bad community string"); |