]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Iface: trace log messages cleanup
authorMaria Matejka <mq@ucw.cz>
Sun, 24 Sep 2023 20:20:01 +0000 (22:20 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 24 Sep 2023 20:20:01 +0000 (22:20 +0200)
nest/iface.c
nest/iface.h
nest/proto.c

index bbe38d3fabce5d0f04425d3bb45b818a1d1c6077..31eb9de15d10fe206fb2c16caa6ca9f5f6f4f960 100644 (file)
@@ -190,7 +190,7 @@ void ifa_link(struct ifa *a)
 
   if (a)
   {
-    debug("ifa_link: %p %d\n", a, a->uc);
+//    debug("ifa_link: %p %d\n", a, a->uc);
     a->uc++;
   }
 }
@@ -202,7 +202,7 @@ void ifa_unlink(struct ifa *a)
   if (!a)
     return;
 
-  debug("ifa_unlink: %p %d\n", a, a->uc);
+//  debug("ifa_unlink: %p %d\n", a, a->uc);
   if (--a->uc)
     return;
 
@@ -267,8 +267,7 @@ if_enqueue_notify_to(struct iface_notification x, struct iface_subscription *s)
   struct iface_notification *in = sl_alloc(iface_sub_slab);
   *in = x;
 
-  debug("Enqueue notify %d/%p (%p) to %p\n", x.type, x.a, in, s);
-
+  iface_trace(s, "Enqueueing interface notification (%d, %p, %p)", x.type, x.a, in);
   ifnot_add_tail(&s->queue, in);
   ev_send(s->target, &s->event);
 }
@@ -558,11 +557,11 @@ iface_notify_hook(void *_s)
   struct iface_subscription *s = _s;
 
   IFACE_LOCK;
+  iface_trace(s, "Processing interface notifications");
 
   while (!EMPTY_TLIST(ifnot, &s->queue))
   {
     struct iface_notification *n = THEAD(ifnot, &s->queue);
-    debug("Process notify %d/%p (%p) to %p\n", n->type, n->a, n, s);
     IFACE_UNLOCK;
 
     switch (n->type) {
@@ -663,7 +662,7 @@ iface_unsubscribe(struct iface_subscription *s)
 
   WALK_TLIST_DELSAFE(ifnot, n, &s->queue)
   {
-    debug("Drop notify %d/%p (%p) to %p\n", n->type, n->a, n, s);
+    iface_trace(s, "Dropping interface notification (%d, %p, %p) on unsubscribe", n->type, n->a, n);
     switch (n->type)
     {
       case IFNOT_ADDRESS:
index 05898a55a4434ed5720cc3efe0cc2121bafe4004..1411ac2a6ef3f49e2c979c66aec31cfdb9404b6d 100644 (file)
@@ -218,6 +218,9 @@ struct iface_subscription {
   void (*if_notify)(struct proto *, unsigned flags, struct iface *i);
   void (*ifa_notify)(struct proto *, unsigned flags, struct ifa *a);
   void (*neigh_notify)(struct neighbor *neigh);
+
+  const char *name;
+  int debug;
 };
 
 #include "lib/tlists.h"
@@ -229,6 +232,11 @@ void iface_flush_notifications(struct iface_subscription *);
 void iface_subscribe(struct iface_subscription *);
 void iface_unsubscribe(struct iface_subscription *);
 
+#define iface_trace(s, fmt, args...)  do {     \
+  if (s->debug)                                        \
+    log(L_TRACE "%s: " fmt, s->name, ##args);  \
+} while (0)
+
 /*
  *     Interface Pattern Lists
  */
index 476764b8c58d3baba04e141ff2bf35458abaff40..fd61321725fcd92b3dac6b0cad63ad2e6d043b1d 100644 (file)
@@ -1244,6 +1244,8 @@ proto_start(struct proto *p)
     p->pool = rp_newf(proto_pool, the_bird_domain.the_bird, "Protocol %s", p->cf->name);
 
   p->iface_sub.target = proto_event_list(p);
+  p->iface_sub.name = p->name;
+  p->iface_sub.debug = !!(p->debug & D_IFACES);
 
   PROTO_LOCKED_FROM_MAIN(p)
   {