From mboxrd@z Thu Jan 1 00:00:00 1970 From: Atzm Watanabe Subject: [PATCH v4 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear Date: Tue, 17 Dec 2013 22:53:32 +0900 Message-ID: <87fvpr7fdv.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-qa0-f54.google.com ([209.85.216.54]:43633 "EHLO mail-qa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755Ab3LQN4c (ORCPT ); Tue, 17 Dec 2013 08:56:32 -0500 Received: by mail-qa0-f54.google.com with SMTP id f11so2621076qae.6 for ; Tue, 17 Dec 2013 05:56:31 -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 cc803c6..c6baa59 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