 l-mpm/net/Kconfig           |    9 ++-
 l-mpm/net/core/Makefile     |    1 
 l-mpm/net/core/netconsole.c |  126 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff -puN /dev/null net/core/netconsole.c
--- /dev/null	2003-02-25 20:03:23.000000000 -0600
+++ l-mpm/net/core/netconsole.c	2003-09-08 11:26:03.000000000 -0500
@@ -0,0 +1,126 @@
+/*
+ *  linux/drivers/net/netconsole.c
+ *
+ *  Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
+ *
+ *  This file contains the implementation of an IRQ-safe, crash-safe
+ *  kernel console implementation that outputs kernel messages to the
+ *  network.
+ *
+ * Modification history:
+ *
+ * 2001-09-17    started by Ingo Molnar.
+ * 2003-08-11    2.6 port by Matt Mackall
+ *               simplified options
+ *               generic card hooks
+ *               works non-modular
+ * 2003-09-07    rewritten with netpoll api
+ */
+
+/****************************************************************
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2, or (at your option)
+ *      any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ****************************************************************/
+
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/console.h>
+#include <linux/tty_driver.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/string.h>
+#include <linux/sysrq.h>
+#include <linux/smp.h>
+#include <linux/netpoll.h>
+
+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 void rx_hook(struct netpoll *np, char *msg, int len);
+
+static struct netpoll np = {
+	.name = "netconsole",
+	.dev_name = "eth0",
+	.rx_hook = rx_hook,
+	.local_port = 6666,
+	.remote_port = 6666,
+	.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+};
+
+#define MAX_PRINT_CHUNK 1000
+
+static void write_msg(struct console *con, const char *msg, unsigned int len)
+{
+	int frag, left;
+	unsigned long flags;
+
+	if (!np.dev)
+		return;
+
+	local_irq_save(flags);
+
+	for(left = len; left; ) {
+		frag = min(left, MAX_PRINT_CHUNK);
+		netpoll_send_udp(&np, msg, frag);
+		msg += frag;
+		left -= frag;
+	}
+
+	local_irq_restore(flags);
+}
+
+static void rx_hook(struct netpoll *np, char *msg, int len)
+{
+	/* add sysrq support */
+	printk("netconsole: got something len %d\n", len);
+}
+
+static struct console netconsole = {
+	.flags = CON_ENABLED,
+	.write = write_msg
+};
+
+static int option_setup(char *opt)
+{
+	return netpoll_parse_options(&np, opt);
+}
+
+__setup("netconsole=", option_setup);
+
+static int init_netconsole(void)
+{
+	if(strlen(config) && option_setup(config))
+		return 1;
+
+	if(!np.remote_ip || netpoll_setup(&np))
+		return 1;
+
+	register_console(&netconsole);
+	printk(KERN_INFO "netconsole: network logging started\n");
+	return 0;
+}
+
+static void cleanup_netconsole(void)
+{
+	printk(KERN_INFO "netconsole: network logging shut down.\n");
+	unregister_console(&netconsole);
+	np.dev = NULL;
+}
+
+module_init(init_netconsole);
+module_exit(cleanup_netconsole);
diff -puN net/core/Makefile~netconsole net/core/Makefile
--- l/net/core/Makefile~netconsole	2003-09-08 11:26:03.000000000 -0500
+++ l-mpm/net/core/Makefile	2003-09-08 11:26:03.000000000 -0500
@@ -14,3 +14,4 @@ obj-$(CONFIG_NET_DIVERT) += dv.o
 obj-$(CONFIG_NET_PKTGEN) += pktgen.o
 obj-$(CONFIG_NET_RADIO) += wireless.o
 obj-$(CONFIG_NETPOLL) += netpoll.o
+obj-$(CONFIG_NETCONSOLE) += netconsole.o
diff -puN net/Kconfig~netconsole net/Kconfig
--- l/net/Kconfig~netconsole	2003-09-08 11:26:03.000000000 -0500
+++ l-mpm/net/Kconfig	2003-09-08 11:26:03.000000000 -0500
@@ -704,6 +704,13 @@ endmenu
 source "drivers/net/Kconfig"
 
 config NETPOLL
-	def_bool KGDB
+	def_bool KGDB || NETCONSOLE
+
+config NETCONSOLE
+	tristate "Network console logging support"
+	depends on NETDEVICES
+	---help---
+	If you want to log kernel messages over the network, then say
+	"M" here. See Documentation/networking/netlogging.txt for details.
 
 endmenu

_
