solaris.c revision 14d3298ea5ac04e3c29e86a4769ff92a49e9f4af
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Copyright (C) 1993-2001, 2003 by Darren Reed.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * See the IPFILTER.LICENCE file for details on licencing.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Use is subject to license terms.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg void *, void **));
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic int ipf_attach __P((dev_info_t *, ddi_attach_cmd_t));
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic int ipf_detach __P((dev_info_t *, ddi_detach_cmd_t));
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void ipf_stack_destroy __P((const netid_t, void *));
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void ipf_stack_shutdown __P((const netid_t, void *));
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic char *ipf_devfiles[] = { IPL_NAME, IPNAT_NAME, IPSTATE_NAME,
83c4dfe9546fd839e7a52bca7e9920da918f916ejg (struct bus_ops *)0,
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic struct modlinkage modlink1 = { MODREV_1, &iplmod, NULL };
83c4dfe9546fd839e7a52bca7e9920da918f916ejg#endif /* SOLARIS2 >= 6 */
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void
83c4dfe9546fd839e7a52bca7e9920da918f916ejg ifs->ifs_kstatp[0] = net_kstat_create(ifs->ifs_netid, "ipf", 0,
83c4dfe9546fd839e7a52bca7e9920da918f916ejg ifs->ifs_kstatp[1] = net_kstat_create(ifs->ifs_netid, "ipf", 0,
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_NOTE, "IP Filter: ipf_kstat_init(%p) installed %p, %p",
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void
83c4dfe9546fd839e7a52bca7e9920da918f916ejg for (i = 0; i < 2; i++) {
83c4dfe9546fd839e7a52bca7e9920da918f916ejg return (0);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_NOTE, "IP Filter: _info(%p) = %d", modinfop, ipfinst);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Initialize things for IPF for each stack instance
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void *
83c4dfe9546fd839e7a52bca7e9920da918f916ejg ifs = (ipf_stack_t *)kmem_alloc(sizeof (*ifs), KM_SLEEP);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Initialize mutex's
83c4dfe9546fd839e7a52bca7e9920da918f916ejg RWLOCK_INIT(&ifs->ifs_ipf_global, "ipf filter load/unload mutex");
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_CONT, "IP Filter:stack_create zone=%d", ifs->ifs_zone);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Lock people out while we set things up.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg /* Limit to global stack */
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * This function should only ever be used to find the pointer to the
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * ipfilter stack structure for the zone that is currently being
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * executed... so if you're running in the context of zone 1, you
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * should not attempt to find the ipf_stack_t for zone 0 or 2 or
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * anything else but 1. In that way, the returned pointer is safe
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * as it will only be nuked when the instance is destroyed as part
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * of the final shutdown of a zone.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg for (ifs = ipf_stacks; ifs != NULL; ifs = ifs->ifs_next) {
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Make sure we're the only one's modifying things. With
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * this lock others should just fall out of the loop.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg return (-1);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Make sure there is no active filter rule.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg return (-1);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg return (0);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Destroy things for ipf for one stack.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg/* ARGSUSED */
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Destroy things for ipf for one stack.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg/* ARGSUSED */
83c4dfe9546fd839e7a52bca7e9920da918f916ejgstatic void
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Make sure we're the only one's modifying things. With
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * this lock others should just fall out of the loop.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_NOTE, "IP Filter: ipf_attach(%p,%x)", dip, cmd);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg /* Only one instance of ipf (instance 0) can be attached. */
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_CONT, "IP Filter: attach ipf instance %d", instance);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_CONT, "IP Filter:stack_create callback_reg=%d", i);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg /* NOTREACHED */
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_NOTE, "IP Filter: ipf_detach(%p,%x)", dip, cmd);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg switch (cmd) {
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Undo what we did in ipf_attach, freeing resources
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * and removing things we installed. The system
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * framework guarantees we are not active with this devinfo
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * node in any other entry points at this time.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg if (i > 0) {
83c4dfe9546fd839e7a52bca7e9920da918f916ejg /* NOTREACHED */
83c4dfe9546fd839e7a52bca7e9920da918f916ejg/*ARGSUSED*/
83c4dfe9546fd839e7a52bca7e9920da918f916ejg cmn_err(CE_NOTE, "IP Filter: ipf_getinfo(%p,%x,%p)", dip, infocmd, arg);
83c4dfe9546fd839e7a52bca7e9920da918f916ejg *result = (void *)0;
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * Fetch configuration file values that have been entered into the ipf.conf
83c4dfe9546fd839e7a52bca7e9920da918f916ejg * driver file.
83c4dfe9546fd839e7a52bca7e9920da918f916ejg return (rv);