solaris.c revision 94bdecd9e84ae1042607002db3e64a6849da5874
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz/*
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * Copyright (C) 1993-2001, 2003 by Darren Reed.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * See the IPFILTER.LICENCE file for details on licencing.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz *
14d3298ea5ac04e3c29e86a4769ff92a49e9f4afAlexandr Nedvedicky * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz * Use is subject to license terms.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Copyright (c) 2014, Joyent, Inc. All rights reserved.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich/*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * ipfilter kernel module mutexes and locking:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Enabling ipfilter creates a per-netstack ipf_stack_t object that is
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * stored in the ipf_stacks list, which is protected by ipf_stack_lock.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * ipf_stack_t objects are accessed in three contexts:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * 1) administering that filter (eg: ioctls handled with iplioctl())
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * 2) reading log data (eg: iplread() / iplwrite())
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * 3) filtering packets (eg: ipf_hook4_* and ipf_hook6_* pfhooks
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * functions)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Each ipf_stack_t has a RW lock, ifs_ipf_global, protecting access to the
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * whole structure. The structure also has locks protecting the various
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * data structures used for filtering. The following guidelines should be
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * followed for ipf_stack_t locks:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - ipf_stack_lock must be held when accessing the ipf_stacks list
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - ipf_stack_lock should be held before acquiring ifs_ipf_global for
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * a stack (the exception to this is ipf_stack_destroy(), which removes
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * the ipf_stack_t from the list, then drops ipf_stack_lock before
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * acquiring ifs_ipf_global)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - ifs_ipf_global must be held when accessing an ipf_stack_t in that list:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - The write lock is held only during stack creation / destruction
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - The read lock should be held for all other accesses
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - To alter the filtering data in the administrative context, one must:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - acquire the read lock for ifs_ipf_global
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - then acquire the write lock for the data in question
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - In the filtering path, the read lock needs to be held for each type of
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * filtering data used
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - ifs_ipf_global does not need to be held in the filtering path:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - The filtering hooks don't need to modify the stack itself
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * - The ipf_stack_t will not be destroyed until the hooks are unregistered.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * This requires a write lock on the hook, ensuring that no active hooks
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * (eg: the filtering path) are running, and that the hooks won't be run
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * afterward.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Note that there is a deadlock possible when calling net_hook_register()
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * or net_hook_unregister() with ifs_ipf_global held: see the comments in
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * iplattach() and ipldetach() for details.
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz */
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
193974072f41a843678abf5f61979c748687e66bSherry Moore#include <net/if_types.h>
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
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,
193974072f41a843678abf5f61979c748687e66bSherry Moore 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));
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedstatic void *ipf_stack_create __P((const netid_t));
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedstatic void ipf_stack_destroy __P((const netid_t, void *));
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reedstatic void ipf_stack_shutdown __P((const netid_t, void *));
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 };
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichextern void *ipf_state; /* DDI state */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichextern vmem_t *ipf_minor; /* minor number arena */
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,
193974072f41a843678abf5f61979c748687e66bSherry Moore (struct bus_ops *)0,
193974072f41a843678abf5f61979c748687e66bSherry Moore NULL,
193974072f41a843678abf5f61979c748687e66bSherry Moore ddi_quiesce_not_needed, /* quiesce */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz};
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedstatic net_instance_t *ipfncb = NULL;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedstatic ipf_stack_t *ipf_stacks = NULL;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedstatic kmutex_t ipf_stack_lock;
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
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_kstat_init(ipf_stack_t *ifs, boolean_t from_gz)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs->ifs_kstatp[0] = net_kstat_create(ifs->ifs_netid,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich (from_gz ? "ipf_gz" : "ipf"),
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich 0, "inbound", "net", KSTAT_TYPE_NAMED,
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ifs->ifs_kstatp[0] != NULL) {
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[0]->ks_data,
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed sizeof (filter_kstats_t));
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_kstatp[0]->ks_update = ipf_kstat_update;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_kstatp[0]->ks_private = &ifs->ifs_frstats[0];
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed kstat_install(ifs->ifs_kstatp[0]);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs->ifs_kstatp[1] = net_kstat_create(ifs->ifs_netid,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich (from_gz ? "ipf_gz" : "ipf"),
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich 0, "outbound", "net", KSTAT_TYPE_NAMED,
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ifs->ifs_kstatp[1] != NULL) {
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[1]->ks_data,
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed sizeof (filter_kstats_t));
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_kstatp[1]->ks_update = ipf_kstat_update;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_kstatp[1]->ks_private = &ifs->ifs_frstats[1];
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed kstat_install(ifs->ifs_kstatp[1]);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: ipf_kstat_init(%p) installed %p, %p",
193974072f41a843678abf5f61979c748687e66bSherry Moore ifs, ifs->ifs_kstatp[0], ifs->ifs_kstatp[1]);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic void
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reedipf_kstat_fini(ipf_stack_t *ifs)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int i;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz for (i = 0; i < 2; i++) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ifs->ifs_kstatp[i] != NULL) {
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed net_kstat_delete(ifs->ifs_netid, ifs->ifs_kstatp[i]);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ifs->ifs_kstatp[i] = NULL;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
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
193974072f41a843678abf5f61979c748687e66bSherry Mooreint
193974072f41a843678abf5f61979c748687e66bSherry Moore_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
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_init(&ipf_stack_lock, NULL, MUTEX_DRIVER, NULL);
193974072f41a843678abf5f61979c748687e66bSherry Moore return (ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
193974072f41a843678abf5f61979c748687e66bSherry Mooreint
193974072f41a843678abf5f61979c748687e66bSherry Moore_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
193974072f41a843678abf5f61979c748687e66bSherry Moore return (ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
193974072f41a843678abf5f61979c748687e66bSherry Mooreint
193974072f41a843678abf5f61979c748687e66bSherry Moore_info(modinfop)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstruct modinfo *modinfop;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz int ipfinst;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipfinst = mod_info(&modlink1, modinfop);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: _info(%p) = %d", modinfop, ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
193974072f41a843678abf5f61979c748687e66bSherry Moore return (ipfinst);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#if SOLARIS2 < 10
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzstatic int ipf_identify(dip)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzdev_info_t *dip;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz{
193974072f41a843678abf5f61979c748687e66bSherry Moore#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: ipf_identify(%p)", dip);
193974072f41a843678abf5f61979c748687e66bSherry Moore#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 *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_stack_create_one(const netid_t id, const zoneid_t zid, boolean_t from_gz,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_stack_t *ifs_gz)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipf_stack_t *ifs;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#ifdef IPFDEBUG
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich cmn_err(CE_NOTE, "IP Filter:stack_create_one id=%d global=%d", id,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs = (ipf_stack_t *)kmem_alloc(sizeof (*ifs), KM_SLEEP);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh bzero(ifs, sizeof (*ifs));
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");
14d3298ea5ac04e3c29e86a4769ff92a49e9f4afAlexandr Nedvedicky RWLOCK_INIT(&ifs->ifs_ipf_frcache, "ipf cache rwlock");
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_netid = id;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs->ifs_zone = zid;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs->ifs_gz_controlled = from_gz;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs->ifs_gz_cont_ifs = ifs_gz;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_kstat_init(ifs, from_gz);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_CONT, "IP Filter:stack_create zone=%d", ifs->ifs_zone);
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 RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark /* Limit to global stack */
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ifs->ifs_zone == GLOBAL_ZONEID)
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark cmn_err(CE_CONT, "!%s, running.\n", ipfilter_version);
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_enter(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ipf_stacks != NULL)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipf_stacks->ifs_pnext = &ifs->ifs_next;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_next = ipf_stacks;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_pnext = &ipf_stacks;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipf_stacks = ifs;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_exit(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh return (ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichstatic void *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_stack_create(const netid_t id)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich{
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_stack_t *ifs = NULL;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich zoneid_t zid = net_getzoneidbynetid(id);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Create two ipfilter stacks for a zone - the first can only be
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * controlled from the global zone, and the second is owned by
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * the zone itself. There is no need to create a GZ-controlled
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * stack for the global zone, since we're already in the global
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * zone. See the "GZ-controlled and per-zone stacks" comment block in
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * ip_fil_solaris.c for details.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (zid != GLOBAL_ZONEID)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ifs = ipf_stack_create_one(id, zid, B_TRUE, NULL);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich return (ipf_stack_create_one(id, zid, B_FALSE, ifs));
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich}
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed/*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Find an ipfilter stack for the given zone. Return the GZ-controlled or
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * per-zone stack if set by an earlier SIOCIPFZONESET ioctl call. See the
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * "GZ-controlled and per-zone stacks" comment block in ip_fil_solaris.c for
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * details.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * This function returns with the ipf_stack_t's ifs_ipf_global
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * read lock held (if the stack is found). See the "ipfilter kernel module
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * mutexes and locking" comment block at the top of this file.
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed */
193974072f41a843678abf5f61979c748687e66bSherry Mooreipf_stack_t *
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_find_stack(const zoneid_t orig_zone, ipf_devstate_t *isp)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed{
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipf_stack_t *ifs;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich boolean_t gz_stack;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich zoneid_t zone;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * If we're in the GZ, determine if we're acting on a zone's stack,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * and whether or not that stack is the GZ-controlled or in-zone
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * one. See the "GZ and per-zone stacks" note at the top of this
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * file.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (orig_zone == GLOBAL_ZONEID &&
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich (isp->ipfs_zoneid != IPFS_ZONE_UNSET)) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /* Global zone, and we've set the zoneid for this fd already */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (orig_zone == isp->ipfs_zoneid) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /* There's only a per-zone stack for the GZ */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich gz_stack = B_FALSE;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich } else {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich gz_stack = isp->ipfs_gz;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich }
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich zone = isp->ipfs_zoneid;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich } else {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Non-global zone or GZ without having set a zoneid: act on
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * the per-zone stack of the zone that this ioctl originated
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * from.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich gz_stack = B_FALSE;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich zone = orig_zone;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich }
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_enter(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed for (ifs = ipf_stacks; ifs != NULL; ifs = ifs->ifs_next) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ifs->ifs_zone == zone && ifs->ifs_gz_controlled == gz_stack)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed break;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed }
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ifs != NULL) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich READ_ENTER(&ifs->ifs_ipf_global);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich }
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_exit(&ipf_stack_lock);
193974072f41a843678abf5f61979c748687e66bSherry Moore return (ifs);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed}
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
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 }
193974072f41a843678abf5f61979c748687e66bSherry Moore
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
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic int ipf_detach_check_all()
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipf_stack_t *ifs;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_enter(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed for (ifs = ipf_stacks; ifs != NULL; ifs = ifs->ifs_next)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ipf_detach_check_zone(ifs) != 0)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed break;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_exit(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed return ((ifs == NULL) ? 0 : -1);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed/*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Remove ipf kstats for both the per-zone ipf stack and the
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * GZ-controlled stack for the same zone, if it exists.
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed */
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed/* ARGSUSED */
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reedstatic void
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reedipf_stack_shutdown(const netid_t id, void *arg)
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed{
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed ipf_stack_t *ifs = (ipf_stack_t *)arg;
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * The GZ-controlled stack
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ifs->ifs_gz_cont_ifs != NULL)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_kstat_fini(ifs->ifs_gz_cont_ifs);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * The per-zone stack
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed ipf_kstat_fini(ifs);
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed}
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Destroy things for ipf for one stack.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/* ARGSUSED */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstatic void
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_stack_destroy_one(const netid_t id, ipf_stack_t *ifs)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed timeout_id_t tid;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#ifdef IPFDEBUG
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich (void) printf("ipf_stack_destroy_one(%p)\n", (void *)ifs);
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;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed tid = ifs->ifs_fr_timer_id;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_fr_timer_id = NULL;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_enter(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (ifs->ifs_next != NULL)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ifs->ifs_next->ifs_pnext = ifs->ifs_pnext;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed *ifs->ifs_pnext = ifs->ifs_next;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed mutex_exit(&ipf_stack_lock);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed if (tid != NULL)
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed (void) untimeout(tid);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh WRITE_ENTER(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ipldetach(ifs) != 0) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich printf("ipf_stack_destroy_one: ipldetach failed\n");
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh }
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipftuneable_free(ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RWLOCK_EXIT(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RW_DESTROY(&ifs->ifs_ipf_mutex);
14d3298ea5ac04e3c29e86a4769ff92a49e9f4afAlexandr Nedvedicky RW_DESTROY(&ifs->ifs_ipf_frcache);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh RW_DESTROY(&ifs->ifs_ipf_global);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh KFREE(ifs);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich/*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * Destroy things for ipf for both the per-zone ipf stack and the
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * GZ-controlled stack for the same zone, if it exists. See the "GZ-controlled
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * and per-zone stacks" comment block in ip_fil_solaris.c for details.
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich/* ARGSUSED */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichstatic void
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewichipf_stack_destroy(const netid_t id, void *arg)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich{
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_stack_t *ifs = (ipf_stack_t *)arg;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * The GZ-controlled stack
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ifs->ifs_gz_cont_ifs != NULL)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_stack_destroy_one(id, ifs->ifs_gz_cont_ifs);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich /*
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich * The per-zone stack
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich */
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_stack_destroy_one(id, ifs);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich}
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
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
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: ipf_attach(%p,%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)
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_FAILURE);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_CONT, "IP Filter: attach ipf instance %d", instance);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh (void) ipf_property_g_update(dip);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ddi_soft_state_init(&ipf_state, sizeof (ipf_devstate_t), 1)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich != 0) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ddi_prop_remove_all(dip);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich return (DDI_FAILURE);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich }
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
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,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich DDI_PSEUDO, 0) == DDI_FAILURE)
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz goto attach_failed;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz ipf_dev_info = dip;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipfncb = net_instance_alloc(NETINFO_VERSION);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (ipfncb == NULL)
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich goto attach_failed;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipfncb->nin_name = "ipf";
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipfncb->nin_create = ipf_stack_create;
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed ipfncb->nin_destroy = ipf_stack_destroy;
8ad7418892268f9f0ba29518ab332f6a26f69fc5Darren Reed ipfncb->nin_shutdown = ipf_stack_shutdown;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich if (net_instance_register(ipfncb) == DDI_FAILURE) {
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich net_instance_free(ipfncb);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich goto attach_failed;
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich }
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ipf_minor = vmem_create("ipf_minor", (void *)1, UINT32_MAX - 1,
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich 1, NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#ifdef IPFDEBUG
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_CONT, "IP Filter:stack_create callback_reg=%d", i);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#endif
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_SUCCESS);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz /* NOTREACHED */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yzattach_failed:
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ddi_remove_minor_node(dip, NULL);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ddi_prop_remove_all(dip);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ddi_soft_state_fini(&ipf_state);
193974072f41a843678abf5f61979c748687e66bSherry Moore 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
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: ipf_detach(%p,%x)", dip, cmd);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz switch (cmd) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz case DDI_DETACH:
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if (ipf_detach_check_all() != 0)
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_FAILURE);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
193974072f41a843678abf5f61979c748687e66bSherry Moore /*
193974072f41a843678abf5f61979c748687e66bSherry Moore * 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);
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_FAILURE);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich vmem_destroy(ipf_minor);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich ddi_soft_state_fini(&ipf_state);
94bdecd9e84ae1042607002db3e64a6849da5874Rob Gulewich
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed (void) net_instance_unregister(ipfncb);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed net_instance_free(ipfncb);
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_SUCCESS);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /* NOTREACHED */
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz default:
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz break;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz cmn_err(CE_NOTE, "IP Filter: failed to detach\n");
193974072f41a843678abf5f61979c748687e66bSherry Moore 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
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed cmn_err(CE_NOTE, "IP Filter: ipf_getinfo(%p,%x,%p)", 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");
193974072f41a843678abf5f61979c748687e66bSherry Moore 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");
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_FAILURE);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
193974072f41a843678abf5f61979c748687e66bSherry Moore return (DDI_SUCCESS);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
193974072f41a843678abf5f61979c748687e66bSherry Mooreint
193974072f41a843678abf5f61979c748687e66bSherry Mooreipf_property_update(dip, ifs)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhdev_info_t *dip;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhipf_stack_t *ifs;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh{
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh ipftuneable_t *ipft;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh char *name;
193974072f41a843678abf5f61979c748687e66bSherry Moore uint_t one;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int *i32p;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky int err, rv = 0;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky for (ipft = ifs->ifs_ipf_tuneables;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky (name = ipft->ipft_name) != NULL; ipft++) {
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz one = 1;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky i32p = NULL;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky err = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, dip,
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky 0, name, &i32p, &one);
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky if (err == DDI_PROP_NOT_FOUND)
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky continue;
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#ifdef IPFDEBUG
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky cmn_err(CE_CONT, "IP Filter: lookup_int(%s) = %d\n",
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky name, err);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz#endif
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky if (err != DDI_PROP_SUCCESS) {
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky rv = err;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky continue;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky if (*i32p >= ipft->ipft_min &&
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky *i32p <= ipft->ipft_max) {
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky if (ipft->ipft_sz == sizeof (uint32_t)) {
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky *ipft->ipft_pint = *i32p;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky } else if (ipft->ipft_sz == sizeof (uint64_t)) {
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky *ipft->ipft_plong = *i32p;
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky }
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky ddi_prop_free(i32p);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz }
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky
40cdc2e8babc6bb3ab847f6a129fc9eb76c5f4d5Alexandr Nedvedicky return (rv);
ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4yz}