version 1.1, 2017/08/22 12:33:54
|
version 1.1.1.2, 2021/03/17 19:50:23
|
Line 386 proto_init(struct proto_config *c)
|
Line 386 proto_init(struct proto_config *c)
|
q->core_state = FS_HUNGRY; |
q->core_state = FS_HUNGRY; |
q->export_state = ES_DOWN; |
q->export_state = ES_DOWN; |
q->last_state_change = now; |
q->last_state_change = now; |
|
q->vrf = c->vrf; |
|
q->vrf_set = c->vrf_set; |
|
|
add_tail(&initial_proto_list, &q->n); |
add_tail(&initial_proto_list, &q->n); |
|
|
Line 409 proto_reconfigure(struct proto *p, struct proto_config
|
Line 411 proto_reconfigure(struct proto *p, struct proto_config
|
/* If there is a too big change in core attributes, ... */ |
/* If there is a too big change in core attributes, ... */ |
if ((nc->protocol != oc->protocol) || |
if ((nc->protocol != oc->protocol) || |
(nc->disabled != p->disabled) || |
(nc->disabled != p->disabled) || |
|
(nc->vrf != oc->vrf) || |
|
(nc->vrf_set != oc->vrf_set) || |
(nc->table->table != oc->table->table)) |
(nc->table->table != oc->table->table)) |
return 0; |
return 0; |
|
|
Line 431 proto_reconfigure(struct proto *p, struct proto_config
|
Line 435 proto_reconfigure(struct proto *p, struct proto_config
|
if (p->proto->multitable) |
if (p->proto->multitable) |
return 1; |
return 1; |
|
|
|
int import_changed = ! filter_same(nc->in_filter, oc->in_filter); |
|
int export_changed = ! filter_same(nc->out_filter, oc->out_filter); |
|
|
|
/* We treat a change in preferences by reimporting routes */ |
|
if (nc->preference != oc->preference) |
|
import_changed = 1; |
|
|
/* Update filters and limits in the main announce hook |
/* Update filters and limits in the main announce hook |
Note that this also resets limit state */ |
Note that this also resets limit state */ |
if (p->main_ahook) |
if (p->main_ahook) |
{ | { |
struct announce_hook *ah = p->main_ahook; |
struct announce_hook *ah = p->main_ahook; |
ah->in_filter = nc->in_filter; |
ah->in_filter = nc->in_filter; |
ah->out_filter = nc->out_filter; |
ah->out_filter = nc->out_filter; |
Line 443 proto_reconfigure(struct proto *p, struct proto_config
|
Line 454 proto_reconfigure(struct proto *p, struct proto_config
|
ah->out_limit = nc->out_limit; |
ah->out_limit = nc->out_limit; |
ah->in_keep_filtered = nc->in_keep_filtered; |
ah->in_keep_filtered = nc->in_keep_filtered; |
proto_verify_limits(ah); |
proto_verify_limits(ah); |
|
|
|
if (export_changed) |
|
ah->last_out_filter_change = now; |
} |
} |
|
|
/* Update routes when filters changed. If the protocol in not UP, |
/* Update routes when filters changed. If the protocol in not UP, |
Line 450 proto_reconfigure(struct proto *p, struct proto_config
|
Line 464 proto_reconfigure(struct proto *p, struct proto_config
|
if ((p->proto_state != PS_UP) || (type == RECONFIG_SOFT)) |
if ((p->proto_state != PS_UP) || (type == RECONFIG_SOFT)) |
return 1; |
return 1; |
|
|
int import_changed = ! filter_same(nc->in_filter, oc->in_filter); |
|
int export_changed = ! filter_same(nc->out_filter, oc->out_filter); |
|
|
|
/* We treat a change in preferences by reimporting routes */ |
|
if (nc->preference != oc->preference) |
|
import_changed = 1; |
|
|
|
if (import_changed || export_changed) |
if (import_changed || export_changed) |
log(L_INFO "Reloading protocol %s", p->name); |
log(L_INFO "Reloading protocol %s", p->name); |
|
|
Line 608 proto_rethink_goal(struct proto *p)
|
Line 615 proto_rethink_goal(struct proto *p)
|
config_del_obstacle(p->cf->global); |
config_del_obstacle(p->cf->global); |
rem_node(&p->n); |
rem_node(&p->n); |
rem_node(&p->glob_node); |
rem_node(&p->glob_node); |
|
mb_free(p->message); |
mb_free(p); |
mb_free(p); |
if (!nc) |
if (!nc) |
return; |
return; |
Line 907 protos_build(void)
|
Line 915 protos_build(void)
|
#ifdef CONFIG_STATIC |
#ifdef CONFIG_STATIC |
proto_build(&proto_static); |
proto_build(&proto_static); |
#endif |
#endif |
|
#ifdef CONFIG_MRT |
|
proto_build(&proto_mrt); |
|
#endif |
#ifdef CONFIG_OSPF |
#ifdef CONFIG_OSPF |
proto_build(&proto_ospf); |
proto_build(&proto_ospf); |
#endif |
#endif |
Line 1094 proto_schedule_down(struct proto *p, byte restart, byt
|
Line 1105 proto_schedule_down(struct proto *p, byte restart, byt
|
tm_start_max(proto_shutdown_timer, restart ? 2 : 0); |
tm_start_max(proto_shutdown_timer, restart ? 2 : 0); |
} |
} |
|
|
|
/** |
|
* proto_set_message - set administrative message to protocol |
|
* @p: protocol |
|
* @msg: message |
|
* @len: message length (-1 for NULL-terminated string) |
|
* |
|
* The function sets administrative message (string) related to protocol state |
|
* change. It is called by the nest code for manual enable/disable/restart |
|
* commands all routes to the protocol, and by protocol-specific code when the |
|
* protocol state change is initiated by the protocol. Using NULL message clears |
|
* the last message. The message string may be either NULL-terminated or with an |
|
* explicit length. |
|
*/ |
|
void |
|
proto_set_message(struct proto *p, char *msg, int len) |
|
{ |
|
mb_free(p->message); |
|
p->message = NULL; |
|
|
|
if (!msg || !len) |
|
return; |
|
|
|
if (len < 0) |
|
len = strlen(msg); |
|
|
|
if (!len) |
|
return; |
|
|
|
p->message = mb_alloc(proto_pool, len + 1); |
|
memcpy(p->message, msg, len); |
|
p->message[len] = 0; |
|
} |
|
|
|
|
/** |
/** |
* proto_request_feeding - request feeding routes to the protocol |
* proto_request_feeding - request feeding routes to the protocol |
* @p: given protocol |
* @p: given protocol |
Line 1474 proto_show_limit(struct proto_limit *l, const char *ds
|
Line 1518 proto_show_limit(struct proto_limit *l, const char *ds
|
void |
void |
proto_show_basic_info(struct proto *p) |
proto_show_basic_info(struct proto *p) |
{ |
{ |
// cli_msg(-1006, " Table: %s", p->table->name); | if (p->vrf) |
| cli_msg(-1006, " VRF: %s", p->vrf->name); |
| |
cli_msg(-1006, " Preference: %d", p->preference); |
cli_msg(-1006, " Preference: %d", p->preference); |
cli_msg(-1006, " Input filter: %s", filter_name(p->cf->in_filter)); |
cli_msg(-1006, " Input filter: %s", filter_name(p->cf->in_filter)); |
cli_msg(-1006, " Output filter: %s", filter_name(p->cf->out_filter)); |
cli_msg(-1006, " Output filter: %s", filter_name(p->cf->out_filter)); |
Line 1493 proto_show_basic_info(struct proto *p)
|
Line 1539 proto_show_basic_info(struct proto *p)
|
} |
} |
|
|
void |
void |
proto_cmd_show(struct proto *p, uint verbose, int cnt) | proto_cmd_show(struct proto *p, uintptr_t verbose, int cnt) |
{ |
{ |
byte buf[256], tbuf[TM_DATETIME_BUFFER_SIZE]; |
byte buf[256], tbuf[TM_DATETIME_BUFFER_SIZE]; |
|
|
Line 1516 proto_cmd_show(struct proto *p, uint verbose, int cnt)
|
Line 1562 proto_cmd_show(struct proto *p, uint verbose, int cnt)
|
{ |
{ |
if (p->cf->dsc) |
if (p->cf->dsc) |
cli_msg(-1006, " Description: %s", p->cf->dsc); |
cli_msg(-1006, " Description: %s", p->cf->dsc); |
|
|
|
if (p->message) |
|
cli_msg(-1006, " Message: %s", p->message); |
|
|
if (p->cf->router_id) |
if (p->cf->router_id) |
cli_msg(-1006, " Router ID: %R", p->cf->router_id); |
cli_msg(-1006, " Router ID: %R", p->cf->router_id); |
|
|
|
if (p->vrf_set) |
|
cli_msg(-1006, " VRF: %s", p->vrf ? p->vrf->name : "default"); |
|
|
if (p->proto->show_proto_info) |
if (p->proto->show_proto_info) |
p->proto->show_proto_info(p); |
p->proto->show_proto_info(p); |
else |
else |
Line 1529 proto_cmd_show(struct proto *p, uint verbose, int cnt)
|
Line 1582 proto_cmd_show(struct proto *p, uint verbose, int cnt)
|
} |
} |
|
|
void |
void |
proto_cmd_disable(struct proto *p, uint arg UNUSED, int cnt UNUSED) | proto_cmd_disable(struct proto *p, uintptr_t arg, int cnt UNUSED) |
{ |
{ |
if (p->disabled) |
if (p->disabled) |
{ |
{ |
Line 1540 proto_cmd_disable(struct proto *p, uint arg UNUSED, in
|
Line 1593 proto_cmd_disable(struct proto *p, uint arg UNUSED, in
|
log(L_INFO "Disabling protocol %s", p->name); |
log(L_INFO "Disabling protocol %s", p->name); |
p->disabled = 1; |
p->disabled = 1; |
p->down_code = PDC_CMD_DISABLE; |
p->down_code = PDC_CMD_DISABLE; |
|
proto_set_message(p, (char *) arg, -1); |
proto_rethink_goal(p); |
proto_rethink_goal(p); |
cli_msg(-9, "%s: disabled", p->name); |
cli_msg(-9, "%s: disabled", p->name); |
} |
} |
|
|
void |
void |
proto_cmd_enable(struct proto *p, uint arg UNUSED, int cnt UNUSED) | proto_cmd_enable(struct proto *p, uintptr_t arg, int cnt UNUSED) |
{ |
{ |
if (!p->disabled) |
if (!p->disabled) |
{ |
{ |
Line 1555 proto_cmd_enable(struct proto *p, uint arg UNUSED, int
|
Line 1609 proto_cmd_enable(struct proto *p, uint arg UNUSED, int
|
|
|
log(L_INFO "Enabling protocol %s", p->name); |
log(L_INFO "Enabling protocol %s", p->name); |
p->disabled = 0; |
p->disabled = 0; |
|
proto_set_message(p, (char *) arg, -1); |
proto_rethink_goal(p); |
proto_rethink_goal(p); |
cli_msg(-11, "%s: enabled", p->name); |
cli_msg(-11, "%s: enabled", p->name); |
} |
} |
|
|
void |
void |
proto_cmd_restart(struct proto *p, uint arg UNUSED, int cnt UNUSED) | proto_cmd_restart(struct proto *p, uintptr_t arg, int cnt UNUSED) |
{ |
{ |
if (p->disabled) |
if (p->disabled) |
{ |
{ |
Line 1571 proto_cmd_restart(struct proto *p, uint arg UNUSED, in
|
Line 1626 proto_cmd_restart(struct proto *p, uint arg UNUSED, in
|
log(L_INFO "Restarting protocol %s", p->name); |
log(L_INFO "Restarting protocol %s", p->name); |
p->disabled = 1; |
p->disabled = 1; |
p->down_code = PDC_CMD_RESTART; |
p->down_code = PDC_CMD_RESTART; |
|
proto_set_message(p, (char *) arg, -1); |
proto_rethink_goal(p); |
proto_rethink_goal(p); |
p->disabled = 0; |
p->disabled = 0; |
proto_rethink_goal(p); |
proto_rethink_goal(p); |
Line 1578 proto_cmd_restart(struct proto *p, uint arg UNUSED, in
|
Line 1634 proto_cmd_restart(struct proto *p, uint arg UNUSED, in
|
} |
} |
|
|
void |
void |
proto_cmd_reload(struct proto *p, uint dir, int cnt UNUSED) | proto_cmd_reload(struct proto *p, uintptr_t dir, int cnt UNUSED) |
{ |
{ |
if (p->disabled) |
if (p->disabled) |
{ |
{ |
Line 1620 proto_cmd_reload(struct proto *p, uint dir, int cnt UN
|
Line 1676 proto_cmd_reload(struct proto *p, uint dir, int cnt UN
|
} |
} |
|
|
void |
void |
proto_cmd_debug(struct proto *p, uint mask, int cnt UNUSED) | proto_cmd_debug(struct proto *p, uintptr_t mask, int cnt UNUSED) |
{ |
{ |
p->debug = mask; |
p->debug = mask; |
} |
} |
|
|
void |
void |
proto_cmd_mrtdump(struct proto *p, uint mask, int cnt UNUSED) | proto_cmd_mrtdump(struct proto *p, uintptr_t mask, int cnt UNUSED) |
{ |
{ |
p->mrtdump = mask; |
p->mrtdump = mask; |
} |
} |
|
|
static void |
static void |
proto_apply_cmd_symbol(struct symbol *s, void (* cmd)(struct proto *, uint, int), uint arg) | proto_apply_cmd_symbol(struct symbol *s, void (* cmd)(struct proto *, uintptr_t, int), uintptr_t arg) |
{ |
{ |
if (s->class != SYM_PROTO) |
if (s->class != SYM_PROTO) |
{ |
{ |
Line 1645 proto_apply_cmd_symbol(struct symbol *s, void (* cmd)(
|
Line 1701 proto_apply_cmd_symbol(struct symbol *s, void (* cmd)(
|
} |
} |
|
|
static void |
static void |
proto_apply_cmd_patt(char *patt, void (* cmd)(struct proto *, uint, int), uint arg) | proto_apply_cmd_patt(char *patt, void (* cmd)(struct proto *, uintptr_t, int), uintptr_t arg) |
{ |
{ |
int cnt = 0; |
int cnt = 0; |
|
|
Line 1665 proto_apply_cmd_patt(char *patt, void (* cmd)(struct p
|
Line 1721 proto_apply_cmd_patt(char *patt, void (* cmd)(struct p
|
} |
} |
|
|
void |
void |
proto_apply_cmd(struct proto_spec ps, void (* cmd)(struct proto *, uint, int), | proto_apply_cmd(struct proto_spec ps, void (* cmd)(struct proto *, uintptr_t, int), |
int restricted, uint arg) | int restricted, uintptr_t arg) |
{ |
{ |
if (restricted && cli_access_restricted()) |
if (restricted && cli_access_restricted()) |
return; |
return; |