NetKGDB support.
Subsystems (3)
This is tentative patch set I am sending for feedback. It implements a network I/O backend for KDB/KGDB, the kernel debugger.
Very similar to netconsole, on which it is based, but with a crucial difference - netkgdb is designed to accept connections from any hosts, i.e. it is not necessary to specify these ahead of time. This makes it that much more useful in a "this host crashed and a I want a developer to take a look at it" scenario, common to large scale test/QA farms and automated testing harnesses. This involves a minor change to the netpoll rx_hook, namely, to provide source connection information.
[PATCH 1/2] NETPOLL: Extend rx_hook support. [PATCH 2/2] NETKGDB: Ethernet/UDP/IP KDB transport.
Thanks,
A
PATCH 1/2 NETPOLL: Extend rx_hook support.
From: Andrei Warkentin <[email protected]>
Pass down source information to rx_hook, useful for accepting connections from unspecified clients.
--- include/linux/netpoll.h | 10 +++++++++- net/core/netpoll.c | 10 ++++------ 2 files changed, 13 insertions(+), 7 deletions(-)
include/linux/netpoll.h +9 -1
@@ -11,12 +11,19 @@#include <linux/interrupt.h> #include <linux/rcupdate.h> #include <linux/list.h> +#include <linux/if_ether.h> +#include <net/tcp.h> +#include <net/udp.h> struct netpoll {struct net_device *dev;char dev_name[IFNAMSIZ ];const char *name; -void (*rx_hook)(struct netpoll *,int ,char *,int ); +void (*rx_hook)(struct netpoll *, +u8 *h_source, +__be32 saddr, +struct udphdr *, +char *,int );__be32 local_ip, remote_ip;u16 local_port, remote_port;
@@ -40,6 +47,7 @@ struct netpoll_info {struct netpoll *netpoll; }; +void netpoll_poll_dev (struct net_device *dev);void netpoll_send_udp (struct netpoll *np,const char *msg,int len);void netpoll_print_options (struct netpoll *np);int netpoll_parse_options (struct netpoll *np,char *opt);
net/core/netpoll.c +4 -6
@@ -26,8 +26,6 @@#include <linux/workqueue.h> #include <linux/slab.h> #include <linux/export.h> -#include <net/tcp.h> -#include <net/udp.h> #include <asm/unaligned.h> #include <trace/events/napi.h>
@@ -189,7 +187,7 @@ static void service_arp_queue(struct netpoll_info *npi) } } -static void netpoll_poll_dev (struct net_device *dev) +void netpoll_poll_dev (struct net_device *dev) {const struct net_device_ops *ops;
@@ -615,9 +613,9 @@ int __netpoll_rx(struct sk_buff *skb)if (np->local_port && np->local_port !=ntohs (uh->dest))continue ; - np->rx_hook (np,ntohs (uh->source), - (char *)(uh+1 ), - ulen -sizeof (struct udphdr )); + np->rx_hook (np,eth_hdr (skb)->h_source, + iph->saddr, uh, (char *)(uh+1 ), + ulen -sizeof (struct udphdr )); hits++; }
Signature · 1 line
1.7.8.3
David Miller
maintainerRe: [PATCH 1/2] NETPOLL: Extend rx_hook support.
From: Andrei Warkentin <[email protected]>
Date: Fri, 24 Feb 2012 21:15:08 -0500
Quoted 6 lines
From: Andrei Warkentin <[email protected]>
Pass down source information to
rx_hook, useful for accepting connections from unspecified clients.Signed-off-by Andrei Warkentin <[email protected]>
This needs to be submitted to netdev for review, not linux-kernel and your kgdb list.
Re: [PATCH 1/2] NETPOLL: Extend rx_hook support.
Hi David,
----- Original Message -----
Quoted 10 lines
From: "David Miller" <[email protected]>
To: "andrey warkentin" <[email protected]>
Cc: [email protected], [email protected], "jason wessel" <[email protected]>, [email protected]
Sent: Friday, February 24, 2012 10:31:59 PM
Subject: Re: [PATCH 1/2] NETPOLL: Extendrx_hooksupport.This needs to be submitted to netdev for review, not linux-kernel and your kgdb list.
Thanks for pointing me to the right place. I'll send this patch set over there as well.
A
PATCH 2/2 NETKGDB: Ethernet/UDP/IP KDB transport.
In reply to Andrei WarkentinFrom: Andrei Warkentin <[email protected]>
Allows debugging a crashed kernel, and breaking into a live kernel via a network interface.
Useful in testing/QA farms where physical access is not necessarily easy/desired, and iLO-like solutions end up using USB HID and not i8042-based keyboard.
--- Documentation/networking/netkgdb.txt | 87 +++++ drivers/net/Kconfig | 8 +- drivers/net/Makefile | 1 + drivers/net/netkgdb.c | 639 ++++++++++++++++++++++++++++++++++ 4 files changed, 734 insertions(+), 1 deletions(-) create mode 100644 Documentation/networking/netkgdb.txt create mode 100644 drivers/net/netkgdb.c
Documentation/networking/netkgdb.txt new file +87 -0
@@ -0,0 +1,87 @@ +(based off netconsole.txt) + +Started by Andrei Warkentin <[email protected]>, 2012.02.24 + +Please send bug reports to Andrey Warkentin <[email protected]> + +Introduction: +============= + +This module allows debugging a crashed kernel over the network, +where other means are not practical. + +It can be used either built-in or as a module. As a built-in, +netkgdb initializes immediately after NIC cards and will bring up +the specified interface as soon as possible. While this doesn't allow +early kernel debugging, it's useful for handling random crashes and +such. + +Sender and receiver configuration: +================================== + +It takes an optional string configuration parameter "netkgdb" in the +following format: + + netkgdb=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr] + + where + src-port source for UDP packets (defaults to 7777) + src-ip source IP to use (interface address) + dev network interface (eth0) + tgt-port port for remote agent (7777) + tgt-ip IP address for remote agent + tgt-macaddr ethernet MAC address for remote agent (broadcast) + +Examples: + + linux [email protected]/eth1,[email protected]/12:34:56:78:9a:bc + + or + + insmod netkgdb netkgdb=@/,@10.0.0.2/ + +Note that the parameter is optional and largely unneeded unless you +are running a listen server - netkgdb will accept connection from any +IP on all interfaces and will reconfigure itself appropriately if +the assigned interface IP address changes. This makes it useful +in an environment where it's not known ahead of time what computer +will connect to perform the crash analysis. + +The remote host can run either 'netcat -u -l -p <port>' or 'nc -l -u <port>'. + +Using: +====== + +If the kernel is running, then any input will result in following string +to be sent back - + Alive - '!!!BREAK!!!' to break in. + +This lets you know the machine is alive. + +Sending "!!!BREAK!!!", followed by a '\n' will result in breaking into +KGDB/KDB. + +Miscellaneous notes: +==================== + +The following notes are only relevant if you want the debugged +host to automatically send the KDB/KGDB data on a crash to a +host preconfigured with the netkgdb= parameter. + +WARNING: the default target ethernet setting uses the broadcast +ethernet address to send packets, which can cause increased load on +other systems on the same ethernet segment. After the first reply +connection, the target ethernet address is updated to match the source. + +TIP: some LAN switches may be configured to suppress ethernet broadcasts +so it is advised to explicitly specify the remote agents' MAC addresses +from the config parameters passed to netkgdb. + +TIP: to find out the MAC address of, say, 10.0.0.2, you may try using: + + ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2 + +TIP: in case the remote agent is on a separate LAN subnet than +the sender, it is suggested to try specifying the MAC address of the +default gateway (you may use /sbin/route -n to find it out) as the +remote MAC address instead.
drivers/net/Kconfig +7 -1
@@ -160,6 +160,12 @@ config NETCONSOLE If you want to log kernel messages over the network, enable this. See <file:Documentation/networking/netconsole.txt> for details. +config NETKGDB + tristate "Network kgdb I/O backend" + ---help--- + If you want to debug the kernel over the network, enable this. + See <file:Documentation/networking/netkgdb.txt> for details. + config NETCONSOLE_DYNAMIC bool "Dynamic reconfiguration of logging targets" depends on NETCONSOLE && SYSFS && CONFIGFS_FS && \
@@ -171,7 +177,7 @@ config NETCONSOLE_DYNAMIC See <file:Documentation/networking/netconsole.txt> for details. config NETPOLL - def_bool NETCONSOLE + def_bool NETCONSOLE || NETKGDB config NETPOLL_TRAP bool "Netpoll traffic trapping"
drivers/net/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_MII) += mii.o obj-$(CONFIG_MDIO) += mdio.o obj-$(CONFIG_NET) += Space.o loopback.o obj-$(CONFIG_NETCONSOLE) += netconsole.o +obj-$(CONFIG_NETKGDB) += netkgdb.o obj-$(CONFIG_PHYLIB) += phy/ obj-$(CONFIG_RIONET) += rionet.o obj-$(CONFIG_NET_TEAM) += team/
drivers/net/netkgdb.c new file +639 -0
639 lines not on this page · raw message
Signature · 1 line
1.7.8.3