Skip to content

net: replace buggy tcp_optlen, and cleanup

William Allen Simpson lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest0 of 2 patches 9 repliesIn review

Patches in v1 No applies recorded yet

None of the 2 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] net: replace buggy tcp_optlen, and cleanup

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 [email protected]