1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate /* 30*7c478bd9Sstevel@tonic-gate * STREAMS Packet Filter Module 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate * This module applies a filter to messages arriving on its read 33*7c478bd9Sstevel@tonic-gate * queue, passing on messages that the filter accepts adn discarding 34*7c478bd9Sstevel@tonic-gate * the others. It supports ioctls for setting the filter. 35*7c478bd9Sstevel@tonic-gate * 36*7c478bd9Sstevel@tonic-gate * On the write side, the module simply passes everything through 37*7c478bd9Sstevel@tonic-gate * unchanged. 38*7c478bd9Sstevel@tonic-gate * 39*7c478bd9Sstevel@tonic-gate * Based on SunOS 4.x version. This version has minor changes: 40*7c478bd9Sstevel@tonic-gate * - general SVR4 porting stuff 41*7c478bd9Sstevel@tonic-gate * - change name and prefixes from "nit" buffer to streams buffer 42*7c478bd9Sstevel@tonic-gate * - multithreading assumes configured as D_MTQPAIR 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/stropts.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 53*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 54*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 55*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 56*7c478bd9Sstevel@tonic-gate #include <sys/strsun.h> 57*7c478bd9Sstevel@tonic-gate #include <sys/pfmod.h> 58*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* 61*7c478bd9Sstevel@tonic-gate * Expanded version of the Packetfilt structure that includes 62*7c478bd9Sstevel@tonic-gate * some additional fields that aid filter execution efficiency. 63*7c478bd9Sstevel@tonic-gate */ 64*7c478bd9Sstevel@tonic-gate struct epacketfilt { 65*7c478bd9Sstevel@tonic-gate struct Pf_ext_packetfilt pf; 66*7c478bd9Sstevel@tonic-gate #define pf_Priority pf.Pf_Priority 67*7c478bd9Sstevel@tonic-gate #define pf_FilterLen pf.Pf_FilterLen 68*7c478bd9Sstevel@tonic-gate #define pf_Filter pf.Pf_Filter 69*7c478bd9Sstevel@tonic-gate /* pointer to word immediately past end of filter */ 70*7c478bd9Sstevel@tonic-gate ushort_t *pf_FilterEnd; 71*7c478bd9Sstevel@tonic-gate /* length in bytes of packet prefix the filter examines */ 72*7c478bd9Sstevel@tonic-gate ushort_t pf_PByteLen; 73*7c478bd9Sstevel@tonic-gate }; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * (Internal) packet descriptor for FilterPacket 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate struct packdesc { 79*7c478bd9Sstevel@tonic-gate ushort_t *pd_hdr; /* header starting address */ 80*7c478bd9Sstevel@tonic-gate uint_t pd_hdrlen; /* header length in shorts */ 81*7c478bd9Sstevel@tonic-gate ushort_t *pd_body; /* body starting address */ 82*7c478bd9Sstevel@tonic-gate uint_t pd_bodylen; /* body length in shorts */ 83*7c478bd9Sstevel@tonic-gate }; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * Function prototypes. 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate static int pfopen(queue_t *, dev_t *, int, int, cred_t *); 90*7c478bd9Sstevel@tonic-gate static int pfclose(queue_t *); 91*7c478bd9Sstevel@tonic-gate static void pfioctl(queue_t *wq, mblk_t *mp); 92*7c478bd9Sstevel@tonic-gate static int FilterPacket(struct packdesc *, struct epacketfilt *); 93*7c478bd9Sstevel@tonic-gate /* 94*7c478bd9Sstevel@tonic-gate * To save instructions, since STREAMS ignores the return value 95*7c478bd9Sstevel@tonic-gate * from these functions, they are defined as void here. Kind of icky, but... 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate static void pfwput(queue_t *, mblk_t *); 98*7c478bd9Sstevel@tonic-gate static void pfrput(queue_t *, mblk_t *); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate static struct module_info pf_minfo = { 101*7c478bd9Sstevel@tonic-gate 22, /* mi_idnum */ 102*7c478bd9Sstevel@tonic-gate "pfmod", /* mi_idname */ 103*7c478bd9Sstevel@tonic-gate 0, /* mi_minpsz */ 104*7c478bd9Sstevel@tonic-gate INFPSZ, /* mi_maxpsz */ 105*7c478bd9Sstevel@tonic-gate 0, /* mi_hiwat */ 106*7c478bd9Sstevel@tonic-gate 0 /* mi_lowat */ 107*7c478bd9Sstevel@tonic-gate }; 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate static struct qinit pf_rinit = { 110*7c478bd9Sstevel@tonic-gate (int (*)())pfrput, /* qi_putp */ 111*7c478bd9Sstevel@tonic-gate NULL, 112*7c478bd9Sstevel@tonic-gate pfopen, /* qi_qopen */ 113*7c478bd9Sstevel@tonic-gate pfclose, /* qi_qclose */ 114*7c478bd9Sstevel@tonic-gate NULL, /* qi_qadmin */ 115*7c478bd9Sstevel@tonic-gate &pf_minfo, /* qi_minfo */ 116*7c478bd9Sstevel@tonic-gate NULL /* qi_mstat */ 117*7c478bd9Sstevel@tonic-gate }; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate static struct qinit pf_winit = { 120*7c478bd9Sstevel@tonic-gate (int (*)())pfwput, /* qi_putp */ 121*7c478bd9Sstevel@tonic-gate NULL, /* qi_srvp */ 122*7c478bd9Sstevel@tonic-gate NULL, /* qi_qopen */ 123*7c478bd9Sstevel@tonic-gate NULL, /* qi_qclose */ 124*7c478bd9Sstevel@tonic-gate NULL, /* qi_qadmin */ 125*7c478bd9Sstevel@tonic-gate &pf_minfo, /* qi_minfo */ 126*7c478bd9Sstevel@tonic-gate NULL /* qi_mstat */ 127*7c478bd9Sstevel@tonic-gate }; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate static struct streamtab pf_info = { 130*7c478bd9Sstevel@tonic-gate &pf_rinit, /* st_rdinit */ 131*7c478bd9Sstevel@tonic-gate &pf_winit, /* st_wrinit */ 132*7c478bd9Sstevel@tonic-gate NULL, /* st_muxrinit */ 133*7c478bd9Sstevel@tonic-gate NULL /* st_muxwinit */ 134*7c478bd9Sstevel@tonic-gate }; 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate static struct fmodsw fsw = { 137*7c478bd9Sstevel@tonic-gate "pfmod", 138*7c478bd9Sstevel@tonic-gate &pf_info, 139*7c478bd9Sstevel@tonic-gate D_MTQPAIR | D_MP 140*7c478bd9Sstevel@tonic-gate }; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate static struct modlstrmod modlstrmod = { 143*7c478bd9Sstevel@tonic-gate &mod_strmodops, "streams packet filter module", &fsw 144*7c478bd9Sstevel@tonic-gate }; 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 147*7c478bd9Sstevel@tonic-gate MODREV_1, &modlstrmod, NULL 148*7c478bd9Sstevel@tonic-gate }; 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate int 151*7c478bd9Sstevel@tonic-gate _init(void) 152*7c478bd9Sstevel@tonic-gate { 153*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 154*7c478bd9Sstevel@tonic-gate } 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate int 157*7c478bd9Sstevel@tonic-gate _fini(void) 158*7c478bd9Sstevel@tonic-gate { 159*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 160*7c478bd9Sstevel@tonic-gate } 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate int 163*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 164*7c478bd9Sstevel@tonic-gate { 165*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 166*7c478bd9Sstevel@tonic-gate } 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 169*7c478bd9Sstevel@tonic-gate static int 170*7c478bd9Sstevel@tonic-gate pfopen(queue_t *rq, dev_t *dev, int oflag, int sflag, cred_t *crp) 171*7c478bd9Sstevel@tonic-gate { 172*7c478bd9Sstevel@tonic-gate struct epacketfilt *pfp; 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate ASSERT(rq); 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate if (sflag != MODOPEN) 177*7c478bd9Sstevel@tonic-gate return (EINVAL); 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate if (rq->q_ptr) 180*7c478bd9Sstevel@tonic-gate return (0); 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate /* 183*7c478bd9Sstevel@tonic-gate * Allocate and initialize per-Stream structure. 184*7c478bd9Sstevel@tonic-gate */ 185*7c478bd9Sstevel@tonic-gate pfp = kmem_alloc(sizeof (struct epacketfilt), KM_SLEEP); 186*7c478bd9Sstevel@tonic-gate rq->q_ptr = WR(rq)->q_ptr = (char *)pfp; 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate qprocson(rq); 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate return (0); 191*7c478bd9Sstevel@tonic-gate } 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate static int 194*7c478bd9Sstevel@tonic-gate pfclose(queue_t *rq) 195*7c478bd9Sstevel@tonic-gate { 196*7c478bd9Sstevel@tonic-gate struct epacketfilt *pfp = (struct epacketfilt *)rq->q_ptr; 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate ASSERT(pfp); 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate qprocsoff(rq); 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate kmem_free(pfp, sizeof (struct epacketfilt)); 203*7c478bd9Sstevel@tonic-gate rq->q_ptr = WR(rq)->q_ptr = NULL; 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate return (0); 206*7c478bd9Sstevel@tonic-gate } 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate /* 209*7c478bd9Sstevel@tonic-gate * Write-side put procedure. Its main task is to detect ioctls. 210*7c478bd9Sstevel@tonic-gate * Other message types are passed on through. 211*7c478bd9Sstevel@tonic-gate */ 212*7c478bd9Sstevel@tonic-gate static void 213*7c478bd9Sstevel@tonic-gate pfwput(queue_t *wq, mblk_t *mp) 214*7c478bd9Sstevel@tonic-gate { 215*7c478bd9Sstevel@tonic-gate switch (mp->b_datap->db_type) { 216*7c478bd9Sstevel@tonic-gate case M_IOCTL: 217*7c478bd9Sstevel@tonic-gate pfioctl(wq, mp); 218*7c478bd9Sstevel@tonic-gate break; 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate default: 221*7c478bd9Sstevel@tonic-gate putnext(wq, mp); 222*7c478bd9Sstevel@tonic-gate break; 223*7c478bd9Sstevel@tonic-gate } 224*7c478bd9Sstevel@tonic-gate } 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate /* 227*7c478bd9Sstevel@tonic-gate * Read-side put procedure. It's responsible for applying the 228*7c478bd9Sstevel@tonic-gate * packet filter and passing upstream message on or discarding it 229*7c478bd9Sstevel@tonic-gate * depending upon the results. 230*7c478bd9Sstevel@tonic-gate * 231*7c478bd9Sstevel@tonic-gate * Upstream messages can start with zero or more M_PROTO mblks 232*7c478bd9Sstevel@tonic-gate * which are skipped over before executing the packet filter 233*7c478bd9Sstevel@tonic-gate * on any remaining M_DATA mblks. 234*7c478bd9Sstevel@tonic-gate */ 235*7c478bd9Sstevel@tonic-gate static void 236*7c478bd9Sstevel@tonic-gate pfrput(queue_t *rq, mblk_t *mp) 237*7c478bd9Sstevel@tonic-gate { 238*7c478bd9Sstevel@tonic-gate struct epacketfilt *pfp = (struct epacketfilt *)rq->q_ptr; 239*7c478bd9Sstevel@tonic-gate mblk_t *mbp, *mpp; 240*7c478bd9Sstevel@tonic-gate struct packdesc pd; 241*7c478bd9Sstevel@tonic-gate int need; 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate ASSERT(pfp); 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate switch (DB_TYPE(mp)) { 246*7c478bd9Sstevel@tonic-gate case M_PROTO: 247*7c478bd9Sstevel@tonic-gate case M_DATA: 248*7c478bd9Sstevel@tonic-gate /* 249*7c478bd9Sstevel@tonic-gate * Skip over protocol information and find the start 250*7c478bd9Sstevel@tonic-gate * of the message body, saving the overall message 251*7c478bd9Sstevel@tonic-gate * start in mpp. 252*7c478bd9Sstevel@tonic-gate */ 253*7c478bd9Sstevel@tonic-gate for (mpp = mp; mp && (DB_TYPE(mp) == M_PROTO); mp = mp->b_cont) 254*7c478bd9Sstevel@tonic-gate ; 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate /* 257*7c478bd9Sstevel@tonic-gate * Null body (exclusive of M_PROTO blocks) ==> accept. 258*7c478bd9Sstevel@tonic-gate * Note that a null body is not the same as an empty body. 259*7c478bd9Sstevel@tonic-gate */ 260*7c478bd9Sstevel@tonic-gate if (mp == NULL) { 261*7c478bd9Sstevel@tonic-gate putnext(rq, mpp); 262*7c478bd9Sstevel@tonic-gate break; 263*7c478bd9Sstevel@tonic-gate } 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate /* 266*7c478bd9Sstevel@tonic-gate * Pull the packet up to the length required by 267*7c478bd9Sstevel@tonic-gate * the filter. Note that doing so destroys sharing 268*7c478bd9Sstevel@tonic-gate * relationships, which is unfortunate, since the 269*7c478bd9Sstevel@tonic-gate * results of pulling up here are likely to be useful 270*7c478bd9Sstevel@tonic-gate * for shared messages applied to a filter on a sibling 271*7c478bd9Sstevel@tonic-gate * stream. 272*7c478bd9Sstevel@tonic-gate * 273*7c478bd9Sstevel@tonic-gate * Most packet sources will provide the packet in two 274*7c478bd9Sstevel@tonic-gate * logical pieces: an initial header in a single mblk, 275*7c478bd9Sstevel@tonic-gate * and a body in a sequence of mblks hooked to the 276*7c478bd9Sstevel@tonic-gate * header. We're prepared to deal with variant forms, 277*7c478bd9Sstevel@tonic-gate * but in any case, the pullup applies only to the body 278*7c478bd9Sstevel@tonic-gate * part. 279*7c478bd9Sstevel@tonic-gate */ 280*7c478bd9Sstevel@tonic-gate mbp = mp->b_cont; 281*7c478bd9Sstevel@tonic-gate need = pfp->pf_PByteLen; 282*7c478bd9Sstevel@tonic-gate if (mbp && (MBLKL(mbp) < need)) { 283*7c478bd9Sstevel@tonic-gate int len = msgdsize(mbp); 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate /* XXX discard silently on pullupmsg failure */ 286*7c478bd9Sstevel@tonic-gate if (pullupmsg(mbp, MIN(need, len)) == 0) { 287*7c478bd9Sstevel@tonic-gate freemsg(mpp); 288*7c478bd9Sstevel@tonic-gate break; 289*7c478bd9Sstevel@tonic-gate } 290*7c478bd9Sstevel@tonic-gate } 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate /* 293*7c478bd9Sstevel@tonic-gate * Misalignment (not on short boundary) ==> reject. 294*7c478bd9Sstevel@tonic-gate */ 295*7c478bd9Sstevel@tonic-gate if (((uintptr_t)mp->b_rptr & (sizeof (ushort_t) - 1)) || 296*7c478bd9Sstevel@tonic-gate (mbp != NULL && 297*7c478bd9Sstevel@tonic-gate ((uintptr_t)mbp->b_rptr & (sizeof (ushort_t) - 1)))) { 298*7c478bd9Sstevel@tonic-gate freemsg(mpp); 299*7c478bd9Sstevel@tonic-gate break; 300*7c478bd9Sstevel@tonic-gate } 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate /* 303*7c478bd9Sstevel@tonic-gate * These assignments are distasteful, but necessary, 304*7c478bd9Sstevel@tonic-gate * since the packet filter wants to work in terms of 305*7c478bd9Sstevel@tonic-gate * shorts. Odd bytes at the end of header or data can't 306*7c478bd9Sstevel@tonic-gate * participate in the filtering operation. 307*7c478bd9Sstevel@tonic-gate */ 308*7c478bd9Sstevel@tonic-gate pd.pd_hdr = (ushort_t *)mp->b_rptr; 309*7c478bd9Sstevel@tonic-gate pd.pd_hdrlen = (mp->b_wptr - mp->b_rptr) / sizeof (ushort_t); 310*7c478bd9Sstevel@tonic-gate if (mbp) { 311*7c478bd9Sstevel@tonic-gate pd.pd_body = (ushort_t *)mbp->b_rptr; 312*7c478bd9Sstevel@tonic-gate pd.pd_bodylen = (mbp->b_wptr - mbp->b_rptr) / 313*7c478bd9Sstevel@tonic-gate sizeof (ushort_t); 314*7c478bd9Sstevel@tonic-gate } else { 315*7c478bd9Sstevel@tonic-gate pd.pd_body = NULL; 316*7c478bd9Sstevel@tonic-gate pd.pd_bodylen = 0; 317*7c478bd9Sstevel@tonic-gate } 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate /* 320*7c478bd9Sstevel@tonic-gate * Apply the filter. 321*7c478bd9Sstevel@tonic-gate */ 322*7c478bd9Sstevel@tonic-gate if (FilterPacket(&pd, pfp)) 323*7c478bd9Sstevel@tonic-gate putnext(rq, mpp); 324*7c478bd9Sstevel@tonic-gate else 325*7c478bd9Sstevel@tonic-gate freemsg(mpp); 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate break; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate default: 330*7c478bd9Sstevel@tonic-gate putnext(rq, mp); 331*7c478bd9Sstevel@tonic-gate break; 332*7c478bd9Sstevel@tonic-gate } 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate } 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate /* 337*7c478bd9Sstevel@tonic-gate * Handle write-side M_IOCTL messages. 338*7c478bd9Sstevel@tonic-gate */ 339*7c478bd9Sstevel@tonic-gate static void 340*7c478bd9Sstevel@tonic-gate pfioctl(queue_t *wq, mblk_t *mp) 341*7c478bd9Sstevel@tonic-gate { 342*7c478bd9Sstevel@tonic-gate struct epacketfilt *pfp = (struct epacketfilt *)wq->q_ptr; 343*7c478bd9Sstevel@tonic-gate struct Pf_ext_packetfilt *upfp; 344*7c478bd9Sstevel@tonic-gate struct packetfilt *opfp; 345*7c478bd9Sstevel@tonic-gate ushort_t *fwp; 346*7c478bd9Sstevel@tonic-gate int maxoff, arg; 347*7c478bd9Sstevel@tonic-gate struct iocblk *iocp = (struct iocblk *)mp->b_rptr; 348*7c478bd9Sstevel@tonic-gate int error; 349*7c478bd9Sstevel@tonic-gate 350*7c478bd9Sstevel@tonic-gate switch (iocp->ioc_cmd) { 351*7c478bd9Sstevel@tonic-gate case PFIOCSETF: 352*7c478bd9Sstevel@tonic-gate /* 353*7c478bd9Sstevel@tonic-gate * Verify argument length. Since the size of packet filter 354*7c478bd9Sstevel@tonic-gate * got increased (ENMAXFILTERS was bumped up to 2047), to 355*7c478bd9Sstevel@tonic-gate * maintain backwards binary compatibility, we need to 356*7c478bd9Sstevel@tonic-gate * check for both possible sizes. 357*7c478bd9Sstevel@tonic-gate */ 358*7c478bd9Sstevel@tonic-gate switch (iocp->ioc_count) { 359*7c478bd9Sstevel@tonic-gate case sizeof (struct Pf_ext_packetfilt): 360*7c478bd9Sstevel@tonic-gate error = miocpullup(mp, 361*7c478bd9Sstevel@tonic-gate sizeof (struct Pf_ext_packetfilt)); 362*7c478bd9Sstevel@tonic-gate if (error != 0) { 363*7c478bd9Sstevel@tonic-gate miocnak(wq, mp, 0, error); 364*7c478bd9Sstevel@tonic-gate return; 365*7c478bd9Sstevel@tonic-gate } 366*7c478bd9Sstevel@tonic-gate upfp = (struct Pf_ext_packetfilt *)mp->b_cont->b_rptr; 367*7c478bd9Sstevel@tonic-gate if (upfp->Pf_FilterLen > PF_MAXFILTERS) { 368*7c478bd9Sstevel@tonic-gate miocnak(wq, mp, 0, EINVAL); 369*7c478bd9Sstevel@tonic-gate return; 370*7c478bd9Sstevel@tonic-gate } 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate bcopy(upfp, pfp, sizeof (struct Pf_ext_packetfilt)); 373*7c478bd9Sstevel@tonic-gate pfp->pf_FilterEnd = &pfp->pf_Filter[pfp->pf_FilterLen]; 374*7c478bd9Sstevel@tonic-gate break; 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate case sizeof (struct packetfilt): 377*7c478bd9Sstevel@tonic-gate error = miocpullup(mp, sizeof (struct packetfilt)); 378*7c478bd9Sstevel@tonic-gate if (error != 0) { 379*7c478bd9Sstevel@tonic-gate miocnak(wq, mp, 0, error); 380*7c478bd9Sstevel@tonic-gate return; 381*7c478bd9Sstevel@tonic-gate } 382*7c478bd9Sstevel@tonic-gate opfp = (struct packetfilt *)mp->b_cont->b_rptr; 383*7c478bd9Sstevel@tonic-gate /* this strange comparison keeps gcc from complaining */ 384*7c478bd9Sstevel@tonic-gate if (opfp->Pf_FilterLen - 1 >= ENMAXFILTERS) { 385*7c478bd9Sstevel@tonic-gate miocnak(wq, mp, 0, EINVAL); 386*7c478bd9Sstevel@tonic-gate return; 387*7c478bd9Sstevel@tonic-gate } 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate pfp->pf.Pf_Priority = opfp->Pf_Priority; 390*7c478bd9Sstevel@tonic-gate pfp->pf.Pf_FilterLen = (unsigned int)opfp->Pf_FilterLen; 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate bcopy(opfp->Pf_Filter, pfp->pf.Pf_Filter, 393*7c478bd9Sstevel@tonic-gate sizeof (opfp->Pf_Filter)); 394*7c478bd9Sstevel@tonic-gate pfp->pf_FilterEnd = &pfp->pf_Filter[pfp->pf_FilterLen]; 395*7c478bd9Sstevel@tonic-gate break; 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate default: 398*7c478bd9Sstevel@tonic-gate miocnak(wq, mp, 0, EINVAL); 399*7c478bd9Sstevel@tonic-gate return; 400*7c478bd9Sstevel@tonic-gate } 401*7c478bd9Sstevel@tonic-gate 402*7c478bd9Sstevel@tonic-gate /* 403*7c478bd9Sstevel@tonic-gate * Find and record maximum byte offset that the 404*7c478bd9Sstevel@tonic-gate * filter users. We use this when executing the 405*7c478bd9Sstevel@tonic-gate * filter to determine how much of the packet 406*7c478bd9Sstevel@tonic-gate * body to pull up. This code depends on the 407*7c478bd9Sstevel@tonic-gate * filter encoding. 408*7c478bd9Sstevel@tonic-gate */ 409*7c478bd9Sstevel@tonic-gate maxoff = 0; 410*7c478bd9Sstevel@tonic-gate for (fwp = pfp->pf_Filter; fwp < pfp->pf_FilterEnd; fwp++) { 411*7c478bd9Sstevel@tonic-gate arg = *fwp & ((1 << ENF_NBPA) - 1); 412*7c478bd9Sstevel@tonic-gate switch (arg) { 413*7c478bd9Sstevel@tonic-gate default: 414*7c478bd9Sstevel@tonic-gate if ((arg -= ENF_PUSHWORD) > maxoff) 415*7c478bd9Sstevel@tonic-gate maxoff = arg; 416*7c478bd9Sstevel@tonic-gate break; 417*7c478bd9Sstevel@tonic-gate 418*7c478bd9Sstevel@tonic-gate case ENF_PUSHLIT: 419*7c478bd9Sstevel@tonic-gate /* Skip over the literal. */ 420*7c478bd9Sstevel@tonic-gate fwp++; 421*7c478bd9Sstevel@tonic-gate break; 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate case ENF_PUSHZERO: 424*7c478bd9Sstevel@tonic-gate case ENF_PUSHONE: 425*7c478bd9Sstevel@tonic-gate case ENF_PUSHFFFF: 426*7c478bd9Sstevel@tonic-gate case ENF_PUSHFF00: 427*7c478bd9Sstevel@tonic-gate case ENF_PUSH00FF: 428*7c478bd9Sstevel@tonic-gate case ENF_NOPUSH: 429*7c478bd9Sstevel@tonic-gate break; 430*7c478bd9Sstevel@tonic-gate } 431*7c478bd9Sstevel@tonic-gate } 432*7c478bd9Sstevel@tonic-gate 433*7c478bd9Sstevel@tonic-gate /* 434*7c478bd9Sstevel@tonic-gate * Convert word offset to length in bytes. 435*7c478bd9Sstevel@tonic-gate */ 436*7c478bd9Sstevel@tonic-gate pfp->pf_PByteLen = (maxoff + 1) * sizeof (ushort_t); 437*7c478bd9Sstevel@tonic-gate 438*7c478bd9Sstevel@tonic-gate miocack(wq, mp, 0, 0); 439*7c478bd9Sstevel@tonic-gate break; 440*7c478bd9Sstevel@tonic-gate 441*7c478bd9Sstevel@tonic-gate default: 442*7c478bd9Sstevel@tonic-gate putnext(wq, mp); 443*7c478bd9Sstevel@tonic-gate break; 444*7c478bd9Sstevel@tonic-gate } 445*7c478bd9Sstevel@tonic-gate } 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate /* #define DEBUG 1 */ 448*7c478bd9Sstevel@tonic-gate /* #define INNERDEBUG 1 */ 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 451*7c478bd9Sstevel@tonic-gate #define enprintf(flags) if (enDebug & (flags)) printf 452*7c478bd9Sstevel@tonic-gate 453*7c478bd9Sstevel@tonic-gate /* 454*7c478bd9Sstevel@tonic-gate * Symbolic definitions for enDebug flag bits 455*7c478bd9Sstevel@tonic-gate * ENDBG_TRACE should be 1 because it is the most common 456*7c478bd9Sstevel@tonic-gate * use in the code, and the compiler generates faster code 457*7c478bd9Sstevel@tonic-gate * for testing the low bit in a word. 458*7c478bd9Sstevel@tonic-gate */ 459*7c478bd9Sstevel@tonic-gate 460*7c478bd9Sstevel@tonic-gate #define ENDBG_TRACE 1 /* trace most operations */ 461*7c478bd9Sstevel@tonic-gate #define ENDBG_DESQ 2 /* trace descriptor queues */ 462*7c478bd9Sstevel@tonic-gate #define ENDBG_INIT 4 /* initialization info */ 463*7c478bd9Sstevel@tonic-gate #define ENDBG_SCAV 8 /* scavenger operation */ 464*7c478bd9Sstevel@tonic-gate #define ENDBG_ABNORM 16 /* abnormal events */ 465*7c478bd9Sstevel@tonic-gate 466*7c478bd9Sstevel@tonic-gate int enDebug = /* ENDBG_ABNORM | ENDBG_INIT | ENDBG_TRACE */ -1; 467*7c478bd9Sstevel@tonic-gate #endif /* INNERDEBUG */ 468*7c478bd9Sstevel@tonic-gate 469*7c478bd9Sstevel@tonic-gate /* 470*7c478bd9Sstevel@tonic-gate * Apply the packet filter given by pfp to the packet given by 471*7c478bd9Sstevel@tonic-gate * pp. Return nonzero iff the filter accepts the packet. 472*7c478bd9Sstevel@tonic-gate * 473*7c478bd9Sstevel@tonic-gate * The packet comes in two pieces, a header and a body, since 474*7c478bd9Sstevel@tonic-gate * that's the most convenient form for our caller. The header 475*7c478bd9Sstevel@tonic-gate * is in contiguous memory, whereas the body is in a mbuf. 476*7c478bd9Sstevel@tonic-gate * Our caller will have adjusted the mbuf chain so that its first 477*7c478bd9Sstevel@tonic-gate * min(MLEN, length(body)) bytes are guaranteed contiguous. For 478*7c478bd9Sstevel@tonic-gate * the sake of efficiency (and some laziness) the filter is prepared 479*7c478bd9Sstevel@tonic-gate * to examine only these two contiguous pieces. Furthermore, it 480*7c478bd9Sstevel@tonic-gate * assumes that the header length is even, so that there's no need 481*7c478bd9Sstevel@tonic-gate * to glue the last byte of header to the first byte of data. 482*7c478bd9Sstevel@tonic-gate */ 483*7c478bd9Sstevel@tonic-gate 484*7c478bd9Sstevel@tonic-gate #define opx(i) ((i) >> ENF_NBPA) 485*7c478bd9Sstevel@tonic-gate 486*7c478bd9Sstevel@tonic-gate static int 487*7c478bd9Sstevel@tonic-gate FilterPacket(struct packdesc *pp, struct epacketfilt *pfp) 488*7c478bd9Sstevel@tonic-gate { 489*7c478bd9Sstevel@tonic-gate int maxhdr = pp->pd_hdrlen; 490*7c478bd9Sstevel@tonic-gate int maxword = maxhdr + pp->pd_bodylen; 491*7c478bd9Sstevel@tonic-gate ushort_t *sp; 492*7c478bd9Sstevel@tonic-gate ushort_t *fp; 493*7c478bd9Sstevel@tonic-gate ushort_t *fpe; 494*7c478bd9Sstevel@tonic-gate unsigned op; 495*7c478bd9Sstevel@tonic-gate unsigned arg; 496*7c478bd9Sstevel@tonic-gate ushort_t stack[ENMAXFILTERS+1]; 497*7c478bd9Sstevel@tonic-gate 498*7c478bd9Sstevel@tonic-gate fp = &pfp->pf_Filter[0]; 499*7c478bd9Sstevel@tonic-gate fpe = pfp->pf_FilterEnd; 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 502*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("FilterPacket(%p, %p, %p, %p):\n", 503*7c478bd9Sstevel@tonic-gate pp, pfp, fp, fpe); 504*7c478bd9Sstevel@tonic-gate #endif 505*7c478bd9Sstevel@tonic-gate 506*7c478bd9Sstevel@tonic-gate /* 507*7c478bd9Sstevel@tonic-gate * Push TRUE on stack to start. The stack size is chosen such 508*7c478bd9Sstevel@tonic-gate * that overflow can't occur -- each operation can push at most 509*7c478bd9Sstevel@tonic-gate * one item on the stack, and the stack size equals the maximum 510*7c478bd9Sstevel@tonic-gate * program length. 511*7c478bd9Sstevel@tonic-gate */ 512*7c478bd9Sstevel@tonic-gate sp = &stack[ENMAXFILTERS]; 513*7c478bd9Sstevel@tonic-gate *sp = 1; 514*7c478bd9Sstevel@tonic-gate 515*7c478bd9Sstevel@tonic-gate while (fp < fpe) { 516*7c478bd9Sstevel@tonic-gate op = *fp >> ENF_NBPA; 517*7c478bd9Sstevel@tonic-gate arg = *fp & ((1 << ENF_NBPA) - 1); 518*7c478bd9Sstevel@tonic-gate fp++; 519*7c478bd9Sstevel@tonic-gate 520*7c478bd9Sstevel@tonic-gate switch (arg) { 521*7c478bd9Sstevel@tonic-gate default: 522*7c478bd9Sstevel@tonic-gate arg -= ENF_PUSHWORD; 523*7c478bd9Sstevel@tonic-gate /* 524*7c478bd9Sstevel@tonic-gate * Since arg is unsigned, 525*7c478bd9Sstevel@tonic-gate * if it were less than ENF_PUSHWORD before, 526*7c478bd9Sstevel@tonic-gate * it would now be huge. 527*7c478bd9Sstevel@tonic-gate */ 528*7c478bd9Sstevel@tonic-gate if (arg < maxhdr) 529*7c478bd9Sstevel@tonic-gate *--sp = pp->pd_hdr[arg]; 530*7c478bd9Sstevel@tonic-gate else if (arg < maxword) 531*7c478bd9Sstevel@tonic-gate *--sp = pp->pd_body[arg - maxhdr]; 532*7c478bd9Sstevel@tonic-gate else { 533*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 534*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>0(len)\n"); 535*7c478bd9Sstevel@tonic-gate #endif 536*7c478bd9Sstevel@tonic-gate return (0); 537*7c478bd9Sstevel@tonic-gate } 538*7c478bd9Sstevel@tonic-gate break; 539*7c478bd9Sstevel@tonic-gate case ENF_PUSHLIT: 540*7c478bd9Sstevel@tonic-gate *--sp = *fp++; 541*7c478bd9Sstevel@tonic-gate break; 542*7c478bd9Sstevel@tonic-gate case ENF_PUSHZERO: 543*7c478bd9Sstevel@tonic-gate *--sp = 0; 544*7c478bd9Sstevel@tonic-gate break; 545*7c478bd9Sstevel@tonic-gate case ENF_PUSHONE: 546*7c478bd9Sstevel@tonic-gate *--sp = 1; 547*7c478bd9Sstevel@tonic-gate break; 548*7c478bd9Sstevel@tonic-gate case ENF_PUSHFFFF: 549*7c478bd9Sstevel@tonic-gate *--sp = 0xffff; 550*7c478bd9Sstevel@tonic-gate break; 551*7c478bd9Sstevel@tonic-gate case ENF_PUSHFF00: 552*7c478bd9Sstevel@tonic-gate *--sp = 0xff00; 553*7c478bd9Sstevel@tonic-gate break; 554*7c478bd9Sstevel@tonic-gate case ENF_PUSH00FF: 555*7c478bd9Sstevel@tonic-gate *--sp = 0x00ff; 556*7c478bd9Sstevel@tonic-gate break; 557*7c478bd9Sstevel@tonic-gate case ENF_NOPUSH: 558*7c478bd9Sstevel@tonic-gate break; 559*7c478bd9Sstevel@tonic-gate } 560*7c478bd9Sstevel@tonic-gate 561*7c478bd9Sstevel@tonic-gate if (sp < &stack[2]) { /* check stack overflow: small yellow zone */ 562*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 563*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>0(--sp)\n"); 564*7c478bd9Sstevel@tonic-gate #endif 565*7c478bd9Sstevel@tonic-gate return (0); 566*7c478bd9Sstevel@tonic-gate } 567*7c478bd9Sstevel@tonic-gate 568*7c478bd9Sstevel@tonic-gate if (op == ENF_NOP) 569*7c478bd9Sstevel@tonic-gate continue; 570*7c478bd9Sstevel@tonic-gate 571*7c478bd9Sstevel@tonic-gate /* 572*7c478bd9Sstevel@tonic-gate * all non-NOP operators binary, must have at least two operands 573*7c478bd9Sstevel@tonic-gate * on stack to evaluate. 574*7c478bd9Sstevel@tonic-gate */ 575*7c478bd9Sstevel@tonic-gate if (sp > &stack[ENMAXFILTERS-2]) { 576*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 577*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>0(sp++)\n"); 578*7c478bd9Sstevel@tonic-gate #endif 579*7c478bd9Sstevel@tonic-gate return (0); 580*7c478bd9Sstevel@tonic-gate } 581*7c478bd9Sstevel@tonic-gate 582*7c478bd9Sstevel@tonic-gate arg = *sp++; 583*7c478bd9Sstevel@tonic-gate switch (op) { 584*7c478bd9Sstevel@tonic-gate default: 585*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 586*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>0(def)\n"); 587*7c478bd9Sstevel@tonic-gate #endif 588*7c478bd9Sstevel@tonic-gate return (0); 589*7c478bd9Sstevel@tonic-gate case opx(ENF_AND): 590*7c478bd9Sstevel@tonic-gate *sp &= arg; 591*7c478bd9Sstevel@tonic-gate break; 592*7c478bd9Sstevel@tonic-gate case opx(ENF_OR): 593*7c478bd9Sstevel@tonic-gate *sp |= arg; 594*7c478bd9Sstevel@tonic-gate break; 595*7c478bd9Sstevel@tonic-gate case opx(ENF_XOR): 596*7c478bd9Sstevel@tonic-gate *sp ^= arg; 597*7c478bd9Sstevel@tonic-gate break; 598*7c478bd9Sstevel@tonic-gate case opx(ENF_EQ): 599*7c478bd9Sstevel@tonic-gate *sp = (*sp == arg); 600*7c478bd9Sstevel@tonic-gate break; 601*7c478bd9Sstevel@tonic-gate case opx(ENF_NEQ): 602*7c478bd9Sstevel@tonic-gate *sp = (*sp != arg); 603*7c478bd9Sstevel@tonic-gate break; 604*7c478bd9Sstevel@tonic-gate case opx(ENF_LT): 605*7c478bd9Sstevel@tonic-gate *sp = (*sp < arg); 606*7c478bd9Sstevel@tonic-gate break; 607*7c478bd9Sstevel@tonic-gate case opx(ENF_LE): 608*7c478bd9Sstevel@tonic-gate *sp = (*sp <= arg); 609*7c478bd9Sstevel@tonic-gate break; 610*7c478bd9Sstevel@tonic-gate case opx(ENF_GT): 611*7c478bd9Sstevel@tonic-gate *sp = (*sp > arg); 612*7c478bd9Sstevel@tonic-gate break; 613*7c478bd9Sstevel@tonic-gate case opx(ENF_GE): 614*7c478bd9Sstevel@tonic-gate *sp = (*sp >= arg); 615*7c478bd9Sstevel@tonic-gate break; 616*7c478bd9Sstevel@tonic-gate 617*7c478bd9Sstevel@tonic-gate /* short-circuit operators */ 618*7c478bd9Sstevel@tonic-gate 619*7c478bd9Sstevel@tonic-gate case opx(ENF_COR): 620*7c478bd9Sstevel@tonic-gate if (*sp++ == arg) { 621*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 622*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>COR %x\n", *sp); 623*7c478bd9Sstevel@tonic-gate #endif 624*7c478bd9Sstevel@tonic-gate return (1); 625*7c478bd9Sstevel@tonic-gate } 626*7c478bd9Sstevel@tonic-gate break; 627*7c478bd9Sstevel@tonic-gate case opx(ENF_CAND): 628*7c478bd9Sstevel@tonic-gate if (*sp++ != arg) { 629*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 630*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>CAND %x\n", *sp); 631*7c478bd9Sstevel@tonic-gate #endif 632*7c478bd9Sstevel@tonic-gate return (0); 633*7c478bd9Sstevel@tonic-gate } 634*7c478bd9Sstevel@tonic-gate break; 635*7c478bd9Sstevel@tonic-gate case opx(ENF_CNOR): 636*7c478bd9Sstevel@tonic-gate if (*sp++ == arg) { 637*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 638*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>COR %x\n", *sp); 639*7c478bd9Sstevel@tonic-gate #endif 640*7c478bd9Sstevel@tonic-gate return (0); 641*7c478bd9Sstevel@tonic-gate } 642*7c478bd9Sstevel@tonic-gate break; 643*7c478bd9Sstevel@tonic-gate case opx(ENF_CNAND): 644*7c478bd9Sstevel@tonic-gate if (*sp++ != arg) { 645*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 646*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>CNAND %x\n", *sp); 647*7c478bd9Sstevel@tonic-gate #endif 648*7c478bd9Sstevel@tonic-gate return (1); 649*7c478bd9Sstevel@tonic-gate } 650*7c478bd9Sstevel@tonic-gate break; 651*7c478bd9Sstevel@tonic-gate } 652*7c478bd9Sstevel@tonic-gate } 653*7c478bd9Sstevel@tonic-gate #ifdef INNERDEBUG 654*7c478bd9Sstevel@tonic-gate enprintf(ENDBG_TRACE)("=>%x\n", *sp); 655*7c478bd9Sstevel@tonic-gate #endif 656*7c478bd9Sstevel@tonic-gate return (*sp); 657*7c478bd9Sstevel@tonic-gate } 658