From: Atzm Watanabe Date: Tue, 17 Dec 2013 13:53:32 +0000 (+0900) Subject: packet: make aligned size of struct tpacket{2,3}_hdr clear X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=51846355bc239b7d229ed7a1ea7b0333cbd23f01;p=linux-beck.git packet: make aligned size of struct tpacket{2,3}_hdr clear 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 Acked-by: Daniel Borkmann Signed-off-by: David S. Miller --- diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 24675f06f4fd..4fd52181b6ce 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;