From: Jeff Moyer <jmoyer@redhat.com>
To: mpm@selenic.com
Cc: linux-kernel@vger.kernel.org
Subject: [patch] teach netconsole how to do syslog
Date: Fri, 25 Jun 2004 13:57:38 -0400 [thread overview]
Message-ID: <16604.26514.243458.631948@segfault.boston.redhat.com> (raw)
Hello,
Here's a patch which adds the option to send messages to a remote syslog,
enabled via the do_syslog= module parameter. Currently logs everything at
info (as did the original netconsole module). Patch is against 2.6.6,
though should apply to later.
Comments?
Jeff
--- linux-2.6.6/drivers/net/netconsole.c 2004-06-21 14:06:34.000000000 -0400
+++ linux-2.6.6-netdump/drivers/net/netconsole.c 2004-06-25 13:51:54.000000000 -0400
@@ -54,6 +54,10 @@ static char config[256];
module_param_string(netconsole, config, 256, 0);
MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
+static int do_syslog;
+module_param(do_syslog, bool, 000);
+MODULE_PARM_DESC(do_syslog, " do_syslog=<yes|no>\n");
+
static struct netpoll np = {
.name = "netconsole",
.dev_name = "eth0",
@@ -64,10 +68,36 @@ static struct netpoll np = {
static int configured = 0;
#define MAX_PRINT_CHUNK 1000
+#define SYSLOG_HEADER_LEN 4
+
+static int syslog_chars = SYSLOG_HEADER_LEN;
+static unsigned char syslog_line [MAX_PRINT_CHUNK + 10] = {
+ '<',
+ '5',
+ '>',
+ ' ',
+ [4 ... MAX_PRINT_CHUNK+5] = '\0',
+};
+
+/*
+ * We feed kernel messages char by char, and send the UDP packet
+ * one linefeed. We buffer all characters received.
+ */
+static inline void feed_syslog_char(const unsigned char c)
+{
+ if (syslog_chars == MAX_PRINT_CHUNK)
+ syslog_chars--;
+ syslog_line[syslog_chars] = c;
+ syslog_chars++;
+ if (c == '\n') {
+ netpoll_send_udp(&np, syslog_line, syslog_chars);
+ syslog_chars = SYSLOG_HEADER_LEN;
+ }
+}
static void write_msg(struct console *con, const char *msg, unsigned int len)
{
- int frag, left;
+ int frag, left, i;
unsigned long flags;
if (!np.dev)
@@ -75,11 +105,16 @@ static void write_msg(struct console *co
local_irq_save(flags);
- for(left = len; left; ) {
- frag = min(left, MAX_PRINT_CHUNK);
- netpoll_send_udp(&np, msg, frag);
- msg += frag;
- left -= frag;
+ if (do_syslog) {
+ for (i = 0; i < len; i++)
+ feed_syslog_char(msg[i]);
+ } else {
+ for(left = len; left; ) {
+ frag = min(left, MAX_PRINT_CHUNK);
+ netpoll_send_udp(&np, msg, frag);
+ msg += frag;
+ left -= frag;
+ }
}
local_irq_restore(flags);
next reply other threads:[~2004-06-25 18:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-25 17:57 Jeff Moyer [this message]
2004-06-25 18:39 ` Matt Mackall
2004-06-25 18:47 ` Jeff Moyer
2004-06-25 19:11 ` Matt Mackall
2004-06-26 2:26 ` Keith Owens
2004-06-26 3:48 ` Matt Mackall
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=16604.26514.243458.631948@segfault.boston.redhat.com \
--to=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/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
all inboxes | Powered by JetHome®