Source-Changes-HG archive

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

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by msaitoh i...



details:   https://anonhg.NetBSD.org/src/rev/3d6b05c024e1
branches:  netbsd-8
changeset: 434436:3d6b05c024e1
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Nov 24 08:39:08 2017 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #389):
        sys/net/if_ether.h: revision 1.69
        sys/net/if_vlan.c: revision 1.108
        sys/dev/pci/if_bge.c: revision 1.313
        sys/net/if_vlanvar.h: revision 1.11
        sys/net/if_vlanvar.h: revision 1.12
        sys/net/if_ether.h: revision 1.70
        sys/net/if_vlan.c: revision 1.110
        sys/dev/pci/if_wm.c: revision 1.544
        sys/dev/pci/if_wmreg.h: revision 1.105
  Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
  Revert part of if_bge.c 1.312. It's not required to mask other than VLAN ID
bits in VLAN tag.
  Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
No functional change:
  - u_int16_t -> uint16_t
  - u_short -> uint16_t
  - tag_hash_func -> vlan_tag_hash
  - 0 -> NULL because vlr_parent is a pointer.

diffstat:

 sys/dev/pci/if_bge.c   |   6 +++---
 sys/dev/pci/if_wm.c    |  10 +++++-----
 sys/dev/pci/if_wmreg.h |  14 +-------------
 sys/net/if_ether.h     |  16 +++++++++-------
 sys/net/if_vlan.c      |  29 +++++++++++++++--------------
 sys/net/if_vlanvar.h   |   9 +++------
 6 files changed, 36 insertions(+), 48 deletions(-)

diffs (299 lines):

diff -r e854aefa7039 -r 3d6b05c024e1 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/dev/pci/if_bge.c      Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.310.2.1 2017/10/24 08:38:59 snj Exp $     */
+/*     $NetBSD: if_bge.c,v 1.310.2.2 2017/11/24 08:39:09 martin Exp $  */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.1 2017/10/24 08:38:59 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.2 2017/11/24 08:39:09 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -4607,7 +4607,7 @@
                 * to vlan_input() instead of ether_input().
                 */
                if (cur_rx->bge_flags & BGE_RXBDFLAG_VLAN_TAG) {
-                       vlan_set_tag(m, cur_rx->bge_vlan_tag & ETHER_VLAN_MASK);
+                       vlan_set_tag(m, cur_rx->bge_vlan_tag);
                }
 
                if_percpuq_enqueue(ifp->if_percpuq, m);
diff -r e854aefa7039 -r 3d6b05c024e1 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.508.4.6 2017/11/22 16:40:42 martin Exp $   */
+/*     $NetBSD: if_wm.c,v 1.508.4.7 2017/11/24 08:39:09 martin Exp $   */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.6 2017/11/22 16:40:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.7 2017/11/24 08:39:09 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8103,11 +8103,11 @@
        struct wm_softc *sc = rxq->rxq_sc;
 
        if (sc->sc_type == WM_T_82574)
-               return EXTRXC_VLAN_ID(rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan);
+               return rxq->rxq_ext_descs[idx].erx_ctx.erxc_vlan;
        else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-               return NQRXC_VLAN_ID(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan);
+               return rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_vlan;
        else
-               return WRX_VLAN_ID(rxq->rxq_descs[idx].wrx_special);
+               return rxq->rxq_descs[idx].wrx_special;
 }
 
 static inline int
