git: e02e3aec3b05 - main - dummynet: do not log when a listing fills the buffer

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Wed, 25 Nov 2026 16:08:05 UTC
The branch main has been updated by kp:

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

commit e02e3aec3b05de5fdba66288a08a4d1a7d56f810
Author:     Osvaldo Janeri Filho <ojanerif@amd.com>
AuthorDate: 2026-11-25 15:36:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-25 16:05:34 +0000

    dummynet: do not log when a listing fills the buffer
    
    When userland lists a range of objects, dummynet_get() sizes the
    buffer from the request, and ipfw(8) and dnctl(8) retry with a bigger
    one if the reply may be truncated.  copy_obj() and copy_obj_q() still
    log every stop as an error, so "ipfw queue N show" with many dynamic
    queues prints "copy_obj_q ERROR ... have 16 need 96" although the
    listing is complete.
    
    Keep the error for a bad object and log the full buffer only at debug
    level 3 and above.
    
    PR:             290420
    Reported by:    dimka@dz.dn.ua
    Reviewed by:    kp
    Sponsored by:   Advanced Micro Devices, Inc.
    Signed-off-by:  Osvaldo Janeri Filho <ojanerif@amd.com>
    Differential Revision:  https://reviews.freebsd.org/D61964
---
 sys/netpfil/ipfw/ip_dummynet.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c
index 7c0f4bd10cbd..346c48699c7c 100644
--- a/sys/netpfil/ipfw/ip_dummynet.c
+++ b/sys/netpfil/ipfw/ip_dummynet.c
@@ -963,11 +963,17 @@ copy_obj(char **start, char *end, void *_o, const char *msg, int i)
 	int have = end - *start;
 
 	memcpy(&o, _o, sizeof(o));
-	if (have < o.len || o.len == 0 || o.type == 0) {
+	if (o.len == 0 || o.type == 0) {
 		D("(WARN) type %d %s %d have %d need %d",
 		    o.type, msg, i, have, o.len);
 		return 1;
 	}
+	if (have < o.len) {
+		/* Expected with a range: userland retries with more space. */
+		DX(2, "type %d %s %d have %d need %d",
+		    o.type, msg, i, have, o.len);
+		return 1;
+	}
 	ND("type %d %s %d len %d", o.type, msg, i, o.len);
 	if (o.type == DN_LINK) {
 		memcpy(&dn.l, _o, sizeof(dn.l));
@@ -998,11 +1004,17 @@ copy_obj_q(char **start, char *end, void *_o, const char *msg, int i)
 	int have = end - *start;
 	int len = sizeof(struct dn_flow); /* see above comment */
 
-	if (have < len || o->len == 0 || o->type != DN_QUEUE) {
+	if (o->len == 0 || o->type != DN_QUEUE) {
 		D("ERROR type %d %s %d have %d need %d",
 			o->type, msg, i, have, len);
 		return 1;
 	}
+	if (have < len) {
+		/* Expected with a range: userland retries with more space. */
+		DX(2, "type %d %s %d have %d need %d",
+			o->type, msg, i, have, len);
+		return 1;
+	}
 	ND("type %d %s %d len %d", o->type, msg, i, len);
 	memcpy(*start, _o, len);
 	((struct dn_id*)(*start))->len = len;