git: 7797719d3a8b - stable/13 - fibs: Limit the WARNING message to only once when setting up with multiple fibs

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Thu, 01 Aug 2024 18:21:22 UTC
The branch stable/13 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=7797719d3a8b1eb50e57c6652f744a6bffc91599

commit 7797719d3a8b1eb50e57c6652f744a6bffc91599
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-08-01 18:00:45 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-08-01 18:04:54 +0000

    fibs: Limit the WARNING message to only once when setting up with multiple fibs
    
    In main [1] this warning message is suppressed but no plans to MFC the
    change as the message may be still useful for users that upgrade from
    older releases to 14.x or 13.x. Well emitting this warning message every
    time increasing the fib number is confusing for users not for the feature
    `net.add_addr_allfibs`, let's limit it to be printed only once.
    
    1. a48f7a2eb90b fibs: Suppress the WARNING message for setups with multiple fibs
    
    This is a direct commit to stable/14 and stable/13.
    
    PR:             280097
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D46204
    
    (cherry picked from commit 352dd826ffdd88d26744023fe8bcff795bdf64d8)
---
 sys/net/route/route_tables.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/net/route/route_tables.c b/sys/net/route/route_tables.c
index 45c1b6cab8ed..47fe5cfae1dd 100644
--- a/sys/net/route/route_tables.c
+++ b/sys/net/route/route_tables.c
@@ -217,6 +217,7 @@ populate_kernel_routes(struct rib_head **new_rt_tables, struct rib_head *rh)
 static void
 grow_rtables(uint32_t num_tables)
 {
+	static bool printedonce;
 	struct domain *dom;
 	struct rib_head **prnh, *rh;
 	struct rib_head **new_rt_tables, **old_rt_tables;
@@ -230,10 +231,12 @@ grow_rtables(uint32_t num_tables)
 	new_rt_tables = mallocarray(num_tables * (AF_MAX + 1), sizeof(void *),
 	    M_RTABLE, M_WAITOK | M_ZERO);
 
-	if ((num_tables > 1) && (V_rt_add_addr_allfibs == 0))
+	if (num_tables > 1 && V_rt_add_addr_allfibs == 0 && !printedonce) {
+		printedonce = true;
 		printf("WARNING: Adding ifaddrs to all fibs has been turned off "
 			"by default. Consider tuning %s if needed\n",
 			"net.add_addr_allfibs");
+	}
 
 #ifdef FIB_ALGO
 	fib_grow_rtables(num_tables);