netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Allen Simpson <william.allen.simpson@gmail.com>
To: Linux Kernel Developers <linux-kernel@vger.kernel.org>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Michael Chan <mchan@broadcom.com>
Subject: [PATCH 0/2] net: replace buggy tcp_optlen, and cleanup
Date: Wed, 06 Jan 2010 16:18:52 -0500	[thread overview]
Message-ID: <4B44FE3C.6060809@gmail.com> (raw)

This bugginess was reported in October, November, December, and
January.  I'm requesting some independent review and testing.

The tcp_optlen() function returns a potential *negative* unsigned:

-static inline unsigned int tcp_optlen(const struct sk_buff *skb)
-{
-	return (tcp_hdr(skb)->doff - 5) * 4;
-}
-

This is replaced by tcp_header_len_th() and tcp_option_len_th().

The tcp_optlen() function is used *only* in two drivers, that
also have rather messy coding practices; such as:

-	if ((mss = skb_shinfo(skb)->gso_size)) {
...
-	} else
-		mss = 0;

Or:

-	mss = 0;
-	if ((mss = skb_shinfo(skb)->gso_size) != 0) {

Or:

-			iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
-			hdrlen = ip_tcp_len + tcp_opt_len;

Or mixing word and byte sized variables, without using defined constants
or useful sizeof() to make the code self-documenting:

-			if (tcp_opt_len || (iph->ihl > 5)) {
-				vlan_tag_flags |= ((iph->ihl - 5) +
-						   (tcp_opt_len >> 2)) << 8;
-			}

Stand-alone patch, originally developed for TCPCT.

Signed-off-by: William.Allen.Simpson@gmail.com

             reply	other threads:[~2010-01-06 21:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 21:18 William Allen Simpson [this message]
2010-01-06 21:28 ` [PATCH 1/2] net: tcp_header_len_th and tcp_option_len_th William Allen Simpson
2010-01-12 10:40   ` Eric Dumazet
2010-01-12 17:42     ` William Allen Simpson
2010-01-12 17:53       ` Eric Dumazet
2010-01-12 20:27         ` Jarek Poplawski
2010-01-13  8:53         ` William Allen Simpson
2010-01-13 10:00           ` Eric Dumazet
2010-01-13 11:03             ` William Allen Simpson
2010-01-06 21:37 ` [PATCH 2/2] net: remove old tcp_optlen function William Allen Simpson

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=4B44FE3C.6060809@gmail.com \
    --to=william.allen.simpson@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    /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).