All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear
@ 2013-12-16  8:12 Atzm Watanabe
  2013-12-16 10:05 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Atzm Watanabe @ 2013-12-16  8:12 UTC (permalink / raw)
  To: netdev
  Cc: Stephen Hemminger, Ben Hutchings, David Miller, Daniel Borkmann,
	David Laight

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 <atzm@stratosphere.co.jp>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear
  2013-12-16  8:12 [PATCH v3 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear Atzm Watanabe
@ 2013-12-16 10:05 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2013-12-16 10:05 UTC (permalink / raw)
  To: Atzm Watanabe
  Cc: netdev, Stephen Hemminger, Ben Hutchings, David Miller, David Laight

On 12/16/2013 09:12 AM, Atzm Watanabe wrote:
> 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 <atzm@stratosphere.co.jp>

Acked-by: Daniel Borkmann <dborkman@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-16 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-16  8:12 [PATCH v3 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear Atzm Watanabe
2013-12-16 10:05 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.