netfilter: nf_log: add packet logging for netdev family
Subsystems (3)
Pablo Neira Ayuso
maintainerPATCH 1/1 netfilter: nf_log: add packet logging for netdev family
Move layer 2 packet logging into nf_log_l2packet() that resides in nf_log_common.c, so this can be shared by both bridge and netdev families.
This patch adds the boiler plate code to register the netdev logging family.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
Support for netdev family was missing, requested via [email protected].
include/net/netfilter/nf_log.h | 5 +++ net/bridge/netfilter/Kconfig | 1 + net/bridge/netfilter/nf_log_bridge.c | 16 +------- net/netfilter/Kconfig | 4 ++ net/netfilter/Makefile | 3 ++ net/netfilter/nf_log_common.c | 27 ++++++++++++ net/netfilter/nf_log_netdev.c | 80 ++++++++++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 net/netfilter/nf_log_netdev.c
include/net/netfilter/nf_log.h +5 -0
@@ -109,5 +109,10 @@ void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,const struct net_device *out, const struct nf_loginfo *loginfo, const char *prefix); +void nf_log_l2packet (struct net *net,u_int8_t pf,unsigned int hooknum, +const struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +const struct nf_loginfo *loginfo,const char *prefix);#endif /* _NF_LOG_H */
net/bridge/netfilter/Kconfig +1 -0
@@ -22,6 +22,7 @@ config NFT_BRIDGE_REJECT config NF_LOG_BRIDGE tristate "Bridge packet logging" + select NF_LOG_COMMON endif # NF_TABLES_BRIDGE
net/bridge/netfilter/nf_log_bridge.c +1 -15
@@ -24,21 +24,7 @@ static void nf_log_bridge_packet(struct net *net, u_int8_t pf,const struct nf_loginfo *loginfo, const char *prefix) { - switch (eth_hdr(skb)->h_proto) { - case htons(ETH_P_IP): - nf_log_packet(net, NFPROTO_IPV4, hooknum, skb, in, out, - loginfo, "%s", prefix); -break ; -case htons (ETH_P_IPV6 ): -nf_log_packet (net,NFPROTO_IPV6 , hooknum, skb, in, out, - loginfo,"%s" , prefix); -break ; -case htons (ETH_P_ARP ): -case htons (ETH_P_RARP ): -nf_log_packet (net,NFPROTO_ARP , hooknum, skb, in, out, - loginfo,"%s" , prefix); -break ; - } +nf_log_l2packet (net ,pf ,hooknum ,skb ,in ,out ,loginfo ,prefix ); } static struct nf_logger nf_bridge_logger __read_mostly = {
net/netfilter/Kconfig +4 -0
@@ -57,6 +57,10 @@ config NF_CONNTRACK config NF_LOG_COMMON tristate +config NF_LOG_NETDEV + tristate "Netdev packet logging" + select NF_LOG_COMMON + if NF_CONNTRACK config NF_CONNTRACK_MARK
net/netfilter/Makefile +3 -0
@@ -48,6 +48,9 @@ nf_nat-y := nf_nat_core.o nf_nat_proto_unknown.o nf_nat_proto_common.o \ # generic transport layer logging obj-$(CONFIG_NF_LOG_COMMON) += nf_log_common.o +# packet logging for netdev family +obj-$(CONFIG_NF_LOG_NETDEV) += nf_log_netdev.o + obj-$(CONFIG_NF_NAT) += nf_nat.o obj-$(CONFIG_NF_NAT_REDIRECT) += nf_nat_redirect.o
net/netfilter/nf_log_common.c +27 -0
@@ -175,6 +175,33 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf, }EXPORT_SYMBOL_GPL (nf_log_dump_packet_common); +/* bridge and netdev logging families share this code. */ +void nf_log_l2packet (struct net *net,u_int8_t pf, +unsigned int hooknum, +const struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +const struct nf_loginfo *loginfo, +const char *prefix) +{ +switch (eth_hdr (skb)->h_proto) { +case htons (ETH_P_IP ): +nf_log_packet (net,NFPROTO_IPV4 , hooknum, skb, in, out, + loginfo,"%s" , prefix); +break ; +case htons (ETH_P_IPV6 ): +nf_log_packet (net,NFPROTO_IPV6 , hooknum, skb, in, out, + loginfo,"%s" , prefix); +break ; +case htons (ETH_P_ARP ): +case htons (ETH_P_RARP ): +nf_log_packet (net,NFPROTO_ARP , hooknum, skb, in, out, + loginfo,"%s" , prefix); +break ; + } +} +EXPORT_SYMBOL_GPL (nf_log_l2packet); +static int __init nf_log_common_init (void ) {return 0 ;
net/netfilter/nf_log_netdev.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.1.4