From 4cdd078453d585ac97a183ea1f3951d85f1b8784 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 12 Oct 2009 23:31:42 +0200 Subject: Implements protocol-specific router id and updates documentation. --- doc/bird.sgml | 31 ++++++++++++++++++++++++++++++- filter/test.conf | 1 + nest/config.Y | 1 + nest/proto.c | 1 + nest/protocol.h | 8 ++++++++ proto/bgp/bgp.c | 2 +- 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index ceff31d..0c2b8fb 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -297,6 +297,10 @@ to zero to disable it. An empty is equivalent to router id This option can be used to override global + router id for a given protocol. This option is not yet implemented for OSPF + protocol. Default: uses global router id. + import all | none | filter Specify a filter to be used for filtering routes coming from the protocol to the routing table. option is used, changes in filters does not cause + returns the first ASN (the neighbor ASN) in path returns the last ASN (the source ASN) in path returns the length of path prepend( prepends ASN can be shortened to + if [= * 4 (1+2) a =]. There is also old syntax that uses / .. / instead of [= .. =] and ? instead of *. + add( adds pair delete( deletes pair can be shortened to + if diff --git a/filter/test.conf b/filter/test.conf index f3b7961..7114fd2 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -62,6 +62,7 @@ clist l; print "Should be true: ", p2 ~ / ? 4 3 2 1 /, " ", p2, " ", / ? 4 3 2 1 /; print "Should be true: ", p2 ~ [= * 4 3 * 1 =], " ", p2, " ", [= * 4 3 * 1 =]; print "Should be true: ", p2 ~ [= (3+2) (2*2) 3 2 1 =], " ", p2 ~ mkpath(5, 4); + print "Should be true: ", p2.len = 5, " ", p2.first = 5, " ", p2.last = 1; print "5 = ", p2.len; pm1 = [= 1 2 * 3 4 5 =]; diff --git a/nest/config.Y b/nest/config.Y index a2c44ab..4721112 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -140,6 +140,7 @@ proto_item: | IMPORT imexport { this_proto->in_filter = $2; } | EXPORT imexport { this_proto->out_filter = $2; } | TABLE rtable { this_proto->table = $2; } + | ROUTER ID idval { this_proto->router_id = $3; } ; imexport: diff --git a/nest/proto.c b/nest/proto.c index d079213..7bb1286 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -313,6 +313,7 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty && nc->preference == oc->preference && nc->disabled == oc->disabled && nc->table->table == oc->table->table + && proto_get_router_id(nc) == proto_get_router_id(oc) && ((type == RECONFIG_SOFT) || filter_same(nc->in_filter, oc->in_filter)) && ((type == RECONFIG_SOFT) || filter_same(nc->out_filter, oc->out_filter)) && p->proto_state != PS_DOWN) diff --git a/nest/protocol.h b/nest/protocol.h index 0f9d59d..484df84 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -12,6 +12,7 @@ #include "lib/lists.h" #include "lib/resource.h" #include "lib/timer.h" +#include "conf/conf.h" struct iface; struct ifa; @@ -81,6 +82,7 @@ struct proto_config { struct proto *proto; /* Instance we've created */ char *name; unsigned debug, preference, disabled; /* Generic parameters */ + u32 router_id; /* Protocol specific router ID */ struct rtable_config *table; /* Table we're attached to */ struct filter *in_filter, *out_filter; /* Attached filters */ @@ -192,6 +194,12 @@ struct proto *proto_get_named(struct symbol *, struct protocol *); void proto_xxable(char *, int); void proto_debug(char *, unsigned int); +static inline u32 +proto_get_router_id(struct proto_config *pc) +{ + return pc->router_id ? pc->router_id : pc->global->router_id; +} + extern list active_proto_list; /* diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index b76b7f9..b38c6b1 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -689,7 +689,7 @@ bgp_start_locked(struct object_lock *lock) } DBG("BGP: Got lock\n"); - p->local_id = cf->c.global->router_id; + p->local_id = proto_get_router_id(&cf->c); p->next_hop = cf->multihop ? cf->multihop_via : cf->remote_ip; p->neigh = neigh_find(&p->p, &p->next_hop, NEF_STICKY); -- cgit v1.2.3