public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@turbolabs.com>
To: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, linux-net@vger.kernel.org,
	netdev@oss.sgi.com
Subject: Re: [patch] netconsole - log kernel messages over the network. 2.4.10.
Date: Wed, 26 Sep 2001 17:46:05 -0600	[thread overview]
Message-ID: <20010926174605.E1140@turbolinux.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0109262128320.8277-100000@localhost.localdomain> <Pine.LNX.4.21.0109261635190.957-100000@freak.distro.conectiva> <20010926152909.D1140@turbolinux.com>
In-Reply-To: <20010926152909.D1140@turbolinux.com>

On Sep 26, 2001  15:29 -0600, adilger wrote:
> On Wed, 26 Sep 2001, Ingo Molnar wrote:
> > sample startup of the netconsole on the server:
> > 
> >      insmod netconsole dev=eth1 target_ip=0x0a000701 \
> >                   source_port=6666 \
> >                   target_port=6666 \
> >                   target_eth_byte0=0x00 \
> >                   target_eth_byte1=0x90\
> >                   target_eth_byte2=0x27 \
> >                   target_eth_byte3=0x8C \
> >                   target_eth_byte4=0xA0 \
> >                   target_eth_byte5=0xA8
> 
> Ugh.  Maybe a wrapper script (netconsole-server) which automates this is
> in order?  I imagine the eth_byteX is a MAC address (or at least that this
> is in the documentation)?

Ok, I read the docs, and this is indeed a target MAC address.  It may still
be easier to accept a regular MAC address like target_mac=XX:XX:XX:XX:XX:XX
as the module parameter (and a target_ip=A.B.C.D).  In any case, here is a
script to automate this (ugly because of the conversions needed).

=========================================================================
#!/bin/sh
prog=netconsole-server
#
# initialize the netconsole using reasonable defaults (normally just the
# client IP address, and possibly the port.  We can determine the MAC
# address of the client system, IP address, the correct device, and verify
# that we are using an ethernet interface (required for netconsole to work).
#
# Andreas Dilger <adilger@turbolinux.com>  Sep 26, 2001

usage()
{
	cat - <<- EOF 1>&2

	Initialize a network message console over UDP.

	usage: $prog [-b] [-d dev] [-m mac] [-p port] target[:port]
		-b       - use broadcast ethernet MAC address
		-m       - specify remote system MAC address (default: detect)
		-p       - local port to use for message traffic (default: 6666)
		-d       - ethernet device to use for messages (default: detect)
		target   - hostname/IP address of remote netconsole-client
		:port    - port on target netconsole-client (default: like -p)
	EOF
	exit 1
}

PATH=$PATH:/sbin:/usr/sbin
PORT=6666

while [ $# -ge 1 ]; do case $1 in
	-b) NOMAC=1 ;;
	-d) DEV=$2; shift ;;
	-m) MAC=$2; shift ;;
	-p) PORT=$2; shift ;;
	*:*) TGT=`echo $1 | sed "s/:.*//"`; TPORT=`echo $1 | sed "s/.*://"` ;;
	*) TGT=$1 ;;
	esac
	shift
done

[ -z "$TGT" ] && usage
[ -z "$TPORT" ] && TPORT=$PORT

ping -c 1 $TGT > /dev/null 2>&1
[ $? -ne 0 ] && echo "$prog: can't ping $TGT" 1>&2 && usage

dquad_to_hex()
{
	echo $1 | sed -e "s/[()]//g" -e "s/\./ /g" | while read I0 I1 I2 I3 ; do
		printf "0x%02X%02X%02X%02X" $I0 $I1 $I2 $I3
	done
}

# output from arp -a of the form:
# good: host.domain (A.B.C.D) at 00:50:BF:06:48:C1 [ether] on eth0
# bad:  ? (A.B.C.D) at <incomplete> on eth0
arp -a | grep $TGT | { read HOSTNAME IPADDR AT MACADDR TYPE ON IFACE;
	[ "$HOSTNAME" = "?" -a -z "$MAC" -a -z "$NOMAC" ] && \
		echo "$prog: can't resolve $TGT MAC" 1>&2 && usage

	[ -z "$MAC" ] && MAC=$MACADDR
	[ -z "$DEV" ] && DEV=$IFACE
	[ "$DEV" = "$IFACE" -a "$TYPE" != "[ether]" ] && \
		echo "$prog: $DEV must be an ethernet interface" 1>&2 && usage
		
	IPHEX=`dquad_to_hex $IPADDR`
	echo $MAC | sed "s/:/ /g" | { read M0 M1 M2 M3 M4 M5;
		if [ -z "$NOMAC" ]; then
			TGTMAC="target_eth_byte0=0x$M0 target_eth_byte1=0x$M1 \
				target_eth_byte2=0x$M2 target_eth_byte3=0x$M3 \
				target_eth_byte4=0x$M4 target_eth_byte5=0x$M5"
		fi
		#insmod netconsole dev=$DEV target_ip=$IPHEX \
		echo dev=$DEV target_ip=$IPHEX \
			source_port=$PORT target_port=$TPORT $TGTMAC
	}
}

Cheers, Andreas
--
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert


  reply	other threads:[~2001-09-26 23:46 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-26 20:04 [patch] netconsole - log kernel messages over the network. 2.4.10 Ingo Molnar
2001-09-26 19:36 ` Marcelo Tosatti
2001-09-26 21:15   ` jamal
2001-09-27  5:45     ` Ingo Molnar
2001-09-26 21:29   ` Andreas Dilger
2001-09-26 23:46     ` Andreas Dilger [this message]
2001-09-27  5:28       ` Ingo Molnar
2001-09-27  6:38   ` [patch] netconsole-2.4.10-B1 Ingo Molnar
2001-09-28  7:08     ` Andreas Dilger
2001-09-29  1:34       ` Randy.Dunlap
2001-09-29  9:52         ` Ingo Molnar
2001-09-29 16:32           ` John Alvord
2001-09-29 16:40           ` Pekka Savola
2001-09-29 22:37             ` Andreas Dilger
2001-09-30  3:38           ` Kenneth Johansson
2001-09-30  7:52             ` Rik van Riel
2001-09-30 10:40               ` Riley Williams
2001-09-30 10:48               ` Glynn Clements
2001-09-30 12:25               ` Richard Gooch
2001-10-01  7:35                 ` Ingo Molnar
2001-10-01 14:55                   ` Oliver Xymoron
2001-10-01 16:28                   ` Richard Gooch
2001-10-01  8:47               ` Henning P. Schmiedehausen
2001-10-01 16:03                 ` Andreas Dilger
2001-09-30 21:18             ` H. Peter Anvin
2001-09-30 16:00           ` Marcus Sundberg
2001-10-01  7:39             ` Ingo Molnar
2001-09-30 19:42           ` Randy.Dunlap
2001-09-30 20:25             ` Randy.Dunlap
2001-10-01  4:09               ` Andreas Dilger
2001-10-03  1:09                 ` [patch] netconsole-2.4.10-C2 Randy.Dunlap
2001-10-01 16:58       ` [patch] netconsole-2.4.10-B1 Randy.Dunlap
  -- strict thread matches above, loose matches on Subject: below --
2001-09-27 15:18 [patch] netconsole - log kernel messages over the network. 2.4.10 Ookhoi
2001-09-27 18:05 ` Andrew Morton
2001-09-27 18:30   ` Ookhoi
2001-09-28  2:53   ` Albert Cranford

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=20010926174605.E1140@turbolinux.com \
    --to=adilger@turbolabs.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@oss.sgi.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