The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/rctl.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2010 The FreeBSD Foundation
    3  * All rights reserved.
    4  *
    5  * This software was developed by Edward Tomasz Napierala under sponsorship
    6  * from the FreeBSD Foundation.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/11.1/sys/sys/rctl.h 297633 2016-04-07 04:23:25Z trasz $
   30  */
   31 
   32 /*
   33  * Resource Limits.
   34  */
   35 
   36 #ifndef _RCTL_H_
   37 #define _RCTL_H_
   38 
   39 #include <sys/cdefs.h>
   40 #include <sys/queue.h>
   41 #include <sys/types.h>
   42 #include <sys/_task.h>
   43 
   44 struct proc;
   45 struct uidinfo;
   46 struct loginclass;
   47 struct prison_racct;
   48 struct ucred;
   49 struct rctl_rule_link;
   50 
   51 #ifdef _KERNEL
   52 
   53 /*
   54  * Rules describe an action to be taken when conditions defined
   55  * in the rule are met.  There is no global list of rules; instead,
   56  * rules are linked to by the racct structures for all the subjects
   57  * they apply to - for example, a rule of type "user" is linked to the
   58  * appropriate struct uidinfo, and to all the processes of that user.
   59  *
   60  * 'rr_refcount' is equal to the number of rctl_rule_link structures
   61  * pointing to the rule.
   62  *
   63  * This structure must never change after being added, via rctl_rule_link
   64  * structures, to subjects.  In order to change a rule, add a new rule
   65  * and remove the previous one.
   66  */
   67 struct rctl_rule {
   68         int             rr_subject_type;
   69         union {
   70                 struct proc             *rs_proc;
   71                 struct uidinfo          *rs_uip;
   72                 struct loginclass       *rs_loginclass;
   73                 struct prison_racct     *rs_prison_racct;
   74         } rr_subject;
   75         int             rr_per;
   76         int             rr_resource;
   77         int             rr_action;
   78         int64_t         rr_amount;
   79         u_int           rr_refcount;
   80         struct task     rr_task;
   81 };
   82 
   83 /*
   84  * Allowed values for rr_subject_type and rr_per fields.
   85  */
   86 #define RCTL_SUBJECT_TYPE_UNDEFINED     -1
   87 #define RCTL_SUBJECT_TYPE_PROCESS       0x0000
   88 #define RCTL_SUBJECT_TYPE_USER          0x0001
   89 #define RCTL_SUBJECT_TYPE_LOGINCLASS    0x0003
   90 #define RCTL_SUBJECT_TYPE_JAIL          0x0004
   91 #define RCTL_SUBJECT_TYPE_MAX           RCTL_SUBJECT_TYPE_JAIL
   92 
   93 /*
   94  * Allowed values for rr_action field.
   95  */
   96 #define RCTL_ACTION_UNDEFINED           -1
   97 #define RCTL_ACTION_SIGHUP              SIGHUP
   98 #define RCTL_ACTION_SIGINT              SIGINT
   99 #define RCTL_ACTION_SIGQUIT             SIGQUIT
  100 #define RCTL_ACTION_SIGILL              SIGILL
  101 #define RCTL_ACTION_SIGTRAP             SIGTRAP
  102 #define RCTL_ACTION_SIGABRT             SIGABRT
  103 #define RCTL_ACTION_SIGEMT              SIGEMT
  104 #define RCTL_ACTION_SIGFPE              SIGFPE
  105 #define RCTL_ACTION_SIGKILL             SIGKILL
  106 #define RCTL_ACTION_SIGBUS              SIGBUS
  107 #define RCTL_ACTION_SIGSEGV             SIGSEGV
  108 #define RCTL_ACTION_SIGSYS              SIGSYS
  109 #define RCTL_ACTION_SIGPIPE             SIGPIPE
  110 #define RCTL_ACTION_SIGALRM             SIGALRM
  111 #define RCTL_ACTION_SIGTERM             SIGTERM
  112 #define RCTL_ACTION_SIGURG              SIGURG
  113 #define RCTL_ACTION_SIGSTOP             SIGSTOP
  114 #define RCTL_ACTION_SIGTSTP             SIGTSTP
  115 #define RCTL_ACTION_SIGCHLD             SIGCHLD
  116 #define RCTL_ACTION_SIGTTIN             SIGTTIN
  117 #define RCTL_ACTION_SIGTTOU             SIGTTOU
  118 #define RCTL_ACTION_SIGIO               SIGIO
  119 #define RCTL_ACTION_SIGXCPU             SIGXCPU
  120 #define RCTL_ACTION_SIGXFSZ             SIGXFSZ
  121 #define RCTL_ACTION_SIGVTALRM           SIGVTALRM
  122 #define RCTL_ACTION_SIGPROF             SIGPROF
  123 #define RCTL_ACTION_SIGWINCH            SIGWINCH
  124 #define RCTL_ACTION_SIGINFO             SIGINFO
  125 #define RCTL_ACTION_SIGUSR1             SIGUSR1
  126 #define RCTL_ACTION_SIGUSR2             SIGUSR2
  127 #define RCTL_ACTION_SIGTHR              SIGTHR
  128 #define RCTL_ACTION_SIGNAL_MAX          RCTL_ACTION_SIGTHR
  129 #define RCTL_ACTION_DENY                (RCTL_ACTION_SIGNAL_MAX + 1)
  130 #define RCTL_ACTION_LOG                 (RCTL_ACTION_SIGNAL_MAX + 2)
  131 #define RCTL_ACTION_DEVCTL              (RCTL_ACTION_SIGNAL_MAX + 3)
  132 #define RCTL_ACTION_THROTTLE            (RCTL_ACTION_SIGNAL_MAX + 4)
  133 #define RCTL_ACTION_MAX                 RCTL_ACTION_THROTTLE
  134 
  135 #define RCTL_AMOUNT_UNDEFINED           -1
  136 
  137 struct rctl_rule *rctl_rule_alloc(int flags);
  138 struct rctl_rule *rctl_rule_duplicate(const struct rctl_rule *rule, int flags);
  139 void    rctl_rule_acquire(struct rctl_rule *rule);
  140 void    rctl_rule_release(struct rctl_rule *rule);
  141 int     rctl_rule_add(struct rctl_rule *rule);
  142 int     rctl_rule_remove(struct rctl_rule *filter);
  143 int     rctl_enforce(struct proc *p, int resource, uint64_t amount);
  144 void    rctl_throttle_decay(struct racct *racct, int resource);
  145 int64_t rctl_pcpu_available(const struct proc *p);
  146 uint64_t rctl_get_limit(struct proc *p, int resource);
  147 uint64_t rctl_get_available(struct proc *p, int resource);
  148 const char *rctl_resource_name(int resource);
  149 void    rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred);
  150 int     rctl_proc_fork(struct proc *parent, struct proc *child);
  151 void    rctl_racct_release(struct racct *racct);
  152 #else /* !_KERNEL */
  153 
  154 /*
  155  * Syscall interface.
  156  */
  157 __BEGIN_DECLS
  158 int     rctl_get_racct(const char *inbufp, size_t inbuflen, char *outbufp,
  159             size_t outbuflen);
  160 int     rctl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp,
  161             size_t outbuflen);
  162 int     rctl_get_limits(const char *inbufp, size_t inbuflen, char *outbufp,
  163             size_t outbuflen);
  164 int     rctl_add_rule(const char *inbufp, size_t inbuflen, char *outbufp,
  165             size_t outbuflen);
  166 int     rctl_remove_rule(const char *inbufp, size_t inbuflen, char *outbufp,
  167             size_t outbuflen);
  168 __END_DECLS
  169 
  170 #endif /* !_KERNEL */
  171 
  172 #endif /* !_RCTL_H_ */

Cache object: 67d0842cd2b73e0ad4f9e96e85fc9011


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.