solaris.c revision 23f4867fdff96a11dd674de6259a5a0d0a13251c
/*
* Copyright (C) 1993-2001, 2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* #pragma ident "@(#)solaris.c 1.12 6/5/96 (C) 1995 Darren Reed"*/
#pragma ident "@(#)$Id: solaris.c,v 2.73.2.6 2005/07/13 21:40:47 darrenr Exp $"
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/dditypes.h>
#include <sys/autoconf.h>
#include <sys/byteorder.h>
#if SOLARIS2 >= 6
# include <net/if_types.h>
#endif
#include <sys/netstack.h>
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include "netinet/ip_compat.h"
#include "netinet/ip_state.h"
#include "netinet/ipf_stack.h"
void *, void **));
#if SOLARIS2 < 10
#endif
IPLOOKUP_NAME, NULL };
static struct cb_ops ipf_cb_ops = {
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
iplwrite, /* write */
iplioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
NULL,
#if SOLARIS2 > 4
nodev, /* aread */
nodev, /* awrite */
#endif
};
0,
#if SOLARIS2 >= 10
#else
#endif
nodev, /* reset */
(struct bus_ops *)0
};
extern struct mod_ops mod_driverops;
#if SOLARIS2 >= 6
{ 0, 0 },
{ IFT_OTHER, 0 },
{ IFT_1822, 0 },
{ IFT_HDH1822, 0 },
{ IFT_X25DDN, 0 },
{ IFT_X25, 0 },
{ IFT_ETHER, 14 },
{ IFT_ISO88023, 0 },
{ IFT_ISO88024, 0 },
{ IFT_ISO88025, 0 },
{ IFT_ISO88026, 0 },
{ IFT_STARLAN, 0 },
{ IFT_P10, 0 },
{ IFT_P80, 0 },
{ IFT_HY, 0 },
{ IFT_FDDI, 24 },
{ IFT_LAPB, 0 },
{ IFT_SDLC, 0 },
{ IFT_T1, 0 },
{ IFT_CEPT, 0 },
{ IFT_ISDNBASIC, 0 },
{ IFT_ISDNPRIMARY, 0 },
{ IFT_PTPSERIAL, 0 },
{ IFT_PPP, 0 },
{ IFT_LOOP, 0 },
{ IFT_EON, 0 },
{ IFT_XETHER, 0 },
{ IFT_NSIP, 0 },
{ IFT_SLIP, 0 },
{ IFT_ULTRA, 0 },
{ IFT_DS3, 0 },
{ IFT_SIP, 0 },
{ IFT_FRELAY, 0 },
{ IFT_RS232, 0 },
{ IFT_PARA, 0 },
{ IFT_ARCNET, 0 },
{ IFT_ARCNETPLUS, 0 },
{ IFT_ATM, 0 },
{ IFT_MIOX25, 0 },
{ IFT_SONET, 0 },
{ IFT_X25PLE, 0 },
{ IFT_ISO88022LLC, 0 },
{ IFT_LOCALTALK, 0 },
{ IFT_SMDSDXI, 0 },
{ IFT_FRELAYDCE, 0 },
{ IFT_V35, 0 },
{ IFT_HSSI, 0 },
{ IFT_HIPPI, 0 },
{ IFT_MODEM, 0 },
{ IFT_AAL5, 0 },
{ IFT_SONETPATH, 0 },
{ IFT_SONETVT, 0 },
{ IFT_SMDSICIP, 0 },
{ IFT_PROPVIRTUAL, 0 },
{ IFT_PROPMUX, 0 },
};
#endif /* SOLARIS2 >= 6 */
static const filter_kstats_t ipf_kstat_tmp = {
{ "pass", KSTAT_DATA_ULONG },
{ "block", KSTAT_DATA_ULONG },
{ "nomatch", KSTAT_DATA_ULONG },
{ "short", KSTAT_DATA_ULONG },
{ "pass, logged", KSTAT_DATA_ULONG },
{ "block, logged", KSTAT_DATA_ULONG },
{ "nomatch, logged", KSTAT_DATA_ULONG },
{ "logged", KSTAT_DATA_ULONG },
{ "skip", KSTAT_DATA_ULONG },
{ "return sent", KSTAT_DATA_ULONG },
{ "acct", KSTAT_DATA_ULONG },
{ "bad frag state alloc", KSTAT_DATA_ULONG },
{ "new frag state kept", KSTAT_DATA_ULONG },
{ "new frag state compl. pkt", KSTAT_DATA_ULONG },
{ "bad pkt state alloc", KSTAT_DATA_ULONG },
{ "new pkt kept state", KSTAT_DATA_ULONG },
{ "cachehit", KSTAT_DATA_ULONG },
{ "tcp cksum bad", KSTAT_DATA_ULONG },
{{ "pullup ok", KSTAT_DATA_ULONG },
{ "pullup nok", KSTAT_DATA_ULONG }},
{ "src != route", KSTAT_DATA_ULONG },
{ "ttl invalid", KSTAT_DATA_ULONG },
{ "bad ip pkt", KSTAT_DATA_ULONG },
{ "ipv6 pkt", KSTAT_DATA_ULONG },
{ "dropped:pps ceiling", KSTAT_DATA_ULONG },
{ "ip upd. fail", KSTAT_DATA_ULONG }
};
static void
{
int i;
for (i = 0; i < 2; i++) {
(i==0)?"inbound":"outbound",
"net",
sizeof (filter_kstats_t) / sizeof (kstat_named_t),
0, stackid);
sizeof (filter_kstats_t));
}
}
#ifdef IPFDEBUG
#endif
}
static void
{
int i;
for (i = 0; i < 2; i++) {
}
}
}
static int
{
return (EIO);
if (rwflag == KSTAT_WRITE)
return (EACCES);
return (0);
}
int _init()
{
int ipfinst;
#ifdef IPFDEBUG
#endif
return ipfinst;
}
int _fini(void)
{
int ipfinst;
#ifdef IPFDEBUG
#endif
return ipfinst;
}
{
int ipfinst;
#ifdef IPFDEBUG
#endif
return ipfinst;
}
#if SOLARIS2 < 10
static int ipf_identify(dip)
{
# ifdef IPFDEBUG
# endif
return (DDI_IDENTIFIED);
return (DDI_NOT_IDENTIFIED);
}
#endif
/*
* Initialize things for IPF for each stack instance
*/
static void *
{
#ifdef NS_DEBUG
#endif
/*
* Initialize mutex's
*/
#ifdef KERNEL
#endif
/*
* Lock people out while we set things up.
*/
drv_usectohz(500000));
/* Limit to global stack */
if (stackid == GLOBAL_NETSTACKID)
return (ifs);
}
{
/*
* Make sure we're the only one's modifying things. With
* this lock others should just fall out of the loop.
*/
return (-1);
}
/*
* Make sure there is no active filter rule.
*/
return (-1);
}
return (0);
}
static int ipf_detach_check_all()
{
netstack_t *ns;
int ret;
if (ret != 0) {
return (-1);
}
}
return (0);
}
/*
* Destroy things for ipf for one stack.
*/
/* ARGSUSED */
static void
{
#ifdef NS_DEBUG
(void) printf("ipf_stack_destroy(%p, stackid %d)\n",
#endif
/*
* Make sure we're the only one's modifying things. With
* this lock others should just fall out of the loop.
*/
return;
}
#ifdef KERNEL
#endif
if (ifs->ifs_fr_timer_id != 0) {
ifs->ifs_fr_timer_id = 0;
}
printf("ipf_stack_fini: ipldetach failed\n");
}
}
{
char *s;
int i;
int instance;
#ifdef IPFDEBUG
#endif
switch (cmd)
{
case DDI_ATTACH:
/* Only one instance of ipf (instance 0) can be attached. */
if (instance > 0)
return DDI_FAILURE;
#ifdef IPFDEBUG
#endif
(void) ipf_property_g_update(dip);
for (i = 0; ((s = ipf_devfiles[i]) != NULL); i++) {
s = strrchr(s, '/');
if (s == NULL)
continue;
s++;
DDI_PSEUDO, 0) ==
DDI_FAILURE) {
goto attach_failed;
}
}
ipf_dev_info = dip;
return DDI_SUCCESS;
/* NOTREACHED */
default:
break;
}
return DDI_FAILURE;
}
{
int i;
#ifdef IPFDEBUG
#endif
switch (cmd) {
case DDI_DETACH:
if (ipf_detach_check_all() != 0)
return DDI_FAILURE;
/* Undo what we did in ipf_attach, freeing resources
* and removing things we installed. The system
* framework guarantees we are not active with this devinfo
* node in any other entry points at this time.
*/
i = ddi_get_instance(dip);
if (i > 0) {
return DDI_FAILURE;
}
return DDI_SUCCESS;
/* NOTREACHED */
default:
break;
}
return DDI_FAILURE;
}
/*ARGSUSED*/
{
int error;
error = DDI_FAILURE;
#ifdef IPFDEBUG
#endif
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = ipf_dev_info;
error = DDI_SUCCESS;
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
break;
}
return (error);
}
/*
* Fetch configuration file values that have been entered into the ipf.conf
* driver file.
*/
static int ipf_property_g_update(dip)
{
#ifdef DDI_NO_AUTODETACH
return DDI_FAILURE;
}
#else
return DDI_FAILURE;
}
#endif
return DDI_SUCCESS;
}
{
char *name;
int *i32p;
int err;
one = 1;
{
case 4 :
if (err == DDI_PROP_NOT_FOUND)
continue;
#ifdef IPFDEBUG
#endif
if (err != DDI_PROP_SUCCESS)
return err;
else
break;
#if SOLARIS2 > 8
case 8 :
if (err == DDI_PROP_NOT_FOUND)
continue;
# ifdef IPFDEBUG
# endif
if (err != DDI_PROP_SUCCESS)
return err;
else
break;
#endif
default :
break;
}
if (err != DDI_SUCCESS)
break;
}
return err;
}