From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org
Subject: [PATCH net-next 06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols
Date: Mon, 11 Apr 2022 12:27:39 +0200 [thread overview]
Message-ID: <20220411102744.282101-7-pablo@netfilter.org> (raw)
In-Reply-To: <20220411102744.282101-1-pablo@netfilter.org>
From: Phil Sutter <phil@nwl.cc>
With netdev and bridge nfprotos, loggers may see arbitrary ethernet
frames. Print at least basic info like interfaces and MAC header data.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_log_syslog.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c
index d1dcf36545d7..a7ff6fdbafc9 100644
--- a/net/netfilter/nf_log_syslog.c
+++ b/net/netfilter/nf_log_syslog.c
@@ -894,6 +894,33 @@ static struct nf_logger nf_ip6_logger __read_mostly = {
.me = THIS_MODULE,
};
+static void nf_log_unknown_packet(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)
+{
+ struct nf_log_buf *m;
+
+ /* FIXME: Disabled from containers until syslog ns is supported */
+ if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ return;
+
+ m = nf_log_buf_open();
+
+ if (!loginfo)
+ loginfo = &default_loginfo;
+
+ nf_log_dump_packet_common(m, pf, hooknum, skb, in, out, loginfo,
+ prefix);
+
+ dump_mac_header(m, loginfo, skb);
+
+ nf_log_buf_close(m);
+}
+
static void nf_log_netdev_packet(struct net *net, u_int8_t pf,
unsigned int hooknum,
const struct sk_buff *skb,
@@ -913,6 +940,10 @@ static void nf_log_netdev_packet(struct net *net, u_int8_t pf,
case htons(ETH_P_RARP):
nf_log_arp_packet(net, pf, hooknum, skb, in, out, loginfo, prefix);
break;
+ default:
+ nf_log_unknown_packet(net, pf, hooknum, skb,
+ in, out, loginfo, prefix);
+ break;
}
}
--
2.30.2
next prev parent reply other threads:[~2022-04-11 10:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
2022-04-11 10:50 ` patchwork-bot+netdevbpf
2022-04-11 10:27 ` [PATCH net-next 02/11] netfilter: ecache: move to separate structure Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 03/11] netfilter: conntrack: split inner loop of list dumping to own function Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 05/11] netfilter: nf_log_syslog: Merge MAC header dumpers Pablo Neira Ayuso
2022-04-11 10:27 ` Pablo Neira Ayuso [this message]
2022-04-11 10:27 ` [PATCH net-next 07/11] netfilter: nf_log_syslog: Consolidate entry checks Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 09/11] netfilter: bitwise: improve error goto labels Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 11/11] selftests: netfilter: add fib expression forward test case Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220411102744.282101-7-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).