1 | /* |
---|
2 | * ksyslog: In-kernel syslog receiver |
---|
3 | * Copyright(C) 2013 Atzm WATANABE All rights reserved |
---|
4 | * Distributed under the GPL |
---|
5 | */ |
---|
6 | |
---|
7 | #include <linux/module.h> |
---|
8 | #include <linux/ip.h> |
---|
9 | #include <linux/udp.h> |
---|
10 | #include <linux/namei.h> |
---|
11 | #include <net/udp.h> |
---|
12 | #include "ksyslog.h" |
---|
13 | |
---|
14 | static DEFINE_SPINLOCK(ksyslog_queue_lock); |
---|
15 | static DEFINE_SPINLOCK(ksyslog_vfs_lock); |
---|
16 | |
---|
17 | static struct socket *ksyslog_rcv_sk = NULL; |
---|
18 | |
---|
19 | static struct delayed_work ksyslog_work; |
---|
20 | static struct workqueue_struct *ksyslog_wq = NULL; |
---|
21 | |
---|
22 | static struct ksyslog_queue ksyslog_queue; |
---|
23 | |
---|
24 | #ifdef CONFIG_PROC_FS |
---|
25 | static struct proc_dir_entry *ksyslog_procdir = NULL; |
---|
26 | static struct proc_dir_entry *ksyslog_proc_queue = NULL; |
---|
27 | #endif |
---|
28 | |
---|
29 | static char *ksyslog_host = "0.0.0.0"; |
---|
30 | static ushort ksyslog_port = 514; |
---|
31 | static char *ksyslog_path = "/var/log/ksyslog.log"; |
---|
32 | static uint ksyslog_queue_max = 2048; |
---|
33 | static ulong ksyslog_flush_interval = 45; /* milliseconds */ |
---|
34 | |
---|
35 | module_param(ksyslog_host, charp, 0444); |
---|
36 | module_param(ksyslog_port, ushort, 0444); |
---|
37 | module_param(ksyslog_path, charp, 0644); |
---|
38 | module_param(ksyslog_queue_max, uint, 0644); |
---|
39 | module_param(ksyslog_flush_interval, ulong, 0644); |
---|
40 | |
---|
41 | static int |
---|
42 | ksyslog_close(struct file *file) |
---|
43 | { |
---|
44 | return filp_close(file, NULL); |
---|
45 | } |
---|
46 | |
---|
47 | static struct file * |
---|
48 | ksyslog_open(const char *path) |
---|
49 | { |
---|
50 | struct file *file; |
---|
51 | struct nameidata nd; |
---|
52 | mm_segment_t oldfs; |
---|
53 | |
---|
54 | oldfs = get_fs(); |
---|
55 | set_fs(get_ds()); |
---|
56 | |
---|
57 | if (unlikely(path_lookup(path, LOOKUP_OPEN|LOOKUP_FOLLOW, &nd))) |
---|
58 | file = filp_open(path, O_CREAT|O_WRONLY|O_APPEND|O_LARGEFILE, 0600); |
---|
59 | else |
---|
60 | file = filp_open(path, O_WRONLY|O_APPEND|O_LARGEFILE, 0); |
---|
61 | |
---|
62 | if (unlikely(IS_ERR(file))) |
---|
63 | goto out; |
---|
64 | |
---|
65 | if (unlikely(S_ISDIR(file->f_path.dentry->d_inode->i_mode))) { |
---|
66 | ksyslog_close(file); |
---|
67 | file = ERR_PTR(-EISDIR); |
---|
68 | goto out; |
---|
69 | } |
---|
70 | |
---|
71 | if (unlikely(file->f_pos < 0)) { |
---|
72 | ksyslog_close(file); |
---|
73 | file = ERR_PTR(-EIO); |
---|
74 | goto out; |
---|
75 | } |
---|
76 | |
---|
77 | out: |
---|
78 | set_fs(oldfs); |
---|
79 | return file; |
---|
80 | } |
---|
81 | |
---|
82 | static int |
---|
83 | ksyslog_write(struct file *file, const char *buf, const size_t length) |
---|
84 | { |
---|
85 | int err; |
---|
86 | mm_segment_t oldfs; |
---|
87 | |
---|
88 | oldfs = get_fs(); |
---|
89 | set_fs(get_ds()); |
---|
90 | |
---|
91 | err = vfs_write(file, (__force void __user *)buf, length, &file->f_pos); |
---|
92 | |
---|
93 | set_fs(oldfs); |
---|
94 | return err; |
---|
95 | } |
---|
96 | |
---|
97 | static void |
---|
98 | ksyslog_drop_warning(const struct ksyslog_entry *entry) |
---|
99 | { |
---|
100 | pr_warn("dropped: %llu %s.%s %u.%u.%u.%u %.*s\n", |
---|
101 | timeval_to_ns(&entry->tv) / 1000 / 1000 / 1000, |
---|
102 | ksyslog_facility_str(entry->facility), |
---|
103 | ksyslog_severity_str(entry->severity), |
---|
104 | entry->saddr.addr8[0], entry->saddr.addr8[1], |
---|
105 | entry->saddr.addr8[2], entry->saddr.addr8[3], |
---|
106 | (int)entry->length, entry->data); |
---|
107 | } |
---|
108 | |
---|
109 | static int |
---|
110 | ksyslog_format(char **buf, const struct ksyslog_entry *entry) |
---|
111 | { |
---|
112 | *buf = kzalloc(54 + entry->length + 2, GFP_ATOMIC); |
---|
113 | if (unlikely(*buf == NULL)) |
---|
114 | return -ENOMEM; |
---|
115 | |
---|
116 | return sprintf(*buf, "%llu %s.%s %u.%u.%u.%u %.*s\n", |
---|
117 | timeval_to_ns(&entry->tv) / 1000 / 1000 / 1000, |
---|
118 | ksyslog_facility_str(entry->facility), |
---|
119 | ksyslog_severity_str(entry->severity), |
---|
120 | entry->saddr.addr8[0], entry->saddr.addr8[1], |
---|
121 | entry->saddr.addr8[2], entry->saddr.addr8[3], |
---|
122 | (int)entry->length, entry->data); |
---|
123 | } |
---|
124 | |
---|
125 | static struct ksyslog_entry * |
---|
126 | ksyslog_entry_create(const struct sk_buff *skb, |
---|
127 | const struct iphdr *iph, const struct udphdr *udph) |
---|
128 | { |
---|
129 | struct ksyslog_entry *entry; |
---|
130 | unsigned int priority, facility, severity, month, day, hour, minute, second; |
---|
131 | unsigned char *start, month_s[4]; |
---|
132 | struct tm tm; |
---|
133 | int length, i; |
---|
134 | |
---|
135 | if (sscanf(skb->data, "<%3u>%3s %2u %2u:%2u:%2u ", |
---|
136 | &priority, month_s, &day, &hour, &minute, &second) != 6) |
---|
137 | return ERR_PTR(-EINVAL); |
---|
138 | |
---|
139 | start = memchr(skb->data, '>', 5); |
---|
140 | if (start == NULL) |
---|
141 | return ERR_PTR(-EINVAL); |
---|
142 | start++; |
---|
143 | |
---|
144 | facility = priority >> 3; |
---|
145 | severity = priority & 7; |
---|
146 | |
---|
147 | if (facility >= __KSYSLOG_F_MAX) |
---|
148 | return ERR_PTR(-EINVAL); |
---|
149 | if (severity >= __KSYSLOG_S_MAX) |
---|
150 | return ERR_PTR(-EINVAL); |
---|
151 | |
---|
152 | month = ksyslog_month_num(month_s); |
---|
153 | if (!month) |
---|
154 | return ERR_PTR(-EINVAL); |
---|
155 | if (day > 31) |
---|
156 | return ERR_PTR(-EINVAL); |
---|
157 | if (hour > 23) |
---|
158 | return ERR_PTR(-EINVAL); |
---|
159 | if (minute > 59) |
---|
160 | return ERR_PTR(-EINVAL); |
---|
161 | if (second > 59) |
---|
162 | return ERR_PTR(-EINVAL); |
---|
163 | |
---|
164 | entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
---|
165 | if (unlikely(entry == NULL)) |
---|
166 | return ERR_PTR(-ENOMEM); |
---|
167 | |
---|
168 | length = skb->len - (start - skb->data); |
---|
169 | entry->data = kzalloc(length, GFP_ATOMIC); |
---|
170 | if (unlikely(entry->data == NULL)) { |
---|
171 | kfree(entry); |
---|
172 | return ERR_PTR(-ENOMEM); |
---|
173 | } |
---|
174 | |
---|
175 | if (skb->tstamp.tv64) |
---|
176 | entry->tv = ktime_to_timeval(skb->tstamp); |
---|
177 | else |
---|
178 | do_gettimeofday(&entry->tv); |
---|
179 | |
---|
180 | time_to_tm(entry->tv.tv_sec, 0, &tm); |
---|
181 | entry->time = mktime(tm.tm_year + 1900, month, day, hour, minute, second); |
---|
182 | |
---|
183 | entry->priority = priority; |
---|
184 | entry->facility = facility; |
---|
185 | entry->severity = severity; |
---|
186 | |
---|
187 | entry->daddr.addr32 = iph->daddr; |
---|
188 | entry->saddr.addr32 = iph->saddr; |
---|
189 | |
---|
190 | entry->dport = udph->dest; |
---|
191 | entry->sport = udph->source; |
---|
192 | |
---|
193 | entry->length = length; |
---|
194 | memcpy(entry->data, start, length); |
---|
195 | |
---|
196 | for (i = 0; i < length; i++) |
---|
197 | if (unlikely(entry->data[i] == '\n')) |
---|
198 | entry->data[i] = ' '; |
---|
199 | |
---|
200 | return entry; |
---|
201 | } |
---|
202 | |
---|
203 | static void |
---|
204 | ksyslog_entry_free(struct rcu_head *head) |
---|
205 | { |
---|
206 | struct ksyslog_entry *entry = container_of(head, struct ksyslog_entry, rcu); |
---|
207 | kfree(entry->data); |
---|
208 | kfree(entry); |
---|
209 | } |
---|
210 | |
---|
211 | static int |
---|
212 | ksyslog_entry_add(struct ksyslog_queue *queue, struct ksyslog_entry *entry) |
---|
213 | { |
---|
214 | if (unlikely(queue->length >= ksyslog_queue_max)) |
---|
215 | return -ENOBUFS; |
---|
216 | list_add_tail_rcu(&entry->list, &queue->head); |
---|
217 | WARN_ON(++queue->length > ksyslog_queue_max); |
---|
218 | return 0; |
---|
219 | } |
---|
220 | |
---|
221 | static void |
---|
222 | ksyslog_entry_del(struct ksyslog_queue *queue, struct ksyslog_entry *entry, bool free) |
---|
223 | { |
---|
224 | WARN_ON(--queue->length < 0); |
---|
225 | list_del_rcu(&entry->list); |
---|
226 | if (free) |
---|
227 | call_rcu(&entry->rcu, ksyslog_entry_free); |
---|
228 | } |
---|
229 | |
---|
230 | static void |
---|
231 | ksyslog_entry_destroy(struct ksyslog_queue *queue) |
---|
232 | { |
---|
233 | struct ksyslog_entry *entry, *next; |
---|
234 | |
---|
235 | list_for_each_entry_safe(entry, next, &queue->head, list) |
---|
236 | ksyslog_entry_del(queue, entry, true); |
---|
237 | } |
---|
238 | |
---|
239 | static void |
---|
240 | ksyslog_entry_migrate(struct ksyslog_queue *from, struct ksyslog_queue *to) |
---|
241 | { |
---|
242 | struct ksyslog_entry *entry, *next; |
---|
243 | |
---|
244 | list_for_each_entry_safe(entry, next, &from->head, list) { |
---|
245 | ksyslog_entry_del(from, entry, false); |
---|
246 | if (unlikely(ksyslog_entry_add(to, entry))) { |
---|
247 | ksyslog_drop_warning(entry); |
---|
248 | call_rcu(&entry->rcu, ksyslog_entry_free); |
---|
249 | } |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | static void |
---|
254 | ksyslog_work_register(unsigned long timer) |
---|
255 | { |
---|
256 | queue_delayed_work(ksyslog_wq, &ksyslog_work, timer * HZ / 1000); |
---|
257 | } |
---|
258 | |
---|
259 | static void |
---|
260 | ksyslog_work_unregister(void) |
---|
261 | { |
---|
262 | cancel_delayed_work_sync(&ksyslog_work); |
---|
263 | } |
---|
264 | |
---|
265 | static void |
---|
266 | ksyslog_work_handler(struct work_struct *work) |
---|
267 | { |
---|
268 | struct file *file = NULL; |
---|
269 | struct ksyslog_entry *entry, *next; |
---|
270 | struct ksyslog_queue write_queue; |
---|
271 | |
---|
272 | memset(&write_queue, 0, sizeof(write_queue)); |
---|
273 | INIT_LIST_HEAD(&write_queue.head); |
---|
274 | |
---|
275 | spin_lock_bh(&ksyslog_queue_lock); |
---|
276 | ksyslog_entry_migrate(&ksyslog_queue, &write_queue); |
---|
277 | spin_unlock_bh(&ksyslog_queue_lock); |
---|
278 | |
---|
279 | if (write_queue.length <= 0) |
---|
280 | goto out; |
---|
281 | |
---|
282 | spin_lock(&ksyslog_vfs_lock); |
---|
283 | |
---|
284 | file = ksyslog_open(ksyslog_path); |
---|
285 | if (unlikely(IS_ERR(file))) { |
---|
286 | spin_unlock(&ksyslog_vfs_lock); |
---|
287 | |
---|
288 | spin_lock_bh(&ksyslog_queue_lock); |
---|
289 | ksyslog_entry_migrate(&write_queue, &ksyslog_queue); |
---|
290 | spin_unlock_bh(&ksyslog_queue_lock); |
---|
291 | |
---|
292 | goto out; |
---|
293 | } |
---|
294 | |
---|
295 | list_for_each_entry_safe(entry, next, &write_queue.head, list) { |
---|
296 | int length; |
---|
297 | char *buf; |
---|
298 | |
---|
299 | ksyslog_entry_del(&write_queue, entry, false); |
---|
300 | |
---|
301 | length = ksyslog_format(&buf, entry); |
---|
302 | if (unlikely(length < 0)) |
---|
303 | goto restore; |
---|
304 | |
---|
305 | if (unlikely(ksyslog_write(file, buf, length) < 0)) { |
---|
306 | kfree(buf); |
---|
307 | goto restore; |
---|
308 | } |
---|
309 | |
---|
310 | kfree(buf); |
---|
311 | call_rcu(&entry->rcu, ksyslog_entry_free); |
---|
312 | continue; |
---|
313 | |
---|
314 | restore: |
---|
315 | spin_lock_bh(&ksyslog_queue_lock); |
---|
316 | if (unlikely(ksyslog_entry_add(&ksyslog_queue, entry))) { |
---|
317 | ksyslog_drop_warning(entry); |
---|
318 | call_rcu(&entry->rcu, ksyslog_entry_free); |
---|
319 | } |
---|
320 | spin_unlock_bh(&ksyslog_queue_lock); |
---|
321 | } |
---|
322 | |
---|
323 | ksyslog_close(file); |
---|
324 | spin_unlock(&ksyslog_vfs_lock); |
---|
325 | |
---|
326 | out: |
---|
327 | ksyslog_work_register(ksyslog_flush_interval); |
---|
328 | } |
---|
329 | |
---|
330 | static int |
---|
331 | ksyslog_rcv(struct sock *sk, struct sk_buff *skb) |
---|
332 | { |
---|
333 | int err; |
---|
334 | struct iphdr *iph; |
---|
335 | struct udphdr *udph; |
---|
336 | struct ksyslog_entry *entry; |
---|
337 | |
---|
338 | err = skb_linearize(skb); |
---|
339 | if (unlikely(err)) |
---|
340 | goto out; |
---|
341 | |
---|
342 | iph = ip_hdr(skb); |
---|
343 | udph = udp_hdr(skb); |
---|
344 | |
---|
345 | if (unlikely(!skb_pull(skb, sizeof(*udph)))) { |
---|
346 | err = -EINVAL; |
---|
347 | goto out; |
---|
348 | } |
---|
349 | |
---|
350 | entry = ksyslog_entry_create(skb, iph, udph); |
---|
351 | if (unlikely(IS_ERR(entry))) { |
---|
352 | err = PTR_ERR(entry); |
---|
353 | goto out; |
---|
354 | } |
---|
355 | |
---|
356 | spin_lock_bh(&ksyslog_queue_lock); |
---|
357 | err = ksyslog_entry_add(&ksyslog_queue, entry); |
---|
358 | spin_unlock_bh(&ksyslog_queue_lock); |
---|
359 | |
---|
360 | if (unlikely(err)) |
---|
361 | ksyslog_entry_free(&entry->rcu); |
---|
362 | |
---|
363 | out: |
---|
364 | if (unlikely(err)) |
---|
365 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, IS_UDPLITE(sk)); |
---|
366 | |
---|
367 | consume_skb(skb); |
---|
368 | return 0; |
---|
369 | } |
---|
370 | |
---|
371 | #ifdef CONFIG_PROC_FS |
---|
372 | static void * |
---|
373 | ksyslog_queue_seq_start(struct seq_file *seq, loff_t *pos) |
---|
374 | { |
---|
375 | struct list_head *lh, *head = seq->private; |
---|
376 | loff_t ppos = *pos; |
---|
377 | |
---|
378 | rcu_read_lock(); |
---|
379 | |
---|
380 | __list_for_each_rcu(lh, head) |
---|
381 | if (ppos-- == 0) |
---|
382 | return lh; |
---|
383 | |
---|
384 | return NULL; |
---|
385 | } |
---|
386 | |
---|
387 | static void * |
---|
388 | ksyslog_queue_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
---|
389 | { |
---|
390 | struct list_head *lh = rcu_dereference(((struct list_head *)v)->next); |
---|
391 | ++(*pos); |
---|
392 | return lh == seq->private ? NULL : lh; |
---|
393 | } |
---|
394 | |
---|
395 | static void |
---|
396 | ksyslog_queue_seq_stop(struct seq_file *seq, void *v) |
---|
397 | { |
---|
398 | rcu_read_unlock(); |
---|
399 | } |
---|
400 | |
---|
401 | static int |
---|
402 | ksyslog_queue_seq_show(struct seq_file *seq, void *v) |
---|
403 | { |
---|
404 | const struct ksyslog_entry *entry = list_entry_rcu(v, struct ksyslog_entry, list); |
---|
405 | |
---|
406 | seq_printf(seq, "%llu %s.%s %u.%u.%u.%u %.*s\n", |
---|
407 | timeval_to_ns(&entry->tv) / 1000 / 1000 / 1000, |
---|
408 | ksyslog_facility_str(entry->facility), |
---|
409 | ksyslog_severity_str(entry->severity), |
---|
410 | entry->saddr.addr8[0], entry->saddr.addr8[1], |
---|
411 | entry->saddr.addr8[2], entry->saddr.addr8[3], |
---|
412 | (int)entry->length, entry->data); |
---|
413 | |
---|
414 | return 0; |
---|
415 | } |
---|
416 | |
---|
417 | static struct seq_operations ksyslog_queue_seq_ops = { |
---|
418 | .start = ksyslog_queue_seq_start, |
---|
419 | .next = ksyslog_queue_seq_next, |
---|
420 | .stop = ksyslog_queue_seq_stop, |
---|
421 | .show = ksyslog_queue_seq_show, |
---|
422 | }; |
---|
423 | |
---|
424 | static int |
---|
425 | ksyslog_queue_seq_open(struct inode *inode, struct file *file) |
---|
426 | { |
---|
427 | int err = seq_open(file, &ksyslog_queue_seq_ops); |
---|
428 | |
---|
429 | if (!err) |
---|
430 | ((struct seq_file *)file->private_data)->private = PDE(inode)->data; |
---|
431 | |
---|
432 | return err; |
---|
433 | } |
---|
434 | |
---|
435 | static struct file_operations ksyslog_queue_fops = { |
---|
436 | .owner = THIS_MODULE, |
---|
437 | .open = ksyslog_queue_seq_open, |
---|
438 | .read = seq_read, |
---|
439 | .llseek = seq_lseek, |
---|
440 | .release = seq_release, |
---|
441 | }; |
---|
442 | |
---|
443 | static int |
---|
444 | ksyslog_proc_init(void) |
---|
445 | { |
---|
446 | ksyslog_procdir = proc_mkdir("ksyslog", NULL); |
---|
447 | if (ksyslog_procdir == NULL) { |
---|
448 | pr_err("proc_mkdir failed\n"); |
---|
449 | return -ENOMEM; |
---|
450 | } |
---|
451 | |
---|
452 | ksyslog_proc_queue = proc_create("queue", S_IRUGO, |
---|
453 | ksyslog_procdir, &ksyslog_queue_fops); |
---|
454 | if (ksyslog_proc_queue == NULL) { |
---|
455 | remove_proc_entry(ksyslog_procdir->name, ksyslog_procdir->parent); |
---|
456 | pr_err("proc_create failed\n"); |
---|
457 | return -ENOMEM; |
---|
458 | } |
---|
459 | |
---|
460 | ksyslog_proc_queue->data = &ksyslog_queue.head; |
---|
461 | return 0; |
---|
462 | } |
---|
463 | |
---|
464 | static void |
---|
465 | ksyslog_proc_destroy(void) |
---|
466 | { |
---|
467 | if (ksyslog_proc_queue) |
---|
468 | remove_proc_entry(ksyslog_proc_queue->name, ksyslog_proc_queue->parent); |
---|
469 | ksyslog_proc_queue = NULL; |
---|
470 | |
---|
471 | if (ksyslog_procdir) |
---|
472 | remove_proc_entry(ksyslog_procdir->name, ksyslog_procdir->parent); |
---|
473 | ksyslog_procdir = NULL; |
---|
474 | } |
---|
475 | #endif |
---|
476 | |
---|
477 | static void |
---|
478 | ksyslog_finish(void) |
---|
479 | { |
---|
480 | if (ksyslog_rcv_sk) |
---|
481 | sock_release(ksyslog_rcv_sk); |
---|
482 | ksyslog_rcv_sk = NULL; |
---|
483 | |
---|
484 | if (ksyslog_wq) { |
---|
485 | ksyslog_work_unregister(); |
---|
486 | destroy_workqueue(ksyslog_wq); |
---|
487 | } |
---|
488 | ksyslog_wq = NULL; |
---|
489 | |
---|
490 | #ifdef CONFIG_PROC_FS |
---|
491 | ksyslog_proc_destroy(); |
---|
492 | #endif |
---|
493 | |
---|
494 | ksyslog_entry_destroy(&ksyslog_queue); |
---|
495 | synchronize_rcu(); |
---|
496 | } |
---|
497 | |
---|
498 | static int __init |
---|
499 | ksyslog_init(void) |
---|
500 | { |
---|
501 | int err; |
---|
502 | struct sockaddr_in sin; |
---|
503 | |
---|
504 | INIT_LIST_HEAD(&ksyslog_queue.head); |
---|
505 | |
---|
506 | #ifdef CONFIG_PROC_FS |
---|
507 | err = ksyslog_proc_init(); |
---|
508 | if (err) |
---|
509 | goto err; |
---|
510 | #endif |
---|
511 | |
---|
512 | ksyslog_wq = create_singlethread_workqueue("ksyslog"); |
---|
513 | if (ksyslog_wq == NULL) { |
---|
514 | pr_err("create_workqueue failed\n"); |
---|
515 | err = -ENOMEM; |
---|
516 | goto err; |
---|
517 | } |
---|
518 | |
---|
519 | INIT_DELAYED_WORK(&ksyslog_work, ksyslog_work_handler); |
---|
520 | |
---|
521 | err = sock_create(AF_INET, SOCK_DGRAM, 0, &ksyslog_rcv_sk); |
---|
522 | if (err) { |
---|
523 | pr_err("sock_create failed\n"); |
---|
524 | goto err; |
---|
525 | } |
---|
526 | |
---|
527 | sin.sin_family = AF_INET; |
---|
528 | sin.sin_addr.s_addr = in_aton(ksyslog_host); |
---|
529 | sin.sin_port = htons(ksyslog_port); |
---|
530 | |
---|
531 | err = kernel_bind(ksyslog_rcv_sk, (struct sockaddr *)&sin, |
---|
532 | sizeof(struct sockaddr_in)); |
---|
533 | if (err) { |
---|
534 | pr_err("kernel_bind failed\n"); |
---|
535 | goto err; |
---|
536 | } |
---|
537 | |
---|
538 | udp_sk(ksyslog_rcv_sk->sk)->encap_type = UDP_ENCAP_KSYSLOG; |
---|
539 | udp_sk(ksyslog_rcv_sk->sk)->encap_rcv = ksyslog_rcv; |
---|
540 | |
---|
541 | ksyslog_work_register(ksyslog_flush_interval); |
---|
542 | |
---|
543 | return 0; |
---|
544 | |
---|
545 | err: |
---|
546 | ksyslog_finish(); |
---|
547 | return err; |
---|
548 | } |
---|
549 | |
---|
550 | static void __exit |
---|
551 | ksyslog_exit(void) |
---|
552 | { |
---|
553 | ksyslog_finish(); |
---|
554 | } |
---|
555 | |
---|
556 | module_init(ksyslog_init); |
---|
557 | module_exit(ksyslog_exit); |
---|
558 | |
---|
559 | MODULE_AUTHOR("Atzm WATANABE"); |
---|
560 | MODULE_DESCRIPTION("In-kernel syslog receiver"); |
---|
561 | MODULE_LICENSE("GPL"); |
---|