Source-Changes-HG archive

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

[src/trunk]: src switch from kame-based m_aux mbuf auxiliary data, to openbsd...



details:   https://anonhg.NetBSD.org/src/rev/88376f852f8d
branches:  trunk
changeset: 541707:88376f852f8d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Jan 17 08:11:49 2003 +0000

description:
switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation.  it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized.  from Joel Wilsson

diffstat:

 share/man/man9/malloc.9 |    4 +-
 sys/dev/pci/if_bge.c    |   23 ++--
 sys/dev/pci/if_sip.c    |   17 ++-
 sys/dev/pci/if_ti.c     |   33 +++---
 sys/dev/pci/if_wm.c     |   19 ++-
 sys/kern/uipc_mbuf2.c   |  216 ++++++++++++++++++++++++++++++++++--------------
 sys/net/if_ecosubr.c    |   36 +++----
 sys/net/if_ethersubr.c  |    8 +-
 sys/net/if_vlan.c       |   27 +++--
 sys/netinet/ip_encap.c  |   23 ++--
 sys/netinet/ip_encap.h  |    4 +-
 sys/netinet6/ipsec.c    |  122 ++++++++++++--------------
 sys/netinet6/nd6.c      |    8 +-
 sys/sys/malloc.h        |    8 +-
 sys/sys/mbuf.h          |   62 ++++++++-----
 15 files changed, 353 insertions(+), 257 deletions(-)

diffs (truncated from 1213 to 300 lines):

diff -r b5c431c773ad -r 88376f852f8d share/man/man9/malloc.9
--- a/share/man/man9/malloc.9   Fri Jan 17 06:23:52 2003 +0000
+++ b/share/man/man9/malloc.9   Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: malloc.9,v 1.26 2002/10/14 13:43:26 wiz Exp $
+.\"    $NetBSD: malloc.9,v 1.27 2003/01/17 08:11:49 itojun Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -411,6 +411,8 @@
 SMBFS hash table.
 .It Dv M_SA
 Scheduler activations data structures
+.It Dv M_PACKET_TAGS
+Packet-attached information
 .El
 .Pp
 Statistics based on the
diff -r b5c431c773ad -r 88376f852f8d sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Fri Jan 17 06:23:52 2003 +0000
+++ b/sys/dev/pci/if_bge.c      Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.27 2003/01/17 00:24:29 jonathan Exp $     */
+/*     $NetBSD: if_bge.c,v 1.28 2003/01/17 08:11:50 itojun Exp $       */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -2379,12 +2379,13 @@
                 * to vlan_input() instead of ether_input().
                 */
                if (have_tag) {
-                       struct mbuf *n;
-
-                       n = m_aux_add(m, AF_LINK, ETHERTYPE_VLAN);
-                       if (n != NULL) {
-                               *mtod(n, int *) = vlan_tag;
-                               n->m_len = sizeof(int);
+                       struct m_tag *mtag;
+
+                       mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int),
+                           M_NOWAIT);
+                       if (mtag != NULL) {
+                               *(u_int *)(mtag + 1) = vlan_tag;
+                               m_tag_prepend(m, mtag);
                                have_tag = vlan_tag = 0;
                        } else {
                                printf("%s: no mbuf for tag\n", ifp->if_xname);
@@ -2721,8 +2722,8 @@
            BUS_DMA_NOWAIT))
                return(ENOBUFS);
 
