Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nf_log_bridge: merge with nf_log_syslog

Provide bridge log support from nf_log_syslog.

After the merge there is no need to load the "real packet loggers",
all of them now reside in the same module.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
77ccee96 1510618e

+22 -94
-1
include/net/netfilter/nf_log.h
··· 68 68 69 69 int nf_logger_find_get(int pf, enum nf_log_type type); 70 70 void nf_logger_put(int pf, enum nf_log_type type); 71 - void nf_logger_request_module(int pf, enum nf_log_type type); 72 71 73 72 #define MODULE_ALIAS_NF_LOGGER(family, type) \ 74 73 MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
-4
net/bridge/netfilter/Kconfig
··· 23 23 help 24 24 Add support to reject packets. 25 25 26 - config NF_LOG_BRIDGE 27 - tristate "Bridge packet logging" 28 - select NF_LOG_COMMON 29 - 30 26 endif # NF_TABLES_BRIDGE 31 27 32 28 config NF_CONNTRACK_BRIDGE
-3
net/bridge/netfilter/Makefile
··· 9 9 # connection tracking 10 10 obj-$(CONFIG_NF_CONNTRACK_BRIDGE) += nf_conntrack_bridge.o 11 11 12 - # packet logging 13 - obj-$(CONFIG_NF_LOG_BRIDGE) += nf_log_bridge.o 14 - 15 12 obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o 16 13 17 14 # tables
-79
net/bridge/netfilter/nf_log_bridge.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * (C) 2014 by Pablo Neira Ayuso <pablo@netfilter.org> 4 - */ 5 - 6 - #include <linux/module.h> 7 - #include <linux/spinlock.h> 8 - #include <linux/skbuff.h> 9 - #include <linux/if_bridge.h> 10 - #include <linux/ip.h> 11 - #include <net/route.h> 12 - 13 - #include <linux/netfilter.h> 14 - #include <net/netfilter/nf_log.h> 15 - 16 - static void nf_log_bridge_packet(struct net *net, u_int8_t pf, 17 - unsigned int hooknum, 18 - const struct sk_buff *skb, 19 - const struct net_device *in, 20 - const struct net_device *out, 21 - const struct nf_loginfo *loginfo, 22 - const char *prefix) 23 - { 24 - nf_log_l2packet(net, pf, eth_hdr(skb)->h_proto, hooknum, skb, 25 - in, out, loginfo, prefix); 26 - } 27 - 28 - static struct nf_logger nf_bridge_logger __read_mostly = { 29 - .name = "nf_log_bridge", 30 - .type = NF_LOG_TYPE_LOG, 31 - .logfn = nf_log_bridge_packet, 32 - .me = THIS_MODULE, 33 - }; 34 - 35 - static int __net_init nf_log_bridge_net_init(struct net *net) 36 - { 37 - return nf_log_set(net, NFPROTO_BRIDGE, &nf_bridge_logger); 38 - } 39 - 40 - static void __net_exit nf_log_bridge_net_exit(struct net *net) 41 - { 42 - nf_log_unset(net, &nf_bridge_logger); 43 - } 44 - 45 - static struct pernet_operations nf_log_bridge_net_ops = { 46 - .init = nf_log_bridge_net_init, 47 - .exit = nf_log_bridge_net_exit, 48 - }; 49 - 50 - static int __init nf_log_bridge_init(void) 51 - { 52 - int ret; 53 - 54 - /* Request to load the real packet loggers. */ 55 - nf_logger_request_module(NFPROTO_IPV4, NF_LOG_TYPE_LOG); 56 - nf_logger_request_module(NFPROTO_IPV6, NF_LOG_TYPE_LOG); 57 - nf_logger_request_module(NFPROTO_ARP, NF_LOG_TYPE_LOG); 58 - 59 - ret = register_pernet_subsys(&nf_log_bridge_net_ops); 60 - if (ret < 0) 61 - return ret; 62 - 63 - nf_log_register(NFPROTO_BRIDGE, &nf_bridge_logger); 64 - return 0; 65 - } 66 - 67 - static void __exit nf_log_bridge_exit(void) 68 - { 69 - unregister_pernet_subsys(&nf_log_bridge_net_ops); 70 - nf_log_unregister(&nf_bridge_logger); 71 - } 72 - 73 - module_init(nf_log_bridge_init); 74 - module_exit(nf_log_bridge_exit); 75 - 76 - MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>"); 77 - MODULE_DESCRIPTION("Netfilter bridge packet logging"); 78 - MODULE_LICENSE("GPL"); 79 - MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 0);
-7
net/netfilter/nf_log.c
··· 151 151 } 152 152 EXPORT_SYMBOL(nf_log_unbind_pf); 153 153 154 - void nf_logger_request_module(int pf, enum nf_log_type type) 155 - { 156 - if (loggers[pf][type] == NULL) 157 - request_module("nf-logger-%u-%u", pf, type); 158 - } 159 - EXPORT_SYMBOL_GPL(nf_logger_request_module); 160 - 161 154 int nf_logger_find_get(int pf, enum nf_log_type type) 162 155 { 163 156 struct nf_logger *logger;
+22
net/netfilter/nf_log_syslog.c
··· 787 787 .me = THIS_MODULE, 788 788 }; 789 789 790 + static struct nf_logger nf_bridge_logger __read_mostly = { 791 + .name = "nf_log_bridge", 792 + .type = NF_LOG_TYPE_LOG, 793 + .logfn = nf_log_netdev_packet, 794 + .me = THIS_MODULE, 795 + }; 796 + 790 797 static int __net_init nf_log_syslog_net_init(struct net *net) 791 798 { 792 799 int ret = nf_log_set(net, NFPROTO_IPV4, &nf_ip_logger); ··· 812 805 ret = nf_log_set(net, NFPROTO_NETDEV, &nf_netdev_logger); 813 806 if (ret) 814 807 goto err3; 808 + 809 + ret = nf_log_set(net, NFPROTO_BRIDGE, &nf_bridge_logger); 810 + if (ret) 811 + goto err4; 815 812 return 0; 813 + err4: 814 + nf_log_unset(net, &nf_netdev_logger); 816 815 err3: 817 816 nf_log_unset(net, &nf_ip6_logger); 818 817 err2: ··· 865 852 if (ret < 0) 866 853 goto err4; 867 854 855 + ret = nf_log_register(NFPROTO_BRIDGE, &nf_bridge_logger); 856 + if (ret < 0) 857 + goto err5; 858 + 868 859 return 0; 860 + err5: 861 + nf_log_unregister(&nf_netdev_logger); 869 862 err4: 870 863 nf_log_unregister(&nf_ip6_logger); 871 864 err3: ··· 891 872 nf_log_unregister(&nf_arp_logger); 892 873 nf_log_unregister(&nf_ip6_logger); 893 874 nf_log_unregister(&nf_netdev_logger); 875 + nf_log_unregister(&nf_bridge_logger); 894 876 } 895 877 896 878 module_init(nf_log_syslog_init); ··· 901 881 MODULE_DESCRIPTION("Netfilter syslog packet logging"); 902 882 MODULE_LICENSE("GPL"); 903 883 MODULE_ALIAS("nf_log_arp"); 884 + MODULE_ALIAS("nf_log_bridge"); 904 885 MODULE_ALIAS("nf_log_ipv4"); 905 886 MODULE_ALIAS("nf_log_ipv6"); 906 887 MODULE_ALIAS("nf_log_netdev"); 888 + MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 0); 907 889 MODULE_ALIAS_NF_LOGGER(AF_INET, 0); 908 890 MODULE_ALIAS_NF_LOGGER(3, 0); 909 891 MODULE_ALIAS_NF_LOGGER(5, 0); /* NFPROTO_NETDEV */