All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] net: replace buggy tcp_optlen, and cleanup
@ 2010-01-06 21:18 William Allen Simpson
  2010-01-06 21:28 ` [PATCH 1/2] net: tcp_header_len_th and tcp_option_len_th William Allen Simpson
  2010-01-06 21:37 ` [PATCH 2/2] net: remove old tcp_optlen function William Allen Simpson
  0 siblings, 2 replies; 10+ messages in thread
From: William Allen Simpson @ 2010-01-06 21:18 UTC (permalink / raw)
  To: Linux Kernel Developers; +Cc: Linux Kernel Network Developers, Michael Chan

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-01-13 11:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-06 21:18 [PATCH 0/2] net: replace buggy tcp_optlen, and cleanup William Allen Simpson
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.