Print this page
4770 soconfig(1M) needs an option to print the in-kernel socket configuration table


  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * University Copyright- Copyright (c) 1982, 1986, 1988
  31  * The Regents of the University of California
  32  * All Rights Reserved
  33  *
  34  * University Acknowledgment- Portions of this document are derived from
  35  * software developed by the University of California, Berkeley, and its
  36  * contributors.
  37  */



  38 
  39 #ifndef _SYS_SOCKETVAR_H
  40 #define _SYS_SOCKETVAR_H
  41 
  42 #include <sys/types.h>
  43 #include <sys/stream.h>
  44 #include <sys/t_lock.h>
  45 #include <sys/cred.h>
  46 #include <sys/vnode.h>
  47 #include <sys/file.h>
  48 #include <sys/param.h>
  49 #include <sys/zone.h>
  50 #include <sys/sdt.h>
  51 #include <sys/modctl.h>
  52 #include <sys/atomic.h>
  53 #include <sys/socket.h>
  54 #include <sys/ksocket.h>
  55 #include <sys/kstat.h>
  56 
  57 #ifdef _KERNEL


 489 
 490 /*
 491  * sockparams flags
 492  */
 493 #define SOCKPARAMS_EPHEMERAL    0x1     /* temp. entry, not on global list */
 494 
 495 extern void sockparams_init(void);
 496 extern struct sockparams *sockparams_hold_ephemeral_bydev(int, int, int,
 497     const char *, int, int *);
 498 extern struct sockparams *sockparams_hold_ephemeral_bymod(int, int, int,
 499     const char *, int, int *);
 500 extern void sockparams_ephemeral_drop_last_ref(struct sockparams *);
 501 
 502 extern struct sockparams *sockparams_create(int, int, int, char *, char *, int,
 503     int, int, int *);
 504 extern void     sockparams_destroy(struct sockparams *);
 505 extern int      sockparams_add(struct sockparams *);
 506 extern int      sockparams_delete(int, int, int);
 507 extern int      sockparams_new_filter(struct sof_entry *);
 508 extern void     sockparams_filter_cleanup(struct sof_entry *);

 509 
 510 extern void smod_init(void);
 511 extern void smod_add(smod_info_t *);
 512 extern int smod_register(const smod_reg_t *);
 513 extern int smod_unregister(const char *);
 514 extern smod_info_t *smod_lookup_byname(const char *);
 515 
 516 #define SOCKPARAMS_HAS_DEVICE(sp)                                       \
 517         ((sp)->sp_sdev_info.sd_devpath != NULL)
 518 
 519 /* Increase the smod_info_t reference count */
 520 #define SMOD_INC_REF(smodp) {                                           \
 521         ASSERT((smodp) != NULL);                                        \
 522         DTRACE_PROBE1(smodinfo__inc__ref, struct smod_info *, (smodp)); \
 523         atomic_inc_uint(&(smodp)->smod_refcnt);                          \
 524 }
 525 
 526 /*
 527  * Decreace the socket module entry reference count.
 528  * When no one mapping to the entry, we try to unload the module from the


 958         uint_t          si_ux_laddr_sou_magic;
 959         uint_t          si_ux_faddr_sou_magic;
 960         t_scalar_t      si_serv_type;
 961         t_uscalar_t     si_laddr_soa_len;
 962         t_uscalar_t     si_faddr_soa_len;
 963         uint16_t        si_laddr_family;
 964         uint16_t        si_faddr_family;
 965         char            si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
 966         char            si_faddr_sun_path[MAXPATHLEN + 1];
 967         boolean_t       si_faddr_noxlate;
 968         zoneid_t        si_szoneid;
 969 };
 970 
 971 /*
 972  * Subcodes for sockconf() system call
 973  */
 974 #define SOCKCONFIG_ADD_SOCK             0
 975 #define SOCKCONFIG_REMOVE_SOCK          1
 976 #define SOCKCONFIG_ADD_FILTER           2
 977 #define SOCKCONFIG_REMOVE_FILTER        3

 978 
 979 /*
 980  * Data structures for configuring socket filters.
 981  */
 982 
 983 /*
 984  * Placement hint for automatic filters
 985  */
 986 typedef enum {
 987         SOF_HINT_NONE,
 988         SOF_HINT_TOP,
 989         SOF_HINT_BOTTOM,
 990         SOF_HINT_BEFORE,
 991         SOF_HINT_AFTER
 992 } sof_hint_t;
 993 
 994 /*
 995  * Socket tuple. Used by sockconfig_filter_props to list socket
 996  * types of interest.
 997  */
 998 typedef struct sof_socktuple {
 999         int     sofst_family;
1000         int     sofst_type;
1001         int     sofst_protocol;
1002 } sof_socktuple_t;
1003 
1004 /*
1005  * Socket filter properties used by sockconfig() system call.
1006  */
1007 struct sockconfig_filter_props {
1008         char            *sfp_modname;
1009         boolean_t       sfp_autoattach;
1010         sof_hint_t      sfp_hint;
1011         char            *sfp_hintarg;
1012         uint_t          sfp_socktuple_cnt;
1013         sof_socktuple_t *sfp_socktuple;
1014 };
1015 


















