Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pcmcia Protect ec_multicnt.



details:   https://anonhg.NetBSD.org/src/rev/b5db7c1891fc
branches:  trunk
changeset: 968192:b5db7c1891fc
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jan 06 07:15:03 2020 +0000

description:
Protect ec_multicnt.

diffstat:

 sys/arch/x86/pci/if_vmx.c |  10 ++++------
 sys/dev/isa/if_iy.c       |   6 +++---
 sys/dev/pci/if_de.c       |   8 ++++----
 sys/dev/pcmcia/if_ray.c   |   8 ++++----
 sys/dev/pcmcia/if_xi.c    |   9 ++++-----
 5 files changed, 19 insertions(+), 22 deletions(-)

diffs (230 lines):

diff -r b4eb2fb49e99 -r b5db7c1891fc sys/arch/x86/pci/if_vmx.c
--- a/sys/arch/x86/pci/if_vmx.c Mon Jan 06 06:50:00 2020 +0000
+++ b/sys/arch/x86/pci/if_vmx.c Mon Jan 06 07:15:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vmx.c,v 1.53 2019/12/24 10:21:08 knakahara Exp $    */
+/*     $NetBSD: if_vmx.c,v 1.54 2020/01/06 07:15:03 msaitoh Exp $      */
 /*     $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $        */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.53 2019/12/24 10:21:08 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.54 2020/01/06 07:15:03 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -3313,16 +3313,15 @@
         */
        mode = VMXNET3_RXMODE_BCAST | VMXNET3_RXMODE_UCAST;
 
+       ETHER_LOCK(ec);
        if (ISSET(ifp->if_flags, IFF_PROMISC) ||
            ec->ec_multicnt > VMXNET3_MULTICAST_MAX)
                goto allmulti;
 
        p = sc->vmx_mcast;
-       ETHER_LOCK(ec);
        ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
                if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
-                       ETHER_UNLOCK(ec);
                        /*
                         * We must listen to a range of multicast addresses.
                         * For now, just accept all multicasts, rather than
@@ -3339,17 +3338,16 @@
 
                ETHER_NEXT_MULTI(step, enm);
        }
-       ETHER_UNLOCK(ec);
 
        if (ec->ec_multicnt > 0) {
                SET(mode, VMXNET3_RXMODE_MCAST);
                ds->mcast_tablelen = p - sc->vmx_mcast;
        }
+       ETHER_UNLOCK(ec);
 
        goto setit;
 
 allmulti:
-       ETHER_LOCK(ec);
        SET(ec->ec_flags, ETHER_F_ALLMULTI);
        ETHER_UNLOCK(ec);
        SET(mode, (VMXNET3_RXMODE_ALLMULTI | VMXNET3_RXMODE_MCAST));
diff -r b4eb2fb49e99 -r b5db7c1891fc sys/dev/isa/if_iy.c
--- a/sys/dev/isa/if_iy.c       Mon Jan 06 06:50:00 2020 +0000
+++ b/sys/dev/isa/if_iy.c       Mon Jan 06 07:15:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iy.c,v 1.111 2019/11/12 13:17:44 msaitoh Exp $      */
+/*     $NetBSD: if_iy.c,v 1.112 2020/01/06 07:15:03 msaitoh Exp $      */
 /* #define IYDEBUG */
 /* #define IYMEMDEBUG */
 
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.111 2019/11/12 13:17:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.112 2020/01/06 07:15:03 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -1305,6 +1305,7 @@
        iot = sc->sc_iot;
        ioh = sc->sc_ioh;
 
+       ETHER_LOCK(ecp);
        len = 6 * ecp->ec_multicnt;
 
        avail = sc->tx_start - sc->tx_end;
@@ -1330,7 +1331,6 @@
        bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
        bus_space_write_stream_2(iot, ioh, MEM_PORT_REG, htole16(len));
 
