Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * cn_proc.c - process events connector |
| 3 | * |
| 4 | * Copyright (C) Matt Helsley, IBM Corp. 2005 |
| 5 | * Based on cn_fork.c by Guillaume Thouvenin <guillaume.thouvenin@bull.net> |
| 6 | * Original copyright notice follows: |
| 7 | * Copyright (C) 2005 BULL SA. |
| 8 | * |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/kernel.h> |
Matt Helsley | caf3c9d | 2006-01-09 20:52:40 -0800 | [diff] [blame] | 27 | #include <linux/ktime.h> |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 28 | #include <linux/init.h> |
Matt Helsley | 1d31a4e | 2006-06-23 02:05:42 -0700 | [diff] [blame] | 29 | #include <linux/connector.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/gfp.h> |
Vladimir Zapolskiy | f701e5b | 2011-07-15 20:45:18 +0300 | [diff] [blame] | 31 | #include <linux/ptrace.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 32 | #include <linux/atomic.h> |
Eric W. Biederman | 9582d90 | 2012-02-07 16:48:16 -0800 | [diff] [blame] | 33 | #include <linux/pid_namespace.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 34 | |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 35 | #include <asm/unaligned.h> |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 36 | |
| 37 | #include <linux/cn_proc.h> |
| 38 | |
| 39 | #define CN_PROC_MSG_SIZE (sizeof(struct cn_msg) + sizeof(struct proc_event)) |
| 40 | |
| 41 | static atomic_t proc_event_num_listeners = ATOMIC_INIT(0); |
| 42 | static struct cb_id cn_proc_event_id = { CN_IDX_PROC, CN_VAL_PROC }; |
| 43 | |
David S. Miller | cc398c2 | 2006-01-08 01:03:34 -0800 | [diff] [blame] | 44 | /* proc_event_counts is used as the sequence number of the netlink message */ |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 45 | static DEFINE_PER_CPU(__u32, proc_event_counts) = { 0 }; |
| 46 | |
| 47 | static inline void get_seq(__u32 *ts, int *cpu) |
| 48 | { |
Christoph Lameter | 3ea9f68 | 2010-12-08 17:42:23 +0100 | [diff] [blame] | 49 | preempt_disable(); |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 50 | *ts = __this_cpu_inc_return(proc_event_counts) - 1; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 51 | *cpu = smp_processor_id(); |
Christoph Lameter | 3ea9f68 | 2010-12-08 17:42:23 +0100 | [diff] [blame] | 52 | preempt_enable(); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void proc_fork_connector(struct task_struct *task) |
| 56 | { |
| 57 | struct cn_msg *msg; |
| 58 | struct proc_event *ev; |
| 59 | __u8 buffer[CN_PROC_MSG_SIZE]; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 60 | struct timespec ts; |
Oleg Nesterov | 9e8f90d | 2011-07-28 18:26:32 -0700 | [diff] [blame] | 61 | struct task_struct *parent; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 62 | |
| 63 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 64 | return; |
| 65 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 66 | msg = (struct cn_msg *)buffer; |
| 67 | ev = (struct proc_event *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 68 | get_seq(&msg->seq, &ev->cpu); |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 69 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 70 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 71 | ev->what = PROC_EVENT_FORK; |
Oleg Nesterov | 9e8f90d | 2011-07-28 18:26:32 -0700 | [diff] [blame] | 72 | rcu_read_lock(); |
| 73 | parent = rcu_dereference(task->real_parent); |
| 74 | ev->event_data.fork.parent_pid = parent->pid; |
| 75 | ev->event_data.fork.parent_tgid = parent->tgid; |
| 76 | rcu_read_unlock(); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 77 | ev->event_data.fork.child_pid = task->pid; |
| 78 | ev->event_data.fork.child_tgid = task->tgid; |
| 79 | |
| 80 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 81 | msg->ack = 0; /* not used */ |
| 82 | msg->len = sizeof(*ev); |
| 83 | /* If cn_netlink_send() failed, the data is not sent */ |
| 84 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 85 | } |
| 86 | |
| 87 | void proc_exec_connector(struct task_struct *task) |
| 88 | { |
| 89 | struct cn_msg *msg; |
| 90 | struct proc_event *ev; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 91 | struct timespec ts; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 92 | __u8 buffer[CN_PROC_MSG_SIZE]; |
| 93 | |
| 94 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 95 | return; |
| 96 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 97 | msg = (struct cn_msg *)buffer; |
| 98 | ev = (struct proc_event *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 99 | get_seq(&msg->seq, &ev->cpu); |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 100 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 101 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 102 | ev->what = PROC_EVENT_EXEC; |
| 103 | ev->event_data.exec.process_pid = task->pid; |
| 104 | ev->event_data.exec.process_tgid = task->tgid; |
| 105 | |
| 106 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 107 | msg->ack = 0; /* not used */ |
| 108 | msg->len = sizeof(*ev); |
| 109 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 110 | } |
| 111 | |
| 112 | void proc_id_connector(struct task_struct *task, int which_id) |
| 113 | { |
| 114 | struct cn_msg *msg; |
| 115 | struct proc_event *ev; |
| 116 | __u8 buffer[CN_PROC_MSG_SIZE]; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 117 | struct timespec ts; |
David Howells | c69e8d9 | 2008-11-14 10:39:19 +1100 | [diff] [blame] | 118 | const struct cred *cred; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 119 | |
| 120 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 121 | return; |
| 122 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 123 | msg = (struct cn_msg *)buffer; |
| 124 | ev = (struct proc_event *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 125 | ev->what = which_id; |
| 126 | ev->event_data.id.process_pid = task->pid; |
| 127 | ev->event_data.id.process_tgid = task->tgid; |
David Howells | c69e8d9 | 2008-11-14 10:39:19 +1100 | [diff] [blame] | 128 | rcu_read_lock(); |
| 129 | cred = __task_cred(task); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 130 | if (which_id == PROC_EVENT_UID) { |
Eric W. Biederman | 9582d90 | 2012-02-07 16:48:16 -0800 | [diff] [blame] | 131 | ev->event_data.id.r.ruid = from_kuid_munged(&init_user_ns, cred->uid); |
| 132 | ev->event_data.id.e.euid = from_kuid_munged(&init_user_ns, cred->euid); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 133 | } else if (which_id == PROC_EVENT_GID) { |
Eric W. Biederman | 9582d90 | 2012-02-07 16:48:16 -0800 | [diff] [blame] | 134 | ev->event_data.id.r.rgid = from_kgid_munged(&init_user_ns, cred->gid); |
| 135 | ev->event_data.id.e.egid = from_kgid_munged(&init_user_ns, cred->egid); |
David Howells | c69e8d9 | 2008-11-14 10:39:19 +1100 | [diff] [blame] | 136 | } else { |
| 137 | rcu_read_unlock(); |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 138 | return; |
David Howells | c69e8d9 | 2008-11-14 10:39:19 +1100 | [diff] [blame] | 139 | } |
| 140 | rcu_read_unlock(); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 141 | get_seq(&msg->seq, &ev->cpu); |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 142 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 143 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 144 | |
| 145 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 146 | msg->ack = 0; /* not used */ |
| 147 | msg->len = sizeof(*ev); |
| 148 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 149 | } |
| 150 | |
Scott James Remnant | 02b51df | 2009-09-22 16:43:44 -0700 | [diff] [blame] | 151 | void proc_sid_connector(struct task_struct *task) |
| 152 | { |
| 153 | struct cn_msg *msg; |
| 154 | struct proc_event *ev; |
| 155 | struct timespec ts; |
| 156 | __u8 buffer[CN_PROC_MSG_SIZE]; |
| 157 | |
| 158 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 159 | return; |
| 160 | |
| 161 | msg = (struct cn_msg *)buffer; |
| 162 | ev = (struct proc_event *)msg->data; |
| 163 | get_seq(&msg->seq, &ev->cpu); |
| 164 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
| 165 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
| 166 | ev->what = PROC_EVENT_SID; |
| 167 | ev->event_data.sid.process_pid = task->pid; |
| 168 | ev->event_data.sid.process_tgid = task->tgid; |
| 169 | |
| 170 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 171 | msg->ack = 0; /* not used */ |
| 172 | msg->len = sizeof(*ev); |
| 173 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 174 | } |
| 175 | |
Vladimir Zapolskiy | f701e5b | 2011-07-15 20:45:18 +0300 | [diff] [blame] | 176 | void proc_ptrace_connector(struct task_struct *task, int ptrace_id) |
| 177 | { |
| 178 | struct cn_msg *msg; |
| 179 | struct proc_event *ev; |
| 180 | struct timespec ts; |
| 181 | __u8 buffer[CN_PROC_MSG_SIZE]; |
Vladimir Zapolskiy | f701e5b | 2011-07-15 20:45:18 +0300 | [diff] [blame] | 182 | |
| 183 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 184 | return; |
| 185 | |
| 186 | msg = (struct cn_msg *)buffer; |
| 187 | ev = (struct proc_event *)msg->data; |
| 188 | get_seq(&msg->seq, &ev->cpu); |
| 189 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
| 190 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
| 191 | ev->what = PROC_EVENT_PTRACE; |
| 192 | ev->event_data.ptrace.process_pid = task->pid; |
| 193 | ev->event_data.ptrace.process_tgid = task->tgid; |
| 194 | if (ptrace_id == PTRACE_ATTACH) { |
| 195 | ev->event_data.ptrace.tracer_pid = current->pid; |
| 196 | ev->event_data.ptrace.tracer_tgid = current->tgid; |
| 197 | } else if (ptrace_id == PTRACE_DETACH) { |
| 198 | ev->event_data.ptrace.tracer_pid = 0; |
| 199 | ev->event_data.ptrace.tracer_tgid = 0; |
| 200 | } else |
| 201 | return; |
| 202 | |
| 203 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 204 | msg->ack = 0; /* not used */ |
| 205 | msg->len = sizeof(*ev); |
| 206 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 207 | } |
| 208 | |
Vladimir Zapolskiy | f786ecb | 2011-09-21 09:26:44 +0000 | [diff] [blame] | 209 | void proc_comm_connector(struct task_struct *task) |
| 210 | { |
| 211 | struct cn_msg *msg; |
| 212 | struct proc_event *ev; |
| 213 | struct timespec ts; |
| 214 | __u8 buffer[CN_PROC_MSG_SIZE]; |
| 215 | |
| 216 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 217 | return; |
| 218 | |
| 219 | msg = (struct cn_msg *)buffer; |
| 220 | ev = (struct proc_event *)msg->data; |
| 221 | get_seq(&msg->seq, &ev->cpu); |
| 222 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
| 223 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
| 224 | ev->what = PROC_EVENT_COMM; |
| 225 | ev->event_data.comm.process_pid = task->pid; |
| 226 | ev->event_data.comm.process_tgid = task->tgid; |
| 227 | get_task_comm(ev->event_data.comm.comm, task); |
| 228 | |
| 229 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 230 | msg->ack = 0; /* not used */ |
| 231 | msg->len = sizeof(*ev); |
| 232 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 233 | } |
| 234 | |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 235 | void proc_exit_connector(struct task_struct *task) |
| 236 | { |
| 237 | struct cn_msg *msg; |
| 238 | struct proc_event *ev; |
| 239 | __u8 buffer[CN_PROC_MSG_SIZE]; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 240 | struct timespec ts; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 241 | |
| 242 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 243 | return; |
| 244 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 245 | msg = (struct cn_msg *)buffer; |
| 246 | ev = (struct proc_event *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 247 | get_seq(&msg->seq, &ev->cpu); |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 248 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 249 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 250 | ev->what = PROC_EVENT_EXIT; |
| 251 | ev->event_data.exit.process_pid = task->pid; |
| 252 | ev->event_data.exit.process_tgid = task->tgid; |
| 253 | ev->event_data.exit.exit_code = task->exit_code; |
| 254 | ev->event_data.exit.exit_signal = task->exit_signal; |
| 255 | |
| 256 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 257 | msg->ack = 0; /* not used */ |
| 258 | msg->len = sizeof(*ev); |
| 259 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | * Send an acknowledgement message to userspace |
| 264 | * |
| 265 | * Use 0 for success, EFOO otherwise. |
| 266 | * Note: this is the negative of conventional kernel error |
| 267 | * values because it's not being returned via syscall return |
| 268 | * mechanisms. |
| 269 | */ |
| 270 | static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) |
| 271 | { |
| 272 | struct cn_msg *msg; |
| 273 | struct proc_event *ev; |
| 274 | __u8 buffer[CN_PROC_MSG_SIZE]; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 275 | struct timespec ts; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 276 | |
| 277 | if (atomic_read(&proc_event_num_listeners) < 1) |
| 278 | return; |
| 279 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 280 | msg = (struct cn_msg *)buffer; |
| 281 | ev = (struct proc_event *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 282 | msg->seq = rcvd_seq; |
Chandra Seetharaman | 822cfbff | 2006-07-30 03:03:04 -0700 | [diff] [blame] | 283 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ |
Erik Jacobson | af3e095 | 2007-01-05 16:37:05 -0800 | [diff] [blame] | 284 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 285 | ev->cpu = -1; |
| 286 | ev->what = PROC_EVENT_NONE; |
| 287 | ev->event_data.ack.err = err; |
| 288 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); |
| 289 | msg->ack = rcvd_ack + 1; |
| 290 | msg->len = sizeof(*ev); |
| 291 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * cn_proc_mcast_ctl |
| 296 | * @data: message sent from userspace via the connector |
| 297 | */ |
Stephen Boyd | f0b2593 | 2009-10-06 01:39:51 -0700 | [diff] [blame] | 298 | static void cn_proc_mcast_ctl(struct cn_msg *msg, |
| 299 | struct netlink_skb_parms *nsp) |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 300 | { |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 301 | enum proc_cn_mcast_op *mc_op = NULL; |
| 302 | int err = 0; |
| 303 | |
| 304 | if (msg->len != sizeof(*mc_op)) |
| 305 | return; |
| 306 | |
Eric W. Biederman | 9582d90 | 2012-02-07 16:48:16 -0800 | [diff] [blame] | 307 | /* |
| 308 | * Events are reported with respect to the initial pid |
| 309 | * and user namespaces so ignore requestors from |
| 310 | * other namespaces. |
| 311 | */ |
| 312 | if ((current_user_ns() != &init_user_ns) || |
| 313 | (task_active_pid_ns(current) != &init_pid_ns)) |
| 314 | return; |
| 315 | |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 316 | mc_op = (enum proc_cn_mcast_op *)msg->data; |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 317 | switch (*mc_op) { |
| 318 | case PROC_CN_MCAST_LISTEN: |
| 319 | atomic_inc(&proc_event_num_listeners); |
| 320 | break; |
| 321 | case PROC_CN_MCAST_IGNORE: |
| 322 | atomic_dec(&proc_event_num_listeners); |
| 323 | break; |
| 324 | default: |
| 325 | err = EINVAL; |
| 326 | break; |
| 327 | } |
| 328 | cn_proc_ack(err, msg->seq, msg->ack); |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | * cn_proc_init - initialization entry point |
| 333 | * |
| 334 | * Adds the connector callback to the connector driver. |
| 335 | */ |
| 336 | static int __init cn_proc_init(void) |
| 337 | { |
Valentin Ilie | f3c48ec | 2012-07-14 13:08:29 +0000 | [diff] [blame] | 338 | int err = cn_add_callback(&cn_proc_event_id, |
| 339 | "cn_proc", |
| 340 | &cn_proc_mcast_ctl); |
| 341 | if (err) { |
| 342 | pr_warn("cn_proc failed to register\n"); |
Matt Helsley | 9f46080 | 2005-11-07 00:59:16 -0800 | [diff] [blame] | 343 | return err; |
| 344 | } |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | module_init(cn_proc_init); |