2 * Copyright (C) 2007 IBM Corporation
4 * Author: Cedric Le Goater <clg@fr.ibm.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the
12 #include <linux/nsproxy.h>
13 #include <linux/ipc_namespace.h>
14 #include <linux/sysctl.h>
17 * Define the ranges various user-specified maximum values can
20 #define MIN_MSGMAX 1 /* min value for msg_max */
21 #define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
22 #define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
23 #define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
25 static void *get_mq(ctl_table
*table
)
27 char *which
= table
->data
;
28 struct ipc_namespace
*ipc_ns
= current
->nsproxy
->ipc_ns
;
29 which
= (which
- (char *)&init_ipc_ns
) + (char *)ipc_ns
;
33 #ifdef CONFIG_PROC_SYSCTL
34 static int proc_mq_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
35 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
37 struct ctl_table mq_table
;
38 memcpy(&mq_table
, table
, sizeof(mq_table
));
39 mq_table
.data
= get_mq(table
);
41 return proc_dointvec(&mq_table
, write
, filp
, buffer
, lenp
, ppos
);
44 static int proc_mq_dointvec_minmax(ctl_table
*table
, int write
,
45 struct file
*filp
, void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
47 struct ctl_table mq_table
;
48 memcpy(&mq_table
, table
, sizeof(mq_table
));
49 mq_table
.data
= get_mq(table
);
51 return proc_dointvec_minmax(&mq_table
, write
, filp
, buffer
,
55 #define proc_mq_dointvec NULL
56 #define proc_mq_dointvec_minmax NULL
59 static int msg_max_limit_min
= MIN_MSGMAX
;
60 static int msg_max_limit_max
= MAX_MSGMAX
;
62 static int msg_maxsize_limit_min
= MIN_MSGSIZEMAX
;
63 static int msg_maxsize_limit_max
= MAX_MSGSIZEMAX
;
65 static ctl_table mq_sysctls
[] = {
67 .procname
= "queues_max",
68 .data
= &init_ipc_ns
.mq_queues_max
,
69 .maxlen
= sizeof(int),
71 .proc_handler
= proc_mq_dointvec
,
74 .procname
= "msg_max",
75 .data
= &init_ipc_ns
.mq_msg_max
,
76 .maxlen
= sizeof(int),
78 .proc_handler
= proc_mq_dointvec_minmax
,
79 .extra1
= &msg_max_limit_min
,
80 .extra2
= &msg_max_limit_max
,
83 .procname
= "msgsize_max",
84 .data
= &init_ipc_ns
.mq_msgsize_max
,
85 .maxlen
= sizeof(int),
87 .proc_handler
= proc_mq_dointvec_minmax
,
88 .extra1
= &msg_maxsize_limit_min
,
89 .extra2
= &msg_maxsize_limit_max
,
94 static ctl_table mq_sysctl_dir
[] = {
103 static ctl_table mq_sysctl_root
[] = {
108 .child
= mq_sysctl_dir
,
113 struct ctl_table_header
*mq_register_sysctl_table(void)
115 return register_sysctl_table(mq_sysctl_root
);