1016 #ifdef  _SYSCALL32
1017 
1018 typedef struct sof_socktuple32 {
1019         int32_t sofst_family;
1020         int32_t sofst_type;
1021         int32_t sofst_protocol;
1022 } sof_socktuple32_t;
1023 
1024 struct sockconfig_filter_props32 {
1025         caddr32_t       sfp_modname;
1026         boolean_t       sfp_autoattach;
1027         sof_hint_t      sfp_hint;
1028         caddr32_t       sfp_hintarg;
1029         uint32_t        sfp_socktuple_cnt;
1030         caddr32_t       sfp_socktuple;
1031 };
1032 





1033 #endif  /* _SYSCALL32 */
1034 
1035 #define SOCKMOD_PATH    "socketmod"     /* dir where sockmods are stored */
1036 
1037 #ifdef  __cplusplus
1038 }
1039 #endif
1040 
1041 #endif  /* _SYS_SOCKETVAR_H */


  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * University Copyright- Copyright (c) 1982, 1986, 1988
  31  * The Regents of the University of California
  32  * All Rights Reserved
  33  *
  34  * University Acknowledgment- Portions of this document are derived from
  35  * software developed by the University of California, Berkeley, and its
  36  * contributors.
  37  */
  38 /*
  39  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  40  */
  41 
  42 #ifndef _SYS_SOCKETVAR_H
  43 #define _SYS_SOCKETVAR_H
  44 
  45 #include <sys/types.h>
  46 #include <sys/stream.h>
  47 #include <sys/t_lock.h>
  48 #include <sys/cred.h>
  49 #include <sys/vnode.h>
  50 #include <sys/file.h>
  51 #include <sys/param.h>
  52 #include <sys/zone.h>
  53 #include <sys/sdt.h>
  54 #include <sys/modctl.h>
  55 #include <sys/atomic.h>
  56 #include <sys/socket.h>
  57 #include <sys/ksocket.h>
  58 #include <sys/kstat.h>
  59 
  60 #ifdef _KERNEL


 492 
 493 /*
 494  * sockparams flags
 495  */
 496 #define SOCKPARAMS_EPHEMERAL    0x1     /* temp. entry, not on global list */
 497 
 498 extern void sockparams_init(void);
 499 extern struct sockparams *sockparams_hold_ephemeral_bydev(int, int, int,
 500     const char *, int, int *);
 501 extern struct sockparams *sockparams_hold_ephemeral_bymod(int, int, int,
 502     const char *, int, int *);
 503 extern void sockparams_ephemeral_drop_last_ref(struct sockparams *);
 504 
 505 extern struct sockparams *sockparams_create(int, int, int, char *, char *, int,
 506     int, int, int *);
 507 extern void     sockparams_destroy(struct sockparams *);
 508 extern int      sockparams_add(struct sockparams *);
 509 extern int      sockparams_delete(int, int, int);
 510 extern int      sockparams_new_filter(struct sof_entry *);
 511 extern void     sockparams_filter_cleanup(struct sof_entry *);
 512 extern int      sockparams_copyout_socktable(uintptr_t);
 513 
 514 extern void smod_init(void);
 515 extern void smod_add(smod_info_t *);
 516 extern int smod_register(const smod_reg_t *);
 517 extern int smod_unregister(const char *);
 518 extern smod_info_t *smod_lookup_byname(const char *);
 519 
 520 #define SOCKPARAMS_HAS_DEVICE(sp)                                       \
 521         ((sp)->sp_sdev_info.sd_devpath != NULL)
 522 
 523 /* Increase the smod_info_t reference count */
 524 #define SMOD_INC_REF(smodp) {                                           \
 525         ASSERT((smodp) != NULL);                                        \
 526         DTRACE_PROBE1(smodinfo__inc__ref, struct smod_info *, (smodp)); \
 527         atomic_inc_uint(&(smodp)->smod_refcnt);                          \
 528 }
 529 
 530 /*
 531  * Decreace the socket module entry reference count.
 532  * When no one mapping to the entry, we try to unload the module from the


 962         uint_t          si_ux_laddr_sou_magic;
 963         uint_t          si_ux_faddr_sou_magic;
 964         t_scalar_t      si_serv_type;
 965         t_uscalar_t     si_laddr_soa_len;
 966         t_uscalar_t     si_faddr_soa_len;
 967         uint16_t        si_laddr_family;
 968         uint16_t        si_faddr_family;
 969         char            si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
 970         char            si_faddr_sun_path[MAXPATHLEN + 1];
 971         boolean_t       si_faddr_noxlate;
 972         zoneid_t        si_szoneid;
 973 };
 974 
 975 /*
 976  * Subcodes for sockconf() system call
 977  */
 978 #define SOCKCONFIG_ADD_SOCK             0
 979 #define SOCKCONFIG_REMOVE_SOCK          1
 980 #define SOCKCONFIG_ADD_FILTER           2
 981 #define SOCKCONFIG_REMOVE_FILTER        3
 982 #define SOCKCONFIG_GET_SOCKTABLE        4
 983 
 984 /*
 985  * Data structures for configuring socket filters.
 986  */
 987 
 988 /*
 989  * Placement hint for automatic filters
 990  */
 991 typedef enum {
 992         SOF_HINT_NONE,
 993         SOF_HINT_TOP,
 994         SOF_HINT_BOTTOM,
 995         SOF_HINT_BEFORE,
 996         SOF_HINT_AFTER
 997 } sof_hint_t;
 998 
 999 /*
1000  * Socket tuple. Used by sockconfig_filter_props to list socket
1001  * types of interest.
1002  */
1003 typedef struct sof_socktuple {
1004         int     sofst_family;
1005         int     sofst_type;
1006         int     sofst_protocol;
1007 } sof_socktuple_t;
1008 
1009 /*
1010  * Socket filter properties used by sockconfig() system call.
1011  */
1012 struct sockconfig_filter_props {
1013         char            *sfp_modname;
1014         boolean_t       sfp_autoattach;
1015         sof_hint_t      sfp_hint;
1016         char            *sfp_hintarg;
1017         uint_t          sfp_socktuple_cnt;
1018         sof_socktuple_t *sfp_socktuple;
1019 };
1020 
1021 /*
1022  * Data structures for the in-kernel socket configuration table.
1023  */
1024 typedef struct sockconfig_socktable_entry {
1025         int             se_family;
1026         int             se_type;
1027         int             se_protocol;
1028         int             se_refcnt;
1029         int             se_flags;
1030         char            se_modname[MODMAXNAMELEN];
1031         char            se_strdev[MAXPATHLEN];
1032 } sockconfig_socktable_entry_t;
1033 
1034 typedef struct sockconfig_socktable {
1035         uint_t          num_of_entries;
1036         sockconfig_socktable_entry_t *st_entries;
1037 } sockconfig_socktable_t;
1038 
1039 #ifdef  _SYSCALL32
1040 
1041 typedef struct sof_socktuple32 {
1042         int32_t sofst_family;
1043         int32_t sofst_type;
1044         int32_t sofst_protocol;
1045 } sof_socktuple32_t;
1046 
1047 struct sockconfig_filter_props32 {
1048         caddr32_t       sfp_modname;
1049         boolean_t       sfp_autoattach;
1050         sof_hint_t      sfp_hint;
1051         caddr32_t       sfp_hintarg;
1052         uint32_t        sfp_socktuple_cnt;
1053         caddr32_t       sfp_socktuple;
1054 };
1055 
1056 typedef struct sockconfig_socktable32 {
1057         uint_t          num_of_entries;
1058         caddr32_t       st_entries;
1059 } sockconfig_socktable32_t;
1060 
1061 #endif  /* _SYSCALL32 */
1062 
1063 #define SOCKMOD_PATH    "socketmod"     /* dir where sockmods are stored */
1064 
1065 #ifdef  __cplusplus
1066 }
1067 #endif
1068 
1069 #endif  /* _SYS_SOCKETVAR_H */