Skip to content

Commit

Permalink
netfilter: nf_log_bridge: merge with nf_log_syslog
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Mar 31, 2021
1 parent 1510618 commit 77ccee9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 94 deletions.
1 change: 0 additions & 1 deletion include/net/netfilter/nf_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void nf_log_unbind_pf(struct net *net, u_int8_t pf);

int nf_logger_find_get(int pf, enum nf_log_type type);
void nf_logger_put(int pf, enum nf_log_type type);
void nf_logger_request_module(int pf, enum nf_log_type type);

#define MODULE_ALIAS_NF_LOGGER(family, type) \
MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
Expand Down
4 changes: 0 additions & 4 deletions net/bridge/netfilter/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ config NFT_BRIDGE_REJECT
help
Add support to reject packets.

config NF_LOG_BRIDGE
tristate "Bridge packet logging"
select NF_LOG_COMMON

endif # NF_TABLES_BRIDGE

config NF_CONNTRACK_BRIDGE
Expand Down
3 changes: 0 additions & 3 deletions net/bridge/netfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ obj-$(CONFIG_NFT_BRIDGE_REJECT) += nft_reject_bridge.o
# connection tracking
obj-$(CONFIG_NF_CONNTRACK_BRIDGE) += nf_conntrack_bridge.o

# packet logging
obj-$(CONFIG_NF_LOG_BRIDGE) += nf_log_bridge.o

obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o

# tables
Expand Down
79 changes: 0 additions & 79 deletions net/bridge/netfilter/nf_log_bridge.c

This file was deleted.

7 changes: 0 additions & 7 deletions net/netfilter/nf_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ void nf_log_unbind_pf(struct net *net, u_int8_t pf)
}
EXPORT_SYMBOL(nf_log_unbind_pf);

void nf_logger_request_module(int pf, enum nf_log_type type)
{
if (loggers[pf][type] == NULL)
request_module("nf-logger-%u-%u", pf, type);
}
EXPORT_SYMBOL_GPL(nf_logger_request_module);

int nf_logger_find_get(int pf, enum nf_log_type type)
{
struct nf_logger *logger;
Expand Down
22 changes: 22 additions & 0 deletions net/netfilter/nf_log_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,13 @@ static struct nf_logger nf_netdev_logger __read_mostly = {
.me = THIS_MODULE,
};

static struct nf_logger nf_bridge_logger __read_mostly = {
.name = "nf_log_bridge",
.type = NF_LOG_TYPE_LOG,
.logfn = nf_log_netdev_packet,
.me = THIS_MODULE,
};

static int __net_init nf_log_syslog_net_init(struct net *net)
{
int ret = nf_log_set(net, NFPROTO_IPV4, &nf_ip_logger);
Expand All @@ -805,7 +812,13 @@ static int __net_init nf_log_syslog_net_init(struct net *net)
ret = nf_log_set(net, NFPROTO_NETDEV, &nf_netdev_logger);
if (ret)
goto err3;

ret = nf_log_set(net, NFPROTO_BRIDGE, &nf_bridge_logger);
if (ret)
goto err4;
return 0;
err4:
nf_log_unset(net, &nf_netdev_logger);
err3:
nf_log_unset(net, &nf_ip6_logger);
err2:
Expand Down Expand Up @@ -852,7 +865,13 @@ static int __init nf_log_syslog_init(void)
if (ret < 0)
goto err4;

ret = nf_log_register(NFPROTO_BRIDGE, &nf_bridge_logger);
if (ret < 0)
goto err5;

return 0;
err5:
nf_log_unregister(&nf_netdev_logger);
err4:
nf_log_unregister(&nf_ip6_logger);
err3:
Expand All @@ -872,6 +891,7 @@ static void __exit nf_log_syslog_exit(void)
nf_log_unregister(&nf_arp_logger);
nf_log_unregister(&nf_ip6_logger);
nf_log_unregister(&nf_netdev_logger);
nf_log_unregister(&nf_bridge_logger);
}

module_init(nf_log_syslog_init);
Expand All @@ -881,9 +901,11 @@ MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
MODULE_DESCRIPTION("Netfilter syslog packet logging");
MODULE_LICENSE("GPL");
MODULE_ALIAS("nf_log_arp");
MODULE_ALIAS("nf_log_bridge");
MODULE_ALIAS("nf_log_ipv4");
MODULE_ALIAS("nf_log_ipv6");
MODULE_ALIAS("nf_log_netdev");
MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 0);
MODULE_ALIAS_NF_LOGGER(AF_INET, 0);
MODULE_ALIAS_NF_LOGGER(3, 0);
MODULE_ALIAS_NF_LOGGER(5, 0); /* NFPROTO_NETDEV */
Expand Down

0 comments on commit 77ccee9

Please sign in to comment.