From 024e633c16cf21ae94d7e023e057e59080f92175 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 11 Aug 2009 10:54:50 +0200 Subject: Fixes bug that caused losing of some routes. When update changes preferred route in such a way that it ceased to be preferred, the new route was linked to wrong place and lost. --- nest/rt-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nest') diff --git a/nest/rt-table.c b/nest/rt-table.c index fb2feaca..72138362 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -464,8 +464,8 @@ rte_recalculate(rtable *table, net *net, struct proto *p, struct proto *src, rte } if (new) /* Link in the new non-optimal route */ { - new->next = old_best->next; - old_best->next = new; + new->next = net->routes->next; + net->routes->next = new; rte_trace_in(D_ROUTES, p, new, "added"); } else if (old && (p->debug & D_ROUTES)) -- cgit v1.2.3 From ac07aacd2cdb5cf69a3bfdbc0e078cb0ae96c0db Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 11 Aug 2009 11:03:37 +0200 Subject: Replace assert with log. Although it is true unless there is a bug in BIRD, this assert is not needed (code below does not require that assumption), so we should not crash. --- nest/proto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'nest') diff --git a/nest/proto.c b/nest/proto.c index 2af077b8..d0792134 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -515,7 +515,9 @@ static void proto_fell_down(struct proto *p) { DBG("Protocol %s down\n", p->name); - ASSERT(p->stats.imp_routes == 0); + + if (p->stats.imp_routes != 0) + log(L_ERR "Protocol %s is down but still has %d routes", p->name, p->stats.imp_routes); bzero(&p->stats, sizeof(struct proto_stats)); rt_unlock_table(p->table); -- cgit v1.2.3 From c0973621bc1e06cb6176dc2dfd97bec637861edd Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 11 Aug 2009 15:49:56 +0200 Subject: Fixes another bug in rte_recalculate(). Previous bugfix revealed another hidden bug here. --- nest/rt-table.c | 104 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 37 deletions(-) (limited to 'nest') diff --git a/nest/rt-table.c b/nest/rt-table.c index 72138362..87bf0dc7 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -427,57 +427,87 @@ rte_recalculate(rtable *table, net *net, struct proto *p, struct proto *src, rte rte_announce(table, RA_ANY, net, new, old, tmpa); - if (new && rte_better(new, old_best)) /* It's a new optimal route => announce and relink it */ + + if (new && rte_better(new, old_best)) { + /* The first case - the new route is cleary optimal, we link it + at the first position and announce it */ + rte_trace_in(D_ROUTES, p, new, "added [best]"); rte_announce(table, RA_OPTIMAL, net, new, old_best, tmpa); new->next = net->routes; net->routes = new; } - else + else if (old == old_best) { - if (old == old_best) /* It has _replaced_ the old optimal route */ + /* The second case - the old best route disappeared, we add the + new route (if we have any) to the list (we don't care about + position) and then we elect the new optimal route and relink + that route at the first position and announce it. New optimal + route might be NULL if there is no more routes */ + + /* Add the new route to the list */ + if (new) { - r = new; /* Find new optimal route and announce it */ - for(s=net->routes; s; s=s->next) - if (rte_better(s, r)) - r = s; - rte_announce(table, RA_OPTIMAL, net, r, old_best, tmpa); - if (r) /* Re-link the new optimal route */ + rte_trace_in(D_ROUTES, p, new, "added"); + new->next = net->routes; + net->routes = new; + } + + /* Find new optimal route */ + r = NULL; + for (s=net->routes; s; s=s->next) + if (rte_better(s, r)) + r = s; + + /* Announce optimal route */ + rte_announce(table, RA_OPTIMAL, net, r, old_best, tmpa); + + /* And relink it (if there is any) */ + if (r) + { + k = &net->routes; + while (s = *k) { - k = &net->routes; - while (s = *k) + if (s == r) { - if (s == r) - { - *k = r->next; - break; - } - k = &s->next; + *k = r->next; + break; } - r->next = net->routes; - net->routes = r; + k = &s->next; } - else if (table->gc_counter++ >= table->config->gc_max_ops && - table->gc_time + table->config->gc_min_time <= now) - ev_schedule(table->gc_event); - } - if (new) /* Link in the new non-optimal route */ - { - new->next = net->routes->next; - net->routes->next = new; - rte_trace_in(D_ROUTES, p, new, "added"); - } - else if (old && (p->debug & D_ROUTES)) - { - if (old != old_best) - rte_trace_in(D_ROUTES, p, old, "removed"); - else if (net->routes) - rte_trace_in(D_ROUTES, p, old, "removed [replaced]"); - else - rte_trace_in(D_ROUTES, p, old, "removed [sole]"); + r->next = net->routes; + net->routes = r; } + else if (table->gc_counter++ >= table->config->gc_max_ops && + table->gc_time + table->config->gc_min_time <= now) + ev_schedule(table->gc_event); + } + else if (new) + { + /* The third case - the new route is not better than the old + best route (therefore old_best != NULL) and the old best + route was not removed (therefore old_best == net->routes). + We just link the new route after the old best route. */ + + ASSERT(net->routes != NULL); + new->next = net->routes->next; + net->routes->next = new; + rte_trace_in(D_ROUTES, p, new, "added"); } + else if (old && (p->debug & D_ROUTES)) + { + /* Not really a case - the list of routes is correct, we just + log the route removal */ + + if (old != old_best) + rte_trace_in(D_ROUTES, p, old, "removed"); + else if (net->routes) + rte_trace_in(D_ROUTES, p, old, "removed [replaced]"); + else + rte_trace_in(D_ROUTES, p, old, "removed [sole]"); + } + if (old) { if (p->rte_remove) -- cgit v1.2.3 From 87d7fd9725ded186f6fa331d68a1e9df5d1982cf Mon Sep 17 00:00:00 2001 From: Ondrej Filip Date: Sun, 16 Aug 2009 22:36:41 +0200 Subject: Bugfix - each protocol can be compiled separately. --- nest/config.Y | 3 ++- proto/ospf/config.Y | 3 ++- proto/rip/config.Y | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'nest') diff --git a/nest/config.Y b/nest/config.Y index dc31224a..ad45a0d5 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -44,7 +44,7 @@ CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES) CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE) -CF_KEYWORDS(LISTEN, BGP, V6ONLY, ADDRESS, PORT) +CF_KEYWORDS(LISTEN, BGP, V6ONLY, ADDRESS, PORT, PASSWORDS) CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE) @@ -293,6 +293,7 @@ password_item_params: ; + /* Core commands */ CF_CLI_HELP(SHOW, ..., [[Show status information]]) diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index 5fe8257a..9529f89a 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -38,8 +38,9 @@ CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, BROADCAST) CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT) CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE) CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC) -CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK, PASSWORDS) +CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK) CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY) +CF_KEYWORDS(WAIT, DELAY) %type opttext diff --git a/proto/rip/config.Y b/proto/rip/config.Y index 9a11069e..2df0c5c8 100644 --- a/proto/rip/config.Y +++ b/proto/rip/config.Y @@ -24,7 +24,7 @@ CF_DEFINES CF_DECLS -CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGE, TIMEOUT, PASSWORDS, +CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGE, TIMEOUT, MODE, BROADCAST, MULTICAST, QUIET, NOLISTEN, VERSION1, AUTHENTICATION, NONE, PLAINTEXT, MD5, HONOR, NEVER, NEIGHBOR, ALWAYS, -- cgit v1.2.3 From fee78355b480294f28c3c6814953297dca92d4a0 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 21 Aug 2009 09:31:35 +0200 Subject: Fixes bug in eattr binary search. --- nest/rt-attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nest') diff --git a/nest/rt-attr.c b/nest/rt-attr.c index de63198e..9d78ce07 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -74,7 +74,7 @@ ea__find(ea_list *e, unsigned id) if (e->flags & EALF_BISECT) { l = 0; - r = e->count + 1; + r = e->count - 1; while (l <= r) { m = (l+r) / 2; -- cgit v1.2.3 From 949bd34e81ee99370decdabefa51c9c11ffe915b Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 25 Aug 2009 19:01:37 +0200 Subject: Fixes bug related to AS2->AS4 conversion. --- nest/a-path.c | 6 ++++++ nest/attrs.h | 1 + proto/bgp/attrs.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'nest') diff --git a/nest/a-path.c b/nest/a-path.c index dba214d2..0a4bf829 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -188,6 +188,12 @@ int as_path_getlen(struct adata *path) { int bs = bgp_as4_support ? 4 : 2; + return as_path_getlen_int(path, bs); +} + +int +as_path_getlen_int(struct adata *path, int bs) +{ int res = 0; u8 *p = path->data; u8 *q = p+path->length; diff --git a/nest/attrs.h b/nest/attrs.h index b838ce96..eee6b378 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -28,6 +28,7 @@ int as_path_convert_to_old(struct adata *path, byte *dst, int *new_used); int as_path_convert_to_new(struct adata *path, byte *dst, int req_as); void as_path_format(struct adata *path, byte *buf, unsigned int size); int as_path_getlen(struct adata *path); +int as_path_getlen_int(struct adata *path, int bs); int as_path_get_first(struct adata *path, u32 *orig_as); int as_path_get_last(struct adata *path, u32 *last_as); int as_path_is_member(struct adata *path, u32 as); diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 68f21b97..bf976a6e 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1189,7 +1189,7 @@ bgp_reconstruct_4b_atts(struct bgp_proto *p, rta *a, struct linpool *pool) if (a4) log(L_WARN "%s: AS4_AGGREGATOR attribute received, but AGGREGATOR attribute is missing", p->p.name); - int p2_len = as_path_getlen(p2->u.ptr); + int p2_len = as_path_getlen_int(p2->u.ptr, 2); int p4_len = p4 ? validate_as4_path(p, p4->u.ptr) : -1; if (p4 && (p4_len < 0)) -- cgit v1.2.3 From 05198c12f48c9d4a65ee6d1d4117bd8067a71131 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 27 Aug 2009 19:01:04 +0200 Subject: Some cleanups. --- filter/filter.h | 3 +++ filter/trie.c | 4 ++-- nest/a-path.c | 3 ++- proto/bgp/attrs.c | 3 ++- proto/bgp/packets.c | 2 -- proto/ospf/ospf.h | 2 ++ 6 files changed, 11 insertions(+), 6 deletions(-) (limited to 'nest') diff --git a/filter/filter.h b/filter/filter.h index 2277f519..62bad84c 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -81,10 +81,13 @@ struct rte; int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struct linpool *tmp_pool, int flags); int f_eval_int(struct f_inst *expr); +u32 f_eval_asn(struct f_inst *expr); + char *filter_name(struct filter *filter); int filter_same(struct filter *new, struct filter *old); int i_same(struct f_inst *f1, struct f_inst *f2); +void f_prefix_get_bounds(struct f_prefix *px, int *l, int *h); int val_compare(struct f_val v1, struct f_val v2); void val_print(struct f_val v); diff --git a/filter/trie.c b/filter/trie.c index ffb9b99f..fb405ded 100644 --- a/filter/trie.c +++ b/filter/trie.c @@ -70,6 +70,7 @@ */ #include "nest/bird.h" +#include "lib/string.h" #include "conf/conf.h" #include "filter/filter.h" @@ -177,7 +178,6 @@ trie_add_prefix(struct f_trie *t, struct f_prefix *px) { int l, h; int plen = px->len & LEN_MASK; - ip_addr pmask = ipa_mkmask(plen); /* 'l' and 'h' are lower and upper bounds on accepted prefix lengths, both inclusive. 0 <= l, h <= 32 */ @@ -272,7 +272,7 @@ static int trie_node_print(struct f_trie_node *t, char *buf, int blen) { if (t == NULL) - return; + return 0; int old_blen = blen; int wb = 0; // bsnprintf(buf, blen, "%I/%d accept %I\n", t->addr, t->plen, t->accept); diff --git a/nest/a-path.c b/nest/a-path.c index 0a4bf829..19d61f0b 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -13,6 +13,7 @@ #include "lib/resource.h" #include "lib/unaligned.h" #include "lib/string.h" +#include "filter/filter.h" /* Global AS4 support, shared by all BGP instances. @@ -304,7 +305,7 @@ parse_path(struct adata *path, struct pm_pos *pos) u8 *p = path->data; u8 *q = p + path->length; struct pm_pos *opos = pos; - int i, j, len; + int i, len; while (p < q) diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index bf976a6e..831ada57 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1131,6 +1131,8 @@ as4_aggregator_valid(struct adata *aggr) if ((a[0] == 0) || (a[1] == 0)) return 0; + + return 1; } @@ -1245,7 +1247,6 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin int errcode; byte *z, *attr_start; byte seen[256/8]; - eattr *e; ea_list *ea; struct adata *ad; diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index ae4906ee..49c2add6 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -488,7 +488,6 @@ bgp_parse_capabilities(struct bgp_conn *conn, byte *opt, int len) { struct bgp_proto *p = conn->bgp; int cl; - u32 as; while (len > 0) { @@ -570,7 +569,6 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) { struct bgp_conn *other; struct bgp_proto *p = conn->bgp; - struct bgp_config *cf = p->cf; unsigned hold; u16 base_as; u32 id; diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 22790899..7f0ee54c 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -603,6 +603,8 @@ void schedule_net_lsa(struct ospf_iface *ifa); void ospf_sh_neigh(struct proto *p, char *iff); void ospf_sh(struct proto *p); void ospf_sh_iface(struct proto *p, char *iff); +void ospf_sh_state(struct proto *p, int verbose); + #define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0) #define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1) -- cgit v1.2.3 From f4c6ca8c9c7ca7c0d481e6059396beed6adc768d Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 17 Sep 2009 13:35:37 +0200 Subject: Fixes preference bounds. --- doc/bird.sgml | 2 +- filter/filter.c | 2 ++ nest/config.Y | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'nest') diff --git a/doc/bird.sgml b/doc/bird.sgml index 29fcd5a9..258b8420 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -724,7 +724,7 @@ defined by using the defined( attribute ) operator. Address scope of the network ( - Preference of the route. (See the chapter about routing tables.) + Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.) The router which the route has originated from. Read-only. diff --git a/filter/filter.c b/filter/filter.c index 3df0f0c6..9617482a 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -702,6 +702,8 @@ interpret(struct f_inst *what) ONEARG; if (v1.type != T_INT) runtime( "Can't set preference to non-integer" ); + if ((v1.val.i < 0) || (v1.val.i > 0xFFFF)) + runtime( "Setting preference value out of bounds" ); *f_rte = rte_cow(*f_rte); (*f_rte)->pref = v1.val.i; break; diff --git a/nest/config.Y b/nest/config.Y index ad45a0d5..a2c44ab7 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -132,7 +132,7 @@ proto_name: proto_item: /* EMPTY */ | PREFERENCE expr { - if ($2 < 0 || $2 > 255) cf_error("Invalid preference"); + if ($2 < 0 || $2 > 0xFFFF) cf_error("Invalid preference"); this_proto->preference = $2; } | DISABLED bool { this_proto->disabled = $2; } -- cgit v1.2.3 From 46eb80d5d50a2b284cae19444149d57d857a8e02 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 17 Sep 2009 17:52:36 +0200 Subject: Fixes headers for uintptr_t (and build on NetBSD). --- lib/mempool.c | 1 + lib/resource.c | 1 + lib/slab.c | 1 + nest/attrs.h | 2 ++ proto/bgp/bgp.h | 1 + 5 files changed, 6 insertions(+) (limited to 'nest') diff --git a/lib/mempool.c b/lib/mempool.c index 03a6e6ba..0cb06b58 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -19,6 +19,7 @@ */ #include +#include #include "nest/bird.h" #include "lib/resource.h" diff --git a/lib/resource.c b/lib/resource.c index a4d87517..5ba23f18 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -8,6 +8,7 @@ #include #include +#include #include "nest/bird.h" #include "lib/resource.h" diff --git a/lib/slab.c b/lib/slab.c index 17511d21..8cce52fe 100644 --- a/lib/slab.c +++ b/lib/slab.c @@ -26,6 +26,7 @@ */ #include +#include #include "nest/bird.h" #include "lib/resource.h" diff --git a/nest/attrs.h b/nest/attrs.h index eee6b378..16fb35af 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -9,6 +9,8 @@ #ifndef _BIRD_ATTRS_H_ #define _BIRD_ATTRS_H_ +#include + /* a-path.c */ #define AS_PATH_SET 1 /* Types of path segments */ diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index 9bbdab8e..092c3b34 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -9,6 +9,7 @@ #ifndef _BIRD_BGP_H_ #define _BIRD_BGP_H_ +#include #include "nest/route.h" struct linpool; -- cgit v1.2.3 From 52b9b2a1786140c38af03de570b0cc96c835c1d3 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 12 Oct 2009 20:44:58 +0200 Subject: Rename as_path_get_last/as_path_get_first to be consistent. --- filter/filter.c | 4 ++-- nest/a-path.c | 10 +++++----- proto/bgp/attrs.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'nest') diff --git a/filter/filter.c b/filter/filter.c index 7bcf383d..07a25f4a 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -734,7 +734,7 @@ interpret(struct f_inst *what) runtime( "AS Path expected" ); as = 0; - as_path_get_last(v1.val.ad, &as); /* really last */ + as_path_get_first(v1.val.ad, &as); res.type = T_INT; res.val.i = as; break; @@ -744,7 +744,7 @@ interpret(struct f_inst *what) runtime( "AS path expected" ); as = 0; - as_path_get_first(v1.val.ad, &as); /* really first */ + as_path_get_last(v1.val.ad, &as); res.type = T_INT; res.val.i = as; break; diff --git a/nest/a-path.c b/nest/a-path.c index 19d61f0b..c804619b 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -213,7 +213,7 @@ as_path_getlen_int(struct adata *path, int bs) } int -as_path_get_first(struct adata *path, u32 *orig_as) +as_path_get_last(struct adata *path, u32 *orig_as) { int bs = bgp_as4_support ? 4 : 2; int found = 0; @@ -229,8 +229,7 @@ as_path_get_first(struct adata *path, u32 *orig_as) case AS_PATH_SET: if (len = *p++) { - found = 1; - res = get_as(p); + found = 0; p += bs * len; } break; @@ -246,12 +245,13 @@ as_path_get_first(struct adata *path, u32 *orig_as) } } - *orig_as = res; + if (found) + *orig_as = res; return found; } int -as_path_get_last(struct adata *path, u32 *last_as) +as_path_get_first(struct adata *path, u32 *last_as) { u8 *p = path->data; diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 831ada57..d839ed09 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -996,7 +996,7 @@ bgp_get_neighbor(rte *r) eattr *e = ea_find(r->attrs->eattrs, EA_CODE(EAP_BGP, BA_AS_PATH)); u32 as; - if (e && as_path_get_last(e->u.ptr, &as)) + if (e && as_path_get_first(e->u.ptr, &as)) return as; else return ((struct bgp_proto *) r->attrs->proto)->remote_as; @@ -1470,7 +1470,7 @@ bgp_get_route_info(rte *e, byte *buf, ea_list *attrs) u32 origas; buf += bsprintf(buf, " (%d) [", e->pref); - if (p && as_path_get_first(p->u.ptr, &origas)) + if (p && as_path_get_last(p->u.ptr, &origas)) buf += bsprintf(buf, "AS%u", origas); if (o) buf += bsprintf(buf, "%c", "ie?"[o->u.data]); -- cgit v1.2.3 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(-) (limited to 'nest') diff --git a/doc/bird.sgml b/doc/bird.sgml index ceff31d8..0c2b8fbe 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 f3b79619..7114fd28 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 a2c44ab7..4721112a 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 d0792134..7bb1286d 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 0f9d59d8..484df846 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 b76b7f97..b38c6b13 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