Skip to content

Commit

Permalink
packet: make aligned size of struct tpacket{2,3}_hdr clear
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
iAtsumuWatanabe authored and davem330 committed Dec 18, 2013
1 parent 9f605ac commit 5184635
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5184635

Please sign in to comment.