mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Static: Implement reload hook
This commit is contained in:
parent
211fe69c98
commit
9cf3d53311
@ -148,15 +148,48 @@ static_mark_rte(struct static_proto *p, struct static_route *r)
|
|||||||
ev_schedule(p->event);
|
ev_schedule(p->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_mark_all(struct static_proto *p)
|
||||||
|
{
|
||||||
|
struct static_config *cf = (void *) p->p.cf;
|
||||||
|
struct static_route *r;
|
||||||
|
|
||||||
|
/* We want to reload all routes, mark them as dirty */
|
||||||
|
|
||||||
|
WALK_LIST(r, cf->routes)
|
||||||
|
if (r->state == SRS_CLEAN)
|
||||||
|
r->state = SRS_DIRTY;
|
||||||
|
|
||||||
|
p->marked_all = 1;
|
||||||
|
BUFFER_FLUSH(p->marked);
|
||||||
|
|
||||||
|
if (!ev_active(p->event))
|
||||||
|
ev_schedule(p->event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
static_announce_marked(void *P)
|
static_announce_marked(void *P)
|
||||||
{
|
{
|
||||||
struct static_proto *p = P;
|
struct static_proto *p = P;
|
||||||
|
struct static_config *cf = (void *) p->p.cf;
|
||||||
|
struct static_route *r;
|
||||||
|
|
||||||
|
if (p->marked_all)
|
||||||
|
{
|
||||||
|
WALK_LIST(r, cf->routes)
|
||||||
|
if (r->state == SRS_DIRTY)
|
||||||
|
static_announce_rte(p, r);
|
||||||
|
|
||||||
|
p->marked_all = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
BUFFER_WALK(p->marked, r)
|
BUFFER_WALK(p->marked, r)
|
||||||
static_announce_rte(P, r);
|
static_announce_rte(p, r);
|
||||||
|
|
||||||
BUFFER_FLUSH(p->marked);
|
BUFFER_FLUSH(p->marked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -367,6 +400,16 @@ static_bfd_notify(struct bfd_request *req)
|
|||||||
static_mark_rte(p, r->mp_head);
|
static_mark_rte(p, r->mp_head);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
static_reload_routes(struct channel *C)
|
||||||
|
{
|
||||||
|
struct static_proto *p = (void *) C->proto;
|
||||||
|
|
||||||
|
TRACE(D_EVENTS, "Scheduling route reload");
|
||||||
|
|
||||||
|
static_mark_all(p);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
static_rte_better(rte *new, rte *old)
|
static_rte_better(rte *new, rte *old)
|
||||||
{
|
{
|
||||||
@ -421,6 +464,7 @@ static_init(struct proto_config *CF)
|
|||||||
P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
|
P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
|
||||||
|
|
||||||
P->neigh_notify = static_neigh_notify;
|
P->neigh_notify = static_neigh_notify;
|
||||||
|
P->reload_routes = static_reload_routes;
|
||||||
P->rte_better = static_rte_better;
|
P->rte_better = static_rte_better;
|
||||||
P->rte_mergable = static_rte_mergable;
|
P->rte_mergable = static_rte_mergable;
|
||||||
|
|
||||||
@ -633,6 +677,10 @@ static_reconfigure(struct proto *P, struct proto_config *CF)
|
|||||||
xfree(orbuf);
|
xfree(orbuf);
|
||||||
xfree(nrbuf);
|
xfree(nrbuf);
|
||||||
|
|
||||||
|
/* All dirty routes were announced anyways */
|
||||||
|
BUFFER_FLUSH(p->marked);
|
||||||
|
p->marked_all = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ struct static_proto {
|
|||||||
|
|
||||||
struct event *event; /* Event for announcing updated routes */
|
struct event *event; /* Event for announcing updated routes */
|
||||||
BUFFER_(struct static_route *) marked; /* Routes marked for reannouncement */
|
BUFFER_(struct static_route *) marked; /* Routes marked for reannouncement */
|
||||||
|
int marked_all; /* All routes are marked */
|
||||||
rtable *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */
|
rtable *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */
|
||||||
rtable *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */
|
rtable *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user