diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-02-05 14:29:10 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-02-05 14:29:10 +0000 |
commit | 4776ab85266a99523bbc5a3b6057ca2d40ff52c8 (patch) | |
tree | a80757f3e066850ab634ad5b44d3904d1c1f860a | |
parent | 7f433b31b02247fd1b4b9f1fd58505e8559a55c9 (diff) |
introduce group IDs. will be needed for filtering (or rather, ease things
there)
just assign them from the neighbor ID pool - fortunately, that is rather
simple, we just have to make sure that all members of the group and (later)
all filter rules pointing to the group agree on the ID, but it does not need
to stay the same across config reloads.
ok claudio@
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 21 |
2 files changed, 16 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index e29e6ddc481..df8597e3126 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.89 2004/02/01 19:46:05 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.90 2004/02/05 14:29:09 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -126,6 +126,7 @@ enum announce_type { struct peer_config { u_int32_t id; + u_int32_t groupid; char group[PEER_DESCR_LEN]; char descr[PEER_DESCR_LEN]; struct bgpd_addr remote_addr; diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index a714880219b..ceb17f4923d 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.47 2004/02/03 22:28:05 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.48 2004/02/05 14:29:09 henning Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -267,6 +267,10 @@ group : GROUP string optnl '{' optnl { $2, sizeof(curgroup->conf.group) - 1); YYERROR; } + if (get_id(curgroup)) { + yyerror("get_id failed"); + YYERROR; + } } groupopts_l '}' { free(curgroup); @@ -845,6 +849,7 @@ new_peer(void) if (strlcpy(p->conf.descr, curgroup->conf.descr, sizeof(p->conf.descr)) >= sizeof(p->conf.descr)) fatalx("new_peer descr strlcpy"); + p->conf.groupid = curgroup->conf.id; } p->next = NULL; @@ -892,12 +897,14 @@ get_id(struct peer *newpeer) { struct peer *p; - for (p = peer_l_old; p != NULL; p = p->next) - if (!memcmp(&p->conf.remote_addr, &newpeer->conf.remote_addr, - sizeof(p->conf.remote_addr))) { - newpeer->conf.id = p->conf.id; - return (0); - } + if (newpeer->conf.remote_addr.af) + for (p = peer_l_old; p != NULL; p = p->next) + if (!memcmp(&p->conf.remote_addr, + &newpeer->conf.remote_addr, + sizeof(p->conf.remote_addr))) { + newpeer->conf.id = p->conf.id; + return (0); + } /* new one */ for (; id < UINT_MAX; id++) { |