From: Atzm Watanabe Subject: [PATCH v3 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear Date: Mon, 16 Dec 2013 17:12:03 +0900 Message-ID: <87ppox6wq4.wl%atzm@stratosphere.co.jp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: "Stephen Hemminger" , "Ben Hutchings" , "David Miller" , "Daniel Borkmann" , "David Laight" To: netdev@vger.kernel.org Return-path: Received: from mail-yh0-f54.google.com ([209.85.213.54]:40641 "EHLO mail-yh0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752305Ab3LPIRD (ORCPT ); Mon, 16 Dec 2013 03:17:03 -0500 Received: by mail-yh0-f54.google.com with SMTP id z12so3424444yhz.41 for ; Mon, 16 Dec 2013 00:17:02 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. We may add members to them until current aligned size without forcing userspace to call getsockopt(..., PACKET_HDRLEN, ...). Signed-off-by: Atzm Watanabe --- net/packet/af_packet.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 9d70f13..1c8b982 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1812,6 +1812,13 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct timespec ts; __u32 ts_status; + /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT. + * We may add members to them until current aligned size without forcing + * userspace to call getsockopt(..., PACKET_HDRLEN, ...). + */ + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); + if (skb->pkt_type == PACKET_LOOPBACK) goto drop; -- 1.8.1.5