From: Steven Whitehouse <swhiteho@redhat.com>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: Patrick Caulfield <patrick@tykepenguin.com>,
David Miller <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [DECNET] Endian bug fixes
Date: Mon, 06 Nov 2006 11:50:26 +0000 [thread overview]
Message-ID: <1162813826.18219.47.camel@quoit.chygwyn.com> (raw)
In-Reply-To: <20061106103449.GG29920@ftp.linux.org.uk>
Hi,
On Mon, 2006-11-06 at 10:34 +0000, Al Viro wrote:
> On Mon, Nov 06, 2006 at 10:32:43AM +0000, Al Viro wrote:
> > On Mon, Nov 06, 2006 at 10:31:02AM +0000, Steven Whitehouse wrote:
> > > + opt->opt_optl = dn_htons((__u16)*ptr++);
> >
> > Lose that cast; it's only confusing the things...
> >
> > > + memcpy(opt->opt_data, ptr, dn_ntohs(opt->opt_optl));
> > > + skb_pull(skb, dn_ntohs(opt->opt_optl) + 1);
> >
> > ... and I'd actually do
> >
> > u16 len = *ptr++; /* yes, it's 8bit on the wire */
> > opt->opt_optl = dn_htons(len);
> > BUG_ON(len > 16); /* we've checked the contents earlier */
> > memcpy(opt->opt_data, ptr, len);
> > skb_pull(skb, len + 1);
>
> BTW, why the hell do we keep ->opt_optl __le16 internally? If we ever
> pass it to userland, fine, but let's convert to __le16 *then*...
Really the only thing that we do with this data is verify it and pass to
userland. It does mean that getsockopt() is simpler for just being able
to use copy_to_user() with a ptr & len depending on which of the
structures the user has requested rather than having to convert each
field of each structure for example.
I'm not sure its worth changing it now, for saving just one byte per
socket in this case,
Steve.
next prev parent reply other threads:[~2006-11-06 11:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-06 10:31 [DECNET] Endian bug fixes Steven Whitehouse
2006-11-06 10:32 ` Al Viro
2006-11-06 10:34 ` Al Viro
2006-11-06 11:50 ` Steven Whitehouse [this message]
2006-11-06 11:50 ` Steven Whitehouse
2006-11-07 22:59 ` David Miller
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=1162813826.18219.47.camel@quoit.chygwyn.com \
--to=swhiteho@redhat.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=patrick@tykepenguin.com \
--cc=viro@ftp.linux.org.uk \
/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).