Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/init.h> |
| 3 | #include <linux/module.h> |
| 4 | #include <linux/proc_fs.h> |
| 5 | #include <linux/skbuff.h> |
| 6 | #include <linux/netfilter.h> |
Harald Welte | bbd86b9f | 2005-08-09 20:23:11 -0700 | [diff] [blame] | 7 | #include <linux/seq_file.h> |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 8 | #include <net/protocol.h> |
Patrick McHardy | f01ffbd | 2007-12-17 22:38:49 -0800 | [diff] [blame] | 9 | #include <net/netfilter/nf_log.h> |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 10 | |
| 11 | #include "nf_internals.h" |
| 12 | |
YOSHIFUJI Hideaki | a5d2926 | 2007-07-19 10:44:21 +0900 | [diff] [blame] | 13 | /* Internal logging interface, which relies on the real |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 14 | LOG target modules */ |
| 15 | |
| 16 | #define NF_LOG_PREFIXLEN 128 |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 17 | #define NFLOGGER_NAME_LEN 64 |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 18 | |
Arnd Bergmann | 0906a37 | 2010-03-09 20:59:15 +0100 | [diff] [blame] | 19 | static const struct nf_logger __rcu *nf_loggers[NFPROTO_NUMPROTO] __read_mostly; |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 20 | static struct list_head nf_loggers_l[NFPROTO_NUMPROTO] __read_mostly; |
Patrick McHardy | 9b73534 | 2007-02-12 11:11:39 -0800 | [diff] [blame] | 21 | static DEFINE_MUTEX(nf_log_mutex); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 22 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 23 | static struct nf_logger *__find_logger(int pf, const char *str_logger) |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 24 | { |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 25 | struct nf_logger *t; |
| 26 | |
| 27 | list_for_each_entry(t, &nf_loggers_l[pf], list[pf]) { |
| 28 | if (!strnicmp(str_logger, t->name, strlen(t->name))) |
| 29 | return t; |
| 30 | } |
| 31 | |
| 32 | return NULL; |
| 33 | } |
| 34 | |
| 35 | /* return EEXIST if the same logger is registred, 0 on success. */ |
| 36 | int nf_log_register(u_int8_t pf, struct nf_logger *logger) |
| 37 | { |
Patrick McHardy | b56f2d5 | 2010-05-10 18:47:57 +0200 | [diff] [blame] | 38 | const struct nf_logger *llog; |
Eric Dumazet | b6f0a36 | 2009-04-15 12:16:19 +0200 | [diff] [blame] | 39 | int i; |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 40 | |
Jan Engelhardt | 7e9c6ee | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 41 | if (pf >= ARRAY_SIZE(nf_loggers)) |
Harald Welte | 8a61fad | 2005-08-09 20:23:53 -0700 | [diff] [blame] | 42 | return -EINVAL; |
| 43 | |
Eric Dumazet | b6f0a36 | 2009-04-15 12:16:19 +0200 | [diff] [blame] | 44 | for (i = 0; i < ARRAY_SIZE(logger->list); i++) |
| 45 | INIT_LIST_HEAD(&logger->list[i]); |
| 46 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 47 | mutex_lock(&nf_log_mutex); |
Harald Welte | d72367b | 2005-08-09 20:23:36 -0700 | [diff] [blame] | 48 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 49 | if (pf == NFPROTO_UNSPEC) { |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 50 | for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) |
| 51 | list_add_tail(&(logger->list[i]), &(nf_loggers_l[i])); |
| 52 | } else { |
| 53 | /* register at end of list to honor first register win */ |
| 54 | list_add_tail(&logger->list[pf], &nf_loggers_l[pf]); |
Patrick McHardy | b56f2d5 | 2010-05-10 18:47:57 +0200 | [diff] [blame] | 55 | llog = rcu_dereference_protected(nf_loggers[pf], |
| 56 | lockdep_is_held(&nf_log_mutex)); |
| 57 | if (llog == NULL) |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 58 | rcu_assign_pointer(nf_loggers[pf], logger); |
| 59 | } |
Patrick McHardy | 9b73534 | 2007-02-12 11:11:39 -0800 | [diff] [blame] | 60 | |
| 61 | mutex_unlock(&nf_log_mutex); |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 62 | |
| 63 | return 0; |
YOSHIFUJI Hideaki | 601e68e | 2007-02-12 11:15:49 -0800 | [diff] [blame] | 64 | } |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 65 | EXPORT_SYMBOL(nf_log_register); |
| 66 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 67 | void nf_log_unregister(struct nf_logger *logger) |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 68 | { |
Patrick McHardy | b56f2d5 | 2010-05-10 18:47:57 +0200 | [diff] [blame] | 69 | const struct nf_logger *c_logger; |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 70 | int i; |
| 71 | |
Patrick McHardy | 9b73534 | 2007-02-12 11:11:39 -0800 | [diff] [blame] | 72 | mutex_lock(&nf_log_mutex); |
Jan Engelhardt | 7e9c6ee | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 73 | for (i = 0; i < ARRAY_SIZE(nf_loggers); i++) { |
Patrick McHardy | b56f2d5 | 2010-05-10 18:47:57 +0200 | [diff] [blame] | 74 | c_logger = rcu_dereference_protected(nf_loggers[i], |
| 75 | lockdep_is_held(&nf_log_mutex)); |
| 76 | if (c_logger == logger) |
Patrick McHardy | e92ad99 | 2007-02-12 11:11:55 -0800 | [diff] [blame] | 77 | rcu_assign_pointer(nf_loggers[i], NULL); |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 78 | list_del(&logger->list[i]); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 79 | } |
Patrick McHardy | 9b73534 | 2007-02-12 11:11:39 -0800 | [diff] [blame] | 80 | mutex_unlock(&nf_log_mutex); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 81 | |
Patrick McHardy | a5ea616 | 2007-02-12 11:11:06 -0800 | [diff] [blame] | 82 | synchronize_rcu(); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 83 | } |
Patrick McHardy | e92ad99 | 2007-02-12 11:11:55 -0800 | [diff] [blame] | 84 | EXPORT_SYMBOL(nf_log_unregister); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 85 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 86 | int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger) |
| 87 | { |
Jan Engelhardt | 9ef0298 | 2011-03-02 12:10:13 +0100 | [diff] [blame] | 88 | if (pf >= ARRAY_SIZE(nf_loggers)) |
| 89 | return -EINVAL; |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 90 | mutex_lock(&nf_log_mutex); |
| 91 | if (__find_logger(pf, logger->name) == NULL) { |
| 92 | mutex_unlock(&nf_log_mutex); |
| 93 | return -ENOENT; |
| 94 | } |
| 95 | rcu_assign_pointer(nf_loggers[pf], logger); |
| 96 | mutex_unlock(&nf_log_mutex); |
| 97 | return 0; |
| 98 | } |
| 99 | EXPORT_SYMBOL(nf_log_bind_pf); |
| 100 | |
| 101 | void nf_log_unbind_pf(u_int8_t pf) |
| 102 | { |
Jan Engelhardt | 9ef0298 | 2011-03-02 12:10:13 +0100 | [diff] [blame] | 103 | if (pf >= ARRAY_SIZE(nf_loggers)) |
| 104 | return; |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 105 | mutex_lock(&nf_log_mutex); |
| 106 | rcu_assign_pointer(nf_loggers[pf], NULL); |
| 107 | mutex_unlock(&nf_log_mutex); |
| 108 | } |
| 109 | EXPORT_SYMBOL(nf_log_unbind_pf); |
| 110 | |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 111 | void nf_log_packet(u_int8_t pf, |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 112 | unsigned int hooknum, |
| 113 | const struct sk_buff *skb, |
| 114 | const struct net_device *in, |
| 115 | const struct net_device *out, |
Patrick McHardy | 7b2f963 | 2007-12-17 22:39:08 -0800 | [diff] [blame] | 116 | const struct nf_loginfo *loginfo, |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 117 | const char *fmt, ...) |
| 118 | { |
| 119 | va_list args; |
| 120 | char prefix[NF_LOG_PREFIXLEN]; |
Patrick McHardy | 7b2f963 | 2007-12-17 22:39:08 -0800 | [diff] [blame] | 121 | const struct nf_logger *logger; |
YOSHIFUJI Hideaki | 601e68e | 2007-02-12 11:15:49 -0800 | [diff] [blame] | 122 | |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 123 | rcu_read_lock(); |
Patrick McHardy | e92ad99 | 2007-02-12 11:11:55 -0800 | [diff] [blame] | 124 | logger = rcu_dereference(nf_loggers[pf]); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 125 | if (logger) { |
| 126 | va_start(args, fmt); |
| 127 | vsnprintf(prefix, sizeof(prefix), fmt, args); |
| 128 | va_end(args); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 129 | logger->logfn(pf, hooknum, skb, in, out, loginfo, prefix); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 130 | } |
| 131 | rcu_read_unlock(); |
| 132 | } |
| 133 | EXPORT_SYMBOL(nf_log_packet); |
| 134 | |
| 135 | #ifdef CONFIG_PROC_FS |
| 136 | static void *seq_start(struct seq_file *seq, loff_t *pos) |
| 137 | { |
Patrick McHardy | 6440fe0 | 2009-11-19 04:59:05 +0000 | [diff] [blame] | 138 | mutex_lock(&nf_log_mutex); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 139 | |
Jan Engelhardt | 7e9c6ee | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 140 | if (*pos >= ARRAY_SIZE(nf_loggers)) |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 141 | return NULL; |
| 142 | |
| 143 | return pos; |
| 144 | } |
| 145 | |
| 146 | static void *seq_next(struct seq_file *s, void *v, loff_t *pos) |
| 147 | { |
| 148 | (*pos)++; |
| 149 | |
Jan Engelhardt | 7e9c6ee | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 150 | if (*pos >= ARRAY_SIZE(nf_loggers)) |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 151 | return NULL; |
| 152 | |
| 153 | return pos; |
| 154 | } |
| 155 | |
| 156 | static void seq_stop(struct seq_file *s, void *v) |
| 157 | { |
Patrick McHardy | 6440fe0 | 2009-11-19 04:59:05 +0000 | [diff] [blame] | 158 | mutex_unlock(&nf_log_mutex); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | static int seq_show(struct seq_file *s, void *v) |
| 162 | { |
| 163 | loff_t *pos = v; |
| 164 | const struct nf_logger *logger; |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 165 | struct nf_logger *t; |
| 166 | int ret; |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 167 | |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 168 | logger = rcu_dereference_protected(nf_loggers[*pos], |
| 169 | lockdep_is_held(&nf_log_mutex)); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 170 | |
| 171 | if (!logger) |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 172 | ret = seq_printf(s, "%2lld NONE (", *pos); |
| 173 | else |
| 174 | ret = seq_printf(s, "%2lld %s (", *pos, logger->name); |
YOSHIFUJI Hideaki | 601e68e | 2007-02-12 11:15:49 -0800 | [diff] [blame] | 175 | |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 176 | if (ret < 0) |
| 177 | return ret; |
| 178 | |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 179 | list_for_each_entry(t, &nf_loggers_l[*pos], list[*pos]) { |
| 180 | ret = seq_printf(s, "%s", t->name); |
Patrick McHardy | 6440fe0 | 2009-11-19 04:59:05 +0000 | [diff] [blame] | 181 | if (ret < 0) |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 182 | return ret; |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 183 | if (&t->list[*pos] != nf_loggers_l[*pos].prev) { |
| 184 | ret = seq_printf(s, ","); |
Patrick McHardy | 6440fe0 | 2009-11-19 04:59:05 +0000 | [diff] [blame] | 185 | if (ret < 0) |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 186 | return ret; |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 187 | } |
| 188 | } |
Eric Leblond | c7a913c | 2009-03-16 14:55:27 +0100 | [diff] [blame] | 189 | |
| 190 | return seq_printf(s, ")\n"); |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 193 | static const struct seq_operations nflog_seq_ops = { |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 194 | .start = seq_start, |
| 195 | .next = seq_next, |
| 196 | .stop = seq_stop, |
| 197 | .show = seq_show, |
| 198 | }; |
| 199 | |
| 200 | static int nflog_open(struct inode *inode, struct file *file) |
| 201 | { |
| 202 | return seq_open(file, &nflog_seq_ops); |
| 203 | } |
| 204 | |
Arjan van de Ven | da7071d | 2007-02-12 00:55:36 -0800 | [diff] [blame] | 205 | static const struct file_operations nflog_file_ops = { |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 206 | .owner = THIS_MODULE, |
| 207 | .open = nflog_open, |
| 208 | .read = seq_read, |
| 209 | .llseek = seq_lseek, |
| 210 | .release = seq_release, |
| 211 | }; |
| 212 | |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 213 | |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 214 | #endif /* PROC_FS */ |
| 215 | |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 216 | #ifdef CONFIG_SYSCTL |
Patrick McHardy | 2495561 | 2009-06-22 14:15:30 +0200 | [diff] [blame] | 217 | static struct ctl_path nf_log_sysctl_path[] = { |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 218 | { .procname = "net", }, |
| 219 | { .procname = "netfilter", }, |
| 220 | { .procname = "nf_log", }, |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 221 | { } |
| 222 | }; |
| 223 | |
| 224 | static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3]; |
| 225 | static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1]; |
| 226 | static struct ctl_table_header *nf_log_dir_header; |
| 227 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 228 | static int nf_log_proc_dostring(ctl_table *table, int write, |
Patrick McHardy | 2495561 | 2009-06-22 14:15:30 +0200 | [diff] [blame] | 229 | void __user *buffer, size_t *lenp, loff_t *ppos) |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 230 | { |
| 231 | const struct nf_logger *logger; |
Patrick McHardy | 2495561 | 2009-06-22 14:15:30 +0200 | [diff] [blame] | 232 | char buf[NFLOGGER_NAME_LEN]; |
| 233 | size_t size = *lenp; |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 234 | int r = 0; |
| 235 | int tindex = (unsigned long)table->extra1; |
| 236 | |
| 237 | if (write) { |
Patrick McHardy | 2495561 | 2009-06-22 14:15:30 +0200 | [diff] [blame] | 238 | if (size > sizeof(buf)) |
| 239 | size = sizeof(buf); |
| 240 | if (copy_from_user(buf, buffer, size)) |
| 241 | return -EFAULT; |
| 242 | |
| 243 | if (!strcmp(buf, "NONE")) { |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 244 | nf_log_unbind_pf(tindex); |
| 245 | return 0; |
| 246 | } |
| 247 | mutex_lock(&nf_log_mutex); |
Patrick McHardy | 2495561 | 2009-06-22 14:15:30 +0200 | [diff] [blame] | 248 | logger = __find_logger(tindex, buf); |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 249 | if (logger == NULL) { |
| 250 | mutex_unlock(&nf_log_mutex); |
| 251 | return -ENOENT; |
| 252 | } |
| 253 | rcu_assign_pointer(nf_loggers[tindex], logger); |
| 254 | mutex_unlock(&nf_log_mutex); |
| 255 | } else { |
Patrick McHardy | 266d07c | 2009-06-13 12:21:10 +0200 | [diff] [blame] | 256 | mutex_lock(&nf_log_mutex); |
Eric Dumazet | 0e60ebe | 2010-11-15 18:17:21 +0100 | [diff] [blame] | 257 | logger = rcu_dereference_protected(nf_loggers[tindex], |
| 258 | lockdep_is_held(&nf_log_mutex)); |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 259 | if (!logger) |
| 260 | table->data = "NONE"; |
| 261 | else |
| 262 | table->data = logger->name; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 263 | r = proc_dostring(table, write, buffer, lenp, ppos); |
Patrick McHardy | 266d07c | 2009-06-13 12:21:10 +0200 | [diff] [blame] | 264 | mutex_unlock(&nf_log_mutex); |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | return r; |
| 268 | } |
| 269 | |
| 270 | static __init int netfilter_log_sysctl_init(void) |
| 271 | { |
| 272 | int i; |
| 273 | |
| 274 | for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) { |
| 275 | snprintf(nf_log_sysctl_fnames[i-NFPROTO_UNSPEC], 3, "%d", i); |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 276 | nf_log_sysctl_table[i].procname = |
| 277 | nf_log_sysctl_fnames[i-NFPROTO_UNSPEC]; |
| 278 | nf_log_sysctl_table[i].data = NULL; |
| 279 | nf_log_sysctl_table[i].maxlen = |
| 280 | NFLOGGER_NAME_LEN * sizeof(char); |
| 281 | nf_log_sysctl_table[i].mode = 0644; |
| 282 | nf_log_sysctl_table[i].proc_handler = nf_log_proc_dostring; |
| 283 | nf_log_sysctl_table[i].extra1 = (void *)(unsigned long) i; |
| 284 | } |
| 285 | |
| 286 | nf_log_dir_header = register_sysctl_paths(nf_log_sysctl_path, |
| 287 | nf_log_sysctl_table); |
| 288 | if (!nf_log_dir_header) |
| 289 | return -ENOMEM; |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | #else |
| 294 | static __init int netfilter_log_sysctl_init(void) |
| 295 | { |
| 296 | return 0; |
| 297 | } |
| 298 | #endif /* CONFIG_SYSCTL */ |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 299 | |
| 300 | int __init netfilter_log_init(void) |
| 301 | { |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 302 | int i, r; |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 303 | #ifdef CONFIG_PROC_FS |
Denis V. Lunev | 8eeee8b | 2008-03-27 16:55:53 -0700 | [diff] [blame] | 304 | if (!proc_create("nf_log", S_IRUGO, |
| 305 | proc_net_netfilter, &nflog_file_ops)) |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 306 | return -1; |
Harald Welte | 6224392 | 2005-08-11 15:30:45 -0700 | [diff] [blame] | 307 | #endif |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 308 | |
Eric Leblond | 1762527 | 2009-03-23 13:16:53 +0100 | [diff] [blame] | 309 | /* Errors will trigger panic, unroll on error is unnecessary. */ |
| 310 | r = netfilter_log_sysctl_init(); |
| 311 | if (r < 0) |
| 312 | return r; |
| 313 | |
Eric Leblond | ca735b3 | 2009-03-16 14:54:21 +0100 | [diff] [blame] | 314 | for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) |
| 315 | INIT_LIST_HEAD(&(nf_loggers_l[i])); |
| 316 | |
Harald Welte | f6ebe77 | 2005-08-09 20:21:49 -0700 | [diff] [blame] | 317 | return 0; |
| 318 | } |