1 Reply Latest reply: May 18, 2010 8:27 PM by 807567 RSS

    Communicate b/w Kernel space and User space

    807567
      I'm looking for an efficient mechanism in Solaris 10 to communicate from a kernel module to an application in user space. The kernel module is utilizing PF hooks mechanism to inspect incoming IP packets and based on some criteria would need to send an event along with some data to the user space app. I believe in Linux there is a user-mode API that can be used for this purpose but I'm not sure if there is an equivalent in Solaris.
      Since I'm inspecting all IP packets and would probably be generating events to user space quite frequently the mechanism would need to be efficient.

      Thx...
        • 1. Re: Communicate b/w Kernel space and User space
          807567
          A good design will be to ride on top of existing kstat interface, so that u still can us all the existing kstat userspace utitlities to view the internal info.

          Opensolaris has the ipf_kstat_init() and other interface. I prefer this approach, even though it may not the officially supported / documented interface (man page returns nothing).

          So alternatively is to use the DDI interface, for example: ddi_umem_iosetup() etc for communicating with userspace. Samples codes are found in Opensolaris kernel itself:

          export/home/root/solaris/snv129_src/usr/src/uts/common/os/sunddi.c:
          * ddi_umem_iosetup to create a buf or do devmap_umem_setup/remap to export
          * ddi_umem_iosetup to create a buf or do devmap_umem_setup/remap to export
          ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len,

          /export/home/root/solaris/snv129_src/usr/src/uts/common/io/ib/adapters/tavor/tavor_mr.c:
                    bind->bi_buf = ddi_umem_iosetup(umem_cookie, 0, umem_len,
                    * Free up the memory ddi_umem_iosetup() allocates
               * is actually allocated by ddi_umem_iosetup() internally, then

          /export/home/root/solaris/snv129_src/usr/src/uts/common/io/ib/adapters/hermon/hermon_misc.c:
               pagep->upg_buf = ddi_umem_iosetup(pagep->upg_umemcookie, 0,

          /export/home/root/solaris/snv129_src/usr/src/uts/common/io/ib/adapters/hermon/hermon_mr.c:
                    bind->bi_buf = ddi_umem_iosetup(umem_cookie, 0, umem_len,
                    * Free up the memory ddi_umem_iosetup() allocates
               * is actually allocated by ddi_umem_iosetup() internally, then

          /export/home/root/solaris/snv129_src/usr/src/uts/common/io/rsm/rsm.c:
                    xbuf = ddi_umem_iosetup(cookie, 0, msg->len, B_WRITE,
               xbuf = ddi_umem_iosetup(seg->s_cookie, 0, seg->s_len, B_WRITE,
                              xbuf = ddi_umem_iosetup(ex_seg->s_cookie,
                    * created by ddi_umem_iosetup for each of the iovecs. So we
                    xbuf = ddi_umem_iosetup(segp->s_cookie, 0, segp->s_len, B_WRITE,

          /export/home/root/solaris/snv129_src/usr/src/uts/common/io/aac/aac_ioctl.c:
                    bp = ddi_umem_iosetup(cookie, (uintptr_t)usge->addr - \
                         AACDB_PRINT(softs, CE_NOTE, "ddi_umem_iosetup failed");

          /export/home/root/solaris/snv129_src/usr/src/uts/common/sys/sunddi.h:
          ddi_umem_iosetup(ddi_umem_cookie_t cookie, off_t off, size_t len, int direction,

          /export/home/root/solaris/snv129_src/usr/src/uts/common/sys/ddidevmap.h:
          * Flags to pass to ddi_umem_alloc and ddi_umem_iosetup