All of lore.kernel.org
 help / color / mirror / Atom feed
From: Atzm Watanabe <atzm@stratosphere.co.jp>
To: netdev@vger.kernel.org
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
	"Ben Hutchings" <bhutchings@solarflare.com>,
	"David Miller" <davem@davemloft.net>,
	"Daniel Borkmann" <dborkman@redhat.com>,
	"David Laight" <David.Laight@ACULAB.COM>
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	[thread overview]
Message-ID: <87fvpr7fdv.wl%atzm@stratosphere.co.jp> (raw)

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 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

             reply	other threads:[~2013-12-17 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-17 13:53 Atzm Watanabe [this message]
2013-12-17 14:02 ` [PATCH v4 1/3] packet: make aligned size of struct tpacket{2,3}_hdr clear Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvpr7fdv.wl%atzm@stratosphere.co.jp \
    --to=atzm@stratosphere.co.jp \
    --cc=David.Laight@ACULAB.COM \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.