From e04555c04545278cfe3aeae85d707b1d78e5abeb Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 17 Nov 2009 15:45:05 +0100 Subject: Implement description field of protocol. --- nest/proto.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index 7bb1286..c05db76 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -307,6 +307,7 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty if (sym && sym->class == SYM_PROTO && !new->shutdown) { /* Found match, let's check if we can smoothly switch to new configuration */ + /* No need to check description */ nc = sym->def; if (!force_reconfig && nc->protocol == oc->protocol @@ -702,6 +703,8 @@ proto_do_show(struct proto *p, int verbose) buf); if (verbose) { + if (p->cf->dsc) + cli_msg(-1006, " Description: %s", p->cf->dsc); cli_msg(-1006, " Preference: %d", p->preference); cli_msg(-1006, " Input filter: %s", filter_name(p->in_filter)); cli_msg(-1006, " Output filter: %s", filter_name(p->out_filter)); -- cgit v1.2.3 From bf47fe4b2e40ccfcfe6af2d86548d06cdf9739c5 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 26 Nov 2009 20:47:59 +0100 Subject: Implements BGP route refresh. --- nest/proto.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index c05db76..c531d86 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -73,6 +73,10 @@ proto_relink(struct proto *p) rem_node(&p->n); switch (p->core_state) { + case FS_HUNGRY: + l = &inactive_proto_list; + break; + case FS_FEEDING: case FS_HAPPY: l = &active_proto_list; break; @@ -80,7 +84,7 @@ proto_relink(struct proto *p) l = &flush_proto_list; break; default: - l = &inactive_proto_list; + ASSERT(0); } proto_enqueue(l, p); } @@ -549,7 +553,7 @@ proto_feed_more(void *P) } static void -proto_feed(void *P) +proto_feed_initial(void *P) { struct proto *p = P; @@ -577,15 +581,44 @@ proto_schedule_flush(struct proto *p) } static void -proto_schedule_feed(struct proto *p) +proto_schedule_feed(struct proto *p, int initial) { DBG("%s: Scheduling meal\n", p->name); p->core_state = FS_FEEDING; proto_relink(p); - p->attn->hook = proto_feed; + p->attn->hook = initial ? proto_feed_initial : proto_feed_more; ev_schedule(p->attn); } +/** + * proto_request_feeding - request feeding routes to the protocol + * @p: given protocol + * + * Sometimes it is needed to send again all routes to the + * protocol. This is called feeding and can be requested by this + * function. This would cause protocol core state transition + * to FS_FEEDING (during feeding) and when completed, it will + * switch back to FS_HAPPY. This function can be called even + * when feeding is already running, in that case it is restarted. + */ +void +proto_request_feeding(struct proto *p) +{ + ASSERT(p->proto_state == PS_UP); + + /* If we are already feeding, we want to restart it */ + if (p->core_state == FS_FEEDING) + { + /* Unless feeding is in initial state */ + if (p->attn->hook == proto_feed_initial) + return; + + rt_feed_baby_abort(p); + } + + proto_schedule_feed(p, 0); +} + /** * proto_notify_state - notify core about protocol state change * @p: protocol the state of which has changed @@ -635,7 +668,7 @@ proto_notify_state(struct proto *p, unsigned ps) case PS_UP: ASSERT(ops == PS_DOWN || ops == PS_START); ASSERT(cs == FS_HUNGRY); - proto_schedule_feed(p); + proto_schedule_feed(p, 1); break; case PS_STOP: if ((cs = FS_FEEDING) || (cs == FS_HAPPY)) @@ -798,6 +831,7 @@ proto_xxable(char *pattern, int xx) { cli_msg(-9, "%s: disabled", p->name); p->disabled = 1; + proto_rethink_goal(p); } break; case 1: @@ -807,6 +841,7 @@ proto_xxable(char *pattern, int xx) { cli_msg(-11, "%s: enabled", p->name); p->disabled = 0; + proto_rethink_goal(p); } break; case 2: @@ -817,13 +852,33 @@ proto_xxable(char *pattern, int xx) p->disabled = 1; proto_rethink_goal(p); p->disabled = 0; + proto_rethink_goal(p); cli_msg(-12, "%s: restarted", p->name); } break; + case 3: + // FIXME change msg number + if (p->disabled) + cli_msg(-8, "%s: already disabled", p->name); + else if (p->reload_routes && p->reload_routes(p)) + cli_msg(-12, "%s: reloading", p->name); + else + cli_msg(-12, "%s: reload failed", p->name); + break; + case 4: + // FIXME change msg number + if (p->disabled) + cli_msg(-8, "%s: already disabled", p->name); + else + { + proto_request_feeding(p); + cli_msg(-12, "%s: reexport failed", p->name); + } + break; + default: ASSERT(0); } - proto_rethink_goal(p); } WALK_PROTO_LIST_END; if (!cnt) -- cgit v1.2.3 From 11361a101517c2c87e3d35d2c63cacb3ddb97724 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Dec 2009 22:19:47 +0100 Subject: Implements route re-feed. This can be used to re-feed routes to protocol after soft change in export filters. --- nest/proto.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index c531d86..bdac4bf 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -585,6 +585,7 @@ proto_schedule_feed(struct proto *p, int initial) { DBG("%s: Scheduling meal\n", p->name); p->core_state = FS_FEEDING; + p->refeeding = !initial; proto_relink(p); p->attn->hook = initial ? proto_feed_initial : proto_feed_more; ev_schedule(p->attn); -- cgit v1.2.3 From a421ec33cb9029899122d0ab63bab0fa268348d2 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Dec 2009 22:22:40 +0100 Subject: Fixes silly bug. --- nest/proto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index bdac4bf..b23011d 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -649,7 +649,7 @@ proto_notify_state(struct proto *p, unsigned ps) switch (ps) { case PS_DOWN: - if ((cs = FS_FEEDING) || (cs == FS_HAPPY)) + if ((cs == FS_FEEDING) || (cs == FS_HAPPY)) proto_schedule_flush(p); neigh_prune(); // FIXME convert neighbors to resource? @@ -672,7 +672,7 @@ proto_notify_state(struct proto *p, unsigned ps) proto_schedule_feed(p, 1); break; case PS_STOP: - if ((cs = FS_FEEDING) || (cs == FS_HAPPY)) + if ((cs == FS_FEEDING) || (cs == FS_HAPPY)) proto_schedule_flush(p); break; default: -- cgit v1.2.3 From 8a7fb8858fa87bce6f2f15ee2bbb77704b5fff4e Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 14 Dec 2009 01:32:37 +0100 Subject: Finishes 'route reload' feature. --- nest/proto.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index b23011d..4f352a6 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -586,6 +586,11 @@ proto_schedule_feed(struct proto *p, int initial) DBG("%s: Scheduling meal\n", p->name); p->core_state = FS_FEEDING; p->refeeding = !initial; + + /* Hack: reset exp_routes during refeed, and do not decrease it later */ + if (!initial) + p->stats.exp_routes = 0; + proto_relink(p); p->attn->hook = initial ? proto_feed_initial : proto_feed_more; ev_schedule(p->attn); @@ -825,7 +830,7 @@ proto_xxable(char *pattern, int xx) cnt++; switch (xx) { - case 0: + case XX_DISABLE: if (p->disabled) cli_msg(-8, "%s: already disabled", p->name); else @@ -835,7 +840,8 @@ proto_xxable(char *pattern, int xx) proto_rethink_goal(p); } break; - case 1: + + case XX_ENABLE: if (!p->disabled) cli_msg(-10, "%s: already enabled", p->name); else @@ -845,7 +851,8 @@ proto_xxable(char *pattern, int xx) proto_rethink_goal(p); } break; - case 2: + + case XX_RESTART: if (p->disabled) cli_msg(-8, "%s: already disabled", p->name); else @@ -857,24 +864,29 @@ proto_xxable(char *pattern, int xx) cli_msg(-12, "%s: restarted", p->name); } break; - case 3: - // FIXME change msg number - if (p->disabled) - cli_msg(-8, "%s: already disabled", p->name); - else if (p->reload_routes && p->reload_routes(p)) - cli_msg(-12, "%s: reloading", p->name); - else - cli_msg(-12, "%s: reload failed", p->name); - break; - case 4: - // FIXME change msg number + + case XX_RELOAD: + case XX_RELOAD_IN: + case XX_RELOAD_OUT: if (p->disabled) - cli_msg(-8, "%s: already disabled", p->name); - else { - proto_request_feeding(p); - cli_msg(-12, "%s: reexport failed", p->name); + cli_msg(-8, "%s: already disabled", p->name); + break; } + + /* re-importing routes */ + if (xx != XX_RELOAD_OUT) + if (! (p->reload_routes && p->reload_routes(p))) + { + cli_msg(-8006, "%s: reload failed", p->name); + break; + } + + /* re-exporting routes */ + if (xx != XX_RELOAD_IN) + proto_request_feeding(p); + + cli_msg(-15, "%s: reloading", p->name); break; default: -- cgit v1.2.3