NetKGDB suport.
Subsystems (5)
Hi,
This is tentative patch set I am sending for feedback. It implements a network I/O backend for KDB/KGDB, the kernel debugger. I sent this patch set to linux-kernel, and was kindly referred to this list by David Miller as the right place for feedback.
NetKGDB is 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
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
NetKGDB support v2
In reply to Andrei WarkentinHi!
This is v2 of the tentative patch set I am sending for feedback. It implements a network I/O backend for KDB/KGDB, the kernel debugger.
NetKGDB is 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.
This differs from v1 in cleaning up the netdev notifier code, which was needlessly byzantine and had potential races, and in some docu- mentation changes.
I've also Cc'd Matt Mackall, who wrote the current netconsole code.
[PATCHv2 1/2] NETPOLL: Extend rx_hook support. [PATCHv2 2/2] NETKGDB: Ethernet/UDP/IP KDB transport.
PATCH v2 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 · 9 lines
1.7.8.3 ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2
PATCH v2 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 | 104 +++++ drivers/net/Kconfig | 8 +- drivers/net/Makefile | 1 + drivers/net/netkgdb.c | 728 ++++++++++++++++++++++++++++++++++ 4 files changed, 840 insertions(+), 1 deletions(-) create mode 100644 Documentation/networking/netkgdb.txt create mode 100644 drivers/net/netkgdb.c
Documentation/networking/netkgdb.txt new file +104 -0
@@ -0,0 +1,104 @@ +(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 [email protected]/,@10.0.0.2/ + +Note: 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. + +Note: The format for the string is not netkgdb specific, and its +parsing is part of Linux netpoll support. The netpoll code does +need at least a local IP assigned, so the following will result +in an error and netkgdb will not load if you don't already have +an IP address assigned. + +Note: If you specify a local/remote netkgdb string as a kernel +parameter, with the idea of having a remote server listen on +a socket and wait for the kdb crash connection, don't expect +to be able to connect from the remote host. This is peculiar +behavior of the netpoll code - the interface is not *really* +configured and your packets will never reach netkgdb. You +will need to "ifconfig eth0 x.y.z.w' first. Or just wait +for the crash :-). + +insmod netkgdb netkgdb=@/,@10.0.0.2/ + +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 +728 -0
728 lines not on this page · raw message
Signature · 9 lines
1.7.8.3 ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2
NetKGDB v3
In reply to Andrei WarkentinHi,
This is v3 of the tentative patch set I am sending for feedback. It implements a network I/O backend for KDB/KGDB, the kernel debugger.
NetKGDB is 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.
This differs from v2 in adding the flush() callback in kgdb_io, which would be necessary for correct behavior in gdbstub mode, and enhances the debug core to support registering multiple I/O ops. The later allows both kgdboc, netkgdb and any other providers to coexist peacefully, and allow debugging both interactively and via the network.
V2 cleaned up a lot of the strange cruft in v1 surrounding dealing with netdev notifiers.
[PATCHv3 1/3] NETPOLL: Extend rx_hook support. [PATCHv3 2/3] NETKGDB: Ethernet/UDP/IP KDB transport. [PATCHv3 3/3] KGDB: Allow registering multiple I/O ops.
Thanks,
A
PATCH v3 1/3 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 · 9 lines
1.7.8.3 ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2
Jason Wessel
maintainerRe: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Quoted 27 lines · Andrei Warkentin
From: Andrei Warkentin <[email protected]>
Pass down source information to
rx_hook, useful for accepting connections from unspecified clients.Cc Jason Wessel <[email protected]>Cc Matt Mackall <[email protected]>Signed-off-by Andrei Warkentin <[email protected]>Signed-off-by Andrei Warkentin <[email protected]>--- include/linux/netpoll.h | 10 +++++++++- net/core/netpoll.c | 10 ++++------ 2 files changed, 13 insertions(+), 7 deletions(-)include/linux/netpoll.h +3
-0@@ -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>
include/linux/netpoll.h line 26
Quoted 10 lines
include/linux/netpoll.h +5
-1struct 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 );
I am just now starting to look how this patch set compares to kgdboe. For the kgdboe the patch is a bit different. The kgdboe opted to just pass the skb so as to cut down on the number of arguments to the function call.
Quoted 1 line
From the kgdboe patch:
- void (*rx_hook)(struct netpoll *, int, char *, int);
+ void (*rx_hook)(struct netpoll *, int, char *, int, struct sk_buff *);
Quoted 25 lines
include/linux/netpoll.h +1
-0__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 +0
-2@@ -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>
net/core/netpoll.c static void service_arp_queue(struct netpoll_info *npi) · line 190
Quoted 5 lines
net/core/netpoll.c +1
-1@@ -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)
This is interesting and I will have to look into this further... A large part of the reason kgdboe never went anywhere was all around the locking problems the ability to safely use the network hardware and restore the state when it was done. It appears you made this change so as to make a lockless call directly instead of going through netpoll_poll(). I am not entirely sure you could safely do this.
In kgdboe we always had:
+static int eth_get_char(void)
+{
+ int chr;
+
+ while (atomic_read(&in_count) == 0)
+ netpoll_poll(&np);
If it is the case that you really can safely call the netpoll_poll_dev() without the locks then the horrible sync irq state etc... could go away in kgdboe, and then it would be worth considering digging up all the ethernet polling errata fixes that live of out the mainline and perhaps submit some for review.
Jason.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
Re: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Hi,
Thank you for the review, Jason. Comments inline.
----- Original Message -----
Quoted 17 lines
From: "Jason Wessel" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>
Sent: Monday, February 27, 2012 6:17:12 PM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.I am just now starting to look how this patch set compares to kgdboe.
For the kgdboe the patch is a bit different. The kgdboe opted to
just pass the skb so as to cut down on the number of arguments to the function call.From the kgdboe patch:
(quoted diff) +1
-1- void (*rx_hook)(struct netpoll *, int, char *, int); + void (*rx_hook)(struct netpoll *, int, char *, int, struct
Quoted 3 lines
sk_buff*);
Interesting, I thought about passing the skb, but decided I didn't want to copy and paste the skb parsing code, especially given that it's always UDP anyway. I still have reservations about passing the physical address, but I don't think anyone tried to use netpoll or a non-ethernet device anyway.
Quoted 26 lines
net/core/netpoll.c static void service_arp_queue(struct netpoll_info *npi) · line 190
Quoted 6 lines
net/core/netpoll.c +2
-1+void netpoll_poll_dev (struct net_device *dev);void netpoll_send_udp (struct netpoll *np,const char *msg,int -static void netpoll_poll_dev(struct net_device *dev) +void netpoll_poll_dev(struct net_device *dev)This is interesting and I will have to look into this further... A large part of the reason kgdboe never went anywhere was all around the locking problems the ability to safely use the network hardware and restore the state when it was done. It appears you made this change so as to make a lockless call directly instead of going through
netpoll_poll(). I am not entirely sure you could safely do this.In kgdboe we always had:
(quoted diff) +6
-0+static int eth_get_char(void) +{ + int chr; + + while (atomic_read(&in_count) == 0) + netpoll_poll(&np);
Quoted 6 lines
If it is the case that you really can safely call the
netpoll_poll_dev()without the locks then the horrible sync irq state etc... could go away in kgdboe, and then it would be worth considering digging up all the ethernet polling errata fixes that live of out the mainline and perhaps submit some for review.
I didn't look deeply at kgdboe (probably should have...). Anyway, netpoll_poll doesn't seem to exist. netpoll_poll_dev is called from netpoll_send_skb_on_dev and the only contract I see is running with the interrupts disabled - something that is satisfied by running in the context of KDB.
This is slight OT, but...are WiFi drivers sufficiently similar that netpoll "just works?"
Thanks again.
A
Jason Wessel
maintainerRe: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Quoted 21 lines · Andrei Warkentin
Quoted 17 lines
From: "Jason Wessel" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>
Sent: Monday, February 27, 2012 6:17:12 PM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.I am just now starting to look how this patch set compares to kgdboe.
For the kgdboe the patch is a bit different. The kgdboe opted to
just pass the skb so as to cut down on the number of arguments to the function call.From the kgdboe patch:
(quoted diff) +1
-1- void (*rx_hook)(struct netpoll *, int, char *, int); + void (*rx_hook)(struct netpoll *, int, char *, int, structQuoted 3 lines
sk_buff*);
Quoted 5 lines
Interesting, I thought about passing the skb, but decided I didn't want to copy and paste the skb parsing code, especially given that it's always UDP anyway. I still have reservations about passing the physical address, but I don't think anyone tried to use netpoll or a non-ethernet device anyway.
With some input from the netdev folks we should decide what makes the most sense and stick with that implementation. The previous kgdboe change to just pass the skb was signed off long ago as something ok.
Quoted 10 lines
Quoted 10 lines
(quoted diff) +2
-0+ while (atomic_read(&in_count) == 0) + netpoll_poll(&np);If it is the case that you really can safely call the
netpoll_poll_dev()without the locks then the horrible sync irq state etc... could go away in kgdboe, and then it would be worth considering digging up all the ethernet polling errata fixes that live of out the mainline and perhaps submit some for review.
The code has changed since the last time that kgdboe actually worked. The v3.1 commit 234b921dbcf killed off the netpoll_poll() function as well as the exports needed to allow kgdboe to work as a kernel module. The patch you created here also needs to once again export the netpoll_poll_dev() so that we can call it from a kernel module because kgdboe or the ethernet kdb patch you submitted should be able to be used a loadable module as well as a builtin.
Quoted 5 lines
I didn't look deeply at kgdboe (probably should have...). Anyway,
netpoll_polldoesn't seem to exist.netpoll_poll_devis called fromnetpoll_send_skb_on_devand the only contract I see is running with the interrupts disabled - something that is satisfied by running in the context of KDB.
All that netpoll_poll() did was to call netpoll_poll_dev(). I have not yet looked at the differences between kgdboe and the netkdb code you proposed but I would have suspected it also falls victim to the ethernet preemption problem which prevented kgdboe from ever being considered for a mainline merge. Certainly there are ways to fix this problem but most involved changes to scheduling, core net code, or substantial driver specific changes.
I almost have kgdboe working against the 3.3 kernel so we can have both a code and functional comparison. I would like to do some house cleaning and merging of all the other out of tree patches for things like kgdb over usb as well as kdb usb keyboard, so we can see if any of it makes sense to submit to the mainline.
Quoted 2 lines
This is slight OT, but...are WiFi drivers sufficiently similar that netpoll "just works?"
Yes and no. Yes, you could use the NET_POLL api to transmit packets if the driver implemented polling hooks, but no in the sense that most of the time you need a user space driver to manage the keys which are time sensitive for things like WPA (usually the job of wpa supplicant). This is going to prevent you from having WiFi work at all while the kernel is in the critical exception state.
Jason.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
Re: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Hi,
----- Original Message -----
Quoted 10 lines
From: "Jason Wessel" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>, "Andrei Warkentin" <[email protected]>
Sent: Tuesday, February 28, 2012 11:06:44 AM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.
Quoted 9 lines
All that
netpoll_poll()did was to callnetpoll_poll_dev(). I have not yet looked at the differences between kgdboe and the netkdb code you proposed but I would have suspected it also falls victim to the ethernet preemption problem which prevented kgdboe from ever being considered for a mainline merge. Certainly there are ways to fix this
problem but most involved changes to scheduling, core net code, or substantial driver specific changes.
I see, I read up on the issues w.r.t. preemption. Could this be worked around by modifiying affected drivers to bypass locking if they are used in KDB context? Make some accessor netdev-specific lock/unlocks that won't do anything if running in KDB context.
Quoted 5 lines
Quoted 4 lines
This is slight OT, but...are WiFi drivers sufficiently similar that netpoll "just works?"
Quoted 8 lines
Yes and no. Yes, you could use the
NET_POLLapi to transmit packets if the driver implemented polling hooks, but no in the sense that most
of the time you need a user space driver to manage the keys which are time sensitive for things like WPA (usually the job of wpa supplicant). This is going to prevent you from having WiFi work at all while the kernel is in the critical exception state.
Ah right. I was thinking just open networking. I should give that a try...
A
Re: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
----- Original Message -----
Quoted 20 lines
From: "Andrei Warkentin" <[email protected]>
To: "Jason Wessel" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>, "Andrei Warkentin" <[email protected]>
Sent: Tuesday, February 28, 2012 12:43:52 PM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.Quoted 11 lines
All that
netpoll_poll()did was to callnetpoll_poll_dev(). I have not yet looked at the differences between kgdboe and the netkdb code
you proposed but I would have suspected it also falls victim to the ethernet preemption problem which prevented kgdboe from ever being considered for a mainline merge. Certainly there are ways to fix this
problem but most involved changes to scheduling, core net code, or substantial driver specific changes.
Quoted 7 lines
I see, I read up on the issues w.r.t. preemption. Could this be worked
around by modifiying affected drivers to bypass locking if they are used in KDB context? Make some accessor netdev-specific lock/unlocks that won't do anything if running in KDB context.
By the way, is there a good way to repro the preemption case? Hopefully this doesn't involve some crazy hardware...
A
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
Jason Wessel
maintainerRe: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Quoted 26 lines · Andrei Warkentin
----- Original Message -----
Quoted 18 lines
From: "Andrei Warkentin" <[email protected]>
To: "Jason Wessel" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>, "Andrei Warkentin" <[email protected]>
Sent: Tuesday, February 28, 2012 12:43:52 PM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.Quoted 10 lines
All that
netpoll_poll()did was to callnetpoll_poll_dev(). I have not yet looked at the differences between kgdboe and the netkdb code
you proposed but I would have suspected it also falls victim to the ethernet preemption problem which prevented kgdboe from ever being considered for a mainline merge. Certainly there are ways to fix this
problem but most involved changes to scheduling, core net code, or substantial driver specific changes.Quoted 7 lines
I see, I read up on the issues w.r.t. preemption. Could this be worked
around by modifiying affected drivers to bypass locking if they are used in KDB context? Make some accessor netdev-specific lock/unlocks that won't do anything if running in KDB context.
Quoted 2 lines
By the way, is there a good way to repro the preemption case? Hopefully this doesn't involve some crazy hardware...
I have several cases which will usually hang the machine fairly quickly, but they all involve using gdb and a target using SMP. Most often it is as simple as this:
* Use an SMP system with with at least 2 cores
* Start two threads rapidly running some processes while [ 1 ] ; do date > /dev/null ; done & while [ 1 ] ; do date > /dev/null ; done &
* Connect with gdb to kgdb and set a breakpoint at do_fork Now do "c"
Now do "c 1000"
Generally the system will hang long before you get 1000 breakpoints hit and it will be a condition where there is a lock needed to create an skb, or the ethernet driver is preempted or some part of the network stack is preempted (or holding a lock) on the non master cpu.
There is another condition that is hard to catch that involves a task migrating from one cpu to the next, but we'll stick to the simple test case I described above for now.
I did have a question, because it seems you were using qemu / kvm. I have a number of test cases that use kvm, but the netkkgdb does not seem to work with the nc. My question is how am I supposed to actually use the netkgdb?
Here is what I observe on the target system:
insmod netkgdb.ko netkgdb=@/,@10.0.2.2/
echo g > /proc/sysrq-trigger
On my host system:
nc.traditional -l -u -p 7777
I will type help, and then the netkgdb is toast. It doesn't seem to respond anymore.
Jason.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
Re: [PATCHv3 1/3] NETPOLL: Extend rx_hook support.
Hi,
----- Original Message -----
Quoted 15 lines
From: "Jason Wessel" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Matt Mackall" <[email protected]>, "Andrei Warkentin" <[email protected]>
Sent: Thursday, March 1, 2012 5:24:18 PM
Subject: Re: [PATCHv3 1/3] NETPOLL: Extendrx_hooksupport.Quoted 1 line
I did have a question, because it seems you were using qemu / kvm.
I have a number of test cases that use kvm, but the netkkgdb does
not seem to work with the nc. My question is how am I supposed to actually use the netkgdb?Here is what I observe on the target system:
Quoted 9 lines
insmod netkgdb.ko netkgdb=@/,@10.0.2.2/
echo g >/proc/sysrq-triggerOn my host system:
nc.traditional -l -u -p 7777I will type help, and then the netkgdb is toast. It doesn't seem to respond anymore.
Strange. I've just repeated your steps (I didn't build as a ko before, but now I did) and I don't see this problem. Can you tell me your qemu/kvm command line?
With qemu I've see odd behavior with ne2k_pci, which is the default (qemu would wedge) occasionally. If you are using ne2000, can you try rtl8139?
Note: I just tried ne2k_pci, and other than having to specify a local IP address (something I don't need to for rtl8139). I've also realized that if you insert netkgdb as a module without any parameters, it doesn't bind to existing netdevs - that's a bug.
Anything I should know about your network topology?
Can you also apply the multi-I/O-backend patch and boot with kgdboc=kbd, and see if the VM is toast after you type "help".
A
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
PATCH v3 2/3 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 | 104 +++++ drivers/net/Kconfig | 8 +- drivers/net/Makefile | 1 + drivers/net/netkgdb.c | 729 ++++++++++++++++++++++++++++++++++ 4 files changed, 841 insertions(+), 1 deletions(-) create mode 100644 Documentation/networking/netkgdb.txt create mode 100644 drivers/net/netkgdb.c
Documentation/networking/netkgdb.txt new file +104 -0
@@ -0,0 +1,104 @@ +(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 [email protected]/,@10.0.0.2/ + +Note: 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. + +Note: The format for the string is not netkgdb specific, and its +parsing is part of Linux netpoll support. The netpoll code does +need at least a local IP assigned, so the following will result +in an error and netkgdb will not load if you don't already have +an IP address assigned. + +Note: If you specify a local/remote netkgdb string as a kernel +parameter, with the idea of having a remote server listen on +a socket and wait for the kdb crash connection, don't expect +to be able to connect from the remote host. This is peculiar +behavior of the netpoll code - the interface is not *really* +configured and your packets will never reach netkgdb. You +will need to "ifconfig eth0 x.y.z.w' first. Or just wait +for the crash :-). + +insmod netkgdb netkgdb=@/,@10.0.0.2/ + +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 +729 -0
729 lines not on this page · raw message
Signature · 9 lines
1.7.8.3 ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2
Re: [PATCHv3 2/3] NETKGDB: Ethernet/UDP/IP KDB transport.
Documentation/networking/netkgdb.txt line 45
Quoted 3 lines · Andrei Warkentin
Documentation/networking/netkgdb.txt new file +3
-0+Note: 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
This *really* needs a discussion of the security implications of this. Do you *really* want to have a kgdb that will accept connections from *anywhere*? Sounds like an insta-root waiting to happen.
Documentation/networking/netkgdb.txt line 48
Quoted 3 lines
Documentation/networking/netkgdb.txt new file +3
-0+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.
Exactly. You don't know ahead of time who's going to connect. That's the problem...
Re: [PATCHv3 2/3] NETKGDB: Ethernet/UDP/IP KDB transport.
Hi,
----- Original Message -----
Quoted 7 lines
From: "Valdis Kletnieks" <[email protected]>
To: "Andrei Warkentin" <[email protected]>
Cc: [email protected], [email protected], "Andrei Warkentin" <[email protected]>, [email protected], "Jason Wessel" <[email protected]>, "Matt Mackall" <[email protected]>
Sent: Monday, February 27, 2012 12:29:03 AM
Subject: Re: [PATCHv3 2/3] NETKGDB: Ethernet/UDP/IP KDB transport.
Quoted 6 lines
This *really* needs a discussion of the security implications of this. Do
you *really* want to have a kgdb that will accept connections from *anywhere*?
Sounds like an insta-root waiting to happen.
It does *really* need documentation. It's not meant for general purpose use. Just like Android devices come with KDB compiled out, this shouldn't be built in. That means that netkgdb should be default off and come with a huge warning. It is insta-root. And that's the message it should carry with it. It's no different from running kgdboc - anyone has root access if they press Alt-PrtScrn-g, right?
Quoted 7 lines
Documentation/networking/netkgdb.txt line 48
Quoted 3 lines
Documentation/networking/netkgdb.txt new file +3
-0+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.Exactly. You don't know ahead of time who's going to connect. That's the
problem...
It's not a problem unless you make it one. If I am running a private test farm where I provision 250+ machines or VMs, and I have 10-15 devs that could possibly investigate the issue, it's not realistic to know ahead of times what internal IP address the connection could come from.
I will update the docs and the Kconfig (default=off). That should be sufficient for PEBCAK failures.
Cheers,
A
PATCH v3 3/3 KGDB: Allow registering multiple I/O ops.
In reply to Andrei WarkentinThis allows multiple I/O ops, which is useful, if you want to be able to support debugging say both via console and via network (or 1394, dbgp, etc.)
Tested with kgdboc and netkgdb.
--- drivers/usb/early/ehci-dbgp.c | 4 +- include/linux/kgdb.h | 6 ++- kernel/debug/debug_core.c | 130 +++++++++++++++++++++++++++-------------- kernel/debug/gdbstub.c | 43 ++++++------- kernel/debug/kdb/kdb_io.c | 26 ++++----- 5 files changed, 125 insertions(+), 84 deletions(-)
drivers/usb/early/ehci-dbgp.c +3 -1
@@ -97,7 +97,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)#ifdef CONFIG_KGDB static struct kgdb_io kgdbdbgp_io_ops; -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops) +static int kgdb_registered =0 ; +#define dbgp_kgdb_mode (kgdb_registered)#else #define dbgp_kgdb_mode (0)#endif
@@ -1051,6 +1052,7 @@ static int __init kgdbdbgp_parse_config(char *str) kgdbdbgp_wait_time =simple_strtoul (ptr, &ptr,10 ); }kgdb_register_io_module (&kgdbdbgp_io_ops); + kgdb_registered =1 ; kgdbdbgp_io_ops.is_console = early_dbgp_console.index !=-1 ;return 0 ;
include/linux/kgdb.h +5 -1
@@ -17,6 +17,7 @@#include <linux/linkage.h> #include <linux/init.h> #include <linux/atomic.h> +#include <linux/list.h> #ifdef CONFIG_HAVE_ARCH_KGDB #include <asm/kgdb.h> #endif
@@ -276,6 +277,7 @@ struct kgdb_io {void (*pre_exception) (void );void (*post_exception) (void );int is_console; +struct list_head list; };extern struct kgdb_arch arch_kgdb_ops;
@@ -284,7 +286,9 @@ extern unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs);extern int kgdb_register_io_module (struct kgdb_io *local_kgdb_io_ops);extern void kgdb_unregister_io_module (struct kgdb_io *local_kgdb_io_ops); -extern struct kgdb_io *dbg_io_ops; +extern int dbg_io_get_char (void ); +extern void dbg_io_put_char (u8 ,bool ); +extern void dbg_io_flush (void );extern int kgdb_hex2long (char **ptr,unsigned long *long_val);extern char *kgdb_mem2hex (char *mem,char *buf,int count);
kernel/debug/debug_core.c +86 -44
205 lines not on this page · raw message
kernel/debug/gdbstub.c +20 -23
97 lines not on this page · raw message
kernel/debug/kdb/kdb_io.c +11 -15
@@ -689,14 +689,11 @@ kdb_printit:if (!dbg_kdb_mode && kgdb_connected) {gdbstub_msg_write (kdb_buffer, retlen); }else { -if (!dbg_io_ops->is_console) { - len =strlen (kdb_buffer); - cp = kdb_buffer; -while (len--) { - dbg_io_ops->write_char (*cp); - cp++; - } - } + len =strlen (kdb_buffer); + cp = kdb_buffer; +while (len--) +dbg_io_put_char (*cp++, true); +while (c) { c->write (c, kdb_buffer, retlen);touch_nmi_watchdog ();
@@ -743,14 +740,13 @@ kdb_printit:kdb_input_flush (); c = console_drivers; -if (!dbg_io_ops->is_console) { - len =strlen (moreprompt); - cp = moreprompt; -while (len--) { - dbg_io_ops->write_char (*cp); - cp++; - } + len =strlen (moreprompt); + cp = moreprompt; +while (len--) { +dbg_io_put_char (*cp, true); + cp++; } +while (c) { c->write (c, moreprompt,strlen (moreprompt));touch_nmi_watchdog ();
Signature · 1 line
1.7.8.3
David Miller
maintainerRe: NetKGDB v3
In reply to Andrei WarkentinIt's pretty pointless to post two difference versions merely an hour apart.
I've personally written off reviewing your work until things settle down a bit.
Re: NetKGDB v3
2012/2/26 David Miller <[email protected]>:
Quoted 6 lines
It's pretty pointless to post two difference versions merely an hour apart.
I've personally written off reviewing your work until things settle down a bit.
Hi David,
Sorry about the spam! I swear I'm done... I just didn't feel like getting flamed for something I missed out on in v2 and fixed (namely, flush() callback for gdbstub), but looks like I got flamed nonetheless ;-).
Take care,
A
Re: NetKGDB v3
In reply to Andrei WarkentinQuoted 5 lines · On Sun, 26 Feb 2012 22:30:08 -0500 Andrei Warkentin…
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.
And opens a security hole so wide that no production network or distro should ever enable it!