Module Name: src
Committed By: ozaki-r
Date: Fri Nov 9 06:44:31 UTC 2018
Modified Files:
src/sys/net: if_bridge.c
Log Message:
Fix that brconfig <bridge> (addr) can't show a large number of MAC addresses
The command shows only 256 addresses at maximum even if a bridge caches more
addresses. It occurs because the kernel doesn't return an error if the command
passes a short buffer that can't store all cached addresses; the kernel fills
cached addresses as much as possible and returns it without telling that the
result is truncated.
Fix the issue by telling a required size of a buffer if a buffer passed from the
command is not enough, which lets the command retry with an enough buffer.
Reported by k-goda@IIJ
To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/net/if_bridge.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.159 src/sys/net/if_bridge.c:1.160
--- src/sys/net/if_bridge.c:1.159 Wed Sep 19 07:51:23 2018
+++ src/sys/net/if_bridge.c Fri Nov 9 06:44:31 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.159 2018/09/19 07:51:23 msaitoh Exp $ */
+/* $NetBSD: if_bridge.c,v 1.160 2018/11/09 06:44:31 ozaki-r Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.159 2018/09/19 07:51:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.160 2018/11/09 06:44:31 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@@ -1060,6 +1060,12 @@ bridge_ioctl_rts(struct bridge_softc *sc
BRIDGE_RT_LOCK(sc);
+ /* The passed buffer is not enough, tell a required size. */
+ if (bac->ifbac_len < (sizeof(bareq) * sc->sc_brtcnt)) {
+ count = sc->sc_brtcnt;
+ goto out;
+ }
+
len = bac->ifbac_len;
BRIDGE_RTLIST_WRITER_FOREACH(brt, sc) {
if (len < sizeof(bareq))