2 * (C) 2014 by Pablo Neira Ayuso <pablo@netfilter.org>
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.
9 #include <linux/module.h>
10 #include <linux/spinlock.h>
11 #include <linux/skbuff.h>
12 #include <linux/if_bridge.h>
14 #include <net/route.h>
16 #include <linux/netfilter.h>
17 #include <net/netfilter/nf_log.h>
19 static void nf_log_bridge_packet(struct net *net, u_int8_t pf,
21 const struct sk_buff *skb,
22 const struct net_device *in,
23 const struct net_device *out,
24 const struct nf_loginfo *loginfo,
27 nf_log_l2packet(net, pf, eth_hdr(skb)->h_proto, hooknum, skb,
28 in, out, loginfo, prefix);
31 static struct nf_logger nf_bridge_logger __read_mostly = {
32 .name = "nf_log_bridge",
33 .type = NF_LOG_TYPE_LOG,
34 .logfn = nf_log_bridge_packet,
38 static int __net_init nf_log_bridge_net_init(struct net *net)
40 return nf_log_set(net, NFPROTO_BRIDGE, &nf_bridge_logger);
43 static void __net_exit nf_log_bridge_net_exit(struct net *net)
45 nf_log_unset(net, &nf_bridge_logger);
48 static struct pernet_operations nf_log_bridge_net_ops = {
49 .init = nf_log_bridge_net_init,
50 .exit = nf_log_bridge_net_exit,
53 static int __init nf_log_bridge_init(void)
57 /* Request to load the real packet loggers. */
58 nf_logger_request_module(NFPROTO_IPV4, NF_LOG_TYPE_LOG);
59 nf_logger_request_module(NFPROTO_IPV6, NF_LOG_TYPE_LOG);
60 nf_logger_request_module(NFPROTO_ARP, NF_LOG_TYPE_LOG);
62 ret = register_pernet_subsys(&nf_log_bridge_net_ops);
66 nf_log_register(NFPROTO_BRIDGE, &nf_bridge_logger);
70 static void __exit nf_log_bridge_exit(void)
72 unregister_pernet_subsys(&nf_log_bridge_net_ops);
73 nf_log_unregister(&nf_bridge_logger);
76 module_init(nf_log_bridge_init);
77 module_exit(nf_log_bridge_exit);
79 MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
80 MODULE_DESCRIPTION("Netfilter bridge packet logging");
81 MODULE_LICENSE("GPL");
82 MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 0);