Print this page
    
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/inet/sockmods/datafilt.c
          +++ new/usr/src/uts/common/inet/sockmods/datafilt.c
   1    1  /*
   2      - * This file and its contents are supplied under the terms of the
   3      - * Common Development and Distribution License ("CDDL"), version 1.0.
   4      - * You may only use this file in accordance with the terms of version
   5      - * 1.0 of the CDDL.
        2 + * CDDL HEADER START
   6    3   *
   7      - * A full copy of the text of the CDDL should have accompanied this
   8      - * source.  A copy of the CDDL is also available via the Internet at
   9      - * http://www.illumos.org/license/CDDL.
        4 + * The contents of this file are subject to the terms of the
        5 + * Common Development and Distribution License (the "License").
        6 + * You may not use this file except in compliance with the License.
        7 + *
        8 + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
        9 + * or http://www.opensolaris.org/os/licensing.
       10 + * See the License for the specific language governing permissions
       11 + * and limitations under the License.
       12 + *
       13 + * When distributing Covered Code, include this CDDL HEADER in each
       14 + * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       15 + * If applicable, add the following below this CDDL HEADER, with the
       16 + * fields enclosed by brackets "[]" replaced with your own identifying
       17 + * information: Portions Copyright [yyyy] [name of copyright owner]
       18 + *
       19 + * CDDL HEADER END
  10   20   */
  11      -
  12   21  /*
  13   22   * Copyright (c) 2012, OmniTI Computer Consulting, Inc. All rights reserved.
  14   23   */
  15   24  
  16      -/*
  17      - * This file implements a socketfilter used to deter TCP connections.
  18      - * To defer a connection means to delay the return of accept(3SOCKET)
  19      - * until at least one byte is ready to be read(2). This filter may be
  20      - * applied automatically or programmatically through the use of
  21      - * soconfig(1M) and setsockopt(3SOCKET).
  22      - */
  23      -
  24   25  #include <sys/kmem.h>
  25   26  #include <sys/systm.h>
  26   27  #include <sys/stropts.h>
  27   28  #include <sys/strsun.h>
  28   29  #include <sys/socketvar.h>
  29   30  #include <sys/sockfilter.h>
  30   31  #include <sys/note.h>
  31   32  #include <sys/taskq.h>
  32   33  
  33      -#define DATAFILT_MODULE "datafilt"
  34      -
  35   34  static struct modlmisc dataf_modlmisc = {
  36   35          &mod_miscops,
  37   36          "Kernel data-ready socket filter"
  38   37  };
  39   38  
  40   39  static struct modlinkage dataf_modlinkage = {
  41   40          MODREV_1,
  42   41          &dataf_modlmisc,
  43   42          NULL
  44   43  };
  45   44  
  46      -static sof_rval_t
       45 +#define DATAFILT_MODULE "datafilt"
       46 +
       47 +/* ARGSUSED */
       48 +sof_rval_t
  47   49  dataf_attach_passive_cb(sof_handle_t handle, sof_handle_t ph,
  48   50      void *parg, struct sockaddr *laddr, socklen_t laddrlen,
  49   51      struct sockaddr *faddr, socklen_t faddrlen, void **cookiep)
  50   52  {
  51      -        _NOTE(ARGUNUSED(handle, ph, parg, laddr, laddrlen, faddr, faddrlen,
  52      -        cookiep));
  53   53          return (SOF_RVAL_DEFER);
  54   54  }
  55   55  
  56      -static void
       56 +void
  57   57  dataf_detach_cb(sof_handle_t handle, void *cookie, cred_t *cr)
  58   58  {
  59   59          _NOTE(ARGUNUSED(handle, cookie, cr));
  60   60  }
  61   61  
  62      -static mblk_t *
       62 +/*
       63 + * Called for each incoming segment.
       64 + */
       65 +mblk_t *
  63   66  dataf_data_in_cb(sof_handle_t handle, void *cookie, mblk_t *mp, int flags,
  64   67      size_t *lenp)
  65   68  {
  66   69          _NOTE(ARGUNUSED(cookie, flags, lenp));
  67   70  
  68      -        if (mp != NULL && MBLKL(mp) > 0) {
       71 +        if (mp != NULL && MBLKL(mp) > 0)
  69   72                  sof_newconn_ready(handle);
  70      -                sof_bypass(handle);
  71      -        }
  72   73  
  73   74          return (mp);
  74   75  }
  75   76  
  76      -static sof_ops_t dataf_ops = {
       77 +sof_ops_t dataf_ops = {
  77   78          .sofop_attach_passive = dataf_attach_passive_cb,
  78   79          .sofop_detach = dataf_detach_cb,
  79   80          .sofop_data_in = dataf_data_in_cb
  80   81  };
  81   82  
  82   83  int
  83   84  _init(void)
  84   85  {
  85      -        int err;
       86 +        int error;
  86   87  
  87   88          /*
  88   89           * This module is safe to attach even after some preliminary socket
  89   90           * setup calls have taken place. See the comment for SOF_ATT_SAFE.
  90   91           */
  91      -        err = sof_register(SOF_VERSION, DATAFILT_MODULE, &dataf_ops,
       92 +        error = sof_register(SOF_VERSION, DATAFILT_MODULE, &dataf_ops,
  92   93              SOF_ATT_SAFE);
  93      -        if (err != 0)
  94      -                return (err);
  95      -        if ((err = mod_install(&dataf_modlinkage)) != 0)
       94 +        if (error != 0)
       95 +                return (error);
       96 +        if ((error = mod_install(&dataf_modlinkage)) != 0)
  96   97                  (void) sof_unregister(DATAFILT_MODULE);
  97   98  
  98      -        return (err);
       99 +        return (error);
  99  100  }
 100  101  
 101  102  int
 102  103  _fini(void)
 103  104  {
 104      -        int err;
      105 +        int error;
 105  106  
 106      -        if ((err = sof_unregister(DATAFILT_MODULE)) != 0)
 107      -                return (err);
      107 +        if ((error = sof_unregister(DATAFILT_MODULE)) != 0)
      108 +                return (error);
 108  109  
 109  110          return (mod_remove(&dataf_modlinkage));
 110  111  }
 111  112  
 112  113  int
 113  114  _info(struct modinfo *modinfop)
 114  115  {
 115  116          return (mod_info(&dataf_modlinkage, modinfop));
 116  117  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX