netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros
@ 2013-12-17 13:53 Atzm Watanabe
  2013-12-17 14:03 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Atzm Watanabe @ 2013-12-17 13:53 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.
Explicitly defining and zeroing the gap of this makes additional changes
easier.

Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
---
 include/uapi/linux/if_packet.h | 3 ++-
 net/packet/af_packet.c         | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h
index 1e24aa7..9185dc9 100644
--- a/include/uapi/linux/if_packet.h
+++ b/include/uapi/linux/if_packet.h
@@ -133,7 +133,7 @@ struct tpacket2_hdr {
 	__u32		tp_sec;
 	__u32		tp_nsec;
 	__u16		tp_vlan_tci;
-	__u16		tp_padding;
+	__u8		tp_padding[6];
 };
 
 struct tpacket_hdr_variant1 {
@@ -154,6 +154,7 @@ struct tpacket3_hdr {
 	union {
 		struct tpacket_hdr_variant1 hv1;
 	};
+	__u8		tp_padding[12];
 };
 
 struct tpacket_bd_ts {
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index c6baa59..ccc01d9 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1929,7 +1929,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 		} else {
 			h.h2->tp_vlan_tci = 0;
 		}
-		h.h2->tp_padding = 0;
+		memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding));
 		hdrlen = sizeof(*h.h2);
 		break;
 	case TPACKET_V3:
@@ -1943,6 +1943,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
 		h.h3->tp_net = netoff;
 		h.h3->tp_sec  = ts.tv_sec;
 		h.h3->tp_nsec = ts.tv_nsec;
+		memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding));
 		hdrlen = sizeof(*h.h3);
 		break;
 	default:
-- 
1.8.1.5

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

* Re: [PATCH v4 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros
  2013-12-17 13:53 [PATCH v4 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros Atzm Watanabe
@ 2013-12-17 14:03 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2013-12-17 14:03 UTC (permalink / raw)
  To: Atzm Watanabe
  Cc: netdev, Stephen Hemminger, Ben Hutchings, David Miller,
	David Laight

On 12/17/2013 02:53 PM, Atzm Watanabe wrote:
> struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
> Explicitly defining and zeroing the gap of this makes additional changes
> easier.
>
> 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-17 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-17 13:53 [PATCH v4 2/3] packet: fill the gap of TPACKET_ALIGNMENT with zeros Atzm Watanabe
2013-12-17 14:03 ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).