diff -r e854aefa7039 -r 3d6b05c024e1 sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h    Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/dev/pci/if_wmreg.h    Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wmreg.h,v 1.98.6.2 2017/11/06 09:54:01 snj Exp $    */
+/*     $NetBSD: if_wmreg.h,v 1.98.6.3 2017/11/24 08:39:09 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -208,12 +208,6 @@
 #define EXTRXC_STATUS_PKTTYPE_MASK     __BITS(19,16)
 #define EXTRXC_STATUS_PKTTYPE(status)  __SHIFTOUT(status,EXTRXC_STATUS_PKTTYPE_MASK)
 
-#define        EXTRXC_VLAN_ID_MASK     __BITS(11,0)    /* VLAN identifier mask */
-#define        EXTRXC_VLAN_ID(x)       ((x) & EXTRXC_VLAN_ID_MASK) /* VLAN identifier */
-#define        EXTRXC_VLAN_CFI         __BIT(12)       /* Canonical Form Indicator */
-#define        EXTRXC_VLAN_PRI_MASK    __BITS(15,13)   /* VLAN priority mask */
-#define        EXTRXC_VLAN_PRI(x)      __SHIFTOUT((x),EXTRXC_VLAN_PRI_MASK) /* VLAN priority */
-
 /* advanced RX descriptor for 82575 and newer */
 typedef union nq_rxdesc {
        struct {
@@ -336,12 +330,6 @@
 #define NQRXC_STATUS_MC                __BIT(19) /* Packet received from Manageability Controller */
                                          /* "MBC" in i350 spec */
 
-#define        NQRXC_VLAN_ID_MASK      __BITS(11,0)    /* VLAN identifier mask */
-#define        NQRXC_VLAN_ID(x)        ((x) & NQRXC_VLAN_ID_MASK) /* VLAN identifier */
-#define        NQRXC_VLAN_CFI          __BIT(12)       /* Canonical Form Indicator */
-#define        NQRXC_VLAN_PRI_MASK     __BITS(15,13)   /* VLAN priority mask */
-#define        NQRXC_VLAN_PRI(x)       __SHIFTOUT((x),NQRXC_VLAN_PRI_MASK) /* VLAN priority */
-
 /*
  * The Wiseman transmit descriptor.
  *
diff -r e854aefa7039 -r 3d6b05c024e1 sys/net/if_ether.h
--- a/sys/net/if_ether.h        Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/net/if_ether.h        Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ether.h,v 1.66.8.1 2017/10/24 08:38:59 snj Exp $    */
+/*     $NetBSD: if_ether.h,v 1.66.8.2 2017/11/24 08:39:08 martin Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -59,9 +59,11 @@
 /*
  * Some Ethernet extensions.
  */
-#define        ETHER_VLAN_ENCAP_LEN 4  /* length of 802.1Q VLAN encapsulation */
-#define        ETHER_VLAN_MASK 0xFFF   /* bits in a vlan tag */
-#define        ETHER_PPPOE_ENCAP_LEN 8 /* length of PPPoE encapsulation */
+#define        ETHER_VLAN_ENCAP_LEN    4      /* length of 802.1Q VLAN encapsulation */
+#define        EVL_VLANOFTAG(tag)      ((tag) & 4095)          /* VLAN ID */
+#define        EVL_PRIOFTAG(tag)       (((tag) >> 13) & 7)     /* Priority */
+#define        EVL_CFIOFTAG(tag)       (((tag) >> 12) & 1)     /* CFI */
+#define        ETHER_PPPOE_ENCAP_LEN   8       /* length of PPPoE encapsulation */
 
 /*
  * Ethernet address - 6 octets
@@ -297,12 +299,12 @@
 
 /* add VLAN tag to input/received packet */
 static inline void
-vlan_set_tag(struct mbuf *m, u_int16_t vlanid)
+vlan_set_tag(struct mbuf *m, uint16_t vlantag)
 {
 
-       KASSERT((vlanid & ~ETHER_VLAN_MASK) == 0);
+       /* VLAN tag contains priority, CFI and VLAN ID */
 
-       m->m_pkthdr.ether_vtag = vlanid;
+       m->m_pkthdr.ether_vtag = vlantag;
        m->m_flags |= M_VLANTAG;
        return;
 }
diff -r e854aefa7039 -r 3d6b05c024e1 sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/net/if_vlan.c Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlan.c,v 1.97.2.7 2017/11/22 14:30:23 martin Exp $  */
+/*     $NetBSD: if_vlan.c,v 1.97.2.8 2017/11/24 08:39:09 martin Exp $  */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.97.2.7 2017/11/22 14:30:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.97.2.8 2017/11/24 08:39:09 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -207,6 +207,7 @@
     struct ifvlan_linkmib *);
 static void    vlan_hash_init(void);
 static int     vlan_hash_fini(void);
+static int     vlan_tag_hash(uint16_t, u_long);
 static struct ifvlan_linkmib*  vlan_getref_linkmib(struct ifvlan *,
     struct psref *);
 static void    vlan_putref_linkmib(struct ifvlan_linkmib *,
@@ -215,7 +216,6 @@
     struct ifvlan_linkmib *);
 static struct ifvlan_linkmib*  vlan_lookup_tag_psref(struct ifnet *,
     uint16_t, struct psref *);
-static int     tag_hash_func(uint16_t, u_long);
 
 LIST_HEAD(vlan_ifvlist, ifvlan);
 static struct {
@@ -381,6 +381,7 @@
        struct ifvlan_linkmib *omib = NULL;
        struct ifvlan_linkmib *checkmib = NULL;
        struct psref_target *nmib_psref = NULL;
+       uint16_t vid = EVL_VLANOFTAG(tag);
        int error = 0;
        int idx;
        bool omib_cleanup = false;
@@ -397,7 +398,7 @@
        }
 
        /* Duplicate check */
-       checkmib = vlan_lookup_tag_psref(p, tag, &psref);
+       checkmib = vlan_lookup_tag_psref(p, vid, &psref);
        if (checkmib != NULL) {
                vlan_putref_linkmib(checkmib, &psref);
                error = EEXIST;
@@ -467,7 +468,7 @@
        }
 
        nmib->ifvm_p = p;
-       nmib->ifvm_tag = tag;
+       nmib->ifvm_tag = vid;
        ifv->ifv_if.if_mtu = p->if_mtu - nmib->ifvm_mtufudge;
        ifv->ifv_if.if_flags = p->if_flags &
            (IFF_UP | IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
@@ -479,7 +480,7 @@
        ifv->ifv_if.if_type = p->if_type;
 
        PSLIST_ENTRY_INIT(ifv, ifv_hash);
-       idx = tag_hash_func(tag, ifv_hash.mask);
+       idx = vlan_tag_hash(vid, ifv_hash.mask);
 
        mutex_enter(&ifv_hash.lock);
        PSLIST_WRITER_INSERT_HEAD(&ifv_hash.lists[idx], ifv, ifv_hash);
@@ -649,7 +650,7 @@
 }
 
 static int
-tag_hash_func(uint16_t tag, u_long mask)
+vlan_tag_hash(uint16_t tag, u_long mask)
 {
        uint32_t hash;
 
@@ -693,7 +694,7 @@
        int s;
        struct ifvlan *sc;
 
-       idx = tag_hash_func(tag, ifv_hash.mask);
+       idx = vlan_tag_hash(tag, ifv_hash.mask);
 
        s = pserialize_read_enter();
        PSLIST_READER_FOREACH(sc, &ifv_hash.lists[idx], struct ifvlan,
@@ -910,7 +911,7 @@
                        error = EINVAL;          /* check for valid tag */
                        break;
                }
-               if ((pr = ifunit(vlr.vlr_parent)) == 0) {
+               if ((pr = ifunit(vlr.vlr_parent)) == NULL) {
                        error = ENOENT;
                        break;
                }
@@ -1458,14 +1459,14 @@
 vlan_input(struct ifnet *ifp, struct mbuf *m)
 {
        struct ifvlan *ifv;
-       u_int tag;
+       uint16_t vid;
        struct ifvlan_linkmib *mib;
        struct psref psref;
        bool have_vtag;
 
        have_vtag = vlan_has_tag(m);
        if (have_vtag) {
-               tag = EVL_VLANOFTAG(vlan_get_tag(m));
+               vid = EVL_VLANOFTAG(vlan_get_tag(m));
                m->m_flags &= ~M_VLANTAG;
        } else {
                switch (ifp->if_type) {
@@ -1483,7 +1484,7 @@
                        evl = mtod(m, struct ether_vlan_header *);
                        KASSERT(ntohs(evl->evl_encap_proto) == ETHERTYPE_VLAN);
 
-                       tag = EVL_VLANOFTAG(ntohs(evl->evl_tag));
+                       vid = EVL_VLANOFTAG(ntohs(evl->evl_tag));
 
                        /*
                         * Restore the original ethertype.  We'll remove
@@ -1495,14 +1496,14 @@
                    }
 
                default:
-                       tag = (u_int) -1;       /* XXX GCC */
+                       vid = (uint16_t) -1;    /* XXX GCC */
 #ifdef DIAGNOSTIC
                        panic("vlan_input: impossible");
 #endif
                }
        }
 
-       mib = vlan_lookup_tag_psref(ifp, tag, &psref);
+       mib = vlan_lookup_tag_psref(ifp, vid, &psref);
        if (mib == NULL) {
                m_freem(m);
                ifp->if_noproto++;
diff -r e854aefa7039 -r 3d6b05c024e1 sys/net/if_vlanvar.h
--- a/sys/net/if_vlanvar.h      Fri Nov 24 08:35:34 2017 +0000
+++ b/sys/net/if_vlanvar.h      Fri Nov 24 08:39:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlanvar.h,v 1.9.80.1 2017/06/21 17:39:24 snj Exp $  */
+/*     $NetBSD: if_vlanvar.h,v 1.9.80.2 2017/11/24 08:39:09 martin Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -71,13 +71,10 @@
        uint16_t        evl_proto;
 } __packed;
 
-#define        EVL_VLANOFTAG(tag)      ((tag) & 4095)
-#define        EVL_PRIOFTAG(tag)       (((tag) >> 13) & 7)
-
 /* Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls. */
 struct vlanreq {
-       char    vlr_parent[IFNAMSIZ];
-       u_short vlr_tag;
+       char            vlr_parent[IFNAMSIZ];
+       uint16_t        vlr_tag;
 };
 
 #define        SIOCSETVLAN     SIOCSIFGENERIC



Home | Main Index | Thread Index | Old Index