Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Fix that brconfig <bridge> (addr) can't show a large...



details:   https://anonhg.NetBSD.org/src/rev/3ba2449d0ee7
branches:  trunk
changeset: 836846:3ba2449d0ee7
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Nov 09 06:44:31 2018 +0000

description:
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

diffstat:

 sys/net/if_bridge.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r c1a22f1a864a -r 3ba2449d0ee7 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Fri Nov 09 04:06:40 2018 +0000
+++ b/sys/net/if_bridge.c       Fri Nov 09 06:44:31 2018 +0000
@@ -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_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))



Home | Main Index | Thread Index | Old Index