-       n = sc->ethercom.ec_nvlans ?
-           m_aux_find(m_head, AF_LINK, ETHERTYPE_VLAN) : NULL;
+       mtag = sc->ethercom.ec_nvlans ?
+           m_tag_find(m_head, PACKET_TAG_VLAN, NULL) : NULL;
 
        for (i = 0; i < dmamap->dm_nsegs; i++) {
                f = &sc->bge_rdata->bge_tx_ring[frag];
@@ -2732,9 +2733,9 @@
                f->bge_len = dmamap->dm_segs[i].ds_len;
                f->bge_flags = csum_flags;
 
-               if (n != NULL) {
+               if (mtag != NULL) {
                        f->bge_flags |= BGE_TXBDFLAG_VLAN_TAG;
-                       f->bge_vlan_tag = *mtod(n, int *);
+                       f->bge_vlan_tag = *(u_int *)(mtag + 1);
                } else {
                        f->bge_vlan_tag = 0;
                }
diff -r b5c431c773ad -r 88376f852f8d sys/dev/pci/if_sip.c
--- a/sys/dev/pci/if_sip.c      Fri Jan 17 06:23:52 2003 +0000
+++ b/sys/dev/pci/if_sip.c      Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sip.c,v 1.75 2002/12/23 02:58:37 tsutsui Exp $      */
+/*     $NetBSD: if_sip.c,v 1.76 2003/01/17 08:11:50 itojun Exp $       */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.75 2002/12/23 02:58:37 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.76 2003/01/17 08:11:50 itojun Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -1123,6 +1123,7 @@
        int firsttx = sc->sc_txnext;
 #endif
 #ifdef DP83820
+       struct m_tag *mtag;
        u_int32_t extsts;
 #endif
 
@@ -1309,7 +1310,7 @@
                 * the packet.
                 */
                if (sc->sc_ethercom.ec_nvlans != 0 &&
-                   (m = m_aux_find(m0, AF_LINK, ETHERTYPE_VLAN)) != NULL) {
+                   (mtag = m_tag_find(m0, PACKET_TAG_VLAN, NULL)) != NULL) {
                        sc->sc_txdescs[lasttx].sipd_extsts |=
                            htole32(EXTSTS_VPKT |
                                    htons(*mtod(m, int *) & EXTSTS_VTCI));
@@ -1863,9 +1864,10 @@
                 */
                if (sc->sc_ethercom.ec_nvlans != 0 &&
                    (extsts & EXTSTS_VPKT) != 0) {
-                       struct mbuf *vtag;
-
-                       vtag = m_aux_add(m, AF_LINK, ETHERTYPE_VLAN);
+                       struct m_tag *vtag;
+
+                       vtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int),
+                           M_NOWAIT);
                        if (vtag == NULL) {
                                ifp->if_ierrors++;
                                printf("%s: unable to allocate VLAN tag\n",
@@ -1874,8 +1876,7 @@
                                continue;
                        }
 
-                       *mtod(vtag, int *) = ntohs(extsts & EXTSTS_VTCI);
-                       vtag->m_len = sizeof(int);
+                       *(u_int *)(vtag + 1) = ntohs(extsts & EXTSTS_VTCI);
                }
 
                /*
diff -r b5c431c773ad -r 88376f852f8d sys/dev/pci/if_ti.c
--- a/sys/dev/pci/if_ti.c       Fri Jan 17 06:23:52 2003 +0000
+++ b/sys/dev/pci/if_ti.c       Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.52 2002/10/02 16:51:32 thorpej Exp $ */
+/* $NetBSD: if_ti.c,v 1.53 2003/01/17 08:11:51 itojun Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.52 2002/10/02 16:51:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.53 2003/01/17 08:11:51 itojun Exp $");
 
 #include "bpfilter.h"
 #include "opt_inet.h"
@@ -2071,12 +2071,13 @@
                }
 
                if (have_tag) {
-                       struct mbuf *n;
-                       n = m_aux_add(m, AF_LINK, ETHERTYPE_VLAN);
-                       if (n) {
-                               *mtod(n, int *) = vlan_tag;
-                               n->m_len = sizeof(int);
-                       } else {
+                       struct m_tag *mtag;
+
+                       mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int),
+                           M_NOWAIT);
+                       if (mtag)
+                               *(u_int *)mtag = vlan_tag;
+                       else {
                                printf("%s: no mbuf for tag\n", ifp->if_xname);
                                m_freem(m);
                                continue;
@@ -2277,7 +2278,7 @@
        struct txdmamap_pool_entry *dma;
        bus_dmamap_t dmamap;
        int error, i;
-       struct mbuf *n;
+       struct m_tag *mtag;
        u_int16_t csum_flags = 0;
 
        dma = SIMPLEQ_FIRST(&sc->txdma_list);
@@ -2333,10 +2334,10 @@
                TI_HOSTADDR(f->ti_addr) = dmamap->dm_segs[i].ds_addr;
                f->ti_len = dmamap->dm_segs[i].ds_len;
                f->ti_flags = csum_flags;
-               n = m_aux_find(m_head, AF_LINK, ETHERTYPE_VLAN);
-               if (n) {
+               mtag = m_tag_find(m_head, PACKET_TAG_VLAN, NULL);
+               if (mtag) {
                        f->ti_flags |= TI_BDFLAG_VLAN_TAG;
-                       f->ti_vlan_tag = *mtod(n, int *);
+                       f->ti_vlan_tag = *(u_int *)(mtag + 1);
                } else {
                        f->ti_vlan_tag = 0;
                }
@@ -2384,7 +2385,7 @@
        struct txdmamap_pool_entry *dma;
        bus_dmamap_t dmamap;
        int error, i;
-       struct mbuf *n;
+       struct m_tag *mtag;
        u_int16_t csum_flags = 0;
 
        dma = SIMPLEQ_FIRST(&sc->txdma_list);
@@ -2428,10 +2429,10 @@
                TI_HOSTADDR(f->ti_addr) = dmamap->dm_segs[i].ds_addr;
                f->ti_len = dmamap->dm_segs[i].ds_len;
                f->ti_flags = csum_flags;
-               n = m_aux_find(m_head, AF_LINK, ETHERTYPE_VLAN);
-               if (n) {
+               mtag = m_tag_find(m_head, PACKET_TAG_VLAN, NULL);
+               if (mtag) {
                        f->ti_flags |= TI_BDFLAG_VLAN_TAG;
-                       f->ti_vlan_tag = *mtod(n, int *);
+                       f->ti_vlan_tag = *(u_int *)(mtag + 1);
                } else {
                        f->ti_vlan_tag = 0;
                }
diff -r b5c431c773ad -r 88376f852f8d sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Jan 17 06:23:52 2003 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.29 2002/12/23 02:58:38 tsutsui Exp $       */
+/*     $NetBSD: if_wm.c,v 1.30 2003/01/17 08:11:52 itojun Exp $        */
 
 /*
  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@@ -1109,7 +1109,10 @@
 wm_start(struct ifnet *ifp)
 {
        struct wm_softc *sc = ifp->if_softc;
-       struct mbuf *m0/*, *m*/;
+       struct mbuf *m0;
+#if 0 /* XXXJRT */
+       struct m_tag *mtag;
+#endif
        struct wm_txsoft *txs;
        bus_dmamap_t dmamap;
        int error, nexttx, lasttx, ofree, seg;
@@ -1299,7 +1302,7 @@
                 * This is only valid on the last descriptor of the packet.
                 */
                if (sc->sc_ethercom.ec_nvlans != 0 &&
-                   (m = m_aux_find(m0, AF_LINK, ETHERTYPE_VLAN)) != NULL) {
+                   (mtag = m_tag_find(m0, PACKET_TAG_VLAN, NULL)) != NULL) {
                        sc->sc_txdescs[lasttx].wtx_cmdlen |=
                            htole32(WTX_CMD_VLE);
                        sc->sc_txdescs[lasttx].wtx_fields.wtxu_fields.wtxu_vlan
@@ -1725,9 +1728,10 @@
                 */
                if (sc->sc_ethercom.ec_nvlans != 0 &&
                    (status & WRX_ST_VP) != 0) {
-                       struct mbuf *vtag;
-
-                       vtag = m_aux_add(m, AF_LINK, ETHERTYPE_VLAN);
+                       struct m_tag *vtag;
+
+                       vtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int),
+                           M_NOWAIT);
                        if (vtag == NULL) {
                                ifp->if_ierrors++;
                                printf("%s: unable to allocate VLAN tag\n",
@@ -1736,9 +1740,8 @@
                                continue;
                        }
 
-                       *mtod(m, int *) =
+                       *(u_int *)(vtag + 1) =
                            le16toh(sc->sc_rxdescs[i].wrx_special);
-                       vtag->m_len = sizeof(int);
                }
 #endif /* XXXJRT */
 
diff -r b5c431c773ad -r 88376f852f8d sys/kern/uipc_mbuf2.c
--- a/sys/kern/uipc_mbuf2.c     Fri Jan 17 06:23:52 2003 +0000
+++ b/sys/kern/uipc_mbuf2.c     Fri Jan 17 08:11:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf2.c,v 1.11 2002/10/22 03:29:51 simonb Exp $   */
+/*     $NetBSD: uipc_mbuf2.c,v 1.12 2003/01/17 08:11:52 itojun Exp $   */
 /*     $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $     */
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.11 2002/10/22 03:29:51 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.12 2003/01/17 08:11:52 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -223,82 +223,172 @@
        return n;
 }
 
-/*
- * pkthdr.aux chain manipulation.
- * we don't allow clusters at this moment. 
- */
-struct mbuf *
-m_aux_add(m, af, type)
+/* Get a packet tag structure along with specified data following. */
+struct m_tag *
+m_tag_get(type, len, wait)
+       int type;



Home | Main Index | Thread Index | Old Index