Skip to contentSkip to conversation

Use BUILD_BUG_ON for tcp_skb_cb size checking

PATCH Applied Pavel Emelyanov 2 participants 2 messages Dec 7, 2007 – Dec 11, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use BUILD_BUG_ON for tcp_skb_cb size checking

The sizeof(struct tcp_skb_cb) should not be less than the sizeof(skb->cb). This is checked in net/ipv4/tcp.c, but this check can be made more gracefully.

---

net/ipv4/tcp.c +1 -4
index 8e65182..c8bebd3 100644
@@ -2411,7 +2411,6 @@ void tcp_done(struct sock *sk)
 }
 EXPORT_SYMBOL_GPL(tcp_done);
 
-extern void __skb_cb_too_small_for_tcp(int, int);
 extern struct tcp_congestion_ops tcp_reno;
 
 static __initdata unsigned long thash_entries;
@@ -2430,9 +2429,7 @@ void __init tcp_init(void)
 	unsigned long limit;
 	int order, i, max_share;
 
-	if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb))
-		__skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb),
-					   sizeof(skb->cb));
+	BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb));
 
 	tcp_hashinfo.bind_bucket_cachep =
 		kmem_cache_create("tcp_bind_bucket",
maintainer Applied
#1 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Fri, 07 Dec 2007 20:42:04 +0300

Quoted 5 lines

The sizeof(struct tcp_skb_cb) should not be less than the sizeof(skb->cb). This is checked in net/ipv4/tcp.c, but this check can be made more gracefully.

Applied to net-2.6.25, thanks.