netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: David Miller <davem@davemloft.net>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, penguin-kernel@I-love.SAKURA.ne.jp,
	sd@queasysnail.net
Subject: Re: [PATCH 4/4] netconsole: implement extended console support
Date: Mon, 11 May 2015 16:37:45 -0400	[thread overview]
Message-ID: <20150511203745.GI11388@htj.duckdns.org> (raw)
In-Reply-To: <20150511.132339.403868463230045095.davem@davemloft.net>

Hello,

On Mon, May 11, 2015 at 01:23:39PM -0400, David Miller wrote:
> From: Tejun Heo <tj@kernel.org>
> Date: Mon, 11 May 2015 12:41:34 -0400
> 
> > +	/* need to insert extra header fields, detect header and body */
> > +	header = msg;
> > +	body = memchr(msg, ';', msg_len);
> > +	if (WARN_ON_ONCE(!body))
> > +		return;
> > +
> > +	header_len = body - header;
> > +	body_len = msg_len - header_len - 1;
> > +	body++;
> > +
> > +	/*
> > +	 * Transfer multiple chunks with the following extra header.
> > +	 * "ncfrag=<byte-offset>/<total-bytes>"
> > +	 */
> > +	memcpy(buf, header, header_len);
> > +
> > +	while (offset < body_len) {
> > +		int this_header = header_len;
> > +		int this_chunk;
> > +
> > +		this_header += scnprintf(buf + this_header,
> > +					 sizeof(buf) - this_header,
> > +					 ",ncfrag=%d/%d;", offset, body_len);
> > +
> 
> Hmmm, do you intend ncfrag= to be amongst the other metadata in the first
> fragment?  The way I read the code above it's going to be:
> 
> 	<level>,<sequnum>,<timestamp>,<contflag>;,ncfrag=x/y;
> 
> If you intend to keep all the metadata, including the ncfrag bit,
> together, you probably need to clip off the initial semicolon, so
> that it looks like:
> 
> 	<level>,<sequnum>,<timestamp>,<contflag>,ncfrag=x/y;

The current code does produce the latter outcome.

	header = msg;
	body = memchr(msg, ';', msg_len);
	if (WARN_ON_ONCE(!body))
		return;

	header_len = body - header;
	body_len = msg_len - header_len - 1;
	body++;

@body points to ';' after memchr(), so @header_len doesn't include
';'.  @body is incremented after calculating @header_len.

Thanks.

-- 
tejun

  reply	other threads:[~2015-05-11 20:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 16:41 [PATCHSET v3] netconsole: implement extended console support Tejun Heo
2015-05-11 16:41 ` [PATCH 1/4] netconsole: remove unnecessary netconsole_target_get/out() from write_msg() Tejun Heo
2015-05-11 16:41 ` [PATCH 2/4] netconsole: make netconsole_target->enabled a bool Tejun Heo
2015-05-11 16:41 ` [PATCH 3/4] netconsole: make all dynamic netconsoles share a mutex Tejun Heo
2015-05-11 16:41 ` [PATCH 4/4] netconsole: implement extended console support Tejun Heo
2015-05-11 17:23   ` David Miller
2015-05-11 20:37     ` Tejun Heo [this message]
2015-05-12 23:23       ` David Miller
2015-05-13 15:46         ` Tejun Heo
2015-05-14  4:39           ` David Miller
2015-05-14 15:12             ` Tejun Heo
2015-05-12 23:36   ` Andrew Morton
2015-05-13  2:41     ` David Miller
2015-05-13 15:32     ` Tejun Heo

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=20150511203745.GI11388@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=sd@queasysnail.net \
    /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;
as well as URLs for NNTP newsgroup(s).