summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/config.Y18
-rw-r--r--nest/proto.c48
-rw-r--r--nest/protocol.h7
-rw-r--r--nest/rt-table.c12
4 files changed, 57 insertions, 28 deletions
diff --git a/nest/config.Y b/nest/config.Y
index dde20c5a..dbb10ada 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -45,7 +45,7 @@ CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILT
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, PASSWORDS, DESCRIPTION)
-CF_KEYWORDS(RELOAD, REFEED)
+CF_KEYWORDS(RELOAD, IN, OUT)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
@@ -438,17 +438,17 @@ echo_size:
;
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
-{ proto_xxable($2, 0); } ;
+{ proto_xxable($2, XX_DISABLE); } ;
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
-{ proto_xxable($2, 1); } ;
+{ proto_xxable($2, XX_ENABLE); } ;
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
-{ proto_xxable($2, 2); } ;
+{ proto_xxable($2, XX_RESTART); } ;
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
-{ proto_xxable($2, 3); } ;
-CF_CLI(REFEED, proto_patt, <protocol> | \"<pattern>\" | all, [[Refeed protocol BROKEN]])
-{ proto_xxable($2, 4); } ;
-
-
+{ proto_xxable($2, XX_RELOAD); } ;
+CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
+{ proto_xxable($3, XX_RELOAD_IN); } ;
+CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just exported routes)]])
+{ proto_xxable($3, XX_RELOAD_OUT); } ;
CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging]])
CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging]])
diff --git a/nest/proto.c b/nest/proto.c
index b23011d7..4f352a6f 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:
diff --git a/nest/protocol.h b/nest/protocol.h
index e1adc525..21a1c1b4 100644
--- a/nest/protocol.h
+++ b/nest/protocol.h
@@ -201,6 +201,13 @@ struct proto *proto_get_named(struct symbol *, struct protocol *);
void proto_xxable(char *, int);
void proto_debug(char *, unsigned int);
+#define XX_DISABLE 0
+#define XX_ENABLE 1
+#define XX_RESTART 2
+#define XX_RELOAD 3
+#define XX_RELOAD_IN 4
+#define XX_RELOAD_OUT 5
+
static inline u32
proto_get_router_id(struct proto_config *pc)
{
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 8efc0a61..df2834a6 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -165,6 +165,8 @@ do_rte_announce(struct announce_hook *a, int type, net *net, rte *new, rte *old,
rte *old0 = old;
int ok;
+ int fast_exit_hack = 0;
+
if (new)
{
p->stats.exp_updates_received++;
@@ -174,6 +176,7 @@ do_rte_announce(struct announce_hook *a, int type, net *net, rte *new, rte *old,
{
p->stats.exp_updates_rejected++;
drop_reason = "out of scope";
+ fast_exit_hack = 1;
}
else if ((ok = p->import_control ? p->import_control(p, &new, &tmpa, rte_update_pool) : 0) < 0)
{
@@ -199,6 +202,11 @@ do_rte_announce(struct announce_hook *a, int type, net *net, rte *new, rte *old,
else
p->stats.exp_withdraws_received++;
+ /* Hack: This is here to prevent 'spurious withdraws'
+ for loopback addresses during reload. */
+ if (fast_exit_hack)
+ return;
+
/*
* This is a tricky part - we don't know whether route 'old' was
* exported to protocol 'p' or was filtered by the export filter.
@@ -245,9 +253,11 @@ do_rte_announce(struct announce_hook *a, int type, net *net, rte *new, rte *old,
else
p->stats.exp_withdraws_accepted++;
+ /* Hack: We do not decrease exp_routes during refeed, we instead
+ reset exp_routes at the start of refeed. */
if (new)
p->stats.exp_routes++;
- if (old)
+ if (old && !refeed)
p->stats.exp_routes--;
if (p->debug & D_ROUTES)