0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 02:01:55 +00:00

Moved interface list flush to device protocol cleanup hook.

The interface list must be flushed when device protocol is stopped. This
was done in a hardcoded specific hook inside generic protocol routines.
The cleanup hook was originally used for table reference counting late
cleanup, yet it can be also simply used for prettier interface list flush.
This commit is contained in:
Maria Matejka 2023-01-31 13:11:55 +01:00
parent 05d8c3699d
commit e077d0e770
4 changed files with 13 additions and 15 deletions

View File

@ -386,15 +386,6 @@ if_end_update(void)
} }
} }
void
if_flush_ifaces(struct proto *p)
{
if (p->debug & D_EVENTS)
log(L_TRACE "%s: Flushing interfaces", p->name);
if_start_update();
if_end_update();
}
/** /**
* if_feed_baby - advertise interfaces to a new protocol * if_feed_baby - advertise interfaces to a new protocol
* @p: protocol to feed * @p: protocol to feed

View File

@ -114,7 +114,6 @@ void ifa_delete(struct ifa *);
void if_start_update(void); void if_start_update(void);
void if_end_partial_update(struct iface *); void if_end_partial_update(struct iface *);
void if_end_update(void); void if_end_update(void);
void if_flush_ifaces(struct proto *p);
void if_feed_baby(struct proto *); void if_feed_baby(struct proto *);
struct iface *if_find_by_index(unsigned); struct iface *if_find_by_index(unsigned);
struct iface *if_find_by_name(const char *); struct iface *if_find_by_name(const char *);

View File

@ -968,11 +968,8 @@ proto_event(void *ptr)
if (p->do_stop) if (p->do_stop)
{ {
if (p->proto == &proto_unix_iface)
if_flush_ifaces(p);
p->do_stop = 0; p->do_stop = 0;
} }
if (proto_is_done(p)) if (proto_is_done(p))
{ {
if (p->proto->cleanup) if (p->proto->cleanup)
@ -1863,8 +1860,6 @@ proto_do_stop(struct proto *p)
p->down_sched = 0; p->down_sched = 0;
p->gr_recovery = 0; p->gr_recovery = 0;
p->do_stop = 1;
ev_schedule(p->event);
if (p->main_source) if (p->main_source)
{ {
@ -1873,6 +1868,9 @@ proto_do_stop(struct proto *p)
} }
proto_stop_channels(p); proto_stop_channels(p);
p->do_stop = 1;
ev_schedule(p->event);
} }
static void static void

View File

@ -163,6 +163,15 @@ kif_shutdown(struct proto *P)
return PS_DOWN; return PS_DOWN;
} }
static void
kif_cleanup(struct proto *p)
{
if (p->debug & D_EVENTS)
log(L_TRACE "%s: Flushing interfaces", p->name);
if_start_update();
if_end_update();
}
static int static int
kif_reconfigure(struct proto *p, struct proto_config *new) kif_reconfigure(struct proto *p, struct proto_config *new)
{ {
@ -239,6 +248,7 @@ struct protocol proto_unix_iface = {
.init = kif_init, .init = kif_init,
.start = kif_start, .start = kif_start,
.shutdown = kif_shutdown, .shutdown = kif_shutdown,
.cleanup = kif_cleanup,
.reconfigure = kif_reconfigure, .reconfigure = kif_reconfigure,
.copy_config = kif_copy_config .copy_config = kif_copy_config
}; };