]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Moved interface list flush to device protocol cleanup hook.
authorMaria Matejka <mq@ucw.cz>
Tue, 31 Jan 2023 12:11:55 +0000 (13:11 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 2 Feb 2023 13:40:00 +0000 (14:40 +0100)
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.

nest/iface.c
nest/iface.h
nest/proto.c
sysdep/unix/krt.c

index fc896e2667c164240c30c8bb696f911be0d0520e..fc63dc75019bf9512e4556032f919a03fc17a6d0 100644 (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
  * @p: protocol to feed
index 13f3bd12e78f0649177677f1ee10fd2da96bd1f1..287f3d96399bf78df9e49fc739c54972d880a4c5 100644 (file)
@@ -114,7 +114,6 @@ void ifa_delete(struct ifa *);
 void if_start_update(void);
 void if_end_partial_update(struct iface *);
 void if_end_update(void);
-void if_flush_ifaces(struct proto *p);
 void if_feed_baby(struct proto *);
 struct iface *if_find_by_index(unsigned);
 struct iface *if_find_by_name(const char *);
index 26d648f3791831379e9359425462e4d242e8c19a..0ca72ead20f285771a4bb85ada002dc400d49e12 100644 (file)
@@ -968,11 +968,8 @@ proto_event(void *ptr)
 
   if (p->do_stop)
   {
-    if (p->proto == &proto_unix_iface)
-      if_flush_ifaces(p);
     p->do_stop = 0;
   }
-
   if (proto_is_done(p))
   {
     if (p->proto->cleanup)
@@ -1863,8 +1860,6 @@ proto_do_stop(struct proto *p)
   p->down_sched = 0;
   p->gr_recovery = 0;
 
-  p->do_stop = 1;
-  ev_schedule(p->event);
 
   if (p->main_source)
   {
@@ -1873,6 +1868,9 @@ proto_do_stop(struct proto *p)
   }
 
   proto_stop_channels(p);
+
+  p->do_stop = 1;
+  ev_schedule(p->event);
 }
 
 static void
index 9f95247fe5484c57e6d8196c47ba16a39c5d5464..7ec30eb0ae2f08ea2019915b573b6e6f87fde5b9 100644 (file)
@@ -163,6 +163,15 @@ kif_shutdown(struct proto *P)
   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
 kif_reconfigure(struct proto *p, struct proto_config *new)
 {
@@ -239,6 +248,7 @@ struct protocol proto_unix_iface = {
   .init =              kif_init,
   .start =             kif_start,
   .shutdown =          kif_shutdown,
+  .cleanup =           kif_cleanup,
   .reconfigure =       kif_reconfigure,
   .copy_config =       kif_copy_config
 };