solaris.c revision 23f4867fdff96a11dd674de6259a5a0d0a13251c
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz/*
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * Copyright (C) 1993-2001, 2003 by Darren Reed.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * See the IPFILTER.LICENCE file for details on licencing.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * Use is subject to license terms.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz/* #pragma ident "@(#)solaris.c 1.12 6/5/96 (C) 1995 Darren Reed"*/
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#pragma ident "@(#)$Id: solaris.c,v 2.73.2.6 2005/07/13 21:40:47 darrenr Exp $"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#pragma ident "%Z%%M% %I% %E% SMI"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/systm.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/types.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/param.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/errno.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/uio.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/buf.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/modctl.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/open.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/kmem.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/conf.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/cmn_err.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/stat.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/cred.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/dditypes.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/poll.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/autoconf.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/byteorder.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/socket.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/dlpi.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/stropts.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/kstat.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/sockio.h>
381a2a9a387f449fab7d0c7e97c4184c26963abfdr#include <sys/neti.h>
381a2a9a387f449fab7d0c7e97c4184c26963abfdr#include <sys/hook.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <net/if.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 >= 6
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz# include <net/if_types.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#include <sys/netstack.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <net/af.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <net/route.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/in.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/in_systm.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/if_ether.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/ip.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/ip_var.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/tcp.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/udp.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/tcpip.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <netinet/ip_icmp.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/ddi.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include <sys/sunddi.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_compat.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ipl.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_fil.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_nat.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_frag.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_auth.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#include "netinet/ip_state.h"
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#include "netinet/ipf_stack.h"
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzextern int iplwrite __P((dev_t, struct uio *, cred_t *));
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_getinfo __P((dev_info_t *, ddi_info_cmd_t,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz void *, void **));
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 < 10
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_identify __P((dev_info_t *));
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_attach __P((dev_info_t *, ddi_attach_cmd_t));
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_detach __P((dev_info_t *, ddi_detach_cmd_t));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic int ipf_property_g_update __P((dev_info_t *));
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic char *ipf_devfiles[] = { IPL_NAME, IPNAT_NAME, IPSTATE_NAME,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz IPAUTH_NAME, IPSYNC_NAME, IPSCAN_NAME,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz IPLOOKUP_NAME, NULL };
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic struct cb_ops ipf_cb_ops = {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz iplopen,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz iplclose,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* strategy */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* print */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* dump */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz iplread,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz iplwrite, /* write */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz iplioctl, /* ioctl */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* devmap */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* mmap */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* segmap */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nochpoll, /* poll */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_prop_op,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz NULL,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz D_MTSAFE,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 > 4
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz CB_REV,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* aread */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* awrite */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz};
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic struct dev_ops ipf_ops = {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz DEVO_REV,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz 0,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_getinfo,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 >= 10
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nulldev,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#else
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_identify,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nulldev,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_attach,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_detach,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz nodev, /* reset */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz &ipf_cb_ops,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz (struct bus_ops *)0
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz};
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzextern struct mod_ops mod_driverops;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic struct modldrv iplmod = {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz &mod_driverops, IPL_VERSION, &ipf_ops };
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic struct modlinkage modlink1 = { MODREV_1, &iplmod, NULL };
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 >= 6
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic size_t hdrsizes[57][2] = {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { 0, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_OTHER, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_1822, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_HDH1822, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_X25DDN, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_X25, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ETHER, 14 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISO88023, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISO88024, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISO88025, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISO88026, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_STARLAN, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_P10, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_P80, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_HY, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_FDDI, 24 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_LAPB, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SDLC, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_T1, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_CEPT, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISDNBASIC, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISDNPRIMARY, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_PTPSERIAL, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_PPP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_LOOP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_EON, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_XETHER, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_NSIP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SLIP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ULTRA, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_DS3, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SIP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_FRELAY, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_RS232, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_PARA, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ARCNET, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ARCNETPLUS, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ATM, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_MIOX25, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SONET, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_X25PLE, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_ISO88022LLC, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_LOCALTALK, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SMDSDXI, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_FRELAYDCE, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_V35, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_HSSI, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_HIPPI, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_MODEM, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_AAL5, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SONETPATH, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SONETVT, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_SMDSICIP, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_PROPVIRTUAL, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { IFT_PROPMUX, 0 },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz};
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif /* SOLARIS2 >= 6 */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhdev_info_t *ipf_dev_info = NULL;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic const filter_kstats_t ipf_kstat_tmp = {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "pass", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "block", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "nomatch", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "short", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "pass, logged", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "block, logged", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "nomatch, logged", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "logged", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "skip", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "return sent", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "acct", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "bad frag state alloc", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "new frag state kept", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "new frag state compl. pkt", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "bad pkt state alloc", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "new pkt kept state", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "cachehit", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "tcp cksum bad", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz {{ "pullup ok", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "pullup nok", KSTAT_DATA_ULONG }},
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "src != route", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "ttl invalid", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "bad ip pkt", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "ipv6 pkt", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "dropped:pps ceiling", KSTAT_DATA_ULONG },
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz { "ip upd. fail", KSTAT_DATA_ULONG }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz};
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
381a2a9a387f449fab7d0c7e97c4184c26963abfdr
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_kstat_update(kstat_t *ksp, int rwflag);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic void
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_kstat_init(ipf_stack_t *ifs, netstackid_t stackid)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int i;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz for (i = 0; i < 2; i++) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[i] = kstat_create_netstack("ipf", 0,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz (i==0)?"inbound":"outbound",
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz "net",
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz KSTAT_TYPE_NAMED,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz sizeof (filter_kstats_t) / sizeof (kstat_named_t),
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh 0, stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_kstatp[i] != NULL) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[i]->ks_data,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz sizeof (filter_kstats_t));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[i]->ks_update = ipf_kstat_update;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[i]->ks_private = &ifs->ifs_frstats[i];
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh kstat_install(ifs->ifs_kstatp[i]);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: ipf_kstat_init() installed 0x%x, 0x%x",
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[0], ifs->ifs_kstatp[1]);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic void
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_kstat_fini(ipf_stack_t *ifs, netstackid_t stackid)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int i;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz for (i = 0; i < 2; i++) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_kstatp[i] != NULL) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh kstat_delete_netstack(ifs->ifs_kstatp[i], stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[i] = NULL;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzipf_kstat_update(kstat_t *ksp, int rwflag)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz filter_kstats_t *fkp;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz filterstats_t *fsp;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ksp == NULL || ksp->ks_data == NULL)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (EIO);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (rwflag == KSTAT_WRITE)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return (EACCES);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp = ksp->ks_data;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fsp = ksp->ks_private;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_pass.value.ul = fsp->fr_pass;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_block.value.ul = fsp->fr_block;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_nom.value.ul = fsp->fr_nom;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_short.value.ul = fsp->fr_short;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ppkl.value.ul = fsp->fr_ppkl;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_bpkl.value.ul = fsp->fr_bpkl;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_npkl.value.ul = fsp->fr_npkl;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_pkl.value.ul = fsp->fr_pkl;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_skip.value.ul = fsp->fr_skip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ret.value.ul = fsp->fr_ret;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_acct.value.ul = fsp->fr_acct;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_bnfr.value.ul = fsp->fr_bnfr;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_nfr.value.ul = fsp->fr_nfr;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_cfr.value.ul = fsp->fr_cfr;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_bads.value.ul = fsp->fr_bads;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ads.value.ul = fsp->fr_ads;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_chit.value.ul = fsp->fr_chit;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_tcpbad.value.ul = fsp->fr_tcpbad;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_pull[0].value.ul = fsp->fr_pull[0];
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_pull[1].value.ul = fsp->fr_pull[1];
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_badsrc.value.ul = fsp->fr_badsrc;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_badttl.value.ul = fsp->fr_badttl;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_bad.value.ul = fsp->fr_bad;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ipv6.value.ul = fsp->fr_ipv6;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ppshit.value.ul = fsp->fr_ppshit;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz fkp->fks_ipud.value.ul = fsp->fr_ipud;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return (0);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzint _init()
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipfinst = mod_install(&modlink1);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: _init() = %d", ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzint _fini(void)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipfinst = mod_remove(&modlink1);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: _fini() = %d", ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzint _info(modinfop)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstruct modinfo *modinfop;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipfinst = mod_info(&modlink1, modinfop);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: _info(%x) = %x", modinfop, ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 < 10
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_identify(dip)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz# ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: ipf_identify(%x)", dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz# endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (strcmp(ddi_get_name(dip), "ipf") == 0)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return (DDI_IDENTIFIED);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return (DDI_NOT_IDENTIFIED);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Initialize things for IPF for each stack instance
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic void *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_stack_init(netstackid_t stackid, netstack_t *ns)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_stack_t *ifs;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef NS_DEBUG
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void) printf("ipf_stack_init(%d)\n", stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh KMALLOCS(ifs, ipf_stack_t *, sizeof (*ifs));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh bzero(ifs, sizeof (*ifs));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_netstack = ns;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook4_physical_in = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook4_physical_out = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook4_nic_events = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook4_loopback_in = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook4_loopback_out = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook6_physical_in = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook6_physical_out = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook6_nic_events = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook6_loopback_in = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_hook6_loopback_out = B_FALSE;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Initialize mutex's
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_INIT(&ifs->ifs_ipf_global, "ipf filter load/unload mutex");
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_INIT(&ifs->ifs_ipf_mutex, "ipf filter rwlock");
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_INIT(&ifs->ifs_ipf_frcache, "ipf cache rwlock");
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef KERNEL
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_kstat_init(ifs, stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Lock people out while we set things up.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh WRITE_ENTER(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipftuneable_alloc(ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_fr_timer_id = timeout(fr_slowtimer, (void *)ifs,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh drv_usectohz(500000));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark /* Limit to global stack */
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark if (stackid == GLOBAL_NETSTACKID)
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark cmn_err(CE_CONT, "!%s, running.\n", ipfilter_version);
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic int ipf_detach_check_zone(ipf_stack_t *ifs)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Make sure we're the only one's modifying things. With
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * this lock others should just fall out of the loop.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh READ_ENTER(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_fr_running == 1) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (-1);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Make sure there is no active filter rule.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_ipfilter[0][ifs->ifs_fr_active] ||
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_ipfilter[1][ifs->ifs_fr_active] ||
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_ipfilter6[0][ifs->ifs_fr_active] ||
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_ipfilter6[1][ifs->ifs_fr_active]) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (-1);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (0);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic int ipf_detach_check_all()
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_handle_t nh;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_t *ns;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int ret;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_next_init(&nh);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh while ((ns = netstack_next(&nh)) != NULL) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ret = ipf_detach_check_zone(ns->netstack_ipf);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_rele(ns);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ret != 0) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_next_fini(&nh);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (-1);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_next_fini(&nh);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (0);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Destroy things for ipf for one stack.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/* ARGSUSED */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic void
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_stack_fini(netstackid_t stackid, void *arg)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_stack_t *ifs = (ipf_stack_t *)arg;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef NS_DEBUG
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void) printf("ipf_stack_destroy(%p, stackid %d)\n",
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void *)ifs, stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Make sure we're the only one's modifying things. With
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * this lock others should just fall out of the loop.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh WRITE_ENTER(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_fr_running == -2) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_fr_running = -2;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef KERNEL
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_kstat_fini(ifs, stackid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_fr_timer_id != 0) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void) untimeout(ifs->ifs_fr_timer_id);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_fr_timer_id = 0;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh WRITE_ENTER(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ipldetach(ifs) != 0) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh printf("ipf_stack_fini: ipldetach failed\n");
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipftuneable_free(ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RW_DESTROY(&ifs->ifs_ipf_mutex);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RW_DESTROY(&ifs->ifs_ipf_frcache);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RW_DESTROY(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh KFREE(ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_attach(dip, cmd)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzddi_attach_cmd_t cmd;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz char *s;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int i;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int instance;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: ipf_attach(%x,%x)", dip, cmd);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz switch (cmd)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case DDI_ATTACH:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz instance = ddi_get_instance(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz /* Only one instance of ipf (instance 0) can be attached. */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (instance > 0)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: attach ipf instance %d", instance);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void) ipf_property_g_update(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz for (i = 0; ((s = ipf_devfiles[i]) != NULL); i++) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz s = strrchr(s, '/');
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (s == NULL)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz continue;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz s++;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (ddi_create_minor_node(dip, s, S_IFCHR, i,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz DDI_PSEUDO, 0) ==
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz DDI_FAILURE) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_remove_minor_node(dip, NULL);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz goto attach_failed;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_dev_info = dip;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_register(NS_IPF, ipf_stack_init, NULL,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_stack_fini);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_SUCCESS;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz /* NOTREACHED */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzattach_failed:
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ddi_prop_remove_all(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_detach(dip, cmd)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzddi_detach_cmd_t cmd;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int i;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: ipf_detach(%x,%x)", dip, cmd);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz switch (cmd) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case DDI_DETACH:
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ipf_detach_check_all() != 0)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /* Undo what we did in ipf_attach, freeing resources
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * and removing things we installed. The system
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * framework guarantees we are not active with this devinfo
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * node in any other entry points at this time.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_prop_remove_all(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz i = ddi_get_instance(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_remove_minor_node(dip, NULL);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (i > 0) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_CONT, "IP Filter: still attached (%d)\n", i);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstack_unregister(NS_IPF);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return DDI_SUCCESS;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /* NOTREACHED */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: failed to detach\n");
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz/*ARGSUSED*/
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_getinfo(dip, infocmd, arg, result)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzddi_info_cmd_t infocmd;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzvoid *arg, **result;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int error;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz error = DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: ipf_getinfo(%x,%x,%x)", dip, infocmd, arg);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz switch (infocmd) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case DDI_INFO_DEVT2DEVINFO:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *result = ipf_dev_info;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz error = DDI_SUCCESS;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case DDI_INFO_DEVT2INSTANCE:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *result = (void *)0;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz error = DDI_SUCCESS;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return (error);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz/*
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * Fetch configuration file values that have been entered into the ipf.conf
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * driver file.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic int ipf_property_g_update(dip)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef DDI_NO_AUTODETACH
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz DDI_NO_AUTODETACH, 1) != DDI_PROP_SUCCESS) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_WARN, "!updating DDI_NO_AUTODETACH failed");
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#else
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (ddi_prop_update_int(DDI_DEV_T_NONE, dip,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz "ddi-no-autodetach", 1) != DDI_PROP_SUCCESS) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_WARN, "!updating ddi-no-autodetach failed");
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return DDI_FAILURE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return DDI_SUCCESS;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhint ipf_property_update(dip, ifs)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhdev_info_t *dip;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_stack_t *ifs;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipftuneable_t *ipft;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int64_t *i64p;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh char *name;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh u_int one;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int *i32p;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int err;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh for (ipft = ifs->ifs_ipf_tuneables; (name = ipft->ipft_name) != NULL; ipft++) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz one = 1;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz switch (ipft->ipft_sz)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case 4 :
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz i32p = NULL;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz err = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz 0, name, &i32p, &one);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (err == DDI_PROP_NOT_FOUND)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz continue;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_CONT, "IP Filter: lookup_int(%s) = %d\n",
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz name, err);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (err != DDI_PROP_SUCCESS)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return err;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (*i32p >= ipft->ipft_min && *i32p <= ipft->ipft_max)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *ipft->ipft_pint = *i32p;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz else
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz err = DDI_PROP_CANNOT_DECODE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_prop_free(i32p);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 > 8
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case 8 :
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz i64p = NULL;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz err = ddi_prop_lookup_int64_array(DDI_DEV_T_ANY, dip,
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz 0, name, &i64p, &one);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (err == DDI_PROP_NOT_FOUND)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz continue;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz# ifdef IPFDEBUG
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_CONT, "IP Filter: lookup_int64(%s) = %d\n",
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz name, err);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz# endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (err != DDI_PROP_SUCCESS)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return err;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (*i64p >= ipft->ipft_min && *i64p <= ipft->ipft_max)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *ipft->ipft_pint = *i64p;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz else
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz err = DDI_PROP_CANNOT_DECODE;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ddi_prop_free(i64p);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default :
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz if (err != DDI_SUCCESS)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz return err;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}