diff mbox series

[iptables,12/14] libxtables: Debug: Slightly improve extension ordering debugging

Message ID 20240727213648.28761-13-phil@nwl.cc
State Accepted
Delegated to: Phil Sutter
Headers show
Series Some fixes and trivial improvements | expand

Commit Message

Phil Sutter July 27, 2024, 9:36 p.m. UTC
Print the extension's real name (if present) and prefix the extension
list by a position number for clarity.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 libxtables/xtables.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 7b370d486f888..7d54540b73b73 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1171,11 +1171,21 @@  void xtables_register_match(struct xtables_match *me)
 	me->next = *pos;
 	*pos = me;
 #ifdef DEBUG
-	printf("%s: inserted match %s (family %d, revision %d):\n",
-			__func__, me->name, me->family, me->revision);
-	for (pos = &xtables_pending_matches; *pos; pos = &(*pos)->next) {
-		printf("%s:\tmatch %s (family %d, revision %d)\n", __func__,
-		       (*pos)->name, (*pos)->family, (*pos)->revision);
+#define printmatch(m, sfx)						\
+	printf("match %s (", (m)->name);				\
+	if ((m)->real_name)						\
+		printf("alias %s, ", (m)->real_name);			\
+	printf("family %d, revision %d)%s", (m)->family, (m)->revision, sfx);
+
+	{
+		int i = 1;
+
+		printf("%s: inserted ", __func__);
+		printmatch(me, ":\n");
+		for (pos = &xtables_pending_matches; *pos; pos = &(*pos)->next) {
+			printf("pos %d:\t", i++);
+			printmatch(*pos, "\n");
+		}
 	}
 #endif
 }