-       ETHER_LOCK(ecp);
        ETHER_FIRST_MULTI(step, ecp, enm);
        while (enm) {
                /*
diff -r b4eb2fb49e99 -r b5db7c1891fc sys/dev/pci/if_de.c
--- a/sys/dev/pci/if_de.c       Mon Jan 06 06:50:00 2020 +0000
+++ b/sys/dev/pci/if_de.c       Mon Jan 06 07:15:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_de.c,v 1.164 2019/11/10 21:16:36 chs Exp $  */
+/*     $NetBSD: if_de.c,v 1.165 2020/01/06 07:15:03 msaitoh Exp $      */
 
 /*-
  * Copyright (c) 1994-1997 Matt Thomas (matt%3am-software.com@localhost)
@@ -37,7 +37,7 @@
  *   board which support 21040, 21041, or 21140 (mostly).
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.164 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.165 2020/01/06 07:15:03 msaitoh Exp $");
 
 #define        TULIP_HDR_DATA
 
@@ -3218,6 +3218,7 @@
        sc->tulip_if.if_flags &= ~IFF_ALLMULTI;
 #endif
        sc->tulip_if.if_start = tulip_ifstart;  /* so the setup packet gets queued */
+       ETHER_LOCK(ec);
        if (sc->tulip_multicnt > 14) {
                uint32_t *sp = sc->tulip_setupdata;
                unsigned hash;
@@ -3238,7 +3239,6 @@
                 * hardware).
                 */
                memset(sc->tulip_setupdata, 0, sizeof(sc->tulip_setupdata));
-               ETHER_LOCK(ec);
                ETHER_FIRST_MULTI(step, ec, enm);
                while (enm != NULL) {
                        if (memcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) {
@@ -3256,7 +3256,6 @@
                        }
                        ETHER_NEXT_MULTI(step, enm);
                }
-               ETHER_UNLOCK(ec);
                /*
                 * No reason to use a hash if we are going to be
                 * receiving every multicast.
@@ -3288,6 +3287,7 @@
                        }
                }
        }
+       ETHER_UNLOCK(ec);
        if ((sc->tulip_flags & (TULIP_WANTHASHPERFECT | TULIP_WANTHASHONLY))
            == 0) {
                uint32_t *sp = sc->tulip_setupdata;
diff -r b4eb2fb49e99 -r b5db7c1891fc sys/dev/pcmcia/if_ray.c
--- a/sys/dev/pcmcia/if_ray.c   Mon Jan 06 06:50:00 2020 +0000
+++ b/sys/dev/pcmcia/if_ray.c   Mon Jan 06 07:15:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ray.c,v 1.95 2019/10/21 08:22:06 msaitoh Exp $      */
+/*     $NetBSD: if_ray.c,v 1.96 2020/01/06 07:15:03 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2000 Christian E. Hopps
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.95 2019/10/21 08:22:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.96 2020/01/06 07:15:03 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -2824,9 +2824,9 @@
        ec = &sc->sc_ec;
        ray_cmd_cancel(sc, SCP_UPD_MCAST);
 
+       ETHER_LOCK(ec);
        /* see if we have any ranges */
        if ((count = sc->sc_ec.ec_multicnt) < 17) {
-               ETHER_LOCK(ec);
                ETHER_FIRST_MULTI(step, ec, enm);
                while (enm) {
                        /* see if this is a range */
@@ -2837,8 +2837,8 @@
                        }
                        ETHER_NEXT_MULTI(step, enm);
                }
-               ETHER_UNLOCK(ec);
        }
+       ETHER_UNLOCK(ec);
 
        /* track this stuff even when not running */
        if (count > 16) {
diff -r b4eb2fb49e99 -r b5db7c1891fc sys/dev/pcmcia/if_xi.c
--- a/sys/dev/pcmcia/if_xi.c    Mon Jan 06 06:50:00 2020 +0000
+++ b/sys/dev/pcmcia/if_xi.c    Mon Jan 06 07:15:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_xi.c,v 1.92 2019/11/28 17:09:10 maxv Exp $ */
+/*     $NetBSD: if_xi.c,v 1.93 2020/01/06 07:15:03 msaitoh Exp $ */
 /*     OpenBSD: if_xe.c,v 1.9 1999/09/16 11:28:42 niklas Exp   */
 
 /*
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.92 2019/11/28 17:09:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.93 2020/01/06 07:15:03 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -964,12 +964,12 @@
                        indaddr[i] = enaddr[i];
        num = 1;
 
+       ETHER_LOCK(ec);
        if (ec->ec_multicnt > 9) {
                ifp->if_flags |= IFF_ALLMULTI;
                goto done;
        }
 
-       ETHER_LOCK(ec);
        ETHER_FIRST_MULTI(step, ec, enm);
        for (; enm; num++) {
                if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
@@ -980,7 +980,6 @@
                         * XXX should we be setting IFF_ALLMULTI here?
                         */
                        ifp->if_flags |= IFF_ALLMULTI;
-                       ETHER_UNLOCK(ec);
                        goto done;
                }
                if (sc->sc_chipset >= XI_CHIPSET_MOHAWK)
@@ -991,10 +990,10 @@
                                indaddr[num * 6 + i] = enm->enm_addrlo[i];
                ETHER_NEXT_MULTI(step, enm);
        }
-       ETHER_UNLOCK(ec);
        ifp->if_flags &= ~IFF_ALLMULTI;
 
 done:
+       ETHER_UNLOCK(ec);
        if (num < 10)
                memset(&indaddr[num * 6], 0xff, 6 * (10 - num));
 



Home | Main Index | Thread Index | Old Index