]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - net/bridge/netfilter/nf_log_bridge.c
netfilter: nf_log: add packet logging for netdev family
[mirror_ubuntu-artful-kernel.git] / net / bridge / netfilter / nf_log_bridge.c
CommitLineData
960649d1
PNA
1/*
2 * (C) 2014 by Pablo Neira Ayuso <pablo@netfilter.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/module.h>
10#include <linux/spinlock.h>
11#include <linux/skbuff.h>
12#include <linux/if_bridge.h>
13#include <linux/ip.h>
14#include <net/route.h>
15
16#include <linux/netfilter.h>
17#include <net/netfilter/nf_log.h>
18
19static void nf_log_bridge_packet(struct net *net, u_int8_t pf,
20 unsigned int hooknum,
21 const struct sk_buff *skb,
22 const struct net_device *in,
23 const struct net_device *out,
24 const struct nf_loginfo *loginfo,
25 const char *prefix)
26{
1fddf4ba 27 nf_log_l2packet(net, pf, hooknum, skb, in, out, loginfo, prefix);
960649d1
PNA
28}
29
30static struct nf_logger nf_bridge_logger __read_mostly = {
31 .name = "nf_log_bridge",
32 .type = NF_LOG_TYPE_LOG,
33 .logfn = nf_log_bridge_packet,
34 .me = THIS_MODULE,
35};
36
37static int __net_init nf_log_bridge_net_init(struct net *net)
38{
779994fa 39 return nf_log_set(net, NFPROTO_BRIDGE, &nf_bridge_logger);
960649d1
PNA
40}
41
42static void __net_exit nf_log_bridge_net_exit(struct net *net)
43{
44 nf_log_unset(net, &nf_bridge_logger);
45}
46
47static struct pernet_operations nf_log_bridge_net_ops = {
48 .init = nf_log_bridge_net_init,
49 .exit = nf_log_bridge_net_exit,
50};
51
52static int __init nf_log_bridge_init(void)
53{
54 int ret;
55
56 /* Request to load the real packet loggers. */
57 nf_logger_request_module(NFPROTO_IPV4, NF_LOG_TYPE_LOG);
58 nf_logger_request_module(NFPROTO_IPV6, NF_LOG_TYPE_LOG);
59 nf_logger_request_module(NFPROTO_ARP, NF_LOG_TYPE_LOG);
60
61 ret = register_pernet_subsys(&nf_log_bridge_net_ops);
62 if (ret < 0)
63 return ret;
64
65 nf_log_register(NFPROTO_BRIDGE, &nf_bridge_logger);
66 return 0;
67}
68
69static void __exit nf_log_bridge_exit(void)
70{
71 unregister_pernet_subsys(&nf_log_bridge_net_ops);
72 nf_log_unregister(&nf_bridge_logger);
73}
74
75module_init(nf_log_bridge_init);
76module_exit(nf_log_bridge_exit);
77
78MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
79MODULE_DESCRIPTION("Netfilter bridge packet logging");
80MODULE_LICENSE("GPL");
81MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 0);